libvirt/ci/integration.yml
Erik Skultety e23353756e ci: Define the integration job tag dynamically via a variable
Custom runners are private to a project, so naturally forks cannot run
any workloads on these. The integration test suite which requires
access to our custom runner is naturally disabled on forks and can be
enabled by setting LIBVIRT_CI_INTEGRATION=1.
The problem is that the current integration jobs definitions have tags
statically defined as 'redhat-vm-host'. If users are going to supply
their own private runners for their forks, they can define whatever
tags they want with it and so unless they add 'redhat-vm-host' to their
own runner's tags, the pipeline won't run.
To solve this, define the integration job tag using a variable. The
repo config will use the value defined in the job for the variable
while users can override the value easily on a project/pipeline level
thanks to GitLab's CI variable precedence [1].

[1] https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-03-22 12:07:37 +01:00

111 lines
3.6 KiB
YAML

.integration_tests:
stage: integration_tests
before_script:
- mkdir "$SCRATCH_DIR"
- sudo dnf install -y libvirt-rpms/* libvirt-perl-rpms/*
- sudo pip3 install --prefix=/usr avocado-framework
- source /etc/os-release # in order to query the vendor-provided variables
- if test "$ID" = "centos" && test "$VERSION_ID" -lt 9 ||
test "$ID" = "fedora" && test "$VERSION_ID" -lt 35;
then
DAEMONS="libvirtd virtlogd virtlockd";
else
DAEMONS="virtproxyd virtqemud virtinterfaced virtsecretd virtstoraged virtnwfilterd virtnodedevd virtlogd virtlockd";
fi
- for daemon in $DAEMONS;
do
LOG_OUTPUTS="1:file:/var/log/libvirt/${daemon}.log";
LOG_FILTERS="3:remote 4:event 3:util.json 3:util.object 3:util.dbus 3:util.netlink 3:node_device 3:rpc 3:access 1:*";
sudo augtool set /files/etc/libvirt/${daemon}.conf/log_filters "$LOG_FILTERS" &>/dev/null;
sudo augtool set /files/etc/libvirt/${daemon}.conf/log_outputs "$LOG_OUTPUTS" &>/dev/null;
sudo systemctl --quiet stop ${daemon}.service;
sudo systemctl restart ${daemon}.socket;
done
- sudo virsh net-start default &>/dev/null || true;
script:
- mkdir logs
- cd "$SCRATCH_DIR"
- git clone --depth 1 https://gitlab.com/libvirt/libvirt-tck.git
- cd libvirt-tck
- sudo avocado --config avocado.config run --job-results-dir "$SCRATCH_DIR"/avocado
after_script:
- test "$CI_JOB_STATUS" = "success" && exit 0;
- test -e "$SCRATCH_DIR"/avocado && sudo mv "$SCRATCH_DIR"/avocado/latest/test-results logs/avocado;
- sudo mv /var/log/libvirt logs/libvirt
- sudo chown -R $(whoami):$(whoami) logs
variables:
SCRATCH_DIR: "/tmp/scratch"
artifacts:
name: logs
paths:
- logs
when: on_failure
rules:
- if: '$LIBVIRT_CI_INTEGRATION'
when: on_success
- when: never
centos-stream-8-tests:
extends: .integration_tests
needs:
- x86_64-centos-stream-8
- project: libvirt/libvirt-perl
job: x86_64-centos-stream-8
ref: master
artifacts: true
variables:
# needed by libvirt-gitlab-executor
DISTRO: centos-stream-8
# can be overriden in forks to set a different runner tag
LIBVIRT_CI_INTEGRATION_RUNNER_TAG: redhat-vm-host
tags:
- $LIBVIRT_CI_INTEGRATION_RUNNER_TAG
centos-stream-9-tests:
extends: .integration_tests
needs:
- x86_64-centos-stream-9
- project: libvirt/libvirt-perl
job: x86_64-centos-stream-9
ref: master
artifacts: true
variables:
# needed by libvirt-gitlab-executor
DISTRO: centos-stream-9
# can be overriden in forks to set a different runner tag
LIBVIRT_CI_INTEGRATION_RUNNER_TAG: redhat-vm-host
tags:
- $LIBVIRT_CI_INTEGRATION_RUNNER_TAG
fedora-34-tests:
extends: .integration_tests
needs:
- x86_64-fedora-34
- project: libvirt/libvirt-perl
job: x86_64-fedora-34
ref: master
artifacts: true
variables:
# needed by libvirt-gitlab-executor
DISTRO: fedora-34
# can be overriden in forks to set a different runner tag
LIBVIRT_CI_INTEGRATION_RUNNER_TAG: redhat-vm-host
tags:
- $LIBVIRT_CI_INTEGRATION_RUNNER_TAG
fedora-35-tests:
extends: .integration_tests
needs:
- x86_64-fedora-35
- project: libvirt/libvirt-perl
job: x86_64-fedora-35
ref: master
artifacts: true
variables:
# needed by libvirt-gitlab-executor
DISTRO: fedora-35
# can be overriden in forks to set a different runner tag
LIBVIRT_CI_INTEGRATION_RUNNER_TAG: redhat-vm-host
tags:
- $LIBVIRT_CI_INTEGRATION_RUNNER_TAG