From 2ac0190bfaf68f9423a25c6a6d8304d3a5fa795c Mon Sep 17 00:00:00 2001 From: Roman Dobosz Date: Mon, 22 Nov 2021 18:44:06 +0100 Subject: [PATCH] Raise kubernetes tests version to 1.22.5 and fix legacy tests. Also, there is a need to bump golang version to 1.16.x. Change-Id: I453b04e97b556033e3f30a7406ccb6e4870f2d3c --- .zuul.d/k8s-np-e2e.yaml | 4 +-- playbooks/e2e-tests.patch | 58 ++++++++++++++++++++++++++++++++ playbooks/run_k8s_e2e_tests.yaml | 17 +++++----- 3 files changed, 68 insertions(+), 11 deletions(-) create mode 100644 playbooks/e2e-tests.patch diff --git a/.zuul.d/k8s-np-e2e.yaml b/.zuul.d/k8s-np-e2e.yaml index 4ebf1920d..79bed37c4 100644 --- a/.zuul.d/k8s-np-e2e.yaml +++ b/.zuul.d/k8s-np-e2e.yaml @@ -126,9 +126,9 @@ amp_active_retries: 9999 api_settings: enabled_provider_drivers: amphora:'Octavia Amphora driver',ovn:'Octavia OVN driver' - kubetest_version: v1.20.2 + kubetest_version: v1.22.5 np_parallel_number: 2 - gopkg: go1.15.2.linux-amd64.tar.gz + gopkg: go1.16.12.linux-amd64.tar.gz np_sleep: 30 zuul_copy_output: '/home/zuul/np_kubetest.log': 'logs' diff --git a/playbooks/e2e-tests.patch b/playbooks/e2e-tests.patch new file mode 100644 index 000000000..483a239f4 --- /dev/null +++ b/playbooks/e2e-tests.patch @@ -0,0 +1,58 @@ +diff --git a/test/e2e/framework/pod/wait.go b/test/e2e/framework/pod/wait.go +index 61ab7997ce6..eabf38006ad 100644 +--- a/test/e2e/framework/pod/wait.go ++++ b/test/e2e/framework/pod/wait.go +@@ -51,7 +51,7 @@ const ( + podScheduledBeforeTimeout = podListTimeout + (20 * time.Second) + + // podStartTimeout is how long to wait for the pod to be started. +- podStartTimeout = 5 * time.Minute ++ podStartTimeout = 2 * time.Minute + + // poll is how often to poll pods, nodes and claims. + poll = 2 * time.Second +diff --git a/test/e2e/network/netpol/network_legacy.go b/test/e2e/network/netpol/network_legacy.go +index fb52460560c..895f4c3df85 100644 +--- a/test/e2e/network/netpol/network_legacy.go ++++ b/test/e2e/network/netpol/network_legacy.go +@@ -435,6 +435,7 @@ var _ = common.SIGDescribe("NetworkPolicyLegacy [LinuxOnly]", func() { + + policy, err = f.ClientSet.NetworkingV1().NetworkPolicies(nsA.Name).Create(context.TODO(), policy, metav1.CreateOptions{}) + framework.ExpectNoError(err, "Error creating Network Policy %v: %v", policy.ObjectMeta.Name, err) ++ time.Sleep(60 * time.Second) + defer cleanupNetworkPolicy(f, policy) + + testCannotConnect(f, nsB, "client-a", service, 80) +@@ -957,6 +958,7 @@ var _ = common.SIGDescribe("NetworkPolicyLegacy [LinuxOnly]", func() { + // Client cannot connect to service after updating the server pod's labels to match the network policy's selector. + ginkgo.By(fmt.Sprintf("Updating server pod %s to be selected by network policy %s.", podServer.Name, policy.Name)) + updatePodLabel(f, f.Namespace, podServer.Name, "add", "/metadata/labels/isolated", nil) ++ time.Sleep(60 * time.Second) + testCannotConnect(f, f.Namespace, "client-a", service, allowedPort) + }) + +@@ -1103,6 +1105,7 @@ var _ = common.SIGDescribe("NetworkPolicyLegacy [LinuxOnly]", func() { + } + + policyAllowToServerInNSB, err = f.ClientSet.NetworkingV1().NetworkPolicies(f.Namespace.Name).Create(context.TODO(), policyAllowToServerInNSB, metav1.CreateOptions{}) ++ time.Sleep(60 * time.Second) + framework.ExpectNoError(err, "Error occurred while creating policy: policyAllowToServerInNSB.") + defer cleanupNetworkPolicy(f, policyAllowToServerInNSB) + +@@ -1807,6 +1810,7 @@ var _ = common.SIGDescribe("NetworkPolicy [Feature:SCTPConnectivity][LinuxOnly][ + + ginkgo.By("Testing pods can connect only to the port allowed by the policy.") + testCannotConnectProtocol(f, f.Namespace, "client-a", service, 80, v1.ProtocolSCTP) ++ time.Sleep(60 * time.Second) + testCanConnectProtocol(f, f.Namespace, "client-b", service, 81, v1.ProtocolSCTP) + }) + +@@ -2143,7 +2147,7 @@ func createNetworkClientPodWithRestartPolicy(f *framework.Framework, namespace * + Command: []string{"/bin/sh"}, + Args: []string{ + "-c", +- fmt.Sprintf("for i in $(seq 1 5); do /agnhost connect %s --protocol %s --timeout 8s && exit 0 || sleep 1; done; exit 1", net.JoinHostPort(targetService.Spec.ClusterIP, strconv.Itoa(targetPort)), connectProtocol), ++ fmt.Sprintf("sleep 30; for i in $(seq 1 300); do /agnhost connect %s --protocol %s --timeout 8s && exit 0 || sleep 1; done; exit 1", net.JoinHostPort(targetService.Spec.ClusterIP, strconv.Itoa(targetPort)), connectProtocol), + }, + }, + }, diff --git a/playbooks/run_k8s_e2e_tests.yaml b/playbooks/run_k8s_e2e_tests.yaml index 3a1f955e7..3cd450894 100644 --- a/playbooks/run_k8s_e2e_tests.yaml +++ b/playbooks/run_k8s_e2e_tests.yaml @@ -44,13 +44,12 @@ force: yes - name: Patch e2e tests - shell: | - sed -i 's/podStartTimeout = .*/podStartTimeout = 2 * time.Minute/' test/e2e/framework/pod/wait.go - sed -i 's/for i in $(seq 1 5)/sleep {{ np_sleep }};for i in $(seq 1 300)/' test/e2e/network/network_policy.go - sed -i '/"add", "\/metadata\/labels\/isolated", nil)/a\\t\t\ttime.Sleep(60 * time.Second)' test/e2e/network/network_policy.go - sed -i '/f, f.Namespace, "client-a", service, 80, v1.ProtocolSCTP)/a \\t\t\ttime.Sleep(60 * time.Second)' test/e2e/network/network_policy.go - args: - chdir: ~/kubernetes + # TODO(gryf): for some reason 'patch' plugin doesn't work + block: + - name: patch the kubernetes tests + shell: patch -Np1 < /opt/stack/kuryr-kubernetes/playbooks/e2e-tests.patch + args: + chdir: ~/kubernetes - name: Build e2e tests block: @@ -86,10 +85,10 @@ group: zuul become: yes - - name: Run Network Policy tests + - name: Run Network Policy legacy tests block: - name: Run Network Policy tests without SCTPConnectivity - shell: kubetest --provider=local --check-version-skew=false --test --ginkgo-parallel={{ np_parallel_number }} --test_args="--ginkgo.focus=\[Feature:NetworkPolicy --ginkgo.skip=\[Feature:SCTPConnectivity|should.enforce.policies.to.check.ingress.and.egress.policies.can.be.controlled.independently.based.on.PodSelector" --dump=/tmp > ~/np_kubetest.log + shell: kubetest --provider=local --check-version-skew=false --test --ginkgo-parallel={{ np_parallel_number }} --test_args="--ginkgo.focus=NetworkPolicyLegacy --ginkgo.skip=\[Feature:SCTPConnectivity|should.enforce.policies.to.check.ingress.and.egress.policies.can.be.controlled.independently.based.on.PodSelector" --dump=/tmp > ~/np_kubetest.log args: chdir: ~/kubernetes environment: