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

fixes: fix a bunch of problems in bootstrapping e2e tests. #154

Merged
merged 9 commits into from
Oct 16, 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
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions test/e2e/files/10-bridge.conf.in
Original file line number Diff line number Diff line change
@@ -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" }
]
}
}
9 changes: 9 additions & 0 deletions test/e2e/files/Vagrantfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@ 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

CNI_PLUGIN = "#{ENV['cni_plugin']}"

NRI_RESOURCE_POLICY_SRC = "#{ENV['nri_resource_policy_src']}"
OUTPUT_DIR = "#{ENV['OUTPUT_DIR']}"

Expand Down Expand Up @@ -82,8 +88,11 @@ 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,
cni_plugin: CNI_PLUGIN,
nri_resource_policy_src: NRI_RESOURCE_POLICY_SRC,
outdir: OUTPUT_DIR,
}
Expand Down
38 changes: 0 additions & 38 deletions test/e2e/files/cilium-install.sh

This file was deleted.

40 changes: 0 additions & 40 deletions test/e2e/files/containerd.service

This file was deleted.

18 changes: 0 additions & 18 deletions test/e2e/files/crio.service

This file was deleted.

9 changes: 4 additions & 5 deletions test/e2e/playbook/nri-balloons-plugin-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -65,9 +65,8 @@
when: is_containerd

- name: load nri plugin image when using cri-o
become: yes
become: no
shell: "{{ item }}"
klihub marked this conversation as resolved.
Show resolved Hide resolved
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
9 changes: 4 additions & 5 deletions test/e2e/playbook/nri-topology-aware-plugin-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
106 changes: 76 additions & 30 deletions test/e2e/playbook/provision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
- 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"
- 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 }}"
- cni_plugin: "{{ cni_plugin }}"


tasks:
- set_fact:
Expand All @@ -23,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 }}"
Expand Down Expand Up @@ -119,35 +128,62 @@
- 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 == ""

klihub marked this conversation as resolved.
Show resolved Hide resolved
# 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 == ""
klihub marked this conversation as resolved.
Show resolved Hide resolved

# 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:
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:
Expand Down Expand Up @@ -284,21 +320,31 @@
- 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'

- 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
- 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: Run cilium installer
ansible.builtin.shell:
cmd: cilium install --wait
when: cni_plugin == "cilium"

- 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
Expand Down
Loading