Browse Source

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
tags/4.0.0
Spyros Trigazis 2 years ago
parent
commit
1f81a4e5df

+ 8
- 4
functional_creds.conf.sample View File

@@ -1,16 +1,20 @@
1 1
 # Credentials for functional testing
2 2
 [auth]
3
-auth_url = http://127.0.0.1:5000/v2.0
3
+auth_url = http://127.0.0.1:5000/v3
4 4
 magnum_url = http://127.0.0.1:9511/v1
5 5
 username = demo
6
-tenant_name = demo
6
+project_name = demo
7
+project_domain_id = default
8
+user_domain_id = default
7 9
 password = password
8
-auth_version = v2
10
+auth_version = v3
9 11
 insecure=False
10 12
 [admin]
11 13
 user = admin
12
-tenant = admin
14
+project_name = admin
13 15
 pass = password
16
+project_domain_id = default
17
+user_domain_id = default
14 18
 [magnum]
15 19
 image_id = fedora-atomic-latest
16 20
 nic_id = public

+ 13
- 24
magnum/tests/contrib/post_test_hook.sh View File

@@ -64,6 +64,11 @@ function create_test_data {
64 64
     # qcow2 images, the format is 'bare'.
65 65
     export IMAGE_ID=$(glance --os-image-api-version 1 image-list | grep $container_format | grep -i $image_name | awk '{print $2}')
66 66
 
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
+
67 72
     # pass the appropriate variables via a config file
68 73
     CREDS_FILE=$MAGNUM_DIR/functional_creds.conf
69 74
     cat <<EOF > $CREDS_FILE
@@ -71,15 +76,19 @@ function create_test_data {
71 76
 
72 77
 [auth]
73 78
 auth_url = $OS_AUTH_URL
74
-magnum_url = $BYPASS_URL
79
+magnum_url = $magnum_url
75 80
 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
77 84
 password = $OS_PASSWORD
78
-auth_version = v2
85
+auth_version = v3
79 86
 insecure = False
80 87
 [admin]
81 88
 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
83 92
 pass = $OS_PASSWORD
84 93
 region_name = $OS_REGION_NAME
85 94
 [magnum]
@@ -109,20 +118,8 @@ function add_flavor {
109 118
     # Get admin credentials
110 119
     pushd ../devstack
111 120
     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
119 121
     popd
120 122
 
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
-
126 123
     # Create magnum specific flavor for use in functional tests.
127 124
     echo_summary "Create a flavor"
128 125
     nova flavor-create  m1.magnum 100 1024 10 1
@@ -173,7 +170,6 @@ if [[ "api" == "$coe" ]]; then
173 170
 
174 171
     # Set demo credentials
175 172
     source $BASE/new/devstack/accrc/demo/demo
176
-    unset OS_AUTH_TYPE
177 173
 
178 174
     create_test_data $coe
179 175
 
@@ -198,13 +194,6 @@ else
198 194
     # Get admin credentials
199 195
     pushd ../devstack
200 196
     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
208 197
     popd
209 198
 
210 199
     add_flavor

+ 16
- 7
magnum/tests/functional/python_client_base.py View File

@@ -28,7 +28,7 @@ from six.moves import configparser
28 28
 from heatclient import client as heatclient
29 29
 from k8sclient.client import api_client
30 30
 from k8sclient.client.apis import apiv_api
31
-from keystoneclient.v2_0 import client as ksclient
31
+from keystoneclient.v3 import client as ksclient
32 32
 
33 33
 from magnum.common.utils import rmtree_without_raise
34 34
 import magnum.conf
@@ -53,8 +53,7 @@ class BaseMagnumClient(base.BaseMagnumTest):
53 53
         super(BaseMagnumClient, cls).setUpClass()
54 54
         user = cliutils.env('OS_USERNAME')
55 55
         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')
58 57
         auth_url = cliutils.env('OS_AUTH_URL')
59 58
         insecure = cliutils.env('INSECURE')
60 59
         region_name = cliutils.env('OS_REGION_NAME')
@@ -66,6 +65,8 @@ class BaseMagnumClient(base.BaseMagnumTest):
66 65
         keypair_id = cliutils.env('KEYPAIR_ID')
67 66
         dns_nameserver = cliutils.env('DNS_NAMESERVER')
68 67
         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')
69 70
 
70 71
         config = configparser.RawConfigParser()
71 72
         if config.read('functional_creds.conf'):
@@ -73,7 +74,7 @@ class BaseMagnumClient(base.BaseMagnumTest):
73 74
             # override
74 75
             user = user or config.get('admin', 'user')
75 76
             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')
77 78
             auth_url = auth_url or config.get('auth', 'auth_url')
78 79
             insecure = insecure or config.get('auth', 'insecure')
79 80
             magnum_url = magnum_url or config.get('auth', 'magnum_url')
@@ -85,6 +86,11 @@ class BaseMagnumClient(base.BaseMagnumTest):
85 86
             keypair_id = keypair_id or config.get('magnum', 'keypair_id')
86 87
             dns_nameserver = dns_nameserver or config.get(
87 88
                 '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
+
88 94
             try:
89 95
                 copy_logs = copy_logs or config.get('magnum', 'copy_logs')
90 96
             except configparser.NoOptionError:
@@ -99,16 +105,19 @@ class BaseMagnumClient(base.BaseMagnumTest):
99 105
         cls.copy_logs = str(copy_logs).lower() == 'true'
100 106
         cls.cs = v1client.Client(username=user,
101 107
                                  api_key=passwd,
102
-                                 project_id=tenant_id,
103
-                                 project_name=tenant,
108
+                                 project_name=project_name,
104 109
                                  auth_url=auth_url,
105 110
                                  insecure=insecure,
111
+                                 user_domain_id=user_domain_id,
112
+                                 project_domain_id=project_domain_id,
106 113
                                  service_type='container-infra',
107 114
                                  region_name=region_name,
108 115
                                  magnum_url=magnum_url)
109 116
         cls.keystone = ksclient.Client(username=user,
110 117
                                        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,
112 121
                                        auth_url=auth_url,
113 122
                                        insecure=insecure)
114 123
         token = cls.keystone.auth_token

Loading…
Cancel
Save