From 315313dd10cc234ce20562372000b5d18e2e5461 Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Tue, 11 Mar 2025 11:47:17 +0100 Subject: [PATCH] CI: convert molecule jobs to parallel:matrix With the new provisionning using kubevirt this should be faster. --- .gitlab-ci/molecule.yml | 85 +++++++------------ .../roles/packet-ci/tasks/main.yml | 2 +- .../roles/packet-ci/templates/vm.yml.j2 | 2 +- .../roles/packet-ci/vars/main.yml | 1 - 4 files changed, 31 insertions(+), 59 deletions(-) diff --git a/.gitlab-ci/molecule.yml b/.gitlab-ci/molecule.yml index 119c2ba22..2dd93af00 100644 --- a/.gitlab-ci/molecule.yml +++ b/.gitlab-ci/molecule.yml @@ -19,65 +19,38 @@ paths: - molecule_logs/ +molecule: + extends: .molecule + script: + - ./tests/scripts/molecule_run.sh -i $ROLE + parallel: + matrix: + - ROLE: + - container-engine/cri-dockerd + - container-engine/containerd + - container-engine/cri-o + - adduser + - bastion-ssh-config + - bootstrap-os + # CI template for periodic CI jobs # Enabled when PERIODIC_CI_ENABLED var is set -.molecule_periodic: +molecule_full: only: variables: - $PERIODIC_CI_ENABLED allow_failure: true - extends: .molecule - -molecule_full: - extends: .molecule_periodic - -molecule_no_container_engines: - extends: .molecule - script: - - ./tests/scripts/molecule_run.sh -e container-engine - when: on_success - -molecule_docker: - extends: .molecule - script: - - ./tests/scripts/molecule_run.sh -i container-engine/cri-dockerd - when: on_success - -molecule_containerd: - extends: .molecule - script: - - ./tests/scripts/molecule_run.sh -i container-engine/containerd - when: on_success - -molecule_cri-o: - extends: .molecule - stage: deploy-part1 - script: - - ./tests/scripts/molecule_run.sh -i container-engine/cri-o - allow_failure: true - when: on_success - -# # Stage 3 container engines don't get as much attention so allow them to fail -# molecule_kata: -# extends: .molecule -# stage: deploy-extended -# script: -# - ./tests/scripts/molecule_run.sh -i container-engine/kata-containers -# when: manual -# # FIXME: this test is broken (perma-failing) - -molecule_gvisor: - extends: .molecule - stage: deploy-extended - script: - - ./tests/scripts/molecule_run.sh -i container-engine/gvisor - when: manual -# FIXME: this test is broken (perma-failing) - -molecule_youki: - extends: .molecule - stage: deploy-extended - script: - - ./tests/scripts/molecule_run.sh -i container-engine/youki - when: manual -# FIXME: this test is broken (perma-failing) + extends: molecule + parallel: + matrix: + - ROLE: + - container-engine/cri-dockerd + - container-engine/containerd + - container-engine/cri-o + - adduser + - bastion-ssh-config + - bootstrap-os + # FIXME : tests below are perma-failing + - container-engine/kata-containers + - container-engine/gvisor + - container-engine/youki diff --git a/tests/cloud_playbooks/roles/packet-ci/tasks/main.yml b/tests/cloud_playbooks/roles/packet-ci/tasks/main.yml index 56ed0a414..5f620e7d5 100644 --- a/tests/cloud_playbooks/roles/packet-ci/tasks/main.yml +++ b/tests/cloud_playbooks/roles/packet-ci/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Include custom vars for ci job - include_vars: "../files/{{ ci_job_name }}.yml" + include_vars: "../files/{{ lookup('ansible.builtin.env', 'CI_JOB_NAME') }}.yml" when: molecule_yml is not defined - name: Generate SSH keypair diff --git a/tests/cloud_playbooks/roles/packet-ci/templates/vm.yml.j2 b/tests/cloud_playbooks/roles/packet-ci/templates/vm.yml.j2 index bbe67f26d..db80155fd 100644 --- a/tests/cloud_playbooks/roles/packet-ci/templates/vm.yml.j2 +++ b/tests/cloud_playbooks/roles/packet-ci/templates/vm.yml.j2 @@ -13,7 +13,7 @@ metadata: kubevirt.io/os: {{ cloud_image }} kubevirt.io/size: small ci_job_id: "{{ ci_job_id }}" - ci_job_name: "{{ ci_job_name }}" + ci_job_name: "{{ lookup('ansible.builtin.env', 'CI_JOB_NAME_SLUG') }}" # leverage the Kubernetes GC for resources cleanup ownerReferences: - apiVersion: v1 diff --git a/tests/cloud_playbooks/roles/packet-ci/vars/main.yml b/tests/cloud_playbooks/roles/packet-ci/vars/main.yml index 6a34bb1a8..e8bac22e9 100644 --- a/tests/cloud_playbooks/roles/packet-ci/vars/main.yml +++ b/tests/cloud_playbooks/roles/packet-ci/vars/main.yml @@ -31,7 +31,6 @@ scenarios: # Get pod metadata / CI vars from environment ci_job_id: "{{ lookup('ansible.builtin.env', 'CI_JOB_ID', default=undefined) }}" -ci_job_name: "{{ lookup('ansible.builtin.env', 'CI_JOB_NAME', default=undefined) }}" pod_name: "{{ lookup('ansible.builtin.env', 'POD_NAME', default=undefined) }}" pod_uid: "{{ lookup('ansible.builtin.env', 'POD_UID', default=undefined) }}" pod_namespace: "{{ lookup('ansible.builtin.env', 'POD_NAMESPACE', default=undefined) }}"