From d996ee57d94210c37daf7cc8b10d2aed1309610d Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Fri, 6 Oct 2023 17:13:10 +0300 Subject: [PATCH 1/9] test/shr: don't expect/try to use containerd sources. Signed-off-by: Krisztian Litkey --- test/self-hosted-runner/docker/runner-in-container.sh | 2 +- test/self-hosted-runner/env.in | 4 ---- test/self-hosted-runner/runner.sh | 8 -------- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/test/self-hosted-runner/docker/runner-in-container.sh b/test/self-hosted-runner/docker/runner-in-container.sh index 444e94071..61d685169 100755 --- a/test/self-hosted-runner/docker/runner-in-container.sh +++ b/test/self-hosted-runner/docker/runner-in-container.sh @@ -52,7 +52,7 @@ sudo -n -u runner vagrant box add --name generic/fedora37 /mnt/vagrant/generic-f cd /mnt/actions-runner -sudo --preserve-env=http_proxy,https_proxy,no_proxy,HTTP_PROXY,HTTPS_PROXY,NO_PROXY,containerd_src,dns_nameserver,dns_search_domain \ +sudo --preserve-env=http_proxy,https_proxy,no_proxy,HTTP_PROXY,HTTPS_PROXY,NO_PROXY,containerd_release,dns_nameserver,dns_search_domain \ -n -u runner ./run.sh & wait diff --git a/test/self-hosted-runner/env.in b/test/self-hosted-runner/env.in index 15b99d73c..16eb8e315 100644 --- a/test/self-hosted-runner/env.in +++ b/test/self-hosted-runner/env.in @@ -22,7 +22,3 @@ no_proxy="$NO_PROXY" # Optional DNS settings DNS_SEARCH_DOMAIN="" DNS_NAMESERVER="" - -# Assume containerd sources are found in /../containerd -# The value here is relative path from test/self-hosted-runner/ directory. -CONTAINERD_SRC=../../../containerd/ diff --git a/test/self-hosted-runner/runner.sh b/test/self-hosted-runner/runner.sh index bddb04f89..3b8a0ab42 100755 --- a/test/self-hosted-runner/runner.sh +++ b/test/self-hosted-runner/runner.sh @@ -61,12 +61,6 @@ fi echo "Work directory set to $PREFIX" -if [ ! -f "$CONTAINERD_SRC/bin/ctr" ]; then - echo "########" - echo "WARNING: containerd sources / binaries not found in $CONTAINERD_SRC" - echo "########" -fi - get_runner_token() { local payload sig access_token app_private_key @@ -164,7 +158,6 @@ start_docker_container() { -v "${PREFIX}/mnt/actions-runner:/mnt/actions-runner" \ -v "${PREFIX}/mnt/vagrant:/mnt/vagrant:ro" \ -v "${PREFIX}/mnt/env:/mnt/env:ro" \ - -v "${CONTAINERD_SRC}:/mnt/containerd:ro" \ -v "/var/run/docker.sock:/var/run/docker.sock" \ --device=/dev/kvm \ --env-file "${PREFIX}/mnt/env" \ @@ -189,7 +182,6 @@ while [ $STOPPED -eq 0 ]; do # is exported to the container. echo dns_nameserver="$DNS_NAMESERVER" > ${PREFIX}/mnt/env echo dns_search_domain="$DNS_SEARCH_DOMAIN" >> ${PREFIX}/mnt/env - echo containerd_src=/mnt/containerd >> ${PREFIX}/mnt/env echo HTTP_PROXY="$HTTP_PROXY" >> ${PREFIX}/mnt/env echo HTTPS_PROXY="$HTTPS_PROXY" >> ${PREFIX}/mnt/env echo NO_PROXY="$NO_PROXY" >> ${PREFIX}/mnt/env From 44b7ffd3f07f5c550ee5b0b3d4bbcfbe7ced289c Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Fri, 6 Oct 2023 17:11:56 +0300 Subject: [PATCH 2/9] test/e2e: install runtime from release tarball. Allow installing containerd or CRI-O from a release tarball or pre-compiled sources. Default to installing from release tarballs. Signed-off-by: Krisztian Litkey --- test/e2e/files/Vagrantfile.in | 6 ++++ test/e2e/files/containerd.service | 2 +- test/e2e/files/crio.service | 2 +- test/e2e/playbook/provision.yaml | 49 ++++++++++++++++++++++++------- test/e2e/run.sh | 27 ++++++++++++----- 5 files changed, 66 insertions(+), 20 deletions(-) diff --git a/test/e2e/files/Vagrantfile.in b/test/e2e/files/Vagrantfile.in index d85e54592..f1e80dd24 100644 --- a/test/e2e/files/Vagrantfile.in +++ b/test/e2e/files/Vagrantfile.in @@ -15,12 +15,16 @@ HOSTNAME = "SERVER_NAME" N = 1 CRI_RUNTIME = "#{ENV['k8scri']}" +CRIO_RELEASE = "1.28.1" CRIO_SRC = "" +CONTAINERD_RELEASE = "" CONTAINERD_SRC = "" if CRI_RUNTIME == "containerd" + CONTAINERD_RELEASE = "#{ENV['containerd_release']}" CONTAINERD_SRC = "#{ENV['containerd_src']}" else + CRIO_RELEASE = "#{ENV['crio_release']}" CRIO_SRC = "#{ENV['crio_src']}" end @@ -82,7 +86,9 @@ Vagrant.configure("2") do |config| http_proxy: "#{ENV['HTTP_PROXY']}", no_proxy: "#{ENV['NO_PROXY']}", cri_runtime: CRI_RUNTIME, + containerd_release: CONTAINERD_RELEASE, containerd_src: CONTAINERD_SRC, + crio_release: CRIO_RELEASE, crio_src: CRIO_SRC, nri_resource_policy_src: NRI_RESOURCE_POLICY_SRC, outdir: OUTPUT_DIR, diff --git a/test/e2e/files/containerd.service b/test/e2e/files/containerd.service index e1c80c118..e4c082b3a 100644 --- a/test/e2e/files/containerd.service +++ b/test/e2e/files/containerd.service @@ -19,7 +19,7 @@ After=network.target local-fs.target [Service] ExecStartPre=-/sbin/modprobe overlay -ExecStart=/usr/bin/containerd +ExecStart=/usr/local/bin/containerd Type=notify Delegate=yes diff --git a/test/e2e/files/crio.service b/test/e2e/files/crio.service index 3df93ddb9..41d6d1310 100644 --- a/test/e2e/files/crio.service +++ b/test/e2e/files/crio.service @@ -4,7 +4,7 @@ Documentation=https://cri-o.io After=network.target [Service] -ExecStart=/usr/bin/crio +ExecStart=/usr/local/bin/crio Delegate=yes KillMode=process diff --git a/test/e2e/playbook/provision.yaml b/test/e2e/playbook/provision.yaml index 184a7f14b..4c583bfaa 100644 --- a/test/e2e/playbook/provision.yaml +++ b/test/e2e/playbook/provision.yaml @@ -6,6 +6,13 @@ - cri_runtime: "{{ cri_runtime }}" - is_containerd: false - is_crio: false + - containerd_release: "{{ containerd_release }}" + - containerd_tarball: "https://github.com/containerd/containerd/releases/download/v{{ containerd_release }}/containerd-{{ containerd_release }}-linux-amd64.tar.gz" + - crio_release: "{{ crio_release }}" + - crio_tarball: "https://storage.googleapis.com/cri-o/artifacts/cri-o.amd64.v{{ crio_release }}.tar.gz" + - dns_nameserver: "{{ dns_nameserver }}" + - cni_plugin: "{{ cni_plugin }}" + tasks: - set_fact: @@ -119,27 +126,47 @@ - tomli_w state: present - # We need quite recent containerd that has NRI support so use the one - # that is compiled from sources. - - name: copy containerd sources - copy: src="{{ item }}" dest="/usr/bin" mode=0755 + # Install containerd from a release tarball to /usr/local. + - name: Install containerd binaries from release tarball + ansible.builtin.unarchive: + src: "{{ containerd_tarball }}" + dest: /usr/local + remote_src: yes + when: is_containerd and containerd_src == "" + + # Install containerd binaries from compiled sources. + - name: Install containerd binaries from compiled sources + copy: src="{{ item }}" dest="/usr/local/bin" mode=0755 with_items: - "{{ containerd_src }}/bin/ctr" - "{{ containerd_src }}/bin/containerd" - "{{ containerd_src }}/bin/containerd-shim" - "{{ containerd_src }}/bin/containerd-shim-runc-v1" - "{{ containerd_src }}/bin/containerd-shim-runc-v2" - when: is_containerd - - # We need quite recent cri-o that has NRI support so use the one - # that is compiled from sources. - - name: copy cri-o sources - copy: src="{{ item }}" dest="/usr/bin" mode=0755 + when: is_containerd and containerd_src != "" + + # Install CRI-O from a release tarball to /usr/local. + - block: + - name: Fetch and extract CRI-O release tarball + ansible.builtin.unarchive: + src: "{{ crio_tarball }}" + dest: /usr/local + remote_src: yes + + - name: Install CRI-O binaries from release tarball + ansible.builtin.shell: + cmd: ./install + chdir: /usr/local/cri-o + when: is_crio and crio_src == "" + + # Install CRI-O binaries from compiled sources. + - name: Install CRI-O binaries from compiled sources + copy: src="{{ item }}" dest="/usr/local/bin" mode=0755 with_items: - "{{ crio_src }}/bin/crio" - "{{ crio_src }}/bin/crio-status" - "{{ crio_src }}/bin/pinns" - when: is_crio + when: is_crio and crio_src != "" - name: setup runtime systemd file copy: diff --git a/test/e2e/run.sh b/test/e2e/run.sh index 32813e335..ebb7d47c1 100755 --- a/test/e2e/run.sh +++ b/test/e2e/run.sh @@ -47,11 +47,20 @@ else k8scri_sock="/var/run/crio/crio.sock" fi -# Assume containerd sources are found in parent dir of this repo. -# If that is not the case, set containerd_src when calling the e2e script. -# Same for cri-o if using that. -export containerd_src=${containerd_src:-"$SRC_DIR"/../containerd} -export crio_src=${crio_src:-"$SRC_DIR"/../cri-o} +# If we run tests with containerd as the runtime, we install it +# from a release tarball with the version given below... unless +# a source directory is given, which is then expected to contain +# a compiled version of containerd which we should install. +export containerd_release=${containerd_release:-1.7.6} +export containerd_src=${containerd_src:-} + + +# If we run tests with CRI-O as the runtime, we install it from +# a release tarball with the version given below... unless a +# source directory is given, which is then expected to contain +# a compiled version of CRI-O which we should install. +export crio_release=${crio_release:-1.28.1} +export crio_src=${crio_src:-} # Default topology if not given. The run_tests.sh script will figure out # the topology from the test directory structure and contents. @@ -102,9 +111,13 @@ echo " Output dir = $OUTPUT_DIR" echo " Test output dir = $TEST_OUTPUT_DIR" echo " NRI dir = $nri_resource_policy_src" if [ "$k8scri" == "containerd" ]; then - echo " Containerd dir = $containerd_src" + echo " Containerd" + echo " release = $containerd_release" + echo " sources = $containerd_src" else - echo " CRI-O dir = $crio_src" + echo " CRI-O" + echo " release = $crio_release" + echo " sources = $crio_src" fi echo " Policy = $POLICY" echo " Topology = $topology" From a4f8817bbb31f79865f3514a7ba698f7d3da71dd Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Fri, 13 Oct 2023 15:19:13 +0300 Subject: [PATCH 3/9] test/e2e: ditch local runtime service files. Instead, install service file from release tarball, sources, or using a documented online URL. Signed-off-by: Krisztian Litkey --- test/e2e/files/containerd.service | 40 ------------------------------- test/e2e/files/crio.service | 18 -------------- test/e2e/playbook/provision.yaml | 16 +++++++++---- 3 files changed, 12 insertions(+), 62 deletions(-) delete mode 100644 test/e2e/files/containerd.service delete mode 100644 test/e2e/files/crio.service diff --git a/test/e2e/files/containerd.service b/test/e2e/files/containerd.service deleted file mode 100644 index e4c082b3a..000000000 --- a/test/e2e/files/containerd.service +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright The containerd Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -[Unit] -Description=containerd container runtime -Documentation=https://containerd.io -After=network.target local-fs.target - -[Service] -ExecStartPre=-/sbin/modprobe overlay -ExecStart=/usr/local/bin/containerd - -Type=notify -Delegate=yes -KillMode=process -Restart=always -RestartSec=5 -# Having non-zero Limit*s causes performance problems due to accounting overhead -# in the kernel. We recommend using cgroups to do container-local accounting. -LimitNPROC=infinity -LimitCORE=infinity -LimitNOFILE=infinity -# Comment TasksMax if your systemd version does not supports it. -# Only systemd 226 and above support this version. -TasksMax=infinity -OOMScoreAdjust=-999 - -[Install] -WantedBy=multi-user.target diff --git a/test/e2e/files/crio.service b/test/e2e/files/crio.service deleted file mode 100644 index 41d6d1310..000000000 --- a/test/e2e/files/crio.service +++ /dev/null @@ -1,18 +0,0 @@ -[Unit] -Description=cri-o container runtime -Documentation=https://cri-o.io -After=network.target - -[Service] -ExecStart=/usr/local/bin/crio - -Delegate=yes -KillMode=process -Restart=always -LimitNPROC=infinity -LimitCORE=infinity -LimitNOFILE=1048576 -TasksMax=infinity - -[Install] -WantedBy=multi-user.target diff --git a/test/e2e/playbook/provision.yaml b/test/e2e/playbook/provision.yaml index 4c583bfaa..0fd902e52 100644 --- a/test/e2e/playbook/provision.yaml +++ b/test/e2e/playbook/provision.yaml @@ -8,6 +8,7 @@ - is_crio: false - containerd_release: "{{ containerd_release }}" - containerd_tarball: "https://github.com/containerd/containerd/releases/download/v{{ containerd_release }}/containerd-{{ containerd_release }}-linux-amd64.tar.gz" + - containerd_service_file: "https://raw.githubusercontent.com/containerd/containerd/main/containerd.service" - crio_release: "{{ crio_release }}" - crio_tarball: "https://storage.googleapis.com/cri-o/artifacts/cri-o.amd64.v{{ crio_release }}.tar.gz" - dns_nameserver: "{{ dns_nameserver }}" @@ -168,13 +169,20 @@ - "{{ crio_src }}/bin/pinns" when: is_crio and crio_src != "" - - name: setup runtime systemd file - copy: - src: "{{ nri_resource_policy_src }}/test/e2e/files/{{ cri_runtime }}.service" - dest: "/lib/systemd/system/{{ cri_runtime }}.service" + - name: Install CRI-O systemd service file from compiled sources + copy: src="{{ item }}" dest="/lib/systemd/system/crio.service" mode=0644 + with_items: + - "{{ crio_src }}/contrib/crio.service" + when: is_crio and crio_src != "" + + - name: Install containerd systemd service file + ansible.builtin.get_url: + url: "{{ containerd_service_file }}" + dest: /lib/systemd/system/containerd.service owner: root group: root mode: '0644' + when: is_containerd - name: create service.d directory for the runtime file: From 1e0e055525d0f3c87750f4e5d3d1b5d2868dd12e Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Thu, 12 Oct 2023 22:21:28 +0300 Subject: [PATCH 4/9] test/e2e: don't write broken resolv.conf. Do not try to unconditionally overwrite /etc/resolv.conf with $dns_nameserver as the server. If it is unset, don't touch resolv.conf at all. Signed-off-by: Krisztian Litkey --- test/e2e/playbook/provision.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/playbook/provision.yaml b/test/e2e/playbook/provision.yaml index 0fd902e52..edb22b053 100644 --- a/test/e2e/playbook/provision.yaml +++ b/test/e2e/playbook/provision.yaml @@ -31,6 +31,7 @@ - echo "search {{ dns_search_domain }}" >> /etc/resolv.conf - sed -i "s/DNS=.*$/DNS={{ dns_nameserver }}/" /etc/systemd/resolved.conf - sed -i "s/Domains=.*$/Domains={{ dns_search_domain }}/" /etc/systemd/resolved.conf + when: dns_nameserver != "" - name: setup DNS for Ubuntu shell: "{{ item }}" From ae7f688f820fd99568d9f9771de7ccf4d2a3c4f4 Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Thu, 12 Oct 2023 22:23:35 +0300 Subject: [PATCH 5/9] test/e2e: fix image loading, patching in deployment. Load plugin images for CRI-O using a single podman import instead of an import and a podman scp. Fix plugin image reference patching in test deployment files. Signed-off-by: Krisztian Litkey --- test/e2e/playbook/nri-balloons-plugin-deploy.yaml | 9 ++++----- test/e2e/playbook/nri-topology-aware-plugin-deploy.yaml | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/test/e2e/playbook/nri-balloons-plugin-deploy.yaml b/test/e2e/playbook/nri-balloons-plugin-deploy.yaml index 37281e2ee..59be836e7 100644 --- a/test/e2e/playbook/nri-balloons-plugin-deploy.yaml +++ b/test/e2e/playbook/nri-balloons-plugin-deploy.yaml @@ -47,8 +47,8 @@ - name: fix the image name when using cri-o become: yes shell: > - sed -i 's/image: nri-resource-policy-balloons:unknown/image: localhost\/nri-resource-policy-balloons:unknown/' /etc/nri-resource-policy/nri-resource-policy-deployment.yaml; - sed -i 's/image: nri-resource-policy-balloons:unknown/image: localhost\/nri-resource-policy-balloons:unknown/' /etc/nri-resource-policy/nri-resource-policy-deployment-fallback.yaml + sed -i 's#image: nri-#image: localhost/nri-#g' /etc/nri-resource-policy/nri-resource-policy-deployment.yaml; + sed -i 's#image: nri-#image: localhost/nri-#g' /etc/nri-resource-policy/nri-resource-policy-deployment-fallback.yaml when: is_crio - name: get latest nri-resource-policy deployment image name @@ -65,9 +65,8 @@ when: is_containerd - name: load nri plugin image when using cri-o - become: yes + become: no shell: "{{ item }}" with_items: - - "podman image load -i `basename {{ nri_resource_policy_images.stdout_lines[0] }}`" - - "podman image scp localhost/nri-resource-policy-balloons:unknown vagrant@localhost::" + - "sudo podman image load -i `basename {{ nri_resource_policy_images.stdout_lines[0] }}`" when: is_crio diff --git a/test/e2e/playbook/nri-topology-aware-plugin-deploy.yaml b/test/e2e/playbook/nri-topology-aware-plugin-deploy.yaml index be1159786..c43b14678 100644 --- a/test/e2e/playbook/nri-topology-aware-plugin-deploy.yaml +++ b/test/e2e/playbook/nri-topology-aware-plugin-deploy.yaml @@ -49,8 +49,8 @@ - name: fix the image name when using cri-o become: yes shell: > - sed -i 's/image: nri-resource-policy-topology-aware:unknown/image: localhost\/nri-resource-policy-topology-aware:unknown/' /etc/nri-resource-policy/nri-resource-policy-deployment.yaml; - sed -i 's/image: nri-resource-policy-topology-aware:unknown/image: localhost\/nri-resource-policy-topology-aware:unknown/' /etc/nri-resource-policy/nri-resource-policy-deployment-fallback.yaml + sed -i 's#image: nri-#image: localhost/nri-#g' /etc/nri-resource-policy/nri-resource-policy-deployment.yaml; + sed -i 's#image: nri-#image: localhost/nri-#g' /etc/nri-resource-policy/nri-resource-policy-deployment-fallback.yaml when: is_crio - name: get latest nri-resource-policy deployment image name @@ -68,9 +68,8 @@ when: is_containerd - name: load nri plugin image when using cri-o - become: yes + become: no shell: "{{ item }}" with_items: - - "podman image load -i `basename {{ nri_resource_policy_images.stdout_lines[0] }}`" - - "podman image scp localhost/nri-resource-policy-topology-aware:unknown vagrant@localhost::" + - "sudo podman image load -i `basename {{ nri_resource_policy_images.stdout_lines[0] }}`" when: is_crio From 5947f4fce6e1a9606bd142e368b154178bd30a8b Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Thu, 12 Oct 2023 22:18:44 +0300 Subject: [PATCH 6/9] test/e2e: add support for bridge CNI plugin. And make the bridge plugin the default. Signed-off-by: Krisztian Litkey --- test/e2e/files/10-bridge.conf.in | 14 ++++++++++++++ test/e2e/files/Vagrantfile.in | 3 +++ test/e2e/playbook/provision.yaml | 14 ++++++++++++++ test/e2e/run.sh | 1 + 4 files changed, 32 insertions(+) create mode 100644 test/e2e/files/10-bridge.conf.in diff --git a/test/e2e/files/10-bridge.conf.in b/test/e2e/files/10-bridge.conf.in new file mode 100644 index 000000000..59d2571da --- /dev/null +++ b/test/e2e/files/10-bridge.conf.in @@ -0,0 +1,14 @@ +{ + "cniVersion": "0.4.0", + "name": "demonet", + "type": "bridge", + "isGateway": true, + "ipMasq": true, + "ipam": { + "type": "host-local", + "subnet": "CNI_NETWORK", + "routes": [ + { "dst": "0.0.0.0/0" } + ] + } +} diff --git a/test/e2e/files/Vagrantfile.in b/test/e2e/files/Vagrantfile.in index f1e80dd24..4bb3f4a32 100644 --- a/test/e2e/files/Vagrantfile.in +++ b/test/e2e/files/Vagrantfile.in @@ -28,6 +28,8 @@ else CRIO_SRC = "#{ENV['crio_src']}" end +CNI_PLUGIN = "#{ENV['cni_plugin']}" + NRI_RESOURCE_POLICY_SRC = "#{ENV['nri_resource_policy_src']}" OUTPUT_DIR = "#{ENV['OUTPUT_DIR']}" @@ -90,6 +92,7 @@ Vagrant.configure("2") do |config| containerd_src: CONTAINERD_SRC, crio_release: CRIO_RELEASE, crio_src: CRIO_SRC, + cni_plugin: CNI_PLUGIN, nri_resource_policy_src: NRI_RESOURCE_POLICY_SRC, outdir: OUTPUT_DIR, } diff --git a/test/e2e/playbook/provision.yaml b/test/e2e/playbook/provision.yaml index edb22b053..8e51503b2 100644 --- a/test/e2e/playbook/provision.yaml +++ b/test/e2e/playbook/provision.yaml @@ -336,6 +336,20 @@ - cilium-install.sh - rm -f cilium-linux-amd64.tar.gz + - block: + - name: Copy CNI bridge plugin configuration + copy: + src: "{{ nri_resource_policy_src }}/test/e2e/files/10-bridge.conf.in" + dest: "/etc/cni/net.d/10-bridge.conf" + owner: root + group: root + mode: '0644' + + - name: Update CNI bridge plugin configuration + become: yes + shell: "sed -i 's#CNI_NETWORK#{{ network }}#g' /etc/cni/net.d/10-bridge.conf" + when: cni_plugin == "bridge" + - name: generate join command command: kubeadm token create --print-join-command register: join_command diff --git a/test/e2e/run.sh b/test/e2e/run.sh index ebb7d47c1..3c2f1fc58 100755 --- a/test/e2e/run.sh +++ b/test/e2e/run.sh @@ -19,6 +19,7 @@ export COMMAND_OUTPUT_DIR="$TEST_OUTPUT_DIR"/commands distro=${distro:-$DEFAULT_DISTRO} export k8scri=${k8scri:-"containerd"} +export cni_plugin=${cni_plugin:-bridge} TOPOLOGY_DIR=${TOPOLOGY_DIR:=e2e} source "$LIB_DIR"/vm.bash From 77e6b5f36263019aadda133672c4d4b8c9ad2cc7 Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Thu, 12 Oct 2023 23:07:32 +0300 Subject: [PATCH 7/9] test/e2e: revert default CNI plugin to cilium. Using the bridge plugins seems to break metrics collection tests. Revert the default to cilium for now until we figure out what's wrong and fix it. Signed-off-by: Krisztian Litkey --- test/e2e/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/run.sh b/test/e2e/run.sh index 3c2f1fc58..34d69e3c6 100755 --- a/test/e2e/run.sh +++ b/test/e2e/run.sh @@ -19,7 +19,7 @@ export COMMAND_OUTPUT_DIR="$TEST_OUTPUT_DIR"/commands distro=${distro:-$DEFAULT_DISTRO} export k8scri=${k8scri:-"containerd"} -export cni_plugin=${cni_plugin:-bridge} +export cni_plugin=${cni_plugin:-cilium} TOPOLOGY_DIR=${TOPOLOGY_DIR:=e2e} source "$LIB_DIR"/vm.bash From e732811ef993a9c97ebc90f90b5829af7d93402d Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Thu, 12 Oct 2023 22:20:25 +0300 Subject: [PATCH 8/9] test/e2e: fix cilium CNI provisioning. Signed-off-by: Krisztian Litkey --- test/e2e/files/cilium-install.sh | 38 -------------------------------- test/e2e/playbook/provision.yaml | 24 +++++++++----------- 2 files changed, 10 insertions(+), 52 deletions(-) delete mode 100755 test/e2e/files/cilium-install.sh diff --git a/test/e2e/files/cilium-install.sh b/test/e2e/files/cilium-install.sh deleted file mode 100755 index d12b972ac..000000000 --- a/test/e2e/files/cilium-install.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -timeout=30s -max_retries=5 -count=0 - -ready=$(cilium status -o json --wait --wait-duration $timeout | jq .pod_state.cilium.Ready) -if [ $ready -eq 1 ]; then - echo "Cilium already installed and ready." - exit 0 -fi - -while [ $count -lt $max_retries ]; -do - cilium install - if [ $? -ne 0 ]; then - cilium uninstall - sleep 5 - count=$(($count + 1)) - continue - fi - - ready=$(cilium status -o json --wait --wait-duration $timeout | jq .pod_state.cilium.Ready) - if [ $ready -eq 1 ]; then - break - fi - - echo "Cilium ready timeout, retrying" - count=$(($count + 1)) - - cilium uninstall -done - -if [ $ready -ne 1 ]; then - exit 1 -fi - -exit 0 diff --git a/test/e2e/playbook/provision.yaml b/test/e2e/playbook/provision.yaml index 8e51503b2..26c9dfa81 100644 --- a/test/e2e/playbook/provision.yaml +++ b/test/e2e/playbook/provision.yaml @@ -320,21 +320,17 @@ - kubectl taint nodes --all node-role.kubernetes.io/control-plane- || true - kubectl taint nodes --all node-role.kubernetes.io/master- || true - - name: copy cilium install script - copy: - src: "{{ nri_resource_policy_src }}/test/e2e/files/cilium-install.sh" - dest: /usr/local/bin/cilium-install.sh - owner: root - group: root - mode: '0755' + - block: + - name: Fetch and extract cilium (installer) release tarball + ansible.builtin.unarchive: + src: "https://github.com/cilium/cilium-cli/releases/latest/download/cilium-linux-amd64.tar.gz" + dest: /usr/local/bin + remote_src: yes - - name: Install cilium cni - command: "{{ item }}" - with_items: - - curl -L --remote-name-all https://github.com/cilium/cilium-cli/releases/latest/download/cilium-linux-amd64.tar.gz - - tar xzvfC cilium-linux-amd64.tar.gz /usr/local/bin - - cilium-install.sh - - rm -f cilium-linux-amd64.tar.gz + - name: Run cilium installer + ansible.builtin.shell: + cmd: cilium install --wait + when: cni_plugin == "cilium" - block: - name: Copy CNI bridge plugin configuration From f4c685f57c80e93325cfcbb6ba2a53d02847587d Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Wed, 11 Oct 2023 17:14:07 +0300 Subject: [PATCH 9/9] Makefile: add the e2e-tests target Signed-off-by: Antti Kervinen --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index d847ba981..827765c19 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,9 @@ GINKGO := ginkgo TEST_SETUP := test-setup.sh TEST_CLEANUP := test-cleanup.sh +E2E_TESTS ?= policies.test-suite +RUN_E2E_TESTS := cd test/e2e; ./run_tests.sh + BUILD_PATH := $(shell pwd)/build BIN_PATH := $(BUILD_PATH)/bin COVERAGE_PATH := $(BUILD_PATH)/coverage @@ -337,6 +340,9 @@ ginkgo-subpkgs-tests: # TODO(klihub): coverage ? -r . || exit 1); \ done +e2e-tests: build images + $(Q)$(RUN_E2E_TESTS) $(E2E_TESTS) + codecov: SHELL := $(shell which bash) codecov: bash <(curl -s https://codecov.io/bash) -f $(COVERAGE_PATH)/coverprofile