From d72a2b0c7b767b23d387368641e349bbca0cfdb4 Mon Sep 17 00:00:00 2001 From: Jiri Kortus Date: Thu, 5 Mar 2020 19:51:57 +0100 Subject: [PATCH] [tests] Enable handling of rel-eng images In order to enable testing on rel-eng images, it's necessary to properly change the way lorax-composer packages are installed (in Makefile and vm.install script). Related: rhbz#1810711 --- Makefile | 14 ++++++++++++++ test/README.md | 18 ++++++++++++++++++ test/vm.install | 19 +++++++++++++++---- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 720e9d79..ccdf08db 100644 --- a/Makefile +++ b/Makefile @@ -149,6 +149,20 @@ vm-local-repos: vm --run-command "systemctl enable lorax-composer" \ $(TEST_OS) +vm-releng: + rm -f $(VM_IMAGE) $(VM_IMAGE).qcow2 + bots/image-customize -v \ + --resize 20G \ + --upload $(CURDIR)/test/vm.install:/var/tmp/vm.install \ + --upload $(realpath tests):/ \ + --run-command "chmod +x /var/tmp/vm.install" \ + --run-command "cd /var/tmp; BUILD_SRPM=0 /var/tmp/vm.install" \ + $(TEST_OS) + [ -f ~/.config/lorax-test-env ] && bots/image-customize \ + --upload ~/.config/lorax-test-env:/var/tmp/lorax-test-env \ + $(TEST_OS) || echo + + vm-reset: rm -f $(VM_IMAGE) $(VM_IMAGE).qcow2 diff --git a/test/README.md b/test/README.md index 3e9cde83..e765979d 100644 --- a/test/README.md +++ b/test/README.md @@ -49,6 +49,24 @@ You may also define `REPOS_DIR` variable to point to another directory containing yum .repo files. By default the value is `/etc/yum.repos.d`! This is mostly useful when running tests by hand on a downstream snapshot! +If you need to run the tests on a particular rel-eng RHEL compose, you can +create the image by using [image-create-rhel-compose](https://github.com/cockpit-project/bots/blob/master/image-create-rhel-compose) +script from bots repo. By default it uses the `-latest` extras rel-eng repo, +however it’s advisable to build the image using explicitly specified repos +using `COMPOSE` and `EXTRAS_COMPOSE` environment variables, for example: + + $ export COMPOSE=”RHEL-7.x-yyyymmdd.b” + $ export EXTRAS_COMPOSE=”EXTRAS-7.x-RHEL-7-yyyymmdd.b” + $ bots/image-create-rhel-compose + +This will provide you with a RHEL-7.x-yyyymmdd.b image with preconfigured +rel-eng repos. To perform the composer-specific setup as you would do by `make vm` +for a stock bots image, use + + $ export TEST_OS=”rhel-7-x-yyyymmdd-b” + $ make vm-releng + + ## Running tests After building a test image, run diff --git a/test/vm.install b/test/vm.install index fe00d3e6..045e448a 100755 --- a/test/vm.install +++ b/test/vm.install @@ -1,6 +1,11 @@ #!/bin/sh -eux -SRPM="$1" +# BUILD_SRPM serves as a flag whether we should build and install the composer packages +BUILD_SRPM=${BUILD_SRPM:-1} + +if [ "$BUILD_SRPM" -eq 1 ]; then + SRPM="$1" +fi # always remove older versions of these RPMs if they exist # to ensure newly built packages have been installed @@ -86,11 +91,17 @@ rootlv=$(findmnt --noheadings -oSOURCE /) lvresize $rootlv -l+100%FREE -r rm -rf build-results -su builder -c "/usr/bin/mock --no-clean --resultdir build-results --rebuild $SRPM" -packages=$(find build-results -name '*.rpm' -not -name '*.src.rpm') -yum install -y $packages +if [ "$BUILD_SRPM" -eq 1 ]; then + SRPM="$1" + su builder -c "/usr/bin/mock --no-clean --resultdir build-results --rebuild $SRPM" + + packages=$(find build-results -name '*.rpm' -not -name '*.src.rpm') + yum install -y $packages +else + yum -y install lorax-composer composer-cli +fi systemctl enable lorax-composer.socket if [ -f /usr/bin/docker ]; then