From f0125461eb55d740d3d15ab2b6f0cc023cf66beb Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Thu, 22 Jun 2023 11:35:26 +0300 Subject: [PATCH] connectivity: Address migrate-svc changes * The repo was renamed to cilium/test-connection-disruption. * The executables were renamed. * The client stores a file which can be used for probing client readiness. Signed-off-by: Martynas Pumputis --- connectivity/check/deployment.go | 89 ++++++++++++++++++-------------- connectivity/tests/upgrade.go | 12 ++--- 2 files changed, 56 insertions(+), 45 deletions(-) diff --git a/connectivity/check/deployment.go b/connectivity/check/deployment.go index a25424cd8f..cec3849bad 100644 --- a/connectivity/check/deployment.go +++ b/connectivity/check/deployment.go @@ -49,10 +49,10 @@ const ( hostNetNSDeploymentNameNonCilium = "host-netns-non-cilium" // runs on non-Cilium test nodes kindHostNetNS = "host-netns" - migrateSvcClientDeploymentName = "migrate-svc-client" - migrateSvcServerDeploymentName = "migrate-svc-server" - migrateSvcServiceName = "migrate-svc" - KindMigrateSvc = "migrate-svc" + testConnDisruptClientDeploymentName = "test-conn-disrupt-client" + testConnDisruptServerDeploymentName = "test-conn-disrupt-server" + testConnDisruptServiceName = "test-conn-disrupt" + KindTestConnDisrupt = "test-conn-disrupt" EchoServerHostPort = 40000 @@ -589,63 +589,74 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error { return nil } - // Deploy migrate-svc-client, migrate-svc-server and migrate-svc + // Deploy test-conn-disrupt actors if ct.params.UpgradeTestSetup { - _, err = ct.clients.src.GetDeployment(ctx, ct.params.TestNamespace, migrateSvcServerDeploymentName, metav1.GetOptions{}) + _, err = ct.clients.src.GetDeployment(ctx, ct.params.TestNamespace, testConnDisruptServerDeploymentName, metav1.GetOptions{}) if err != nil { - ct.Logf("✨ [%s] Deploying %s deployment...", ct.clients.src.ClusterName(), migrateSvcServerDeploymentName) - migrateSvcServerDeployment := newDeployment(deploymentParameters{ - Name: migrateSvcServerDeploymentName, - Kind: KindMigrateSvc, - Image: "docker.io/cilium/migrate-svc-test:v0.0.2", + ct.Logf("✨ [%s] Deploying %s deployment...", ct.clients.src.ClusterName(), testConnDisruptServerDeploymentName) + testConnDisruptServerDeployment := newDeployment(deploymentParameters{ + Name: testConnDisruptServerDeploymentName, + Kind: KindTestConnDisrupt, + Image: "quay.io/cilium/test-connection-disruption:v0.0.1", Replicas: 3, - Labels: map[string]string{"app": "migrate-svc-server"}, - Command: []string{"/server", "8000"}, + Labels: map[string]string{"app": "test-conn-disrupt-server"}, + Command: []string{"tcd-server", "8000"}, Port: 8000, }) - _, err = ct.clients.src.CreateServiceAccount(ctx, ct.params.TestNamespace, k8s.NewServiceAccount(migrateSvcServerDeploymentName), metav1.CreateOptions{}) + _, err = ct.clients.src.CreateServiceAccount(ctx, ct.params.TestNamespace, k8s.NewServiceAccount(testConnDisruptServerDeploymentName), metav1.CreateOptions{}) if err != nil { - return fmt.Errorf("unable to create service account %s: %w", migrateSvcServerDeploymentName, err) + return fmt.Errorf("unable to create service account %s: %w", testConnDisruptServerDeploymentName, err) } - _, err = ct.clients.src.CreateDeployment(ctx, ct.params.TestNamespace, migrateSvcServerDeployment, metav1.CreateOptions{}) + _, err = ct.clients.src.CreateDeployment(ctx, ct.params.TestNamespace, testConnDisruptServerDeployment, metav1.CreateOptions{}) if err != nil { - return fmt.Errorf("unable to create deployment %s: %w", migrateSvcServerDeployment, err) + return fmt.Errorf("unable to create deployment %s: %w", testConnDisruptServerDeployment, err) } } - _, err = ct.clients.src.GetService(ctx, ct.params.TestNamespace, migrateSvcServiceName, metav1.GetOptions{}) + _, err = ct.clients.src.GetService(ctx, ct.params.TestNamespace, testConnDisruptServiceName, metav1.GetOptions{}) if err != nil { - ct.Logf("✨ [%s] Deploying %s service...", ct.clients.src.ClusterName(), migrateSvcServiceName) - svc := newService(migrateSvcServiceName, map[string]string{"app": "migrate-svc-server"}, nil, "http", 8000) + ct.Logf("✨ [%s] Deploying %s service...", ct.clients.src.ClusterName(), testConnDisruptServiceName) + svc := newService(testConnDisruptServiceName, map[string]string{"app": "test-conn-disrupt-server"}, nil, "http", 8000) _, err = ct.clients.src.CreateService(ctx, ct.params.TestNamespace, svc, metav1.CreateOptions{}) if err != nil { return err } } - _, err = ct.clients.src.GetDeployment(ctx, ct.params.TestNamespace, migrateSvcClientDeploymentName, metav1.GetOptions{}) + _, err = ct.clients.src.GetDeployment(ctx, ct.params.TestNamespace, testConnDisruptClientDeploymentName, metav1.GetOptions{}) if err != nil { - ct.Logf("✨ [%s] Deploying %s deployment...", ct.clients.src.ClusterName(), migrateSvcClientDeploymentName) - migrateSvcClientDeployment := newDeployment(deploymentParameters{ - Name: migrateSvcClientDeploymentName, - Kind: KindMigrateSvc, - Image: "docker.io/cilium/migrate-svc-test:v0.0.2", + ct.Logf("✨ [%s] Deploying %s deployment...", ct.clients.src.ClusterName(), testConnDisruptClientDeploymentName) + readinessProbe := &corev1.Probe{ + ProbeHandler: corev1.ProbeHandler{ + Exec: &corev1.ExecAction{ + Command: []string{"cat", "/tmp/client-ready"}, + }, + }, + PeriodSeconds: int32(3), + InitialDelaySeconds: int32(1), + FailureThreshold: int32(20), + } + testConnDisruptClientDeployment := newDeployment(deploymentParameters{ + Name: testConnDisruptClientDeploymentName, + Kind: KindTestConnDisrupt, + Image: "quay.io/cilium/test-connection-disruption:v0.0.1", Replicas: 5, - Labels: map[string]string{"app": "migrate-svc-client"}, + Labels: map[string]string{"app": "test-conn-disrupt-client"}, Port: 8000, Command: []string{ - "/client", - fmt.Sprintf("migrate-svc.%s.svc.cluster.local.:8000", ct.params.TestNamespace), + "tcd-client", + fmt.Sprintf("test-conn-disrupt.%s.svc.cluster.local.:8000", ct.params.TestNamespace), }, + ReadinessProbe: readinessProbe, }) - _, err = ct.clients.src.CreateServiceAccount(ctx, ct.params.TestNamespace, k8s.NewServiceAccount(migrateSvcClientDeploymentName), metav1.CreateOptions{}) + _, err = ct.clients.src.CreateServiceAccount(ctx, ct.params.TestNamespace, k8s.NewServiceAccount(testConnDisruptClientDeploymentName), metav1.CreateOptions{}) if err != nil { - return fmt.Errorf("unable to create service account %s: %w", migrateSvcClientDeploymentName, err) + return fmt.Errorf("unable to create service account %s: %w", testConnDisruptClientDeploymentName, err) } - _, err = ct.clients.src.CreateDeployment(ctx, ct.params.TestNamespace, migrateSvcClientDeployment, metav1.CreateOptions{}) + _, err = ct.clients.src.CreateDeployment(ctx, ct.params.TestNamespace, testConnDisruptClientDeployment, metav1.CreateOptions{}) if err != nil { - return fmt.Errorf("unable to create deployment %s: %w", migrateSvcClientDeployment, err) + return fmt.Errorf("unable to create deployment %s: %w", testConnDisruptClientDeployment, err) } } } @@ -1017,8 +1028,8 @@ func (ct *ConnectivityTest) deploymentList() (srcList []string, dstList []string } if ct.params.IncludeUpgradeTest { - srcList = append(srcList, migrateSvcClientDeploymentName) - dstList = append(dstList, migrateSvcServerDeploymentName) + srcList = append(srcList, testConnDisruptClientDeploymentName) + dstList = append(dstList, testConnDisruptServerDeploymentName) } if (ct.params.MultiCluster != "" || !ct.params.SingleNode) && !ct.params.Perf { @@ -1038,14 +1049,14 @@ 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, migrateSvcClientDeploymentName, metav1.DeleteOptions{}) - _ = client.DeleteDeployment(ctx, ct.params.TestNamespace, migrateSvcServerDeploymentName, metav1.DeleteOptions{}) + _ = client.DeleteDeployment(ctx, ct.params.TestNamespace, testConnDisruptClientDeploymentName, metav1.DeleteOptions{}) + _ = client.DeleteDeployment(ctx, ct.params.TestNamespace, testConnDisruptServerDeploymentName, 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, migrateSvcClientDeploymentName, metav1.DeleteOptions{}) - _ = client.DeleteServiceAccount(ctx, ct.params.TestNamespace, migrateSvcServerDeploymentName, metav1.DeleteOptions{}) + _ = client.DeleteServiceAccount(ctx, ct.params.TestNamespace, testConnDisruptClientDeploymentName, metav1.DeleteOptions{}) + _ = client.DeleteServiceAccount(ctx, ct.params.TestNamespace, testConnDisruptServerDeploymentName, 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{}) diff --git a/connectivity/tests/upgrade.go b/connectivity/tests/upgrade.go index 0ee50dc87b..864ef459d9 100644 --- a/connectivity/tests/upgrade.go +++ b/connectivity/tests/upgrade.go @@ -21,9 +21,9 @@ import ( // The test case consists of three steps: // // 1. Deploying pods and a service which establish the long-lived connections -// (done by "--upgrade-test-setup"). The client pods ("migrate-svc-client") -// establish connections via ClusterIP ("migrate-svc") to server pods -// ("migrate-svc-server"). As there former pods come first before the latter, +// (done by "--upgrade-test-setup"). The client pods ("test-conn-disrupt-client") +// establish connections via ClusterIP ("test-conn-disrupt") to server pods +// ("test-conn-disrupt-server"). As there former pods come first before the latter, // the former pods can crash which increases the pod restart counter. The step // is responsible for storing the restart counter too. // 2. Do Cilium upgrade. @@ -44,12 +44,12 @@ func (n *noInterruptedConnections) Run(ctx context.Context, t *check.Test) { ct := t.Context() client := ct.K8sClient() - pods, err := client.ListPods(ctx, ct.Params().TestNamespace, metav1.ListOptions{LabelSelector: "kind=" + check.KindMigrateSvc}) + pods, err := client.ListPods(ctx, ct.Params().TestNamespace, metav1.ListOptions{LabelSelector: "kind=" + check.KindTestConnDisrupt}) if err != nil { - t.Fatalf("Unable to list migrate-svc pods: %s", err) + t.Fatalf("Unable to list test-conn-disrupt pods: %s", err) } if len(pods.Items) == 0 { - t.Fatal("No migrate-svc-{client,server} pods found") + t.Fatal("No test-conn-disrupt-{client,server} pods found") } restartCount := make(map[string]string)