Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connectivity: Address migrate-svc changes #1746

Merged
merged 1 commit into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 50 additions & 39 deletions connectivity/check/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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{})
Expand Down
12 changes: 6 additions & 6 deletions connectivity/tests/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down