Skip to content

Commit 3114c3f

Browse files
pedro-martinspriteau
authored andcommitted
Add grenade tests
Change-Id: I427d4b91cc5da9e9b2ffdb4239a5256ab44a1e06
1 parent f2c1035 commit 3114c3f

5 files changed

Lines changed: 210 additions & 0 deletions

File tree

.zuul.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,38 @@
3131
USE_PYTHON3: True
3232
TEMPEST_PLUGINS: /opt/stack/cloudkitty-tempest-plugin
3333

34+
- job:
35+
name: cloudkitty-grenade-job
36+
parent: grenade
37+
description: |
38+
Grenade job to test release upgrades
39+
required-projects:
40+
- opendev.org/openstack/grenade
41+
- opendev.org/openstack/cloudkitty
42+
- opendev.org/openstack/cloudkitty-tempest-plugin
43+
- opendev.org/openstack/python-cloudkittyclient
44+
irrelevant-files: *base_irrelevant_files
45+
vars:
46+
devstack_plugins:
47+
cloudkitty: https://opendev.org/openstack/cloudkitty.git
48+
cloudkitty-tempest-plugin: https://opendev.org/openstack/cloudkitty-tempest-plugin.git
49+
devstack_services:
50+
ck-api: true
51+
ck-proc: true
52+
tempest_concurrency: 1
53+
tempest_plugins:
54+
- cloudkitty-tempest-plugin
55+
tempest_test_regex: cloudkitty_tempest_plugin.*
56+
tox_envlist: all
57+
grenade_from_branch: master
58+
grenade_devstack_localrc:
59+
shared:
60+
TARGET_BRANCH: master
61+
BASE_DEVSTACK_BRANCH: master
62+
CLOUDKITTY_USE_MOD_WSGI: false
63+
CLOUDKITTY_FETCHER: keystone
64+
USE_PYTHON3: True
65+
3466
- job:
3567
name: base-cloudkitty-v1-api-tempest-job
3668
parent: base-cloudkitty-tempest-job
@@ -161,9 +193,11 @@
161193
- cloudkitty-tempest-full-ipv6-only
162194
- cloudkitty-tox-bandit:
163195
voting: false
196+
- cloudkitty-grenade-job
164197
gate:
165198
jobs:
166199
- cloudkitty-tempest-full-v2-storage-influxdb
167200
- cloudkitty-tempest-full-v2-storage-influxdb-v2
168201
- cloudkitty-tempest-full-v1-storage-sqlalchemy
169202
- cloudkitty-tempest-full-ipv6-only
203+
- cloudkitty-grenade-job

devstack/upgrade/resources.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
source $GRENADE_DIR/grenaderc
6+
source $GRENADE_DIR/functions
7+
8+
source $TOP_DIR/openrc admin
9+
10+
set -o xtrace
11+
12+
CLOUDKITTY_GRENADE_DIR=$(dirname $0)
13+
14+
CK_SERVICE_NAME='test_service'
15+
CK_FIELD_NAME='test_field'
16+
CK_MAPPING_VALUE='test_value'
17+
18+
function create {
19+
CK_SERVICE_ID=$(openstack rating hashmap service create $CK_SERVICE_NAME -c 'Service ID' -f value)
20+
CK_FIELD_ID=$(openstack rating hashmap field create $CK_SERVICE_ID $CK_FIELD_NAME -c 'Field ID' -f value)
21+
openstack rating hashmap mapping create --field-id $CK_FIELD_ID --value $CK_MAPPING_VALUE 3
22+
23+
echo "CloudKitty create: SUCCESS"
24+
}
25+
26+
function verify {
27+
CK_SERVICE_NAME_VERIFY=$(openstack rating hashmap service list -c 'Name' -f value)
28+
if [ $CK_SERVICE_NAME_VERIFY != $CK_SERVICE_NAME ]; then
29+
echo "CloudKitty verify invalid service name. Expected $CK_SERVICE_NAME got $CK_SERVICE_NAME_VERIFY."
30+
errexit
31+
fi
32+
CK_SERVICE_ID=$(openstack rating hashmap service list -c 'Service ID' -f value)
33+
CK_FIELD_NAME_VERIFY=$(openstack rating hashmap field list $CK_SERVICE_ID -c 'Name' -f value)
34+
if [ $CK_FIELD_NAME_VERIFY != $CK_FIELD_NAME ]; then
35+
echo "CloudKitty verify invalid field name. Expected $CK_FIELD_NAME got $CK_FIELD_NAME_VERIFY."
36+
errexit
37+
fi
38+
CK_FIELD_ID=$(openstack rating hashmap field list $CK_SERVICE_ID -c 'Field ID' -f value)
39+
CK_MAPPING_VALUE_VERIFY=$(openstack rating hashmap mapping list --field-id $CK_FIELD_ID -c 'Value' -f value)
40+
if [ $CK_MAPPING_VALUE_VERIFY != $CK_MAPPING_VALUE ]; then
41+
echo "CloudKitty verify invalid mapping value. Expected $CK_MAPPING_VALUE got $CK_MAPPING_VALUE_VERIFY."
42+
errexit
43+
fi
44+
45+
echo "CloudKitty verify: SUCCESS"
46+
}
47+
48+
function verify_noapi {
49+
echo "CloudKitty verify_noapi: SUCCESS"
50+
}
51+
52+
function destroy {
53+
CK_SERVICE_ID=$(openstack rating hashmap service list -c 'Service ID' -f value)
54+
openstack rating hashmap service delete $CK_SERVICE_ID
55+
echo "CloudKitty destroy: SUCCESS"
56+
}
57+
58+
# Dispatcher
59+
case $1 in
60+
"create")
61+
create
62+
;;
63+
"verify_noapi")
64+
verify_noapi
65+
;;
66+
"verify")
67+
verify
68+
;;
69+
"destroy")
70+
destroy
71+
;;
72+
"force_destroy")
73+
set +o errexit
74+
destroy
75+
;;
76+
esac

