2018-12-12 11:38:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Note: execute this file from the project root directory
|
|
|
|
|
|
|
|
#####
|
|
|
|
#
|
|
|
|
# Make sure we can build an image and deploy it inside OpenStack!
|
|
|
|
#
|
|
|
|
#####
|
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
set -e
|
2018-12-12 11:38:09 +00:00
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
. /usr/share/beakerlib/beakerlib.sh
|
|
|
|
. $(dirname $0)/lib/lib.sh
|
2019-03-08 10:29:11 +00:00
|
|
|
|
|
|
|
CLI="${CLI:-./src/bin/composer-cli}"
|
2019-01-28 12:49:42 +00:00
|
|
|
VENV=`mktemp -d /tmp/ansible.venv.XXX`
|
2018-12-12 11:38:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
rlJournalStart
|
|
|
|
rlPhaseStartSetup
|
|
|
|
if [ -z "$OS_AUTH_URL" ]; then
|
|
|
|
rlFail "OS_AUTH_URL is empty!"
|
|
|
|
else
|
|
|
|
rlLogInfo "OS_AUTH_URL=$OS_AUTH_URL"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$OS_USERNAME" ]; then
|
|
|
|
rlFail "OS_USERNAME is empty!"
|
|
|
|
else
|
|
|
|
rlLogInfo "OS_USERNAME=$OS_USERNAME"
|
|
|
|
fi
|
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
export OS_PROJECT_NAME="${OS_PROJECT_NAME:-$OS_USERNAME}"
|
|
|
|
rlLogInfo "OS_PROJECT_NAME=$OS_PROJECT_NAME"
|
2018-12-12 11:38:09 +00:00
|
|
|
|
|
|
|
if [ -z "$OS_PASSWORD" ]; then
|
|
|
|
rlFail "OS_PASSWORD is empty!"
|
|
|
|
else
|
|
|
|
rlLogInfo "OS_PASSWORD is configured"
|
|
|
|
fi
|
|
|
|
|
2019-08-01 11:34:57 +00:00
|
|
|
if ! rlCheckRpm "python2-pip"; then
|
|
|
|
rlRun -t -c "yum -y install python2-pip"
|
|
|
|
rlAssertRpm python2-pip
|
|
|
|
fi
|
|
|
|
|
2019-01-28 12:49:42 +00:00
|
|
|
rlAssertRpm python-virtualenv
|
|
|
|
rlRun -t -c "virtualenv $VENV"
|
|
|
|
source $VENV/bin/activate
|
2018-12-12 11:38:09 +00:00
|
|
|
|
2019-01-03 11:11:12 +00:00
|
|
|
rlRun -t -c "pip install --upgrade pip setuptools"
|
2020-04-01 14:54:55 +00:00
|
|
|
rlRun -t -c "pip install ansible openstacksdk future"
|
2018-12-12 11:38:09 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "compose start"
|
2019-01-25 16:53:50 +00:00
|
|
|
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing"
|
|
|
|
|
2018-12-12 11:38:09 +00:00
|
|
|
# workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1639326
|
|
|
|
cat > $TMP_DIR/http-with-rng.toml << __EOF__
|
|
|
|
name = "http-with-rng"
|
|
|
|
description = "HTTP image for OpenStack with rng-tools"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
2019-04-11 06:02:42 +00:00
|
|
|
[[packages]]
|
2018-12-12 11:38:09 +00:00
|
|
|
name = "httpd"
|
|
|
|
version = "*"
|
|
|
|
|
2019-04-11 06:02:42 +00:00
|
|
|
[[packages]]
|
2018-12-12 11:38:09 +00:00
|
|
|
name = "rng-tools"
|
|
|
|
version = "*"
|
2019-04-08 09:00:41 +00:00
|
|
|
|
|
|
|
[customizations.kernel]
|
|
|
|
append = "custom_cmdline_arg"
|
|
|
|
|
2018-12-12 11:38:09 +00:00
|
|
|
__EOF__
|
|
|
|
|
|
|
|
rlRun -t -c "$CLI blueprints push $TMP_DIR/http-with-rng.toml"
|
|
|
|
|
|
|
|
UUID=`$CLI compose start http-with-rng openstack`
|
|
|
|
rlAssertEquals "exit code should be zero" $? 0
|
|
|
|
|
|
|
|
UUID=`echo $UUID | cut -f 2 -d' '`
|
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "compose finished"
|
2019-09-06 16:56:19 +00:00
|
|
|
wait_for_compose $UUID
|
2018-12-12 11:38:09 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "Upload QCOW2 image to OpenStack"
|
|
|
|
rlRun -t -c "$CLI compose image $UUID"
|
|
|
|
IMAGE="$UUID-disk.qcow2"
|
|
|
|
OS_IMAGE_NAME="Composer-$UUID-Automated-Import"
|
|
|
|
|
|
|
|
response=`ansible localhost -m os_image -a "name=$OS_IMAGE_NAME filename=$IMAGE is_public=no"`
|
|
|
|
rlAssert0 "Image upload successfull" $?
|
|
|
|
rlLogInfo "$response"
|
|
|
|
|
|
|
|
OS_IMAGE_UUID=`echo "$response" | grep '"changed": true' -A1 | grep '"id":' | cut -d'"' -f4`
|
|
|
|
rlLogInfo "OS_IMAGE_UUID=$OS_IMAGE_UUID"
|
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "Start VM instance"
|
|
|
|
VM_NAME="Composer-Auto-VM-$UUID"
|
|
|
|
|
|
|
|
SSH_KEY_DIR=`mktemp -d /tmp/composer-ssh-keys.XXXXXX`
|
|
|
|
rlRun -t -c "ssh-keygen -t rsa -N '' -f $SSH_KEY_DIR/id_rsa"
|
|
|
|
rlRun -t -c "ansible localhost -m os_keypair -a 'name=$VM_NAME-key public_key_file=$SSH_KEY_DIR/id_rsa.pub'"
|
|
|
|
|
2019-02-15 13:39:42 +00:00
|
|
|
response=`ansible localhost -m os_server -a "name=$VM_NAME image=$OS_IMAGE_UUID network=provider_net_cci_2 flavor=ci.m1.medium.ephemeral key_name=$VM_NAME-key auto_ip=yes"`
|
2018-12-12 11:38:09 +00:00
|
|
|
rlAssert0 "VM started successfully" $?
|
|
|
|
rlLogInfo "$response"
|
|
|
|
|
2019-02-15 13:39:42 +00:00
|
|
|
IP_ADDRESS=`echo "$response" | grep '"OS-EXT-IPS:type": "fixed"' -A1| grep '"addr":' | cut -f4 -d'"' | head -n 1`
|
2018-12-12 11:38:09 +00:00
|
|
|
rlLogInfo "Running instance IP_ADDRESS=$IP_ADDRESS"
|
|
|
|
|
|
|
|
rlLogInfo "Waiting 60sec for instance to initialize ..."
|
|
|
|
sleep 60
|
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "Verify VM instance"
|
|
|
|
# cloud-init default config differs between RHEL and Fedora
|
|
|
|
CLOUD_USER="cloud-user"
|
|
|
|
if [ -f "/etc/fedora-release" ]; then
|
|
|
|
CLOUD_USER="fedora"
|
|
|
|
fi
|
|
|
|
|
2019-04-17 14:12:12 +00:00
|
|
|
# run generic tests to verify the instance
|
|
|
|
verify_image "$CLOUD_USER" "$IP_ADDRESS" "-i $SSH_KEY_DIR/id_rsa"
|
2018-12-12 11:38:09 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartCleanup
|
|
|
|
rlRun -t -c "ansible localhost -m os_keypair -a 'name=$VM_NAME-key state=absent'"
|
|
|
|
rlRun -t -c "ansible localhost -m os_server -a 'name=$VM_NAME state=absent'"
|
|
|
|
rlRun -t -c "ansible localhost -m os_image -a 'name=$OS_IMAGE_NAME state=absent'"
|
|
|
|
rlRun -t -c "$CLI compose delete $UUID"
|
2019-01-28 12:49:42 +00:00
|
|
|
deactivate
|
|
|
|
rlRun -t -c "rm -rf $IMAGE $SSH_KEY_DIR $TMP_DIR $VENV"
|
2018-12-12 11:38:09 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlJournalEnd
|
|
|
|
rlJournalPrintText
|