#3 Introduce CI
Merged 3 years ago by nickc. Opened 3 years ago by vkadlcik.
Unknown source master  into  master

file added
+1
@@ -0,0 +1,1 @@

+ 1

file added
+14
@@ -0,0 +1,14 @@

+ --- !Policy

+ product_versions:

+   - fedora-*

+ decision_context: bodhi_update_push_stable

+ subject_type: koji_build

+ rules:

+   - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}

+ --- !Policy

+ product_versions:

+   - rhel-9

+ decision_context: osci_compose_gate

+ rules:

+   - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

+   - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional}

file added
+6
@@ -0,0 +1,6 @@

+ summary: CI Gating Plan

+ discover:

+     how: fmf

+     directory: tests

+ execute:

+     how: beakerlib

file added
+2
@@ -0,0 +1,2 @@

+ The test's Makefiles are not used in Fedora CI infrastructure.  But are kept here

+  for backward compatibility with traditional beakerlib test harness in RHEL.

@@ -0,0 +1,67 @@

+ # Copyright (c) 2009, 2012 Red Hat, Inc. All rights reserved.

+ #

+ # This program is free software: you can redistribute it and/or modify

+ # it under the terms of the GNU General Public License as published by

+ # the Free Software Foundation, either version 3 of the License, or

+ # (at your option) any later version.

+ # 

+ # This program is distributed in the hope that it will be useful,

+ # but WITHOUT ANY WARRANTY; without even the implied warranty of

+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ # GNU General Public License for more details.

+ # 

+ # You should have received a copy of the GNU General Public License

+ # along with this program.  If not, see <http://www.gnu.org/licenses/>.

+ #

+ # Rebuild kernel, install it, reboot, and check if we're running the correct

+ # kernel. Tailored specificaly for binutils buildroot testing process.

+ #

+ # Author: Milos Prchlik <mprchlik@redhat.com>

+ #

+ # Based on gcc/Sanity/rebuild-kernel by:

+ # Author: Michal Nowak <mnowak@redhat.com>

+ # Author: Marek Polacek <polacek@redhat.com>

+ 

+ 

+ export TEST=/tools/binutils/Sanity/rebuild-kernel-and-reboot

+ export TESTVERSION=1.0

+ 

+ BUILT_FILES=

+ 

+ FILES=$(METADATA) runtest.sh Makefile PURPOSE

+ 

+ .PHONY: all install download clean

+ 

+ run: $(FILES) build

+ 	./runtest.sh

+ 

+ build: $(BUILT_FILES)

+ 	chmod a+x ./runtest.sh

+ 

+ clean:

+ 	rm -f *~ $(BUILT_FILES)

+ 

+ 

+ include /usr/share/rhts/lib/rhts-make.include

+ 

+ 

+ $(METADATA): Makefile

+ 	@echo "Owner:        Milos Prchlik <mprchlik@redhat.com>" > $(METADATA)

+ 	@echo "Name:         $(TEST)" >> $(METADATA)

+ 	@echo "Path:         $(TEST_DIR)"       >> $(METADATA)

+ 	@echo "TestVersion:  $(TESTVERSION)"    >> $(METADATA)

+ 	@echo "Description:  Rebuild kernel, install it, reboot, and check if we're running the correct kernel" >> $(METADATA)

+ 	@echo "Type:         Sanity" >> $(METADATA)

+ 	@echo "TestTime:     20h" >> $(METADATA)

+ 	@echo "RunFor:       binutils" >> $(METADATA)

+ 	@echo "Requires:     binutils" >> $(METADATA)

+ 	@echo "Requires:     gcc" >> $(METADATA)

+ 	@echo "Requires:     yum-utils rng-tools" >> $(METADATA)

+ 	@echo "Requires:     rpm-build" >> $(METADATA)

+ 	@echo "Requires:     newt-devel python-devel perl-ExtUtils-Embed unifdef elfutils-libelf-devel" >> $(METADATA)

+ 	@echo "Requires:     elfutils-devel pciutils-devel" >> $(METADATA)

+ 	@echo "Requires:     wget hmaccalc binutils-devel glibc-static texinfo gdb ecj gcc-java ppl-devel cloog-ppl-devel graphviz gmp-devel mpfr-devel" >> $(METADATA)

+ 	@echo "Requires:     xmlto asciidoc net-tools pesign" >> $(METADATA)

