#!/bin/bash set -e # HACK - virt-resize might not be able to resize our xfs rootfs, # depending on how it was compiled and which plugins are installed, # and will just silently not do it. So we do it here. # df --output=source,fstype / | tail -n1 | while read source fstype; do case $fstype in ext*) resize2fs $source ;; xfs*) xfs_growfs / ;; esac done df -Th / # If the file /root/.skip_repos is present on the machine, # all actions regarding the repositories will be skipped: # subscriptions, adding repos, deleting existing entries SKIP_REPO_FLAG="/root/.skip_repos" if [ ! -f "$SKIP_REPO_FLAG" ]; then # Remove any internal files rm -f /etc/yum.repos.d/download.devel.redhat.com.repo cp ~/.rhel/nightly.repo /etc/yum.repos.d/ || true # register system subscription-manager register --auto-attach --username=`cat ~/.rhel/login` --password=`cat ~/.rhel/pass` || true # remove credentials from test machine rm -rf ~/.rhel fi # Only start logging here. Otherwise the subscription credentials # appear in the output above. # set -x if [ ! -f "$SKIP_REPO_FLAG" ]; then # Configure repositories. # # if disabling the repos doesn't work, do without yum -y --disablerepo=rhel-7-server-htb-rpms --disablerepo=rhel-sjis-for-rhel-7-server-rpms install yum-utils || yum -y install yum-utils || true #yum-config-manager --enable rhel-7-server-optional-rpms || true yum-config-manager --add-repo http://download.eng.bos.redhat.com/nightly/latest-RHEL-7/compose/Server-optional/x86_64/os/ echo "gpgcheck=0" >> /etc/yum.repos.d/download.eng.bos.redhat.com_nightly_latest-RHEL-7_compose_Server-optional_x86_64_os_.repo #yum-config-manager --enable rhel-7-server-extras-rpms || true yum-config-manager --add-repo http://download.eng.bos.redhat.com/nightly/EXTRAS-RHEL-7.4/latest-EXTRAS-7-RHEL-7/compose/Server/x86_64/os/ echo "gpgcheck=0" >> /etc/yum.repos.d/download.eng.bos.redhat.com_nightly_EXTRAS-RHEL-7.4_latest-EXTRAS-7-RHEL-7_compose_Server_x86_64_os_.repo # the following don't necessarily need to work yum-config-manager --disable rhel-sjis-for-rhel-7-server-rpms || true yum-config-manager --disable rhel-7-server-htb-rpms || true yum-config-manager --disable rhel-7-server-rt-beta-rpms || true fi yum --nogpgcheck -y update echo foobar | passwd --stdin root # We install all dependencies of the cockpit packages since we want # them to not spontaneously change from one test run to the next when # the distribution repository is updated. COCKPIT_DEPS="\ atomic \ device-mapper-multipath \ docker \ etcd \ glib-networking \ json-glib \ kexec-tools \ kubernetes \ libssh \ libvirt \ libvirt-client \ NetworkManager-team \ PackageKit \ pcp-libs \ pcp \ python-pip \ qemu \ realmd \ selinux-policy-targeted \ setroubleshoot-server \ subscription-manager \ storaged \ storaged-lvm2 \ storaged-iscsi \ sos \ tuned \ " # We also install the packages necessary to join a FreeIPA domain so # that we don't have to go to the network during a test run. # on epel/rhel we have ipa-client instead of freeipa-client IPA_CLIENT_PACKAGES="\ ipa-client \ oddjob \ oddjob-mkhomedir \ sssd \ " TEST_PACKAGES="\ systemtap-runtime-virtguest \ valgrind \ gdb \ yum-utils \ virt-install \ qemu-system-x86 \ qemu-kvm \ " yum install --nogpgcheck -y $TEST_PACKAGES $COCKPIT_DEPS $IPA_CLIENT_PACKAGES # For debugging storaged crashes debuginfo-install -y storaged storaged-lvm2 storaged-iscsi # Prepare for building # only install mock and build if TEST_SOURCE is set if [ -n "$TEST_SOURCE" ]; then yum -y install rpm-build # enable epel for mock if [ ! -f "$SKIP_REPO_FLAG" ]; then mkdir /tmp/dep cd /tmp/dep yum -y install wget wget -T 15 -t 4 http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum -y remove wget rpm -Uvh epel-release-*.rpm cd rm -rf /tmp/dep fi yum -y install mock # disable epel again yum-config-manager --disable 'epel*' useradd -c Builder -G mock builder srpm=$(/var/lib/testvm/make-srpm $TEST_SOURCE) su builder -c "/usr/bin/mock --verbose --installdeps $srpm" fi yum clean all || true if [ ! -f "$SKIP_REPO_FLAG" ]; then subscription-manager unregister || true fi # For the D-Bus test server if type "firewall-cmd" >/dev/null 2>&1; then FIREWALL_STATE=$(firewall-cmd --state || true) if [ "$FIREWALL_STATE" == "running" ]; then firewall-cmd --permanent --add-port 8765/tcp fi fi echo 'NETWORKING=yes' > /etc/sysconfig/network useradd -c Administrator -G wheel admin echo foobar | passwd --stdin admin # To enable persistent logging mkdir -p /var/log/journal # Configure kubernetes /var/lib/testvm/kubernetes.setup if type "docker" >/dev/null 2>&1; then # HACK: docker fails without /etc/resolv.conf # https://bugzilla.redhat.com/show_bug.cgi?id=1448331 mkdir -p /etc/systemd/system/docker.service.d printf "[Service]\nExecStartPre=/bin/sh -c 'echo -n >> /etc/resolv.conf'\n" > /etc/systemd/system/docker.service.d/resolv.conf systemctl daemon-reload # HACK: docker falls over regularly, print its log if it does systemctl start docker || journalctl -u docker docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest # docker images that we need for integration testing /var/lib/testvm/docker-images.setup fi /var/lib/testvm/zero-disk.setup --keep-mock-cache # HACK - kdump.service interferes with our storage tests, by loading # the system for some time after boot and thereby causing a race # between parted and udevd to turn out for the worse. Disabling # kdump.service helps somewhat, but the race is still there, and # parted still fails occasionally. # # https://bugzilla.redhat.com/show_bug.cgi?id=1245144 # Fixed in parted-3.1-23.el7 # systemctl disable kdump.service # Final tweaks rm -rf /var/log/journal/* echo "kernel.core_pattern=|/usr/lib/systemd/systemd-coredump %p %u %g %s %t %e" > /etc/sysctl.d/50-coredump.conf # Prevent SSH from hanging for a long time when no external network access echo 'UseDNS no' >> /etc/ssh/sshd_config touch /.autorelabel # Audit events to the journal rm -f '/etc/systemd/system/multi-user.target.wants/auditd.service' rm -rf /var/log/audit/