From 56ea409507665c2142a85624bce0c49b7d4df04a Mon Sep 17 00:00:00 2001 From: Gilberto Bertin Date: Thu, 14 Dec 2023 12:49:10 +0100 Subject: [PATCH] check: add third client scheduled on a different node for some upcoming tests we will need a new client scheduled on a different node than the first 2 clients. This commit adds this new client. Signed-off-by: Gilberto Bertin --- connectivity/check/deployment.go | 47 +++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/connectivity/check/deployment.go b/connectivity/check/deployment.go index 6ad955f54a..b0b92f40a2 100644 --- a/connectivity/check/deployment.go +++ b/connectivity/check/deployment.go @@ -34,6 +34,7 @@ const ( clientDeploymentName = "client" client2DeploymentName = "client2" + client3DeploymentName = "client3" clientCPDeployment = "client-cp" DNSTestServerContainerName = "dns-test-server" @@ -854,7 +855,48 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error { } } - // 3rd client scheduled on the control plane + if !ct.params.SingleNode || ct.params.MultiCluster != "" { + // 3rd client scheduled on a different node than the first 2 clients + _, err = ct.clients.src.GetDeployment(ctx, ct.params.TestNamespace, client3DeploymentName, metav1.GetOptions{}) + if err != nil { + ct.Logf("✨ [%s] Deploying %s deployment...", ct.clients.src.ClusterName(), client3DeploymentName) + clientDeployment := newDeployment(deploymentParameters{ + Name: client3DeploymentName, + Kind: kindClientName, + NamedPort: "http-8080", + Port: 8080, + Image: ct.params.CurlImage, + Command: []string{"/bin/ash", "-c", "sleep 10000000"}, + Labels: map[string]string{"other": "client-other-node"}, + Annotations: ct.params.DeploymentAnnotations.Match(client3DeploymentName), + Affinity: &corev1.Affinity{ + PodAntiAffinity: &corev1.PodAntiAffinity{ + RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{ + { + LabelSelector: &metav1.LabelSelector{ + MatchExpressions: []metav1.LabelSelectorRequirement{ + {Key: "name", Operator: metav1.LabelSelectorOpIn, Values: []string{clientDeploymentName}}, + }, + }, + TopologyKey: corev1.LabelHostname, + }, + }, + }, + }, + NodeSelector: ct.params.NodeSelector, + }) + _, err = ct.clients.src.CreateServiceAccount(ctx, ct.params.TestNamespace, k8s.NewServiceAccount(client3DeploymentName), metav1.CreateOptions{}) + if err != nil { + return fmt.Errorf("unable to create service account %s: %s", client3DeploymentName, err) + } + _, err = ct.clients.src.CreateDeployment(ctx, ct.params.TestNamespace, clientDeployment, metav1.CreateOptions{}) + if err != nil { + return fmt.Errorf("unable to create deployment %s: %s", client3DeploymentName, err) + } + } + } + + // 4th client scheduled on the control plane if ct.params.K8sLocalHostTest { ct.Logf("✨ [%s] Deploying %s deployment...", ct.clients.src.ClusterName(), clientCPDeployment) clientDeployment := newDeployment(deploymentParameters{ @@ -1083,6 +1125,7 @@ func (ct *ConnectivityTest) deploymentList() (srcList []string, dstList []string } if (ct.params.MultiCluster != "" || !ct.params.SingleNode) && !ct.params.Perf { + srcList = append(srcList, client3DeploymentName) dstList = append(dstList, echoOtherNodeDeploymentName) } @@ -1099,10 +1142,12 @@ func (ct *ConnectivityTest) deleteDeployments(ctx context.Context, client *k8s.C _ = client.DeleteDeployment(ctx, ct.params.TestNamespace, echoOtherNodeDeploymentName, metav1.DeleteOptions{}) _ = client.DeleteDeployment(ctx, ct.params.TestNamespace, clientDeploymentName, metav1.DeleteOptions{}) _ = client.DeleteDeployment(ctx, ct.params.TestNamespace, client2DeploymentName, metav1.DeleteOptions{}) + _ = client.DeleteDeployment(ctx, ct.params.TestNamespace, client3DeploymentName, metav1.DeleteOptions{}) _ = client.DeleteServiceAccount(ctx, ct.params.TestNamespace, echoSameNodeDeploymentName, metav1.DeleteOptions{}) _ = client.DeleteServiceAccount(ctx, ct.params.TestNamespace, echoOtherNodeDeploymentName, metav1.DeleteOptions{}) _ = client.DeleteServiceAccount(ctx, ct.params.TestNamespace, clientDeploymentName, metav1.DeleteOptions{}) _ = client.DeleteServiceAccount(ctx, ct.params.TestNamespace, client2DeploymentName, metav1.DeleteOptions{}) + _ = client.DeleteServiceAccount(ctx, ct.params.TestNamespace, client3DeploymentName, metav1.DeleteOptions{}) _ = client.DeleteService(ctx, ct.params.TestNamespace, echoSameNodeDeploymentName, metav1.DeleteOptions{}) _ = client.DeleteService(ctx, ct.params.TestNamespace, echoOtherNodeDeploymentName, metav1.DeleteOptions{}) _ = client.DeleteConfigMap(ctx, ct.params.TestNamespace, corednsConfigMapName, metav1.DeleteOptions{})