+ 	@echo "License:      GPLv3+" >> $(METADATA)

+ 

+ 	rhts-lint $(METADATA)

@@ -0,0 +1,20 @@

+ Rebuild kernel, install it, reboot, and check if we're running the correct

+ kernel. Tailored specificaly for binutils buildroot testing process.

+ 

+ Author: Milos Prchlik <mprchlik@redhat.com>

+ 

+ Based on gcc/Sanity/rebuild-kernel by:

+ Author: Michal Nowak <mnowak@redhat.com>

+ Author: Marek Polacek <polacek@redhat.com>

+ 

+ Using MACHINE_SET__STRONG host-filter for this test, by setting the "hardware"

+ section in TCMS properly. That has several effects:

+ 

+   - kernel rebuild is very resoruce-intensive task, and having more powerful

+     boxes for it is simply good,

+   - this task will get its own boxes, not clobbered by additional kernel packages

+     that are usually installed by other tasks in the same run. E.g.kernel-debuginfo,

+     when installed, will conflict with freshly build kernel packages. This should

+     workaround such situations,

+   - this tasks reboots its boxes - should such reboot break something, don't ruin

+     the whole run by it, right?

@@ -0,0 +1,62 @@

+ summary: Rebuild kernel, install it, reboot, and check if we're running the correct

+     kernel

+ description: |

+     Rebuild kernel, install it, reboot, and check if we're running the correct

+     kernel. Tailored specificaly for binutils buildroot testing process.

+ 

+     Author: Milos Prchlik <mprchlik@redhat.com>

+ 

+     Based on gcc/Sanity/rebuild-kernel by:

+     Author: Michal Nowak <mnowak@redhat.com>

+     Author: Marek Polacek <polacek@redhat.com>

+ 

+     Using MACHINE_SET__STRONG host-filter for this test, by setting the "hardware"

+     section in TCMS properly. That has several effects:

+ 

+       - kernel rebuild is very resoruce-intensive task, and having more powerful

+         boxes for it is simply good,

+       - this task will get its own boxes, not clobbered by additional kernel packages

+         that are usually installed by other tasks in the same run. E.g.kernel-debuginfo,

+         when installed, will conflict with freshly build kernel packages. This should

+         workaround such situations,

+       - this tasks reboots its boxes - should such reboot break something, don't ruin

+         the whole run by it, right?

+ contact:

+ - Milos Prchlik <mprchlik@redhat.com>

+ component:

+ - binutils

+ test: ./runtest.sh

+ framework: beakerlib

+ recommend:

+ - binutils

+ - gcc

+ - yum-utils

+ - rng-tools

+ - rpm-build

+ - newt-devel

+ - python-devel

+ - perl-ExtUtils-Embed

+ - unifdef

+ - elfutils-libelf-devel

+ - elfutils-devel

+ - pciutils-devel

+ - wget

+ - hmaccalc

+ - binutils-devel

+ - glibc-static

+ - texinfo

+ - gdb

+ - ecj

+ - gcc-java

+ - ppl-devel

+ - cloog-ppl-devel

+ - graphviz

+ - gmp-devel

+ - mpfr-devel

+ - xmlto

+ - asciidoc

+ - net-tools

+ - pesign

+ duration: 20h

+ extra-summary: /tools/binutils/Sanity/rebuild-kernel-and-reboot

+ extra-task: /tools/binutils/Sanity/rebuild-kernel-and-reboot

@@ -0,0 +1,200 @@

+ #!/bin/bash

+ # Copyright (c) 2009, 2012 Red Hat, Inc. All rights reserved.

+ #

+ # This program is free software: you can redistribute it and/or modify

+ # it under the terms of the GNU General Public License as published by

+ # the Free Software Foundation, either version 3 of the License, or

+ # (at your option) any later version.

+ # 

+ # This program is distributed in the hope that it will be useful,

+ # but WITHOUT ANY WARRANTY; without even the implied warranty of

+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ # GNU General Public License for more details.

+ # 

+ # You should have received a copy of the GNU General Public License

+ # along with this program.  If not, see <http://www.gnu.org/licenses/>.

+ #

+ # Rebuild kernel, install it, reboot, and check if we're running the correct

+ # kernel. Tailored specificaly for binutils buildroot testing process.

+ #

+ # Author: Milos Prchlik <mprchlik@redhat.com>

+ #

