Skip to content

Commit 1f81a4e

Browse files
committed
Use keystone v3 for functional tests
* Update functional_creds.conf.sample * and functional_creds.conf in post_gate_hook * Update python_client_base to use keystone v3 credentials * Get magnum_url from magnum.conf Closes-Bug: #1474152 Change-Id: If1ce6e77396857fef68c5c288f0b1c7fecb0b4d4
1 parent efdb202 commit 1f81a4e

File tree

3 files changed

+37
-35
lines changed

3 files changed

+37
-35
lines changed

functional_creds.conf.sample

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
# Credentials for functional testing
22
[auth]
3-
auth_url = http://127.0.0.1:5000/v2.0
3+
auth_url = http://127.0.0.1:5000/v3
44
magnum_url = http://127.0.0.1:9511/v1
55
username = demo
6-
tenant_name = demo
6+
project_name = demo
7+
project_domain_id = default
8+
user_domain_id = default
79
password = password
8-
auth_version = v2
10+
auth_version = v3
911
insecure=False
1012
[admin]
1113
user = admin
12-
tenant = admin
14+
project_name = admin
1315
pass = password
16+
project_domain_id = default
17+
user_domain_id = default
1418
[magnum]
1519
image_id = fedora-atomic-latest
1620
nic_id = public

magnum/tests/contrib/post_test_hook.sh

