3
# This script is intended to allow repeatable migration of the neutron
4
# api tests from tempest. The intention is to allow development to
5
# continue in Tempest while the migration strategy evolves.
9
if [[ "$#" -ne 1 ]]; then
10
>&2 echo "Usage: $0 /path/to/tempest
11
Migrate neutron's api tests from a tempest repo."
15
TEMPEST_PATH=${TEMPEST_PATH:-$1}
17
if [ ! -f "$TEMPEST_PATH/run_tempest.sh" ]; then
18
>&2 echo "Unable to find tempest at '$TEMPEST_PATH'. Please verify that the specified path points to a valid tempest repo."
22
NEUTRON_PATH=${NEUTRON_PATH:-$(cd $(dirname "$0")/.. && pwd)}
23
NEUTRON_TEST_PATH=$NEUTRON_PATH/neutron/tests
26
local tempest_dep_paths=(
29
'tempest/api/network/admin'
31
'tempest/common/generator'
32
'tempest/common/utils'
34
'tempest/services/identity'
35
'tempest/services/identity/v2'
36
'tempest/services/identity/v2/json'
37
'tempest/services/identity/v3'
38
'tempest/services/identity/v3/json'
39
'tempest/services/network'
40
'tempest/services/network/json'
42
for tempest_dep_path in ${tempest_dep_paths[@]}; do
43
local target_path=$NEUTRON_TEST_PATH/$tempest_dep_path
44
if [[ ! -d "$target_path" ]]; then
47
cp $TEMPEST_PATH/$tempest_dep_path/*.py $target_path
49
touch $NEUTRON_TEST_PATH/tempest/api/__init__.py
51
local paths_to_remove=(
52
"$NEUTRON_TEST_PATH/tempest/clients.py"
54
for path_to_remove in ${paths_to_remove[@]}; do
55
if [ -f "$path_to_remove" ]; then
61
function rewrite_imports {
63
's/tempest.common.generator/neutron.tests.tempest.common.generator/'
64
's/tempest.test/neutron.tests.tempest.test/'
65
's/from tempest.openstack.common import lockutils/from oslo_concurrency import lockutils/'
66
's/from tempest.openstack.common import importutils/from oslo_utils import importutils/'
67
's/tempest.openstack.common/neutron.openstack.common/'
68
's/from tempest(?!_lib) import clients/from neutron.tests.api.contrib import clients/'
69
's/from tempest(?!_lib)/from neutron.tests.tempest/'
70
's/CONF.lock_path/CONF.oslo_concurrency.lock_path/'
72
files=$(find $NEUTRON_TEST_PATH/tempest -name '*.py')
73
for ((i = 0; i < ${#regexes[@]}; i++)); do
74
perl -p -i -e "${regexes[$i]}" $files