+ # Based on gcc/Sanity/rebuild-kernel by:

+ # Author: Michal Nowak <mnowak@redhat.com>

+ # Author: Marek Polacek <polacek@redhat.com>

+ 

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ export AVC_ERROR='+no_avc_check'

+ 

+ case "$JUST_BUILD" in

+     0|[Ff][Aa][Ll][Ss][Ee]|[Nn][Oo])

+         JUST_BUILD=no

+         ;;

+     *)

+         JUST_BUILD=yes

+         ;;

+ esac

+ 

+ LD="${LD:-$(which ld)}"

+ GCC="${GCC:-$(which gcc)}"

+ 

+ PACKAGE="${PACKAGE:-$(rpm --qf '%{name}\n' -qf $(which $LD) | head -1)}"

+ GCC_PACKAGE="${GCC_PACKAGE:-$(rpm --qf '%{name}\n' -qf $(which $GCC) | head -1)}"

+ 

+ PACKAGES="${PACKAGES:-$PACKAGE}"

+ 

+ # Kernel package - usualy "kernel", but some trees may use different package

+ # name (e.g. kernel-PAE).

+ KERNEL="${KERNEL:-kernel}"

+ 

+ REQUIRES="${REQUIRES:-$KERNEL $GCC_PACKAGE glibc}"

+ RPM_BUILD_ID="${RPM_BUILD_ID:-.LimeKitten}"

+ 

+ # Workaround possible restraint issues - restraint may fail to set REBOOTCOUNT properly.

+ REBOOT_FLAG=/.rebuild-kernel-and-reboot.flag

+ REBOOTCOUNT="${REBOOTCOUNT:-0}"

+ 

+ unset ARCH

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlLogInfo "PACKAGES=$PACKAGES"

+         rlLogInfo "KERNEL=$KERNEL"

+         rlLogInfo "REQUIRES=$REQUIRES"

+         rlLogInfo "JUST_BUILD=$JUST_BUILD"

+         rlLogInfo "COLLECTIONS=$COLLECTIONS"

+         rlLogInfo "SKIP_COLLECTION_METAPACKAGE_CHECK=$SKIP_COLLECTION_METAPACKAGE_CHECK"

+ 

+         # We'll use a lot of disk space (tens of GBs at least). The root FS

+         # often is the most beefy one in CI environemnts. Let's use it but also

+         # let's log what's actually available.

+         export TMPDIR=/test_tmp_root

+         rlRun "mkdir -p $TMPDIR"

+         rlLogInfo "TMPDIR=$TMPDIR"

+         rlLogInfo 'Disk space:'

+         df -h | while read line; do

+             rlLogInfo "    $line"

+         done

+ 

+         # We optionally need to skip checking for the presence of the metapackage

+         # because that would pull in all the dependent toolset subrpms.  We do not

+         # always want that, especially in CI.

+         _COLLECTIONS="$COLLECTIONS"

+         if ! test -z $SKIP_COLLECTION_METAPACKAGE_CHECK; then

+             for c in $SKIP_COLLECTION_METAPACKAGE_CHECK; do

+                 rlLogInfo "ignoring metapackage check for collection $c"

