summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2020-09-16 10:52:17 +0100
committerStephen Finucane <stephenfin@redhat.com>2020-09-18 15:28:36 +0100
commitcf6db29168c4ee9a34f3b3ebdd1deae31f95f203 (patch)
treec6d2a44738422701e062823d8e3bb5cdfdbfcebf
parentd7a7db6b9062f32b6440bdd78bfcfae42524cab3 (diff)
downloadnova-cf6db29168c4ee9a34f3b3ebdd1deae31f95f203.tar.gz
tests: Add regression test for bug 1894966
You must specify the 'policies' field. Currently, not doing so will result in a HTTP 500 error code. This should be a 4xx error. Add a test to demonstrate the bug before we provide a fix. Changes: nova/tests/functional/regressions/test_bug_1894966.py NOTE(stephenfin): Need to update 'super' call to Python 2-compatible variant. Change-Id: I72e85855f621d3a51cd58d14247abd302dcd958b Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Related-Bug: #1894966 (cherry picked from commit 2c66962c7a40d8ef4fab54324e06edcdec1bd716) (cherry picked from commit 94d24e3e8d04488abdebd4969daf98b780125297)
-rw-r--r--nova/tests/functional/regressions/test_bug_1894966.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/nova/tests/functional/regressions/test_bug_1894966.py b/nova/tests/functional/regressions/test_bug_1894966.py
new file mode 100644
index 0000000000..72173b8255
--- /dev/null
+++ b/nova/tests/functional/regressions/test_bug_1894966.py
@@ -0,0 +1,41 @@
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from nova import test
+from nova.tests import fixtures as nova_fixtures
+from nova.tests.functional.api import client
+from nova.tests.functional import integrated_helpers
+
+
+class TestCreateServerGroupWithEmptyPolicies(
+ test.TestCase, integrated_helpers.InstanceHelperMixin,
+):
+ """Demonstrate bug #1894966.
+
+ Attempt to create a server group with an invalid 'policies' field. It
+ should fail cleanly.
+ """
+ def setUp(self):
+ super(TestCreateServerGroupWithEmptyPolicies, self).setUp()
+
+ api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
+ api_version='v2.1'))
+ self.api = api_fixture.api
+ self.api.microversion = '2.63' # the last version with the bug
+
+ def test_create_with_empty_policies(self):
+ exc = self.assertRaises(
+ client.OpenStackApiException,
+ self.api.post_server_groups,
+ {'name': 'test group', 'policies': []})
+ # FIXME(stephenfin): This should not be a 500 error
+ self.assertEqual(500, exc.response.status_code)