+13-24
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,31 @@ function create_test_data {
6464
# qcow2 images, the format is 'bare'.
6565
export IMAGE_ID=$(glance --os-image-api-version 1 image-list | grep $container_format | grep -i $image_name | awk '{print $2}')
6666

67+
#Get magnum_url
68+
local magnum_api_ip=$(iniget /etc/magnum/magnum.conf api host)
69+
local magnum_api_port=$(iniget /etc/magnum/magnum.conf api port)
70+
local magnum_url="http://"$magnum_api_ip":"$magnum_api_port"/v1"
71+
6772
# pass the appropriate variables via a config file
6873
CREDS_FILE=$MAGNUM_DIR/functional_creds.conf
6974
cat <<EOF > $CREDS_FILE
7075
# Credentials for functional testing
7176
7277
[auth]
7378
auth_url = $OS_AUTH_URL
74-
magnum_url = $BYPASS_URL
79+
magnum_url = $magnum_url
7580
username = $OS_USERNAME
76-
tenant_name = $OS_TENANT_NAME
81+
project_name = $OS_PROJECT_NAME
82+
project_domain_id = $OS_PROJECT_DOMAIN_ID
83+
user_domain_id = $OS_USER_DOMAIN_ID
7784
password = $OS_PASSWORD
78-
auth_version = v2
85+
auth_version = v3
7986
insecure = False
8087
[admin]
8188
user = $OS_USERNAME
82-
tenant = $OS_TENANT_NAME
89+
project_name = $OS_PROJECT_NAME
90+
project_domain_id = $OS_PROJECT_DOMAIN_ID
91+
user_domain_id = $OS_USER_DOMAIN_ID
8392
pass = $OS_PASSWORD
8493
region_name = $OS_REGION_NAME
8594
[magnum]
@@ -109,20 +118,8 @@ function add_flavor {
109118
# Get admin credentials
110119
pushd ../devstack
111120
source openrc admin admin
112-
# NOTE(hongbin): This is a temporary work around. These variables are for
113-
# keystone v3, but magnum is using v2 API. Therefore, unset them to make the
114-
# keystoneclient work.
115-
# Bug: #1473600
116-
unset OS_PROJECT_DOMAIN_ID
117-
unset OS_USER_DOMAIN_ID
118-
unset OS_AUTH_TYPE
119121
popd
120122

121-
# Due to keystone defaulting everything to v3, we need to update to make func tests
122-
# work in our gates back to v2
123-
export OS_AUTH_URL=http://127.0.0.1:5000/v2.0
124-
export OS_IDENTITY_API_VERSION=2.0
125-
126123
# Create magnum specific flavor for use in functional tests.
127124
echo_summary "Create a flavor"
128125
nova flavor-create m1.magnum 100 1024 10 1
@@ -173,7 +170,6 @@ if [[ "api" == "$coe" ]]; then
173170

174171
# Set demo credentials
175172
source $BASE/new/devstack/accrc/demo/demo
176-
unset OS_AUTH_TYPE
177173

178174
create_test_data $coe
179175

@@ -198,13 +194,6 @@ else
198194
# Get admin credentials
199195
pushd ../devstack
200196
source openrc admin admin
201-
# NOTE(hongbin): This is a temporary work around. These variables are for
202-
# keystone v3, but magnum is using v2 API. Therefore, unset them to make the
203-
# keystoneclient work.
204-
# Bug: #1473600
205-
unset OS_PROJECT_DOMAIN_ID
206-
unset OS_USER_DOMAIN_ID
207-
unset OS_AUTH_TYPE
208197
popd
209198

210199
add_flavor

magnum/tests/functional/python_client_base.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from heatclient import client as heatclient
2929
from k8sclient.client import api_client
3030
from k8sclient.client.apis import apiv_api
31-
from keystoneclient.v2_0 import client as ksclient
31+
from keystoneclient.v3 import client as ksclient
3232

3333
from magnum.common.utils import rmtree_without_raise
3434
import magnum.conf
@@ -53,8 +53,7 @@ def setUpClass(cls):
5353
super(BaseMagnumClient, cls).setUpClass()
5454
user = cliutils.env('OS_USERNAME')
5555
passwd = cliutils.env('OS_PASSWORD')
56-
tenant = cliutils.env('OS_TENANT_NAME')
57-
tenant_id = cliutils.env('OS_TENANT_ID')
56+
project_name = cliutils.env('OS_PROJECT_NAME')
5857
auth_url = cliutils.env('OS_AUTH_URL')
5958
insecure = cliutils.env('INSECURE')
6059
region_name = cliutils.env('OS_REGION_NAME')
@@ -66,14 +65,16 @@ def setUpClass(cls):
6665
keypair_id = cliutils.env('KEYPAIR_ID')
6766
dns_nameserver = cliutils.env('DNS_NAMESERVER')
6867
copy_logs = cliutils.env('COPY_LOGS')
68+
user_domain_id = cliutils.env('OS_USER_DOMAIN_ID')
69+
project_domain_id = cliutils.env('OS_PROJECT_DOMAIN_ID')
6970

7071
config = configparser.RawConfigParser()
7172
if config.read('functional_creds.conf'):
7273
# the OR pattern means the environment is preferred for
7374
# override
7475
user = user or config.get('admin', 'user')
7576
passwd = passwd or config.get('admin', 'pass')
76-
tenant = tenant or config.get('admin', 'tenant')
77+
project_name = project_name or config.get('admin', 'project_name')
7778
auth_url = auth_url or config.get('auth', 'auth_url')
7879
insecure = insecure or config.get('auth', 'insecure')
7980
magnum_url = magnum_url or config.get('auth', 'magnum_url')
@@ -85,6 +86,11 @@ def setUpClass(cls):
8586
keypair_id = keypair_id or config.get('magnum', 'keypair_id')
8687
dns_nameserver = dns_nameserver or config.get(
8788
'magnum', 'dns_nameserver')
89+
user_domain_id = user_domain_id or config.get(
90+
'admin', 'user_domain_id')
91+
project_domain_id = project_domain_id or config.get(
92+
'admin', 'project_domain_id')
93+
8894
try:
8995
copy_logs = copy_logs or config.get('magnum', 'copy_logs')
9096
except configparser.NoOptionError:
@@ -99,16 +105,19 @@ def setUpClass(cls):
99105
cls.copy_logs = str(copy_logs).lower() == 'true'
100106
cls.cs = v1client.Client(username=user,
101107
api_key=passwd,
102-
project_id=tenant_id,
103-
project_name=tenant,
108+
project_name=project_name,
104109
auth_url=auth_url,
105110
insecure=insecure,
111+
user_domain_id=user_domain_id,
112+
project_domain_id=project_domain_id,
106113
service_type='container-infra',
107114
region_name=region_name,
108115
magnum_url=magnum_url)
109116
cls.keystone = ksclient.Client(username=user,
110117
password=passwd,
111-
tenant_name=tenant,
118+
project_name=project_name,
119+
project_domain_id=project_domain_id,
120+
user_domain_id=user_domain_id,
112121
auth_url=auth_url,
113122
insecure=insecure)
114123
token = cls.keystone.auth_token

0 commit comments

Comments
 (0)