+                 export COLLECTIONS=$(shopt -s extglob && echo ${COLLECTIONS//$c/})

+             done

+         fi

+ 

+         rlLogInfo "(without skipped) COLLECTIONS=$COLLECTIONS"

+ 

+         rlAssertRpm --all

+ 

+         export COLLECTIONS="$_COLLECTIONS"

+ 

+         rlRun "AFTER_REBOOT=no"

+ 

+         if [ "$REBOOTCOUNT" != "0" ]; then

+             rlLogInfo "Reboot count envvar is non-zero, update our flag"

+             rlRun "AFTER_REBOOT=yes"

+         elif [ -f "$REBOOT_FLAG" ]; then

+             rlLogInfo "FS reboot flag exists, update our flag"

+             rlRun "AFTER_REBOOT=yes"

+         fi

+ 

+         if [ "$AFTER_REBOOT" = "no" ]; then

+             # We optionally need to skip checking for the presence of the metapackage

+             # because that would pull in all the dependent toolset subrpms.  We do not

+             # always want that, especially in CI.

+             rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"

+             rlRun "pushd $TmpDir"

+ 

+             # Speed up keygen.

+             rlRun "rngd -r /dev/hwrandom || rngd -r /dev/urandom"

+ 

+             # Get the SRPM.

+             rlFetchSrcForInstalled "$KERNEL"

+ 

+             rlRun "SRPM=`find . -name '*.src.rpm'`"

+             rlRun "SPECDIR=`rpm --define=\"_topdir $TmpDir\" --eval=%_specdir`"

+ 

+             rlRun "rpm -ivh --define=\"_topdir $TmpDir\" $SRPM"

+             rlRun "SPECFILE=`find $SPECDIR/ -name '*.spec'`"

+ 

+             builddep_options="--nobest"

+             rlRun "yum-builddep -y $builddep_options $SPECFILE"

+         fi

+     rlPhaseEnd

+ 

+     if [ "$AFTER_REBOOT" = "no" ]; then

+         rlPhaseStartTest "Build"

+             if [ "$RPM_BUILD_ID" != "" ]; then

+                 rlRun "sed -i \"s/# % define buildid .local/%define buildid $RPM_BUILD_ID/\" $SPECFILE"

+                 rlRun "sed -i \"s/# define buildid .local/%define buildid $RPM_BUILD_ID/\" $SPECFILE"

+             fi

+ 

+             if [ "`rlGetPrimaryArch`" == "ppc64" ]; then 

+                 TARGET="--target=ppc64"

+             else

+                 TARGET="--target=$(uname -m)"

+             fi

+ 

+             if rlRun "CC=$GCC rpmbuild --define=\"_topdir $TmpDir\" -bb $TARGET --clean $SPECFILE &> BUILD_LOG"; then

+                 rlRun "RPMBUILD_OK=yes"

+             else

+                 rlLogInfo "rpmbuild kernel failed"

+                 rlRun "RPMBUILD_OK=no"

+             fi

+             rlBundleLogs "Build-log" BUILD_LOG

+         rlPhaseEnd

+ 

+         # Install and boot the new kernel only if it's requested *and* the build was successful

+         if [ "$JUST_BUILD" = 'no' ] && [ "$RPMBUILD_OK" = "yes" ]; then

+             rlPhaseStartTest "Install"

+                 RPMS="$(ls -1 $TmpDir/RPMS/*/*.rpm | grep -v kernel-selftests-internal | tr '\n' ' ')"

+ 

+                 rlRun "yum localinstall -y --disablerepo=\* $RPMS"

+ 

+                 rlLogInfo "$(rpm -qa | grep kernel | sort)"

+ 

+                 # Update the boot configuration

+                 if [ "$(arch)" = "s390x" ]; then

+                     rlRun "grubby --info=ALL"

+                     rlLogInfo "Default kernel is $(grubby --default-kernel), index $(grubby --default-index)"

+                     rlRun "KERNEL_FILE=$(ls -1 /boot/vmlinuz-*${RPM_BUILD_ID}.$(arch))"

+                     rlRun "ls -al $KERNEL_FILE"

+                     rlRun "grubby --set-default $KERNEL_FILE"

+                     rlLogInfo "Default kernel is $(grubby --default-kernel), index $(grubby --default-index)"

+                     rlRun "zipl"

+                 else

+                     rlRun "grub2-set-default 2"

+                 fi

+             rlPhaseEnd

+ 

+             rlPhaseStartTest "Reboot"

+                 rlRun "touch $REBOOT_FLAG"

+ 

+                 rlLog "Rebooting ..."

+                 rhts-reboot

+             rlPhaseEnd

+         fi

+     fi

+ 

+     # Verify the build ID only if its install and boot were requested

+     if [ "$JUST_BUILD" = 'no' ]; then

+         rlPhaseStartTest "Test"

+             if ! [ "$AFTER_REBOOT" = 'yes' ]; then

+                 rlFail 'Not rebooted. Probably rhts-reboot did not work.'

+             fi

+             rlLogInfo "$(uname -a)"

+             rlRun "uname -r | grep $RPM_BUILD_ID"

+         rlPhaseEnd

+     fi

+ 

+     rlPhaseStartCleanup

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

This set of commits introduces Fedora CI to binutils, with one test case taken from RHEL.

The test case is a kernel rebuild, optionally with its installation and boot. It may need some tuning, especially regarding the disk space usage. I'll be watching how it works in practice but for that I need to make this and active pull request.

The overall plan is to add as many test cases from RHEL to Fedora but it will take time to get there...

Pull-Request has been merged by nickc

3 years ago