Created
November 19, 2015 10:30
-
-
Save mdbooth/6453e9ae04a071d4e728 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # A script to run tests using khaleesi | |
| # Usage: | |
| # | |
| # Run tests using a RHOS 7/RHEL 7 environment | |
| # ./tools/khaleesi.sh | |
| # | |
| # Run tests using a RHOS 5/RHEL 7 environment | |
| # RHOS_VERSION=5 ./tools/khaleesi.sh | |
| # | |
| # Run tests, fetching all packages through an http proxy | |
| # PROXY=http://proxy.example.com:3128/ ./tools/khaleesi.sh | |
| # | |
| # | |
| # This script creates a fresh chroot of the target RHEL version, then spawns a | |
| # container using the new chroot. It launches the container, after copying in | |
| # the nova working directory. In the container, it installs enough packages to | |
| # install ansible, and checkout and run the khaleesi unittest playbook. This | |
| # playbook reads its configuration from jenkins-config.yml in the nova working | |
| # directory. | |
| # | |
| # You can launch a shell in the container with the command: | |
| # | |
| # sudo systemd-nspawn -D $INSTALL_ROOT | |
| set -e | |
| RHOS_VERSION=${RHOS_VERSION:-7} | |
| RHEL_VERSION=${RHEL_VERSION:-7} | |
| RHEL_URL=${RHEL_URL:-http://download.devel.redhat.com/released/RHEL-7/7.2-Beta/Server/\$basearch/os} | |
| PROXY=${PROXY:-} | |
| KHALEESI_GIT=${KHALEESI_GIT:-https://github.com/redhat-openstack/khaleesi.git} | |
| NOVA_ROOT=${NOVA_ROOT:-`pwd`} | |
| INSTALL_ROOT=${INSTALL_ROOT:-$NOVA_ROOT/../khaleesi_root-nova} | |
| if [ ! -z "$PROXY" ]; then | |
| proxy="proxy=$PROXY" | |
| else | |
| proxy="" | |
| fi | |
| # The initial yum.conf used only to install the bare chroot | |
| CHROOT_YUM=" | |
| [main] | |
| cachedir=/var/cache/yum | |
| debuglevel=1 | |
| logfile=/var/log/yum.log | |
| reposdir=/dev/null | |
| retries=20 | |
| obsoletes=1 | |
| gpgcheck=0 | |
| assumeyes=1 | |
| $proxy | |
| # repos | |
| [build] | |
| name=build | |
| baseurl=$RHEL_URL | |
| " | |
| # The yum.conf installed in the chroot, used to install almost everything | |
| INSTALL_REPO=" | |
| [rhel] | |
| name=build | |
| baseurl=$RHEL_URL | |
| gpgcheck=0 | |
| [copr-install] | |
| name=copr-install | |
| baseurl=http://copr-be.cloud.fedoraproject.org/results/apevec/EL${RHEL_VERSION}-test-reqs/epel-${RHEL_VERSION}-\$basearch | |
| exclude=python-pbr | |
| gpgcheck=0 | |
| [rhos-release-install] | |
| name=rhos-release-install | |
| baseurl=http://rhos-release.virt.bos.redhat.com/repos/rhos-release/ | |
| gpgcheck=0 | |
| " | |
| # An ansible playbook which executes khaleesi's unittest playbook | |
| PLAYBOOK=" | |
| --- | |
| - include: playbooks/installer/project/pre.yml | |
| vars: | |
| installer: | |
| component: | |
| name: nova | |
| short_name: nova | |
| dir: /root/tester/nova | |
| dist_git: openstack-nova | |
| codeng: nova | |
| config_file: jenkins-config.yml | |
| - include: playbooks/installer/project/run.yml | |
| vars: | |
| installer: | |
| component: | |
| name: nova | |
| short_name: nova | |
| dir: /root/tester/nova | |
| dist_git: openstack-nova | |
| codeng: nova | |
| config_file: jenkins-config.yml | |
| - include: playbooks/installer/project/post.yml | |
| vars: | |
| installer: | |
| component: | |
| name: nova | |
| short_name: nova | |
| dir: /root/tester/nova | |
| dist_git: openstack-nova | |
| codeng: nova | |
| config_file: jenkins-config.yml | |
| - include: playbooks/tester/unittest/pre.yml | |
| - include: playbooks/tester/unittest/run.yml | |
| - include: playbooks/tester/unittest/post.yml | |
| " | |
| # A script we run in the chroot | |
| SCRIPT=" | |
| # Configure yum to use a proxy if we specified one | |
| if [ ! -z \"$proxy\" ]; then | |
| yum-config-manager --setopt=$proxy --save | |
| fi | |
| # Install and configure RHOS yum repos | |
| yum install -y rhos-release | |
| rhos-release $RHOS_VERSION | |
| # Requirements to pip install ansible and run our playbook | |
| yum install -y \ | |
| python-paramiko \ | |
| python-jinja2 \ | |
| PyYAML \ | |
| python-crypto \ | |
| python-setuptools \ | |
| sudo | |
| easy_install pip | |
| pip install ansible | |
| # khaleesi wants to rsync the nova repo into place. We've already bind mounted | |
| # it into place, so we make rsync a no-op | |
| rm -f /usr/bin/rsync | |
| ln -s /usr/bin/true /usr/bin/rsync | |
| # The playbook wants to run on a host called tester | |
| echo controller > /inventory | |
| # Clone and configure khaleesi | |
| cd /root | |
| git clone $KHALEESI_GIT | |
| cd /root/khaleesi | |
| cp ansible.cfg.example ansible.cfg | |
| # Run our custom playbook | |
| mv ../run_unittests.yml . | |
| ansible-playbook -v -i /inventory -c local run_unittests.yml | |
| " | |
| mkdir -p "$INSTALL_ROOT" | |
| echo "$CHROOT_YUM" > "$INSTALL_ROOT"/chroot_yum.conf | |
| sudo yum install -c "$INSTALL_ROOT"/chroot_yum.conf \ | |
| --installroot="$INSTALL_ROOT" \ | |
| --releasever "$RHEL_VERSION" \ | |
| redhat-release-server bash yum yum-utils vim-minimal git | |
| echo "$INSTALL_REPO" | \ | |
| sudo bash -c "exec cat >$INSTALL_ROOT/etc/yum.repos.d/install.repo" | |
| echo "$PLAYBOOK" | \ | |
| sudo bash -c "exec cat >$INSTALL_ROOT/root/run_unittests.yml" | |
| sudo mkdir -p "$INSTALL_ROOT"/root/tester | |
| sudo cp -r "$NOVA_ROOT" "$INSTALL_ROOT"/root/tester/ | |
| sudo systemd-nspawn -D "$INSTALL_ROOT" \ | |
| /bin/bash -c "$SCRIPT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment