From 63f94de34a6aabb9f24ef3a88a6ff2e2f59661a4 Mon Sep 17 00:00:00 2001 From: joehuang Date: Thu, 13 Apr 2017 03:28:49 -0400 Subject: [PATCH] Add multi-region scripts for devstack based gate/check test job Just like py27 gate/check test job enabled for each patch submitted for review, devstack based multi-region gate/check test job can be added to each patch too. gate_hook.sh: the script to build two nodes two OpenStack regions with Kingbird installed. post_test_hook.sh: the script to execute test cases against prepared multi-region with running Kingbird These two scripts will take into effect only after the job configured for Kingbird is merged: https://review.openstack.org/456479. So these two scripts should be merged before the patch in project-config. Note: 1. multi-region job alread begins to run in Tricircle project, these two scripts are copied from Tricircle with Kingbird related update. 2. plugin.sh was updated to register endpoint correctly, no need to judge database now. Change-Id: I126365cc8225dc73d758daf70b7efe7b1aafcb27 Signed-off-by: joehuang --- devstack/plugin.sh | 16 ++--- kingbird/tests/tempest/gate_hook.sh | 64 ++++++++++++++++++ kingbird/tests/tempest/post_test_hook.sh | 84 ++++++++++++++++++++++++ 3 files changed, 155 insertions(+), 9 deletions(-) create mode 100755 kingbird/tests/tempest/gate_hook.sh create mode 100755 kingbird/tests/tempest/post_test_hook.sh diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 0025b1e..53db27b 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -17,15 +17,13 @@ function create_kingbird_accounts { if [[ "$ENABLED_SERVICES" =~ "kb-api" ]]; then create_service_user "kingbird" - if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then - local kingbird_service=$(get_or_create_service "kingbird" \ - "Kingbird" "OpenStack Kingbird Service") - get_or_create_endpoint $kingbird_service \ - "$REGION_NAME" \ - "$SERVICE_PROTOCOL://$KINGBIRD_API_HOST:$KINGBIRD_API_PORT/v1.0" \ - "$SERVICE_PROTOCOL://$KINGBIRD_API_HOST:$KINGBIRD_API_PORT/v1.0" \ - "$SERVICE_PROTOCOL://$KINGBIRD_API_HOST:$KINGBIRD_API_PORT/v1.0" - fi + local kingbird_service=$(get_or_create_service "kingbird" \ + "Kingbird" "OpenStack Kingbird Service") + get_or_create_endpoint $kingbird_service \ + "$REGION_NAME" \ + "$SERVICE_PROTOCOL://$KINGBIRD_API_HOST:$KINGBIRD_API_PORT/v1.0" \ + "$SERVICE_PROTOCOL://$KINGBIRD_API_HOST:$KINGBIRD_API_PORT/v1.0" \ + "$SERVICE_PROTOCOL://$KINGBIRD_API_HOST:$KINGBIRD_API_PORT/v1.0" fi } diff --git a/kingbird/tests/tempest/gate_hook.sh b/kingbird/tests/tempest/gate_hook.sh new file mode 100755 index 0000000..7696623 --- /dev/null +++ b/kingbird/tests/tempest/gate_hook.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script is executed inside gate_hook function in devstack gate. + +set -ex + +GATE_DEST=$BASE/new + +# _setup_kingbird_multinode() - Set up two regions test environment +# in devstack multinode job. Kingbird and RegionOne services will be +# enabled in primary node, RegionTwo servies will be enabled in the subnode. +# Currently only two nodes are supported in the test environment. + +function _setup_kingbird_multinode { + + PRIMARY_NODE_IP=$(cat /etc/nodepool/primary_node_private) + SUBNODE_IP=$(head -n1 /etc/nodepool/sub_nodes_private) + + export OVERRIDE_ENABLED_SERVICES="c-api,c-bak,c-sch,c-vol,cinder," + export OVERRIDE_ENABLED_SERVICES+="g-api,g-reg,horizon,key," + export OVERRIDE_ENABLED_SERVICES+="n-api,n-cauth,n-cond,n-cpu,n-crt," + export OVERRIDE_ENABLED_SERVICES+="n-novnc,n-obj,n-sch," + export OVERRIDE_ENABLED_SERVICES+="placement-api,placement-client," + export OVERRIDE_ENABLED_SERVICES+="q-agt,q-dhcp,q-l3,q-meta," + export OVERRIDE_ENABLED_SERVICES+="q-metering,q-svc," + export OVERRIDE_ENABLED_SERVICES+="dstat,peakmem_tracker,rabbit,mysql" + + export DEVSTACK_LOCAL_CONFIG="enable_plugin kingbird https://git.openstack.org/openstack/kingbird" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"Q_ENABLE_KINGBIRD=True" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_service kb-api" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_service kb-api" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"REGION_NAME=RegionOne" + export DEVSTACK_LOCAL_CONFIG+=$'\n'"HOST_IP=$PRIMARY_NODE_IP" + + export DEVSTACK_SUBNODE_CONFIG="REGION_NAME=RegionTwo" + export DEVSTACK_SUBNODE_CONFIG+=$'\n'"HOST_IP=$SUBNODE_IP" + export DEVSTACK_SUBNODE_CONFIG+=$'\n'"KEYSTONE_REGION_NAME=RegionOne" + export DEVSTACK_SUBNODE_CONFIG+=$'\n'"KEYSTONE_SERVICE_HOST=$PRIMARY_NODE_IP" + export DEVSTACK_SUBNODE_CONFIG+=$'\n'"KEYSTONE_AUTH_HOST=$PRIMARY_NODE_IP" + + export DEVSTACK_SUBNODE_CONFIG+=$'\n'"SERVICE_HOST=$SUBNODE_IP" + export DEVSTACK_SUBNODE_CONFIG+=$'\n'"RABBIT_HOST=$SUBNODE_IP" + export DEVSTACK_SUBNODE_CONFIG+=$'\n'"QPID_HOST=$SUBNODE_IP" + export DEVSTACK_SUBNODE_CONFIG+=$'\n'"DATABASE_HOST=$SUBNODE_IP" + export DEVSTACK_SUBNODE_CONFIG+=$'\n'"GLANCE_HOSTPORT=$SUBNODE_IP:9292" + export DEVSTACK_SUBNODE_CONFIG+=$'\n'"Q_HOST=$SUBNODE_IP" +} + +if [ "$DEVSTACK_GATE_TOPOLOGY" == "multinode" ]; then + _setup_kingbird_multinode + $GATE_DEST/devstack-gate/devstack-vm-gate.sh +fi diff --git a/kingbird/tests/tempest/post_test_hook.sh b/kingbird/tests/tempest/post_test_hook.sh new file mode 100755 index 0000000..a8c69db --- /dev/null +++ b/kingbird/tests/tempest/post_test_hook.sh @@ -0,0 +1,84 @@ +#!/bin/bash -xe + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# This script is executed inside post_test_hook function in devstack gate. + +export DEST=$BASE/new +export DEVSTACK_DIR=$DEST/devstack +export KINGBIRD_DIR=$DEST/kingbird +export KINGBIRD_DEVSTACK_PLUGIN_DIR=$TRICIRCLE_DIR/devstack +export KINGBIRD_TEMPEST_PLUGIN_DIR=$TRICIRCLE_DIR/kingbird/tests/tempest +export TEMPEST_DIR=$DEST/tempest +export TEMPEST_CONF=$TEMPEST_DIR/etc/tempest.conf + +# execute test only in the primary node(i.e, RegionOne) +if [ "$OS_REGION_NAME" -ne "RegionOne" ]; then + return 0 +fi + +PRIMARY_NODE_IP=$(cat /etc/nodepool/primary_node_private) + +# use admin role to create Tricircle top Pod and Pod1 +source $DEVSTACK_DIR/openrc admin admin +unset OS_REGION_NAME + +mytoken=$(openstack --os-region-name=RegionOne token issue | awk 'NR==5 {print $4}') +echo $mytoken + +image_id=$(openstack --os-region-name=RegionOne image list | awk 'NR==4 {print $2}') + +# preparation for the tests +cd $TEMPEST_DIR +if [ -d .testrepository ]; then + sudo rm -r .testrepository +fi + +sudo chown -R jenkins:stack $DEST/tempest + +# change the tempest configruation to test Kingbird +env | grep OS_ + +# import functions needed for the below workaround +source $DEVSTACK_DIR/functions + +# designate is a good example how to config TEMPEST_CONF +iniset $TEMPEST_CONF auth admin_username ${ADMIN_USERNAME:-"admin"} +iniset $TEMPEST_CONF auth admin_project_name admin +iniset $TEMPEST_CONF auth admin_password $OS_PASSWORD +iniset $TEMPEST_CONF identity uri $OS_AUTH_URL +iniset $TEMPEST_CONF identity-feature-enabled api_v3 false + +iniset $TEMPEST_CONF compute region RegionOne +iniset $TEMPEST_CONF compute image_ref $image_id +iniset $TEMPEST_CONF compute image_ref_alt $image_id + +iniset $TEMPEST_CONF volume region RegionOne +iniset $TEMPEST_CONF volume catalog_type volumev2 +iniset $TEMPEST_CONF volume endpoint_type publicURL +iniset $TEMPEST_CONF volume-feature-enabled api_v1 false + +iniset $TEMPEST_CONF validation connect_method fixed + + +# Run the Tempest tests through ostestr command +# preparation for the tests + +cd $TEMPEST_DIR + +# ping kingbird api +curl http://$PRIMARY_NODE_IP:8118 + +# specify what kingbird test cases to be tested in TESTCASES environment +# variables, then uncomment the follow line +# ostestr --regex $TESTCASES