From d5e6d330cedd362e621b2f3122f3aa76c55a41f9 Mon Sep 17 00:00:00 2001 From: Chaoyi Huang Date: Mon, 18 Jul 2016 17:11:34 +0800 Subject: [PATCH] Fix regex expresion error in integration test 1.What is the problem Multiline regex does not work in ostestr which is executed in the integration job. This makes the test_volume_get test cases not being executed currently in the check and gate test. After regex issue is fixed, then test_volume_create_get_update_delete_from_image test case failed due to no image_ref is configured in the tempest.conf, so the tempest configuration is moved to the post_test_hook.sh, and correct the image_ref configuration. 2.What's need to be fixed: If we want to add more and more tempest test cases to the integration job, we have to add the filter of them to the regex in the same line, so a string variable is used to concat these filters for the tempest test cases. And need to add image_ref configuration in tempest.conf. And fix the bug for Pecan can not handle the last '/' in the request url, which will lead to the tempest test case test_volume_create_get_update_delete_from_image failure in the check and gate test. 3.What is the purpose of this patch set: To make the integration job work well, we have to fix the regex part of the ostestr in the integration job, and fix the configuration issue in tempest.conf, and Pecan bug. Change-Id: I63e8e5e6372719f68051a486951b32d479607eff Signed-off-by: Chaoyi Huang --- devstack/local.conf.sample | 4 +- tricircle/nova_apigw/controllers/image.py | 2 + tricircle/nova_apigw/controllers/root.py | 12 +++++- tricircle/tempestplugin/post_test_hook.sh | 49 +++++++++++++++++++---- tricircle/tempestplugin/tempest_volume.sh | 34 ++++------------ 5 files changed, 65 insertions(+), 36 deletions(-) diff --git a/devstack/local.conf.sample b/devstack/local.conf.sample index fc3f02f..ec5959f 100644 --- a/devstack/local.conf.sample +++ b/devstack/local.conf.sample @@ -25,6 +25,8 @@ FIXED_NETWORK_SIZE=256 FLOATING_RANGE=10.100.100.160/24 Q_FLOATING_ALLOCATION_POOL=start=10.100.100.160,end=10.100.100.192 +NEUTRON_CREATE_INITIAL_NETWORKS=False + PUBLIC_NETWORK_GATEWAY=10.100.100.3 Q_USE_SECGROUP=False @@ -54,5 +56,5 @@ enable_service c-api enable_service c-vol enable_service c-sch disable_service c-bak -disable_service tempest +# disable_service tempest disable_service horizon diff --git a/tricircle/nova_apigw/controllers/image.py b/tricircle/nova_apigw/controllers/image.py index 9537486..c2c669c 100644 --- a/tricircle/nova_apigw/controllers/image.py +++ b/tricircle/nova_apigw/controllers/image.py @@ -140,6 +140,8 @@ class ImageController(rest.RestController): @expose(generic=True, template='json') def get_one(self, _id): context = t_context.extract_context_from_environ() + if _id == 'detail': + return self.get_all() image = self.client.get_images(context, _id) if not image: return utils.format_nova_error(404, _('Image not found')) diff --git a/tricircle/nova_apigw/controllers/root.py b/tricircle/nova_apigw/controllers/root.py index 9ab47d3..b9a8301 100644 --- a/tricircle/nova_apigw/controllers/root.py +++ b/tricircle/nova_apigw/controllers/root.py @@ -125,7 +125,17 @@ class V21Controller(object): if project_id == 'testrpc': return TestRPCController(), remainder else: - return self._get_resource_controller(project_id, remainder) + # If the last charater of the url path is '/', then + # last remainder element is ''. Since pecan can't + # handle the url properly, '' element must be removed. + # Otherwise pecan will crashed for routing the request + # with incorrect parameter + num = len(remainder) + if num >= 1 and remainder[num - 1] == '': + new_remainder = remainder[:num - 1] + else: + new_remainder = remainder + return self._get_resource_controller(project_id, new_remainder) @pecan.expose(generic=True, template='json') def index(self): diff --git a/tricircle/tempestplugin/post_test_hook.sh b/tricircle/tempestplugin/post_test_hook.sh index 56293b8..fc784b6 100755 --- a/tricircle/tempestplugin/post_test_hook.sh +++ b/tricircle/tempestplugin/post_test_hook.sh @@ -15,13 +15,15 @@ # This script is executed inside post_test_hook function in devstack gate. export DEST=$BASE/new -export DEVSTACK_DIR=$DEST/tricircle/devstack +export DEVSTACK_DIR=$DEST/devstack export TRICIRCLE_DIR=$DEST/tricircle +export TRICIRCLE_DEVSTACK_PLUGIN_DIR=$TRICIRCLE_DIR/devstack export TRICIRCLE_TEMPEST_PLUGIN_DIR=$TRICIRCLE_DIR/tricircle/tempestplugin export TEMPEST_DIR=$DEST/tempest +export TEMPEST_CONF=$TEMPEST_DIR/etc/tempest.conf # use admin role to create Tricircle top Pod and Pod1 -source $BASE/new/devstack/openrc admin admin +source $DEVSTACK_DIR/openrc admin admin token=$(openstack token issue | awk 'NR==5 {print $4}') echo $token @@ -35,24 +37,57 @@ curl -X POST http://127.0.0.1:19999/v1.0/pods \ -H "X-Auth-Token: $token" \ -d '{"pod": {"pod_name": "Pod1", "az_name": "az1"}}' +# the usage of "nova flavor-create": +# nova flavor-create [--ephemeral ] [--swap ] +# [--rxtx-factor ] [--is-public ] +# +# the following command is to create a flavor wih name='test', +# id=1, ram=1024MB, disk=10GB, vcpu=1 +nova flavor-create test 1 1024 10 1 +image_id=$(openstack image list | awk 'NR==4 {print $2}') + # preparation for the tests cd $TEMPEST_DIR if [ -d .testrepository ]; then sudo rm -r .testrepository fi -# sudo -H -u jenkins testr init + +sudo chown -R jenkins:stack $DEST/tempest +# sudo chown -R jenkins:stack $BASE/data/tempest + +# change the tempest configruation to test Tricircle +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 # Run the Compute Tempest tests -# cd $TRICIRCLE_TEMPEST_PLUGIN_DIR -# sudo BASE=$BASE ./tempest_compute.sh +cd $TRICIRCLE_TEMPEST_PLUGIN_DIR +sudo BASE=$BASE ./tempest_compute.sh # Run the Volume Tempest tests cd $TRICIRCLE_TEMPEST_PLUGIN_DIR sudo BASE=$BASE ./tempest_volume.sh # Run the Network Tempest tests -# cd $TRICIRCLE_TEMPEST_PLUGIN_DIR -# sudo BASE=$BASE ./tempest_network.sh +cd $TRICIRCLE_TEMPEST_PLUGIN_DIR +sudo BASE=$BASE ./tempest_network.sh # Run the Scenario Tempest tests # cd $TRICIRCLE_TEMPEST_PLUGIN_DIR diff --git a/tricircle/tempestplugin/tempest_volume.sh b/tricircle/tempestplugin/tempest_volume.sh index bd3aebe..15c7d6c 100755 --- a/tricircle/tempestplugin/tempest_volume.sh +++ b/tricircle/tempestplugin/tempest_volume.sh @@ -12,45 +12,25 @@ # License for the specific language governing permissions and limitations # under the License. + export DEST=$BASE/new -export DEVSTACK_DIR=$DEST/tricircle/devstack -export TRICIRCLE_DIR=$DEST/tricircle export TEMPEST_DIR=$DEST/tempest export TEMPEST_CONF=$TEMPEST_DIR/etc/tempest.conf - # preparation for the tests cd $TEMPEST_DIR -# Import functions needed for the below workaround -source $DEST/devstack/functions - -# add account information to configuration -source $BASE/new/devstack/openrc admin admin -env | grep OS_ -iniset $TEMPEST_CONF auth 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 - -# change the configruation to test Tricircle Cinder-APIGW -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 - # Run functional test echo "Running Tricircle functional test suite..." # all test cases with following prefix -ostestr --regex '(tempest.api.volume.test_volumes_list|\ -tempest.api.volume.test_volumes_get)' +TESTCASES="(tempest.api.volume.test_volumes_list" +TESTCASES="$TESTCASES|tempest.api.volume.test_volumes_get" +# add new test cases like following line for volume_type test +# TESTCASES="$TESTCASES|tempest.api.volume.admin.test_volumes_type" +TESTCASES="$TESTCASES)" -# add test_volume_type like this for volume_type test -# ostestr --regex '(tempest.api.volume.test_volumes_list|\ -# tempest.api.volume.test_volumes_get|\ -# tempest.api.volume.admin.test_volume_type)' +ostestr --regex $TESTCASES # --------------------- IMPORTANT begin -------------------- # # all following test cases are from Cinder tempest test cases,