[libvirt PATCH v2 0/5] ci: Add an integration test job utilizing upstream QEMU

Since QEMU doesn't maintain a spec file in upstream, we cannot build RPM artifacts as part of the CI as we do for libvirt. Instead, we build QEMU from source manually. Since v1: - hard-code the QEMU build steps rather than pulling the build template from upstream QEMU's CI due to a possibility of QEMU moving the template file or renaming the build template itself -> only patch 3/5 was modified, the rest remained the same Successful pipeline: https://gitlab.com/eskultety/libvirt/-/pipelines/537225094 Erik Skultety (5): ci: Separate the integration job template to a separate file ci: Break off the integration_tests template into more templates ci: Introduce a template for upstream QEMU build ci: Add a new integration job template for the upstream QEMU scenario ci: Add a Fedora integration test job utilizing upstream QEMU ci/integration-template.yml | 100 ++++++++++++++++++++++++++++++++++++ ci/integration.yml | 70 +++++++------------------ 2 files changed, 118 insertions(+), 52 deletions(-) create mode 100644 ci/integration-template.yml -- 2.34.3

Future patches will do more code extraction from the existing template using YAML anchors so it'd be better that the templates would live separately from job definitions. Signed-off-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> --- ci/integration-template.yml | 52 +++++++++++++++++++++++++++++++++++ ci/integration.yml | 54 ++----------------------------------- 2 files changed, 54 insertions(+), 52 deletions(-) create mode 100644 ci/integration-template.yml diff --git a/ci/integration-template.yml b/ci/integration-template.yml new file mode 100644 index 0000000000..c4201df6db --- /dev/null +++ b/ci/integration-template.yml @@ -0,0 +1,52 @@ +.integration_tests: + stage: integration_tests + before_script: + - mkdir "$SCRATCH_DIR" + - sudo sh -c "echo DefaultLimitCORE=infinity >> /etc/systemd/system.conf" # Explicitly allow storing cores globally + - sudo systemctl daemon-reexec # need to reexec systemd after changing config + - 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 coredumpctl info --no-pager > logs/coredumpctl.txt + - sudo mv /var/log/libvirt logs/libvirt + - sudo chown -R $(whoami):$(whoami) logs + # rename all Avocado stderr/stdout logs to *.log so that GitLab's web UI doesn't mangle the MIME type + - find logs/avocado/ -type f ! -name "*.log" -exec + sh -c 'DIR=$(dirname {}); NAME=$(basename {}); mv $DIR/$NAME{,.log}' \; + variables: + SCRATCH_DIR: "/tmp/scratch" + artifacts: + name: logs + paths: + - logs + when: on_failure + rules: + - if: '$LIBVIRT_CI_INTEGRATION' + when: on_success + - when: never diff --git a/ci/integration.yml b/ci/integration.yml index 17f20b3945..a71df41694 100644 --- a/ci/integration.yml +++ b/ci/integration.yml @@ -1,55 +1,5 @@ -.integration_tests: - stage: integration_tests - before_script: - - mkdir "$SCRATCH_DIR" - - sudo sh -c "echo DefaultLimitCORE=infinity >> /etc/systemd/system.conf" # Explicitly allow storing cores globally - - sudo systemctl daemon-reexec # need to reexec systemd after changing config - - 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 coredumpctl info --no-pager > logs/coredumpctl.txt - - sudo mv /var/log/libvirt logs/libvirt - - sudo chown -R $(whoami):$(whoami) logs - # rename all Avocado stderr/stdout logs to *.log so that GitLab's web UI doesn't mangle the MIME type - - find logs/avocado/ -type f ! -name "*.log" -exec - sh -c 'DIR=$(dirname {}); NAME=$(basename {}); mv $DIR/$NAME{,.log}' \; - variables: - SCRATCH_DIR: "/tmp/scratch" - artifacts: - name: logs - paths: - - logs - when: on_failure - rules: - - if: '$LIBVIRT_CI_INTEGRATION' - when: on_success - - when: never +include: + - 'ci/integration-template.yml' centos-stream-8-tests: extends: .integration_tests -- 2.34.3

