summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandan Kumar <chkumar@redhat.com>2017-12-08 13:38:31 +0530
committerChandan Kumar <chkumar@redhat.com>2017-12-14 15:48:47 +0530
commit53fa3accea20ea0f89188f59feb96b1031d19f8f (patch)
treefaae9fe4c9b719722ccbb2e1ed8a88ba296975bd
parent2fafa7fdabef814ae17cd87ae790d0bb1c067042 (diff)
Remove intree magnum tempest plugin
* It removes magnum tempest plugin reference in favour of using newly magnum-tempest-plugin. * We removed tempest tests resides under functional.api.v1.test-* files as they are tempest tests and keeping the rest as they are used by functional tests. Depends-On: Ibdddd26da9cfb0d08c2977660320b2c052d7261b Change-Id: Ida2fa1ef5880ebead787e3b27ac7ebf5aa498f62
Notes
Notes (review): Code-Review+2: Spyros Trigazis (strigazi) <strigazi@gmail.com> Code-Review+2: yatin <ykarel@redhat.com> Workflow+1: yatin <ykarel@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 27 Dec 2017 05:20:52 +0000 Reviewed-on: https://review.openstack.org/526618 Project: openstack/magnum Branch: refs/heads/master
-rw-r--r--.zuul.yaml1
-rwxr-xr-xmagnum/tests/contrib/post_test_hook.sh25
-rwxr-xr-xmagnum/tests/functional/api/v1/test_bay.py216
-rw-r--r--magnum/tests/functional/api/v1/test_baymodel.py207
-rw-r--r--magnum/tests/functional/api/v1/test_baymodel_admin.py80
-rwxr-xr-xmagnum/tests/functional/api/v1/test_cluster.py262
-rw-r--r--magnum/tests/functional/api/v1/test_cluster_template.py230
-rw-r--r--magnum/tests/functional/api/v1/test_cluster_template_admin.py86
-rw-r--r--magnum/tests/functional/api/v1/test_magnum_service.py53
-rw-r--r--magnum/tests/functional/tempest_tests/__init__.py0
-rw-r--r--magnum/tests/functional/tempest_tests/config.py67
-rw-r--r--magnum/tests/functional/tempest_tests/plugin.py42
-rw-r--r--playbooks/magnum-functional-base.yaml14
-rw-r--r--setup.cfg2
-rw-r--r--test-requirements.txt1
15 files changed, 28 insertions, 1258 deletions
diff --git a/.zuul.yaml b/.zuul.yaml
index c79c432..580ca99 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -13,6 +13,7 @@
13 - openstack/ironic-lib 13 - openstack/ironic-lib
14 - openstack/ironic-python-agent 14 - openstack/ironic-python-agent
15 - openstack/magnum 15 - openstack/magnum
16 - openstack/magnum-tempest-plugin
16 - openstack/pyghmi 17 - openstack/pyghmi
17 - openstack/python-ironicclient 18 - openstack/python-ironicclient
18 - openstack/python-magnumclient 19 - openstack/python-magnumclient
diff --git a/magnum/tests/contrib/post_test_hook.sh b/magnum/tests/contrib/post_test_hook.sh
index 31bbdf8..e0b1a00 100755
--- a/magnum/tests/contrib/post_test_hook.sh
+++ b/magnum/tests/contrib/post_test_hook.sh
@@ -197,22 +197,23 @@ if [[ "api" == "$coe" ]]; then
197 197
198 # strigazi: don't run test_create_list_sign_delete_clusters because 198 # strigazi: don't run test_create_list_sign_delete_clusters because
199 # it is very unstable in the CI 199 # it is very unstable in the CI
200 _magnum_tests="magnum.tests.functional.api.v1.test_bay" 200 _magnum_tests="magnum_tempest_plugin.tests.api.v1.test_bay"
201 _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_baymodel" 201 _magnum_tests="$_magnum_tests magnum_tempest_plugin.tests.api.v1.test_baymodel"
202 _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster_template" 202 _magnum_tests="$_magnum_tests magnum_tempest_plugin.tests.api.v1.test_cluster_template"
203 _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster_template_admin" 203 _magnum_tests="$_magnum_tests magnum_tempest_plugin.tests.api.v1.test_cluster_template_admin"
204 _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_magnum_service" 204 _magnum_tests="$_magnum_tests magnum_tempest_plugin.tests.api.v1.test_magnum_service"
205 _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster.ClusterTest.test_create_cluster_for_nonexisting_cluster_template" 205 _magnum_tests="$_magnum_tests magnum_tempest_plugin.tests.api.v1.test_cluster.ClusterTest.test_create_cluster_for_nonexisting_cluster_template"
206 _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster.ClusterTest.test_create_cluster_with_node_count_0" 206 _magnum_tests="$_magnum_tests magnum_tempest_plugin.tests.api.v1.test_cluster.ClusterTest.test_create_cluster_with_node_count_0"
207 _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster.ClusterTest.test_create_cluster_with_nonexisting_flavor" 207 _magnum_tests="$_magnum_tests magnum_tempest_plugin.tests.api.v1.test_cluster.ClusterTest.test_create_cluster_with_nonexisting_flavor"
208 _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster.ClusterTest.test_create_cluster_with_zero_masters" 208 _magnum_tests="$_magnum_tests magnum_tempest_plugin.tests.api.v1.test_cluster.ClusterTest.test_create_cluster_with_zero_masters"
209 _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster.ClusterTest.test_delete_cluster_for_nonexisting_cluster" 209 _magnum_tests="$_magnum_tests magnum_tempest_plugin.tests.api.v1.test_cluster.ClusterTest.test_delete_cluster_for_nonexisting_cluster"
210 _magnum_tests="$_magnum_tests magnum.tests.functional.api.v1.test_cluster.ClusterTest.test_update_cluster_for_nonexisting_cluster" 210 _magnum_tests="$_magnum_tests magnum_tempest_plugin.tests.api.v1.test_cluster.ClusterTest.test_update_cluster_for_nonexisting_cluster"
211fi 211fi
212 212
213target="${coe}${special}" 213target="${coe}${special}"
214pushd $BASE/new/magnum-tempest-plugin
214sudo -E -H -u $USER tox -e functional-"$target" $_magnum_tests -- --concurrency=1 215sudo -E -H -u $USER tox -e functional-"$target" $_magnum_tests -- --concurrency=1
215 216popd
216EXIT_CODE=$? 217EXIT_CODE=$?
217 218
218# Delete the keypair used in the functional test. 219# Delete the keypair used in the functional test.
diff --git a/magnum/tests/functional/api/v1/test_bay.py b/magnum/tests/functional/api/v1/test_bay.py
deleted file mode 100755
index 77415ac..0000000
--- a/magnum/tests/functional/api/v1/test_bay.py
+++ /dev/null
@@ -1,216 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13import fixtures
14
15from oslo_log import log as logging
16from oslo_utils import uuidutils
17from tempest.lib.common.utils import data_utils
18from tempest.lib import exceptions
19import testtools
20
21from magnum.tests.functional.api import base
22from magnum.tests.functional.common import config
23from magnum.tests.functional.common import datagen
24
25
26class BayTest(base.BaseTempestTest):
27
28 """Tests for bay CRUD."""
29
30 LOG = logging.getLogger(__name__)
31
32 def __init__(self, *args, **kwargs):
33 super(BayTest, self).__init__(*args, **kwargs)
34 self.bays = []
35 self.creds = None
36 self.keypair = None
37 self.baymodel = None
38 self.baymodel_client = None
39 self.keypairs_client = None
40 self.bay_client = None
41 self.cert_client = None
42
43 def setUp(self):
44 try:
45 super(BayTest, self).setUp()
46 (self.creds, self.keypair) = self.get_credentials_with_keypair(
47 type_of_creds='default')
48 (self.baymodel_client,
49 self.keypairs_client) = self.get_clients_with_existing_creds(
50 creds=self.creds,
51 type_of_creds='default',
52 request_type='baymodel')
53 (self.bay_client, _) = self.get_clients_with_existing_creds(
54 creds=self.creds,
55 type_of_creds='default',
56 request_type='bay')
57 (self.cert_client, _) = self.get_clients_with_existing_creds(
58 creds=self.creds,
59 type_of_creds='default',
60 request_type='cert')
61 model = datagen.valid_swarm_mode_baymodel()
62 _, self.baymodel = self._create_baymodel(model)
63
64 # NOTE (dimtruck) by default tempest sets timeout to 20 mins.
65 # We need more time.
66 test_timeout = 1800
67 self.useFixture(fixtures.Timeout(test_timeout, gentle=True))
68 except Exception:
69 self.tearDown()
70 raise
71
72 def tearDown(self):
73 try:
74 bay_list = self.bays[:]
75 for bay_id in bay_list:
76 self._delete_bay(bay_id)
77 self.bays.remove(bay_id)
78 if self.baymodel:
79 self._delete_baymodel(self.baymodel.uuid)
80 finally:
81 super(BayTest, self).tearDown()
82
83 def _create_baymodel(self, baymodel_model):
84 self.LOG.debug('We will create a baymodel for %s', baymodel_model)
85 resp, model = self.baymodel_client.post_baymodel(baymodel_model)
86 return resp, model
87
88 def _delete_baymodel(self, baymodel_id):
89 self.LOG.debug('We will delete a baymodel for %s', baymodel_id)
90 resp, model = self.baymodel_client.delete_baymodel(baymodel_id)
91 return resp, model
92
93 def _create_bay(self, bay_model, is_async=False):
94 self.LOG.debug('We will create bay for %s', bay_model)
95 headers = {'Content-Type': 'application/json',
96 'Accept': 'application/json'}
97 if is_async:
98 headers["OpenStack-API-Version"] = "container-infra 1.2"
99 resp, model = self.bay_client.post_bay(bay_model, headers=headers)
100 self.LOG.debug('Response: %s', resp)
101 if is_async:
102 self.assertEqual(202, resp.status)
103 else:
104 self.assertEqual(201, resp.status)
105 self.assertIsNotNone(model.uuid)
106 self.assertTrue(uuidutils.is_uuid_like(model.uuid))
107 self.bays.append(model.uuid)
108 self.bay_uuid = model.uuid
109 if config.Config.copy_logs:
110 self.addCleanup(self.copy_logs_handler(
111 lambda: list(
112 [self._get_bay_by_id(self.bay_uuid)[1].master_addresses,
113 self._get_bay_by_id(self.bay_uuid)[1].node_addresses]),
114 self.baymodel.coe,
115 self.keypair))
116 self.bay_client.wait_for_created_bay(model.uuid, delete_on_error=False)
117 return resp, model
118
119 def _delete_bay(self, bay_id):
120 self.LOG.debug('We will delete a bay for %s', bay_id)
121 resp, model = self.bay_client.delete_bay(bay_id)
122 self.assertEqual(204, resp.status)
123 self.bay_client.wait_for_bay_to_delete(bay_id)
124 self.assertRaises(
125 exceptions.NotFound,
126 self.cert_client.get_cert, bay_id)
127 return resp, model
128
129 def _get_bay_by_id(self, bay_id):
130 resp, model = self.bay_client.get_bay(bay_id)
131 return resp, model
132
133 @testtools.testcase.attr('negative')
134 def test_create_bay_for_nonexisting_baymodel(self):
135 gen_model = datagen.valid_bay_data(baymodel_id='this-does-not-exist')
136 self.assertRaises(
137 exceptions.BadRequest,
138 self.bay_client.post_bay, gen_model)
139
140 @testtools.testcase.attr('negative')
141 def test_create_bay_with_node_count_0(self):
142 gen_model = datagen.valid_bay_data(
143 baymodel_id=self.baymodel.uuid, node_count=0)
144 self.assertRaises(
145 exceptions.BadRequest,
146 self.bay_client.post_bay, gen_model)
147
148 @testtools.testcase.attr('negative')
149 def test_create_bay_with_zero_masters(self):
150 gen_model = datagen.valid_bay_data(baymodel_id=self.baymodel.uuid,
151 master_count=0)
152 self.assertRaises(
153 exceptions.BadRequest,
154 self.bay_client.post_bay, gen_model)
155
156 @testtools.testcase.attr('negative')
157 def test_create_bay_with_nonexisting_flavor(self):
158 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
159 resp, baymodel = self._create_baymodel(gen_model)
160 self.assertEqual(201, resp.status)
161 self.assertIsNotNone(baymodel.uuid)
162
163 gen_model = datagen.valid_bay_data(baymodel_id=baymodel.uuid)
164 gen_model.flavor_id = 'aaa'
165 self.assertRaises(
166 exceptions.BadRequest,
167 self.bay_client.post_bay, gen_model)
168
169 resp, _ = self._delete_baymodel(baymodel.uuid)
170 self.assertEqual(204, resp.status)
171
172 @testtools.testcase.attr('negative')
173 def test_create_bay_with_nonexisting_keypair(self):
174 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
175 resp, baymodel = self._create_baymodel(gen_model)
176 self.assertEqual(201, resp.status)
177 self.assertIsNotNone(baymodel.uuid)
178
179 gen_model = datagen.valid_bay_data(baymodel_id=baymodel.uuid)
180 gen_model.keypair_id = 'aaa'
181 self.assertRaises(
182 exceptions.BadRequest,
183 self.bay_client.post_bay, gen_model)
184
185 resp, _ = self._delete_baymodel(baymodel.uuid)
186 self.assertEqual(204, resp.status)
187
188 @testtools.testcase.attr('negative')
189 def test_create_bay_with_nonexisting_external_network(self):
190 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
191 resp, baymodel = self._create_baymodel(gen_model)
192 self.assertEqual(201, resp.status)
193 self.assertIsNotNone(baymodel.uuid)
194
195 gen_model = datagen.valid_bay_data(baymodel_id=baymodel.uuid)
196 gen_model.external_network_id = 'aaa'
197 self.assertRaises(
198 exceptions.BadRequest,
199 self.bay_client.post_bay, gen_model)
200
201 resp, _ = self._delete_baymodel(baymodel.uuid)
202 self.assertEqual(204, resp.status)
203
204 @testtools.testcase.attr('negative')
205 def test_update_bay_for_nonexisting_bay(self):
206 patch_model = datagen.bay_name_patch_data()
207
208 self.assertRaises(
209 exceptions.NotFound,
210 self.bay_client.patch_bay, 'fooo', patch_model)
211
212 @testtools.testcase.attr('negative')
213 def test_delete_bay_for_nonexisting_bay(self):
214 self.assertRaises(
215 exceptions.NotFound,
216 self.bay_client.delete_bay, data_utils.rand_uuid())
diff --git a/magnum/tests/functional/api/v1/test_baymodel.py b/magnum/tests/functional/api/v1/test_baymodel.py
deleted file mode 100644
index 0bdce36..0000000
--- a/magnum/tests/functional/api/v1/test_baymodel.py
+++ /dev/null
@@ -1,207 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13
14from tempest.lib.common.utils import data_utils
15from tempest.lib import exceptions
16import testtools
17
18from magnum.tests.functional.api import base
19from magnum.tests.functional.common import datagen
20
21
22class BayModelTest(base.BaseTempestTest):
23
24 """Tests for baymodel CRUD."""
25
26 def __init__(self, *args, **kwargs):
27 super(BayModelTest, self).__init__(*args, **kwargs)
28 self.baymodels = []
29 self.baymodel_client = None
30 self.keypairs_client = None
31
32 def setUp(self):
33 try:
34 super(BayModelTest, self).setUp()
35 (self.baymodel_client,
36 self.keypairs_client) = self.get_clients_with_new_creds(
37 type_of_creds='default',
38 request_type='baymodel')
39 except Exception:
40 self.tearDown()
41 raise
42
43 def tearDown(self):
44 for baymodel_id in self.baymodels:
45 self._delete_baymodel(baymodel_id)
46 self.baymodels.remove(baymodel_id)
47 super(BayModelTest, self).tearDown()
48
49 def _create_baymodel(self, baymodel_model):
50 resp, model = self.baymodel_client.post_baymodel(baymodel_model)
51 self.assertEqual(201, resp.status)
52 self.baymodels.append(model.uuid)
53 return resp, model
54
55 def _delete_baymodel(self, baymodel_id):
56 resp, model = self.baymodel_client.delete_baymodel(baymodel_id)
57 self.assertEqual(204, resp.status)
58 return resp, model
59
60 @testtools.testcase.attr('positive')
61 def test_list_baymodels(self):
62 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
63 _, temp_model = self._create_baymodel(gen_model)
64 resp, model = self.baymodel_client.list_baymodels()
65 self.assertEqual(200, resp.status)
66 self.assertGreater(len(model.baymodels), 0)
67 self.assertIn(
68 temp_model.uuid, list([x['uuid'] for x in model.baymodels]))
69
70 @testtools.testcase.attr('positive')
71 def test_create_baymodel(self):
72 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
73 resp, model = self._create_baymodel(gen_model)
74
75 @testtools.testcase.attr('positive')
76 def test_create_get_public_baymodel(self):
77 gen_model = datagen.valid_swarm_mode_baymodel(is_public=True)
78 self.assertRaises(
79 exceptions.Forbidden,
80 self.baymodel_client.post_baymodel, gen_model)
81
82 @testtools.testcase.attr('positive')
83 def test_update_baymodel_public_by_uuid(self):
84 path = "/public"
85 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
86 resp, old_model = self._create_baymodel(gen_model)
87
88 patch_model = datagen.baymodel_replace_patch_data(path, value=True)
89 self.assertRaises(
90 exceptions.Forbidden,
91 self.baymodel_client.patch_baymodel, old_model.uuid, patch_model)
92
93 @testtools.testcase.attr('positive')
94 def test_update_baymodel_by_uuid(self):
95 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
96 resp, old_model = self._create_baymodel(gen_model)
97
98 path = "/name"
99 patch_model = datagen.baymodel_replace_patch_data(path)
100 resp, new_model = self.baymodel_client.patch_baymodel(
101 old_model.uuid, patch_model)
102 self.assertEqual(200, resp.status)
103
104 resp, model = self.baymodel_client.get_baymodel(new_model.uuid)
105 self.assertEqual(200, resp.status)
106 self.assertEqual(old_model.uuid, new_model.uuid)
107 self.assertEqual(model.name, new_model.name)
108
109 @testtools.testcase.attr('positive')
110 def test_delete_baymodel_by_uuid(self):
111 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
112 resp, model = self._create_baymodel(gen_model)
113 resp, _ = self.baymodel_client.delete_baymodel(model.uuid)
114 self.assertEqual(204, resp.status)
115 self.baymodels.remove(model.uuid)
116
117 @testtools.testcase.attr('positive')
118 def test_delete_baymodel_by_name(self):
119 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
120 resp, model = self._create_baymodel(gen_model)
121 resp, _ = self.baymodel_client.delete_baymodel(model.name)
122 self.assertEqual(204, resp.status)
123 self.baymodels.remove(model.uuid)
124
125 @testtools.testcase.attr('negative')
126 def test_get_baymodel_by_uuid_404(self):
127 self.assertRaises(
128 exceptions.NotFound,
129 self.baymodel_client.get_baymodel, data_utils.rand_uuid())
130
131 @testtools.testcase.attr('negative')
132 def test_update_baymodel_404(self):
133 path = "/name"
134 patch_model = datagen.baymodel_replace_patch_data(path)
135
136 self.assertRaises(
137 exceptions.NotFound,
138 self.baymodel_client.patch_baymodel,
139 data_utils.rand_uuid(), patch_model)
140
141 @testtools.testcase.attr('negative')
142 def test_delete_baymodel_404(self):
143 self.assertRaises(
144 exceptions.NotFound,
145 self.baymodel_client.delete_baymodel, data_utils.rand_uuid())
146
147 @testtools.testcase.attr('negative')
148 def test_get_baymodel_by_name_404(self):
149 self.assertRaises(
150 exceptions.NotFound,
151 self.baymodel_client.get_baymodel, 'fooo')
152
153 @testtools.testcase.attr('negative')
154 def test_update_baymodel_name_not_found(self):
155 path = "/name"
156 patch_model = datagen.baymodel_replace_patch_data(path)
157
158 self.assertRaises(
159 exceptions.NotFound,
160 self.baymodel_client.patch_baymodel, 'fooo', patch_model)
161
162 @testtools.testcase.attr('negative')
163 def test_delete_baymodel_by_name_404(self):
164 self.assertRaises(
165 exceptions.NotFound,
166 self.baymodel_client.get_baymodel, 'fooo')
167
168 @testtools.testcase.attr('negative')
169 def test_create_baymodel_missing_image(self):
170 gen_model = datagen.baymodel_data_with_missing_image()
171 self.assertRaises(
172 exceptions.BadRequest,
173 self.baymodel_client.post_baymodel, gen_model)
174
175 @testtools.testcase.attr('negative')
176 def test_create_baymodel_missing_flavor(self):
177 gen_model = datagen.baymodel_data_with_missing_flavor()
178 self.assertRaises(
179 exceptions.BadRequest,
180 self.baymodel_client.post_baymodel, gen_model)
181
182 @testtools.testcase.attr('negative')
183 def test_update_baymodel_invalid_patch(self):
184 # get json object
185 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
186 resp, old_model = self._create_baymodel(gen_model)
187
188 self.assertRaises(
189 exceptions.BadRequest,
190 self.baymodel_client.patch_baymodel, data_utils.rand_uuid(),
191 gen_model)
192
193 @testtools.testcase.attr('negative')
194 def test_create_baymodel_invalid_network_driver(self):
195 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
196 gen_model.network_driver = 'invalid_network_driver'
197 self.assertRaises(
198 exceptions.BadRequest,
199 self.baymodel_client.post_baymodel, gen_model)
200
201 @testtools.testcase.attr('negative')
202 def test_create_baymodel_invalid_volume_driver(self):
203 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
204 gen_model.volume_driver = 'invalid_volume_driver'
205 self.assertRaises(
206 exceptions.BadRequest,
207 self.baymodel_client.post_baymodel, gen_model)
diff --git a/magnum/tests/functional/api/v1/test_baymodel_admin.py b/magnum/tests/functional/api/v1/test_baymodel_admin.py
deleted file mode 100644
index 67f5b15..0000000
--- a/magnum/tests/functional/api/v1/test_baymodel_admin.py
+++ /dev/null
@@ -1,80 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13
14import testtools
15
16from magnum.tests.functional.api import base
17from magnum.tests.functional.common import datagen
18
19
20class BayModelAdminTest(base.BaseTempestTest):
21
22 """Tests for baymodel admin operations."""
23
24 def __init__(self, *args, **kwargs):
25 super(BayModelAdminTest, self).__init__(*args, **kwargs)
26 self.baymodels = []
27 self.baymodel_client = None
28 self.keypairs_client = None
29
30 def setUp(self):
31 try:
32 super(BayModelAdminTest, self).setUp()
33 (self.baymodel_client,
34 self.keypairs_client) = self.get_clients_with_new_creds(
35 type_of_creds='admin',
36 request_type='baymodel')
37 except Exception:
38 self.tearDown()
39 raise
40
41 def tearDown(self):
42 for baymodel_id in self.baymodels:
43 self._delete_baymodel(baymodel_id)
44 self.baymodels.remove(baymodel_id)
45 super(BayModelAdminTest, self).tearDown()
46
47 def _create_baymodel(self, baymodel_model):
48 resp, model = self.baymodel_client.post_baymodel(baymodel_model)
49 self.assertEqual(201, resp.status)
50 self.baymodels.append(model.uuid)
51 return resp, model
52
53 def _delete_baymodel(self, baymodel_id):
54 resp, model = self.baymodel_client.delete_baymodel(baymodel_id)
55 self.assertEqual(204, resp.status)
56 return resp, model
57
58 @testtools.testcase.attr('positive')
59 def test_create_get_public_baymodel(self):
60 gen_model = datagen.valid_swarm_mode_baymodel(is_public=True)
61 resp, model = self._create_baymodel(gen_model)
62
63 resp, model = self.baymodel_client.get_baymodel(model.uuid)
64 self.assertEqual(200, resp.status)
65 self.assertTrue(model.public)
66
67 @testtools.testcase.attr('positive')
68 def test_update_baymodel_public_by_uuid(self):
69 path = "/public"
70 gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
71 resp, old_model = self._create_baymodel(gen_model)
72
73 patch_model = datagen.baymodel_replace_patch_data(path, value=True)
74 resp, new_model = self.baymodel_client.patch_baymodel(
75 old_model.uuid, patch_model)
76 self.assertEqual(200, resp.status)
77
78 resp, model = self.baymodel_client.get_baymodel(new_model.uuid)
79 self.assertEqual(200, resp.status)
80 self.assertTrue(model.public)
diff --git a/magnum/tests/functional/api/v1/test_cluster.py b/magnum/tests/functional/api/v1/test_cluster.py
deleted file mode 100755
index 59b7004..0000000
--- a/magnum/tests/functional/api/v1/test_cluster.py
+++ /dev/null
@@ -1,262 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13import fixtures
14
15from oslo_log import log as logging
16from oslo_utils import uuidutils
17from tempest.lib.common.utils import data_utils
18from tempest.lib import exceptions
19import testtools
20
21from magnum.tests.functional.api import base
22from magnum.tests.functional.common import config
23from magnum.tests.functional.common import datagen
24
25
26HEADERS = {'OpenStack-API-Version': 'container-infra latest',
27 'Accept': 'application/json',
28 'Content-Type': 'application/json'}
29
30
31class ClusterTest(base.BaseTempestTest):
32
33 """Tests for cluster CRUD."""
34
35 LOG = logging.getLogger(__name__)
36
37 def __init__(self, *args, **kwargs):
38 super(ClusterTest, self).__init__(*args, **kwargs)
39 self.clusters = []
40 self.creds = None
41 self.keypair = None
42 self.cluster_template = None
43 self.cluster_template_client = None
44 self.keypairs_client = None
45 self.cluster_client = None
46 self.cert_client = None
47
48 def setUp(self):
49 try:
50 super(ClusterTest, self).setUp()
51 (self.creds, self.keypair) = self.get_credentials_with_keypair(
52 type_of_creds='default')
53 (self.cluster_template_client,
54 self.keypairs_client) = self.get_clients_with_existing_creds(
55 creds=self.creds,
56 type_of_creds='default',
57 request_type='cluster_template')
58 (self.cluster_client, _) = self.get_clients_with_existing_creds(
59 creds=self.creds,
60 type_of_creds='default',
61 request_type='cluster')
62 (self.cert_client, _) = self.get_clients_with_existing_creds(
63 creds=self.creds,
64 type_of_creds='default',
65 request_type='cert')
66 model = datagen.valid_swarm_mode_cluster_template()
67 _, self.cluster_template = self._create_cluster_template(model)
68
69 # NOTE (dimtruck) by default tempest sets timeout to 20 mins.
70 # We need more time.
71 test_timeout = 1800
72 self.useFixture(fixtures.Timeout(test_timeout, gentle=True))
73 except Exception:
74 self.tearDown()
75 raise
76
77 def tearDown(self):
78 try:
79 cluster_list = self.clusters[:]
80 for cluster_id in cluster_list:
81 self._delete_cluster(cluster_id)
82 self.clusters.remove(cluster_id)
83 if self.cluster_template:
84 self._delete_cluster_template(self.cluster_template.uuid)
85 finally:
86 super(ClusterTest, self).tearDown()
87
88 def _create_cluster_template(self, cm_model):
89 self.LOG.debug('We will create a clustertemplate for %s', cm_model)
90 resp, model = self.cluster_template_client.post_cluster_template(
91 cm_model)
92 return resp, model
93
94 def _delete_cluster_template(self, cm_id):
95 self.LOG.debug('We will delete a clustertemplate for %s', cm_id)
96 resp, model = self.cluster_template_client.delete_cluster_template(
97 cm_id)
98 return resp, model
99
100 def _create_cluster(self, cluster_model):
101 self.LOG.debug('We will create cluster for %s', cluster_model)
102 resp, model = self.cluster_client.post_cluster(cluster_model)
103 self.LOG.debug('Response: %s', resp)
104 self.assertEqual(202, resp.status)
105 self.assertIsNotNone(model.uuid)
106 self.assertTrue(uuidutils.is_uuid_like(model.uuid))
107 self.clusters.append(model.uuid)
108 self.cluster_uuid = model.uuid
109 if config.Config.copy_logs:
110 self.addCleanup(self.copy_logs_handler(
111 lambda: list(
112 [self._get_cluster_by_id(model.uuid)[1].master_addresses,
113 self._get_cluster_by_id(model.uuid)[1].node_addresses]),
114 self.cluster_template.coe,
115 self.keypair))
116 self.cluster_client.wait_for_created_cluster(model.uuid,
117 delete_on_error=False)
118 return resp, model
119
120 def _delete_cluster(self, cluster_id):
121 self.LOG.debug('We will delete a cluster for %s', cluster_id)
122 resp, model = self.cluster_client.delete_cluster(cluster_id)
123 self.assertEqual(204, resp.status)
124 self.cluster_client.wait_for_cluster_to_delete(cluster_id)
125 self.assertRaises(exceptions.NotFound, self.cert_client.get_cert,
126 cluster_id, headers=HEADERS)
127 return resp, model
128
129 def _get_cluster_by_id(self, cluster_id):
130 resp, model = self.cluster_client.get_cluster(cluster_id)
131 return resp, model
132
133 # (dimtruck) Combining all these tests in one because
134 # they time out on the gate (2 hours not enough)
135 @testtools.testcase.attr('positive')
136 def test_create_list_sign_delete_clusters(self):
137 gen_model = datagen.valid_cluster_data(
138 cluster_template_id=self.cluster_template.uuid, node_count=1)
139
140 # test cluster create
141 _, cluster_model = self._create_cluster(gen_model)
142 self.assertNotIn('status', cluster_model)
143
144 # test cluster list
145 resp, cluster_list_model = self.cluster_client.list_clusters()
146 self.assertEqual(200, resp.status)
147 self.assertGreater(len(cluster_list_model.clusters), 0)
148 self.assertIn(
149 cluster_model.uuid, list([x['uuid']
150 for x in cluster_list_model.clusters]))
151
152 # test invalid cluster update
153 patch_model = datagen.cluster_name_patch_data()
154 self.assertRaises(
155 exceptions.BadRequest,
156 self.cluster_client.patch_cluster,
157 cluster_model.uuid, patch_model)
158
159 # test ca show
160 resp, cert_model = self.cert_client.get_cert(
161 cluster_model.uuid, headers=HEADERS)
162 self.LOG.debug("cert resp: %s", resp)
163 self.assertEqual(200, resp.status)
164 self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
165 self.assertIsNotNone(cert_model.pem)
166 self.assertIn('-----BEGIN CERTIFICATE-----', cert_model.pem)
167 self.assertIn('-----END CERTIFICATE-----', cert_model.pem)
168
169 # test ca sign
170
171 csr_sample = """-----BEGIN CERTIFICATE REQUEST-----
172MIIByjCCATMCAQAwgYkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh
173MRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMR8w
174HQYDVQQLExZJbmZvcm1hdGlvbiBUZWNobm9sb2d5MRcwFQYDVQQDEw53d3cuZ29v
175Z2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApZtYJCHJ4VpVXHfV
176IlstQTlO4qC03hjX+ZkPyvdYd1Q4+qbAeTwXmCUKYHThVRd5aXSqlPzyIBwieMZr
177WFlRQddZ1IzXAlVRDWwAo60KecqeAXnnUK+5fXoTI/UgWshre8tJ+x/TMHaQKR/J
178cIWPhqaQhsJuzZbvAdGA80BLxdMCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4GBAIhl
1794PvFq+e7ipARgI5ZM+GZx6mpCz44DTo0JkwfRDf+BtrsaC0q68eTf2XhYOsq4fkH
180Q0uA0aVog3f5iJxCa3Hp5gxbJQ6zV6kJ0TEsuaaOhEko9sdpCoPOnRBm2i/XRD2D
1816iNh8f8z0ShGsFqjDgFHyF3o+lUyj+UC6H1QW7bn
182-----END CERTIFICATE REQUEST-----
183"""
184
185 cert_data_model = datagen.cert_data(cluster_model.uuid,
186 csr_data=csr_sample)
187 resp, cert_model = self.cert_client.post_cert(cert_data_model,
188 headers=HEADERS)
189 self.LOG.debug("cert resp: %s", resp)
190 self.assertEqual(201, resp.status)
191 self.assertEqual(cert_model.cluster_uuid, cluster_model.uuid)
192 self.assertIsNotNone(cert_model.pem)
193 self.assertIn('-----BEGIN CERTIFICATE-----', cert_model.pem)
194 self.assertIn('-----END CERTIFICATE-----', cert_model.pem)
195
196 # test ca sign invalid
197 cert_data_model = datagen.cert_data(cluster_model.uuid,
198 csr_data="invalid_csr")
199 self.assertRaises(
200 exceptions.BadRequest,
201 self.cert_client.post_cert,
202 cert_data_model, headers=HEADERS)
203
204 # test cluster delete
205 self._delete_cluster(cluster_model.uuid)
206 self.clusters.remove(cluster_model.uuid)
207
208 @testtools.testcase.attr('negative')
209 def test_create_cluster_for_nonexisting_cluster_template(self):
210 cm_id = 'this-does-not-exist'
211 gen_model = datagen.valid_cluster_data(cluster_template_id=cm_id)
212 self.assertRaises(
213 exceptions.BadRequest,
214 self.cluster_client.post_cluster, gen_model)
215
216 @testtools.testcase.attr('negative')
217 def test_create_cluster_with_node_count_0(self):
218 gen_model = datagen.valid_cluster_data(
219 cluster_template_id=self.cluster_template.uuid, node_count=0)
220 self.assertRaises(
221 exceptions.BadRequest,
222 self.cluster_client.post_cluster, gen_model)
223
224 @testtools.testcase.attr('negative')
225 def test_create_cluster_with_zero_masters(self):
226 uuid = self.cluster_template.uuid
227 gen_model = datagen.valid_cluster_data(cluster_template_id=uuid,
228 master_count=0)
229 self.assertRaises(
230 exceptions.BadRequest,
231 self.cluster_client.post_cluster, gen_model)
232
233 @testtools.testcase.attr('negative')
234 def test_create_cluster_with_nonexisting_flavor(self):
235 gen_model = \
236 datagen.cluster_template_data_with_valid_keypair_image_flavor()
237 resp, cluster_template = self._create_cluster_template(gen_model)
238 self.assertEqual(201, resp.status)
239 self.assertIsNotNone(cluster_template.uuid)
240
241 uuid = cluster_template.uuid
242 gen_model = datagen.valid_cluster_data(cluster_template_id=uuid)
243 gen_model.flavor_id = 'aaa'
244 self.assertRaises(exceptions.BadRequest,
245 self.cluster_client.post_cluster, gen_model)
246
247 resp, _ = self._delete_cluster_template(cluster_template.uuid)
248 self.assertEqual(204, resp.status)
249
250 @testtools.testcase.attr('negative')
251 def test_update_cluster_for_nonexisting_cluster(self):
252 patch_model = datagen.cluster_name_patch_data()
253
254 self.assertRaises(
255 exceptions.NotFound,
256 self.cluster_client.patch_cluster, 'fooo', patch_model)
257
258 @testtools.testcase.attr('negative')
259 def test_delete_cluster_for_nonexisting_cluster(self):
260 self.assertRaises(
261 exceptions.NotFound,
262 self.cluster_client.delete_cluster, data_utils.rand_uuid())
diff --git a/magnum/tests/functional/api/v1/test_cluster_template.py b/magnum/tests/functional/api/v1/test_cluster_template.py
deleted file mode 100644
index 8713248..0000000
--- a/magnum/tests/functional/api/v1/test_cluster_template.py
+++ /dev/null
@@ -1,230 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13
14from tempest.lib.common.utils import data_utils
15from tempest.lib import exceptions
16import testtools
17
18from magnum.tests.functional.api import base
19from magnum.tests.functional.common import datagen
20
21
22class ClusterTemplateTest(base.BaseTempestTest):
23
24 """Tests for clustertemplate CRUD."""
25
26 def __init__(self, *args, **kwargs):
27 super(ClusterTemplateTest, self).__init__(*args, **kwargs)
28 self.cluster_templates = []
29 self.cluster_template_client = None
30 self.keypairs_client = None
31
32 def setUp(self):
33 try:
34 super(ClusterTemplateTest, self).setUp()
35 (self.cluster_template_client,
36 self.keypairs_client) = self.get_clients_with_new_creds(
37 type_of_creds='default',
38 request_type='cluster_template')
39 except Exception:
40 self.tearDown()
41 raise
42
43 def tearDown(self):
44 for cluster_template_id in self.cluster_templates:
45 self._delete_cluster_template(cluster_template_id)
46 self.cluster_templates.remove(cluster_template_id)
47 super(ClusterTemplateTest, self).tearDown()
48
49 def _create_cluster_template(self, cmodel_model):
50 resp, model = \
51 self.cluster_template_client.post_cluster_template(cmodel_model)
52 self.assertEqual(201, resp.status)
53 self.cluster_templates.append(model.uuid)
54 return resp, model
55
56 def _delete_cluster_template(self, model_id):
57 resp, model = \
58 self.cluster_template_client.delete_cluster_template(model_id)
59 self.assertEqual(204, resp.status)
60 return resp, model
61
62 @testtools.testcase.attr('positive')
63 def test_list_cluster_templates(self):
64 gen_model = \
65 datagen.cluster_template_data_with_valid_keypair_image_flavor()
66 _, temp_model = self._create_cluster_template(gen_model)
67 resp, model = self.cluster_template_client.list_cluster_templates()
68 self.assertEqual(200, resp.status)
69 self.assertGreater(len(model.clustertemplates), 0)
70 self.assertIn(
71 temp_model.uuid,
72 list([x['uuid'] for x in model.clustertemplates]))
73
74 @testtools.testcase.attr('positive')
75 def test_create_cluster_template(self):
76 gen_model = \
77 datagen.cluster_template_data_with_valid_keypair_image_flavor()
78 resp, model = self._create_cluster_template(gen_model)
79
80 @testtools.testcase.attr('positive')
81 def test_create_get_public_cluster_template(self):
82 gen_model = datagen.valid_swarm_mode_cluster_template(is_public=True)
83 self.assertRaises(
84 exceptions.Forbidden,
85 self.cluster_template_client.post_cluster_template, gen_model)
86
87 @testtools.testcase.attr('positive')
88 def test_update_cluster_template_public_by_uuid(self):
89 path = "/public"
90 gen_model = \
91 datagen.cluster_template_data_with_valid_keypair_image_flavor()
92 resp, old_model = self._create_cluster_template(gen_model)
93
94 patch_model = datagen.cluster_template_replace_patch_data(path,
95 value=True)
96 self.assertRaises(
97 exceptions.Forbidden,
98 self.cluster_template_client.patch_cluster_template,
99 old_model.uuid, patch_model)
100
101 @testtools.testcase.attr('positive')
102 def test_update_cluster_template_by_uuid(self):
103 gen_model = \
104 datagen.cluster_template_data_with_valid_keypair_image_flavor()
105 resp, old_model = self._create_cluster_template(gen_model)
106
107 patch_model = datagen.cluster_template_name_patch_data()
108 resp, new_model = self.cluster_template_client.patch_cluster_template(
109 old_model.uuid, patch_model)
110 self.assertEqual(200, resp.status)
111
112 resp, model = \
113 self.cluster_template_client.get_cluster_template(new_model.uuid)
114 self.assertEqual(200, resp.status)
115 self.assertEqual(old_model.uuid, new_model.uuid)
116 self.assertEqual(model.name, new_model.name)
117
118 @testtools.testcase.attr('positive')
119 def test_delete_cluster_template_by_uuid(self):
120 gen_model = \
121 datagen.cluster_template_data_with_valid_keypair_image_flavor()
122 resp, model = self._create_cluster_template(gen_model)
123 resp, _ = self.cluster_template_client.delete_cluster_template(
124 model.uuid)
125 self.assertEqual(204, resp.status)
126 self.cluster_templates.remove(model.uuid)
127
128 @testtools.testcase.attr('positive')
129 def test_delete_cluster_template_by_name(self):
130 gen_model = \
131 datagen.cluster_template_data_with_valid_keypair_image_flavor()
132 resp, model = self._create_cluster_template(gen_model)
133 resp, _ = self.cluster_template_client.delete_cluster_template(
134 model.name)
135 self.assertEqual(204, resp.status)
136 self.cluster_templates.remove(model.uuid)
137
138 @testtools.testcase.attr('negative')
139 def test_get_cluster_template_by_uuid_404(self):
140 self.assertRaises(
141 exceptions.NotFound,
142 self.cluster_template_client.get_cluster_template,
143 data_utils.rand_uuid())
144
145 @testtools.testcase.attr('negative')
146 def test_update_cluster_template_404(self):
147 patch_model = datagen.cluster_template_name_patch_data()
148
149 self.assertRaises(
150 exceptions.NotFound,
151 self.cluster_template_client.patch_cluster_template,
152 data_utils.rand_uuid(), patch_model)
153
154 @testtools.testcase.attr('negative')
155 def test_delete_cluster_template_404(self):
156 self.assertRaises(
157 exceptions.NotFound,
158 self.cluster_template_client.delete_cluster_template,
159 data_utils.rand_uuid())
160
161 @testtools.testcase.attr('negative')
162 def test_get_cluster_template_by_name_404(self):
163 self.assertRaises(
164 exceptions.NotFound,
165 self.cluster_template_client.get_cluster_template, 'fooo')
166
167 @testtools.testcase.attr('negative')
168 def test_update_cluster_template_name_not_found(self):
169 patch_model = datagen.cluster_template_name_patch_data()
170
171 self.assertRaises(
172 exceptions.NotFound,
173 self.cluster_template_client.patch_cluster_template,
174 'fooo', patch_model)
175
176 @testtools.testcase.attr('negative')
177 def test_delete_cluster_template_by_name_404(self):
178 self.assertRaises(
179 exceptions.NotFound,
180 self.cluster_template_client.get_cluster_template, 'fooo')
181
182 @testtools.testcase.attr('negative')
183 def test_create_cluster_template_missing_image(self):
184 gen_model = datagen.cluster_template_data_with_missing_image()
185 self.assertRaises(
186 exceptions.BadRequest,
187 self.cluster_template_client.post_cluster_template, gen_model)
188
189 @testtools.testcase.attr('negative')
190 def test_create_cluster_template_missing_flavor(self):
191 gen_model = datagen.cluster_template_data_with_missing_flavor()
192 self.assertRaises(
193 exceptions.BadRequest,
194 self.cluster_template_client.post_cluster_template, gen_model)
195
196 @testtools.testcase.attr('positive')
197 def test_create_cluster_template_missing_keypair(self):
198 gen_model = \
199 datagen.cluster_template_data_with_missing_keypair()
200 resp, model = self._create_cluster_template(gen_model)
201
202 @testtools.testcase.attr('negative')
203 def test_update_cluster_template_invalid_patch(self):
204 # get json object
205 gen_model = \
206 datagen.cluster_template_data_with_valid_keypair_image_flavor()
207 resp, old_model = self._create_cluster_template(gen_model)
208
209 self.assertRaises(
210 exceptions.BadRequest,
211 self.cluster_template_client.patch_cluster_template,
212 data_utils.rand_uuid(), gen_model)
213
214 @testtools.testcase.attr('negative')
215 def test_create_cluster_template_invalid_network_driver(self):
216 gen_model = \
217 datagen.cluster_template_data_with_valid_keypair_image_flavor()
218 gen_model.network_driver = 'invalid_network_driver'
219 self.assertRaises(
220 exceptions.BadRequest,
221 self.cluster_template_client.post_cluster_template, gen_model)
222
223 @testtools.testcase.attr('negative')
224 def test_create_cluster_template_invalid_volume_driver(self):
225 gen_model = \
226 datagen.cluster_template_data_with_valid_keypair_image_flavor()
227 gen_model.volume_driver = 'invalid_volume_driver'
228 self.assertRaises(
229 exceptions.BadRequest,
230 self.cluster_template_client.post_cluster_template, gen_model)
diff --git a/magnum/tests/functional/api/v1/test_cluster_template_admin.py b/magnum/tests/functional/api/v1/test_cluster_template_admin.py
deleted file mode 100644
index b8a2e83..0000000
--- a/magnum/tests/functional/api/v1/test_cluster_template_admin.py
+++ /dev/null
@@ -1,86 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13
14import testtools
15
16from magnum.tests.functional.api import base
17from magnum.tests.functional.common import datagen
18
19
20class ClusterTemplateAdminTest(base.BaseTempestTest):
21
22 """Tests for clustertemplate admin operations."""
23
24 def __init__(self, *args, **kwargs):
25 super(ClusterTemplateAdminTest, self).__init__(*args, **kwargs)
26 self.cluster_templates = []
27 self.cluster_template_client = None
28 self.keypairs_client = None
29
30 def setUp(self):
31 try:
32 super(ClusterTemplateAdminTest, self).setUp()
33 (self.cluster_template_client,
34 self.keypairs_client) = self.get_clients_with_new_creds(
35 type_of_creds='admin',
36 request_type='cluster_template')
37 except Exception:
38 self.tearDown()
39 raise
40
41 def tearDown(self):
42 for cluster_template_id in self.cluster_templates:
43 self._delete_cluster_template(cluster_template_id)
44 self.cluster_templates.remove(cluster_template_id)
45 super(ClusterTemplateAdminTest, self).tearDown()
46
47 def _create_cluster_template(self, cmodel_model):
48 resp, model = \
49 self.cluster_template_client.post_cluster_template(cmodel_model)
50 self.assertEqual(201, resp.status)
51 self.cluster_templates.append(model.uuid)
52 return resp, model
53
54 def _delete_cluster_template(self, model_id):
55 resp, model = \
56 self.cluster_template_client.delete_cluster_template(model_id)
57 self.assertEqual(204, resp.status)
58 return resp, model
59
60 @testtools.testcase.attr('positive')
61 def test_create_get_public_cluster_template(self):
62 gen_model = datagen.valid_swarm_mode_cluster_template(is_public=True)
63 resp, model = self._create_cluster_template(gen_model)
64
65 resp, model = \
66 self.cluster_template_client.get_cluster_template(model.uuid)
67 self.assertEqual(200, resp.status)
68 self.assertTrue(model.public)
69
70 @testtools.testcase.attr('positive')
71 def test_update_cluster_template_public_by_uuid(self):
72 path = "/public"
73 gen_model = \
74 datagen.cluster_template_data_with_valid_keypair_image_flavor()
75 resp, old_model = self._create_cluster_template(gen_model)
76
77 patch_model = datagen.cluster_template_replace_patch_data(path,
78 value=True)
79 resp, new_model = self.cluster_template_client.patch_cluster_template(
80 old_model.uuid, patch_model)
81 self.assertEqual(200, resp.status)
82
83 resp, model = self.cluster_template_client.get_cluster_template(
84 new_model.uuid)
85 self.assertEqual(200, resp.status)
86 self.assertTrue(model.public)
diff --git a/magnum/tests/functional/api/v1/test_magnum_service.py b/magnum/tests/functional/api/v1/test_magnum_service.py
deleted file mode 100644
index a85c30b..0000000
--- a/magnum/tests/functional/api/v1/test_magnum_service.py
+++ /dev/null
@@ -1,53 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13
14from tempest.lib import exceptions
15import testtools
16
17from magnum.tests.functional.api import base
18
19
20class MagnumServiceTest(base.BaseTempestTest):
21
22 """Tests for magnum-service ."""
23
24 def __init__(self, *args, **kwargs):
25 super(MagnumServiceTest, self).__init__(*args, **kwargs)
26 self.service_client = None
27
28 @testtools.testcase.attr('negative')
29 def test_magnum_service_list_needs_admin(self):
30 # Ensure that policy enforcement does not allow 'default' user
31 (self.service_client, _) = self.get_clients_with_new_creds(
32 type_of_creds='default',
33 request_type='service')
34 self.assertRaises(exceptions.Forbidden,
35 self.service_client.magnum_service_list)
36
37 @testtools.testcase.attr('positive')
38 def test_magnum_service_list(self):
39 # get json object
40 (self.service_client, _) = self.get_clients_with_new_creds(
41 type_of_creds='admin',
42 request_type='service',
43 class_cleanup=False)
44 resp, msvcs = self.service_client.magnum_service_list()
45 self.assertEqual(200, resp.status)
46 # Note(suro-patz): Following code assumes that we have only
47 # one service, magnum-conductor enabled, as of now.
48 self.assertEqual(1, len(msvcs.mservices))
49 mcond_svc = msvcs.mservices[0]
50 self.assertEqual(mcond_svc['id'], 1)
51 self.assertEqual('up', mcond_svc['state'])
52 self.assertEqual('magnum-conductor', mcond_svc['binary'])
53 self.assertGreater(mcond_svc['report_count'], 0)
diff --git a/magnum/tests/functional/tempest_tests/__init__.py b/magnum/tests/functional/tempest_tests/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/magnum/tests/functional/tempest_tests/__init__.py
+++ /dev/null
diff --git a/magnum/tests/functional/tempest_tests/config.py b/magnum/tests/functional/tempest_tests/config.py
deleted file mode 100644
index f724495..0000000
--- a/magnum/tests/functional/tempest_tests/config.py
+++ /dev/null
@@ -1,67 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13from __future__ import print_function
14
15from oslo_config import cfg
16from tempest import config # noqa
17
18
19service_available_group = cfg.OptGroup(name="service_available",
20 title="Available OpenStack Services")
21
22ServiceAvailableGroup = [
23 cfg.BoolOpt("magnum",
24 default=True,
25 help="Whether or not magnum is expected to be available"),
26]
27
28magnum_group = cfg.OptGroup(name="magnum", title="Magnum Options")
29
30MagnumGroup = [
31 cfg.StrOpt("image_id",
32 default="fedora-atomic-latest",
33 help="Image id to be used for ClusterTemplate."),
34
35 cfg.StrOpt("nic_id",
36 default="public",
37 help="NIC id."),
38
39 cfg.StrOpt("keypair_id",
40 default="default",
41 help="Keypair id to use to log into nova instances."),
42
43 cfg.StrOpt("flavor_id",
44 default="s1.magnum",
45 help="Flavor id to use for ClusterTemplate."),
46
47 cfg.StrOpt("magnum_url",
48 help="Bypass URL for Magnum to skip service catalog lookup"),
49
50 cfg.StrOpt("master_flavor_id",
51 default="m1.magnum",
52 help="Master flavor id to use for ClusterTemplate."),
53
54 cfg.StrOpt("csr_location",
55 default="/opt/stack/new/magnum/default.csr",
56 deprecated_for_removal=True,
57 help="CSR location for certificates. This option is no "
58 "longer used for anything."),
59
60 cfg.StrOpt("dns_nameserver",
61 default="8.8.8.8",
62 help="DNS nameserver to use for ClusterTemplate."),
63
64 cfg.BoolOpt("copy_logs",
65 default=True,
66 help="Specify whether to copy nova server logs on failure."),
67]
diff --git a/magnum/tests/functional/tempest_tests/plugin.py b/magnum/tests/functional/tempest_tests/plugin.py
deleted file mode 100644
index 923f60b..0000000
--- a/magnum/tests/functional/tempest_tests/plugin.py
+++ /dev/null
@@ -1,42 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13
14import os
15
16from tempest import config
17from tempest.test_discover import plugins
18
19import magnum
20from magnum.tests.functional.tempest_tests import config as magnum_config
21
22
23class MagnumTempestPlugin(plugins.TempestPlugin):
24 def load_tests(self):
25 base_path = os.path.split(os.path.dirname(
26 os.path.abspath(magnum.__file__)))[0]
27 test_dir = "magnum/tests/functional/api/v1"
28 full_test_dir = os.path.join(base_path, test_dir)
29 return full_test_dir, base_path
30
31 def register_opts(self, conf):
32 config.register_opt_group(
33 conf, magnum_config.service_available_group,
34 magnum_config.ServiceAvailableGroup)
35 config.register_opt_group(conf, magnum_config.magnum_group,
36 magnum_config.MagnumGroup)
37
38 def get_opt_lists(self):
39 return [
40 (magnum_config.magnum_group.name, magnum_config.MagnumGroup),
41 ('service_available', magnum_config.ServiceAvailableGroup)
42 ]
diff --git a/playbooks/magnum-functional-base.yaml b/playbooks/magnum-functional-base.yaml
index 8a61276..4eceed7 100644
--- a/playbooks/magnum-functional-base.yaml
+++ b/playbooks/magnum-functional-base.yaml
@@ -4,6 +4,19 @@
4 cmd: | 4 cmd: |
5 set -e 5 set -e
6 set -x 6 set -x
7 cat << 'EOF' >>"/tmp/dg-local.conf"
8 [[local|localrc]]
9 # Enable Magnum Tempest plugin
10 TEMPEST_PLUGINS='/opt/stack/new/magnum-tempest-plugin'
11 EOF
12 executable: /bin/bash
13 chdir: '{{ ansible_user_dir }}/workspace'
14 environment: '{{ zuul | zuul_legacy_vars }}'
15
16 - shell:
17 cmd: |
18 set -e
19 set -x
7 export PYTHONUNBUFFERED=true 20 export PYTHONUNBUFFERED=true
8 21
9 if [ "{{ neutron }}" -eq 1 ] ; then 22 if [ "{{ neutron }}" -eq 1 ] ; then
@@ -23,6 +36,7 @@
23 export PROJECTS="openstack/magnum $PROJECTS" 36 export PROJECTS="openstack/magnum $PROJECTS"
24 export PROJECTS="openstack/python-magnumclient $PROJECTS" 37 export PROJECTS="openstack/python-magnumclient $PROJECTS"
25 export PROJECTS="openstack/diskimage-builder $PROJECTS" 38 export PROJECTS="openstack/diskimage-builder $PROJECTS"
39 export PROJECTS="openstack/magnum-tempest-plugin $PROJECTS"
26 40
27 if [ "{{ multinode }}" -eq 1 ] ; then 41 if [ "{{ multinode }}" -eq 1 ] ; then
28 export DEVSTACK_GATE_TOPOLOGY="multinode" 42 export DEVSTACK_GATE_TOPOLOGY="multinode"
diff --git a/setup.cfg b/setup.cfg
index 539bd33..1627622 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -81,8 +81,6 @@ magnum.cert_manager.backend =
81 local = magnum.common.cert_manager.local_cert_manager 81 local = magnum.common.cert_manager.local_cert_manager
82 x509keypair = magnum.common.cert_manager.x509keypair_cert_manager 82 x509keypair = magnum.common.cert_manager.x509keypair_cert_manager
83 83
84tempest.test_plugins =
85 magnum_tests = magnum.tests.functional.tempest_tests.plugin:MagnumTempestPlugin
86[wheel] 84[wheel]
87universal = 1 85universal = 1
88 86
diff --git a/test-requirements.txt b/test-requirements.txt
index 3bc25fe..12535af 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -20,7 +20,6 @@ os-testr>=1.0.0 # Apache-2.0
20python-subunit>=1.0.0 # Apache-2.0/BSD 20python-subunit>=1.0.0 # Apache-2.0/BSD
21pytz>=2013.6 # MIT 21pytz>=2013.6 # MIT
22sphinx>=1.6.2 # BSD 22sphinx>=1.6.2 # BSD
23tempest>=17.1.0 # Apache-2.0
24testrepository>=0.0.18 # Apache-2.0/BSD 23testrepository>=0.0.18 # Apache-2.0/BSD
25testscenarios>=0.4 # Apache-2.0/BSD 24testscenarios>=0.4 # Apache-2.0/BSD
26testtools>=2.2.0 # MIT 25testtools>=2.2.0 # MIT