Skip to content

Commit

Permalink
e2e: added openssl function
Browse files Browse the repository at this point in the history
  • Loading branch information
wirungu committed Mar 18, 2024
1 parent 4cc7026 commit 8e8dbd0
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
2 changes: 2 additions & 0 deletions e2e/internal/kuberesource/resourcegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func main() {
switch set {
case "simple":
resources, err = kuberesource.Simple()
case "openssl":
resources, err = kuberesource.OpenSSL()
default:
fmt.Printf("Error: unknown set: %s\n", set)
os.Exit(1)
Expand Down
103 changes: 103 additions & 0 deletions e2e/internal/kuberesource/sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,106 @@ func Simple() ([]any, error) {

return resources, nil
}

// OpenSSL returns a set of resources for testing with OpenSSL.
func OpenSSL() ([]any, error) {
ns := "edg-default"
namespace := Namespace(ns)
coordinator := Coordinator(ns).DeploymentApplyConfiguration
coordinatorService := ServiceForDeployment(coordinator)
coordinatorForwarder := PortForwarder("coordinator", ns).
WithListenPort(1313).
WithForwardTarget("coordinator", 1313).
PodApplyConfiguration

opensslBackend := Deployment("openssl-backend", ns).
WithSpec(DeploymentSpec().
WithReplicas(1).
WithSelector(LabelSelector().
WithMatchLabels(map[string]string{"app.kubernetes.io/name": "openssl-backend"}),
).
WithTemplate(PodTemplateSpec().
WithLabels(map[string]string{"app.kubernetes.io/name": "openssl-backend"}).
WithSpec(PodSpec().
WithContainers(
Container().
WithName("openssl-backend").
WithImage("ghcr.io/edgelesssys/contrast/openssl:latest").
WithCommand("/bin/sh", "-c", "echo Workload started \n openssl s_server -port 443 -Verify 2 -CAfile /tls-config/MeshCACert.pem -cert /tls-config/certChain.pem -key /tls-config/key.pem").
WithResources(ResourceRequirements().
WithMemoryLimitAndRequest(50),
),
),
),
),
)

opensslBackend, err := AddInitializer(opensslBackend, Initializer())
if err != nil {
return nil, err
}

opensslClient := Deployment("openssl-client", ns).
WithSpec(DeploymentSpec().
WithReplicas(1).
WithSelector(LabelSelector().
WithMatchLabels(map[string]string{"app.kubernetes.io/name": "openssl-client"}),
).
WithTemplate(PodTemplateSpec().
WithLabels(map[string]string{"app.kubernetes.io/name": "openssl-client"}).
WithSpec(PodSpec().
WithContainers(
Container().
WithName("openssl-client").
WithImage("ghcr.io/edgelesssys/contrast/openssl:latest").
WithCommand("/bin/sh", "-c", "echo Workload started \nwhile true; do \n echo \"THIS IS A TEST MESSAGE\" | openssl s_client -connect openssl-frontend:443 -verify_return_error -CAfile /tls-config/RootCACert.pem\n sleep 30\ndone\n").
WithResources(ResourceRequirements().
WithMemoryLimitAndRequest(50),
),
),
),
),
)
opensslClient, err = AddInitializer(opensslClient, Initializer())
if err != nil {
return nil, err
}

opensslFrontend := Deployment("openssl-frontend", ns).
WithSpec(DeploymentSpec().
WithReplicas(1).
WithSelector(LabelSelector().
WithMatchLabels(map[string]string{"app.kubernetes.io/name": "openssl-frontend"}),
).
WithTemplate(PodTemplateSpec().
WithLabels(map[string]string{"app.kubernetes.io/name": "openssl-frontend"}).
WithSpec(PodSpec().
WithContainers(
Container().
WithName("openssl-frontend").
WithImage("ghcr.io/edgelesssys/contrast/openssl:latest").
WithCommand("/bin/sh", "-c", "echo Workload started\nopenssl s_server -www -port 443 -cert /tls-config/certChain.pem -key /tls-config/key.pem -cert_chain /tls-config/certChain.pem &\nwhile true; do \n echo \"THIS IS A TEST MESSAGE\" | openssl s_client -connect openssl-backend:443 -verify_return_error -CAfile /tls-config/MeshCACert.pem -cert /tls-config/certChain.pem -key /tls-config/key.pem\n sleep 10\ndone\n").
WithResources(ResourceRequirements().
WithMemoryLimitAndRequest(50),
),
),
),
),
)
opensslFrontend, err = AddInitializer(opensslFrontend, Initializer())
if err != nil {
return nil, err
}

resources := []any{
namespace,
coordinator,
coordinatorService,
coordinatorForwarder,
opensslBackend,
opensslClient,
opensslFrontend,
}

return resources, nil
}

0 comments on commit 8e8dbd0

Please sign in to comment.