There's quite a lot happening in the .integration_tests template already even without adding upstream QEMU build into the mix. Let's break the template into more pieces which can then reference in the .integration_tests template when putting all the pieces back together using YAML anchors. Signed-off-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> --- ci/integration-template.yml | 76 +++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/ci/integration-template.yml b/ci/integration-template.yml index c4201df6db..195e9cfa5f 100644 --- a/ci/integration-template.yml +++ b/ci/integration-template.yml @@ -1,44 +1,62 @@ + + +.install-deps: &install-deps + - sudo dnf install -y libvirt-rpms/* libvirt-perl-rpms/* + - sudo pip3 install --prefix=/usr avocado-framework + + +.enable-core-dumps: &enable-core-dumps + - sudo sh -c "echo DefaultLimitCORE=infinity >> /etc/systemd/system.conf" # Explicitly allow storing cores globally + - sudo systemctl daemon-reexec # need to reexec systemd after changing config + + +.enable-libvirt-debugging: &enable-libvirt-debugging + - 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 + + +.collect-logs: &collect-logs + - mkdir logs + - test -e "$SCRATCH_DIR"/avocado && sudo mv "$SCRATCH_DIR"/avocado/latest/test-results logs/avocado; + - sudo coredumpctl info --no-pager > logs/coredumpctl.txt + - sudo mv /var/log/libvirt logs/libvirt + - sudo chown -R $(whoami):$(whoami) logs + # rename all Avocado stderr/stdout logs to *.log so that GitLab's web UI doesn't mangle the MIME type + - find logs/avocado/ -type f ! -name "*.log" -exec + sh -c 'DIR=$(dirname {}); NAME=$(basename {}); mv $DIR/$NAME{,.log}' \; + + .integration_tests: stage: integration_tests before_script: - mkdir "$SCRATCH_DIR" - - sudo sh -c "echo DefaultLimitCORE=infinity >> /etc/systemd/system.conf" # Explicitly allow storing cores globally - - sudo systemctl daemon-reexec # need to reexec systemd after changing config - - 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 + - *install-deps + - *enable-core-dumps + - *enable-libvirt-debugging - 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 coredumpctl info --no-pager > logs/coredumpctl.txt - - sudo mv /var/log/libvirt logs/libvirt - - sudo chown -R $(whoami):$(whoami) logs - # rename all Avocado stderr/stdout logs to *.log so that GitLab's web UI doesn't mangle the MIME type - - find logs/avocado/ -type f ! -name "*.log" -exec - sh -c 'DIR=$(dirname {}); NAME=$(basename {}); mv $DIR/$NAME{,.log}' \; + - *collect-logs variables: SCRATCH_DIR: "/tmp/scratch" artifacts: -- 2.34.3

This was heavily inspired by QEMU's upstream CI buildtest-template.yml. Rather than referencing QEMU's template directly (which GitLab can do), this patch resorts to hard-coding the build steps ourselves, solely because there's no guarantee QEMU will keep either the template file name or the template name from which the build steps were mostly copied from. Signed-off-by: Erik Skultety <eskultet@redhat.com> --- ci/integration-template.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ci/integration-template.yml b/ci/integration-template.yml index 195e9cfa5f..89fc3f0bae 100644 --- a/ci/integration-template.yml +++ b/ci/integration-template.yml @@ -1,3 +1,22 @@ +.qemu-build-template: &qemu-build-template + - git clone --depth 1 https://gitlab.com/qemu-project/qemu.git + - cd qemu + # + # inspired by upstream QEMU's buildtest-template.yml + - export JOBS="$(expr $(nproc) + 1)" + - mkdir build + - cd build + - ../configure --prefix=/usr + --enable-werror + --disable-tcg + --disable-docs + --target-list=x86_64-softmmu || (cat config.log meson-logs/meson-log.txt && exit 1) + - make -j"$JOBS" + - if test -n "$MAKE_CHECK_ARGS"; + then + make -j"$JOBS" check-build; + fi + - sudo make install .install-deps: &install-deps -- 2.34.3

On Thu, May 12, 2022 at 10:50:57AM +0200, Erik Skultety wrote:
This was heavily inspired by QEMU's upstream CI buildtest-template.yml. Rather than referencing QEMU's template directly (which GitLab can do), this patch resorts to hard-coding the build steps ourselves, solely because there's no guarantee QEMU will keep either the template file name or the template name from which the build steps were mostly copied from.
Signed-off-by: Erik Skultety <eskultet@redhat.com> --- ci/integration-template.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Thu, May 12, 2022 at 10:04:07AM +0100, Daniel P. Berrangé wrote:
On Thu, May 12, 2022 at 10:50:57AM +0200, Erik Skultety wrote:
This was heavily inspired by QEMU's upstream CI buildtest-template.yml. Rather than referencing QEMU's template directly (which GitLab can do), this patch resorts to hard-coding the build steps ourselves, solely because there's no guarantee QEMU will keep either the template file name or the template name from which the build steps were mostly copied from.
Signed-off-by: Erik Skultety <eskultet@redhat.com> --- ci/integration-template.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Pushed, thanks. Erik

YAML anchors don't work with Shell condition structures, so we cannot simply reference the QEMU build template YAML anchor conditionally and hence have everything as part of a single job template. Instead, we have to "subclass" the .integration_tests template and inject the QEMU building bits explicitly. Signed-off-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> --- ci/integration-template.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ci/integration-template.yml b/ci/integration-template.yml index 89fc3f0bae..e2ccebd1f6 100644 --- a/ci/integration-template.yml +++ b/ci/integration-template.yml @@ -87,3 +87,14 @@ - if: '$LIBVIRT_CI_INTEGRATION' when: on_success - when: never + + +# YAML anchors don't work with Shell conditions so we can't use a variable +# to conditionally build+install QEMU from source. +# Instead, create a new test job template for this scenario. +.integration_tests_upstream_qemu: + extends: .integration_tests + before_script: + - !reference [.integration_tests, before_script] + - cd "$SCRATCH_DIR" + - *qemu-build-template -- 2.34.3

Signed-off-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> --- ci/integration.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ci/integration.yml b/ci/integration.yml index a71df41694..4978d3cf02 100644 --- a/ci/integration.yml +++ b/ci/integration.yml @@ -64,3 +64,19 @@ fedora-35-tests: LIBVIRT_CI_INTEGRATION_RUNNER_TAG: redhat-vm-host tags: - $LIBVIRT_CI_INTEGRATION_RUNNER_TAG + +fedora-35-upstream-qemu-tests: + extends: .integration_tests_upstream_qemu + 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 overridden in forks to set a different runner tag + LIBVIRT_CI_INTEGRATION_RUNNER_TAG: redhat-vm-host + tags: + - $LIBVIRT_CI_INTEGRATION_RUNNER_TAG -- 2.34.3
participants (2)
-
Daniel P. Berrangé
-
Erik Skultety