devstack/upgrade/settings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
register_project_for_upgrade cloudkitty
2+
register_db_to_save cloudkitty

devstack/upgrade/shutdown.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
#
3+
#
4+
5+
set -o errexit
6+
7+
source $GRENADE_DIR/grenaderc
8+
source $GRENADE_DIR/functions
9+
10+
source $BASE_DEVSTACK_DIR/functions
11+
source $BASE_DEVSTACK_DIR/stackrc # needed for status directory
12+
source $BASE_DEVSTACK_DIR/lib/tls
13+
source $BASE_DEVSTACK_DIR/lib/apache
14+
15+
# Locate the cloudkitty plugin and get its functions
16+
CLOUDKITTY_DEVSTACK_DIR=$(dirname $(dirname $0))
17+
source $CLOUDKITTY_DEVSTACK_DIR/plugin.sh
18+
19+
set -o xtrace
20+
21+
stop_cloudkitty
22+
23+
# ensure everything is stopped
24+
25+
SERVICES_DOWN="ck-api ck-proc"
26+
27+
ensure_services_stopped $SERVICES_DOWN

devstack/upgrade/upgrade.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
3+
# ``upgrade-cloudkitty``
4+
5+
echo "*********************************************************************"
6+
echo "Begin $0"
7+
echo "*********************************************************************"
8+
9+
# Clean up any resources that may be in use
10+
cleanup() {
11+
set +o errexit
12+
13+
echo "********************************************************************"
14+
echo "ERROR: Abort $0"
15+
echo "********************************************************************"
16+
17+
# Kill ourselves to signal any calling process
18+
trap 2; kill -2 $$
19+
}
20+
21+
trap cleanup SIGHUP SIGINT SIGTERM
22+
23+
# Keep track of the grenade directory
24+
RUN_DIR=$(cd $(dirname "$0") && pwd)
25+
26+
# Source params
27+
source $GRENADE_DIR/grenaderc
28+
29+
# Import common functions
30+
source $GRENADE_DIR/functions
31+
32+
# This script exits on an error so that errors don't compound and you see
33+
# only the first error that occurred.
34+
set -o errexit
35+
36+
# Upgrade cloudkitty
37+
# ==================
38+
39+
# Get functions from current DevStack
40+
source $TARGET_DEVSTACK_DIR/stackrc
41+
source $TARGET_DEVSTACK_DIR/lib/apache
42+
source $TARGET_DEVSTACK_DIR/lib/tls
43+
source $(dirname $(dirname $BASH_SOURCE))/settings
44+
source $(dirname $(dirname $BASH_SOURCE))/plugin.sh
45+
46+
# Print the commands being run so that we can see the command that triggers
47+
# an error. It is also useful for following allowing as the install occurs.
48+
set -o xtrace
49+
50+
# Save current config files for posterity
51+
[[ -d $SAVE_DIR/etc.cloudkitty ]] || cp -pr $CLOUDKITTY_CONF_DIR $SAVE_DIR/etc.cloudkitty
52+
53+
# Install the target cloudkitty
54+
FILES=/tmp
55+
install_cloudkitty
56+
57+
# calls upgrade-cloudkitty for specific release
58+
upgrade_project cloudkitty $RUN_DIR $BASE_DEVSTACK_BRANCH $TARGET_DEVSTACK_BRANCH
59+
60+
# Migrate the database
61+
upgrade_cloudkitty_database || die $LINO "ERROR in database migration"
62+
63+
start_cloudkitty
64+
65+
# Don't succeed unless the services come up
66+
ensure_services_started ck-api ck-proc
67+
68+
set +o xtrace
69+
echo "*********************************************************************"
70+
echo "SUCCESS: End $0"
71+
echo "*********************************************************************"

0 commit comments

Comments
 (0)