summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-03-08 02:27:37 +0000
committerGerrit Code Review <review@openstack.org>2019-03-08 02:27:37 +0000
commit6868499ad9443960a158143c923da00ea86b7072 (patch)
tree90b1e264a2babc4e4bb56bc6dffda462b682b2ba /openstackclient/tests/functional
parentc305ac28969367699ed2cbeba3c0e93f8b05bba0 (diff)
parentd52920b3878479f7dd549cba1679870b4f00ee33 (diff)
downloadpython-openstackclient-3.18.0.tar.gz
Merge "Add network segment range command object"3.18.0
Diffstat (limited to 'openstackclient/tests/functional')
-rw-r--r--openstackclient/tests/functional/network/v2/test_network_segment_range.py145
1 files changed, 145 insertions, 0 deletions
diff --git a/openstackclient/tests/functional/network/v2/test_network_segment_range.py b/openstackclient/tests/functional/network/v2/test_network_segment_range.py
new file mode 100644
index 00000000..95402dcb
--- /dev/null
+++ b/openstackclient/tests/functional/network/v2/test_network_segment_range.py
@@ -0,0 +1,145 @@
+# Copyright (c) 2019, Intel Corporation.
+# All Rights Reserved.
+#
+# 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.
+#
+
+import json
+import uuid
+
+from openstackclient.tests.functional.network.v2 import common
+
+
+class NetworkSegmentRangeTests(common.NetworkTests):
+ """Functional tests for network segment range"""
+
+ def setUp(self):
+ super(NetworkSegmentRangeTests, self).setUp()
+ # Nothing in this class works with Nova Network
+ if not self.haz_network:
+ self.skipTest("No Network service present")
+ self.PROJECT_NAME = uuid.uuid4().hex
+
+ def test_network_segment_range_create_delete(self):
+ # Make a project
+ project_id = json.loads(self.openstack(
+ 'project create -f json ' + self.PROJECT_NAME))['id']
+ name = uuid.uuid4().hex
+ json_output = json.loads(self.openstack(
+ ' network segment range create -f json ' +
+ '--private ' +
+ "--project " + self.PROJECT_NAME + " " +
+ '--network-type vxlan ' +
+ '--minimum 2018 ' +
+ '--maximum 2055 ' +
+ name
+ ))
+ self.assertEqual(
+ name,
+ json_output["name"],
+ )
+ self.assertEqual(
+ project_id,
+ json_output["project_id"],
+ )
+
+ raw_output = self.openstack(
+ 'network segment range delete ' + name,
+ )
+ self.assertOutput('', raw_output)
+ raw_output_project = self.openstack(
+ 'project delete ' + self.PROJECT_NAME)
+ self.assertEqual('', raw_output_project)
+
+ def test_network_segment_range_list(self):
+ name = uuid.uuid4().hex
+ json_output = json.loads(self.openstack(
+ ' network segment range create -f json ' +
+ '--shared ' +
+ '--network-type geneve ' +
+ '--minimum 2018 ' +
+ '--maximum 2055 ' +
+ name
+ ))
+ network_segment_range_id = json_output.get('id')
+ network_segment_range_name = json_output.get('name')
+ self.addCleanup(
+ self.openstack,
+ 'network segment range delete ' + network_segment_range_id
+ )
+ self.assertEqual(
+ name,
+ json_output["name"],
+ )
+
+ json_output = json.loads(self.openstack(
+ 'network segment list -f json'
+ ))
+ item_map = {
+ item.get('ID'): item.get('Name') for item in json_output
+ }
+ self.assertIn(network_segment_range_id, item_map.keys())
+ self.assertIn(network_segment_range_name, item_map.values())
+
+ def test_network_segment_range_set_show(self):
+ project_id = json.loads(self.openstack(
+ 'project create -f json ' + self.PROJECT_NAME))['id']
+ name = uuid.uuid4().hex
+ json_output = json.loads(self.openstack(
+ ' network segment range create -f json ' +
+ '--private ' +
+ "--project " + self.PROJECT_NAME + " " +
+ '--network-type geneve ' +
+ '--minimum 2018 ' +
+ '--maximum 2055 ' +
+ name
+ ))
+ self.addCleanup(
+ self.openstack,
+ 'network segment range delete ' + name
+ )
+ self.assertEqual(
+ name,
+ json_output["name"],
+ )
+ self.assertEqual(
+ project_id,
+ json_output["project_id"],
+ )
+
+ new_minimum = '2010'
+ new_maximum = '2060'
+ cmd_output = self.openstack(
+ 'network segment range set ' +
+ '--minimum ' + new_minimum + ' ' +
+ '--maximum ' + new_maximum + ' ' +
+ name
+ )
+ self.assertOutput('', cmd_output)
+
+ json_output = json.loads(self.openstack(
+ 'network segment range show -f json ' +
+ name
+ ))
+ self.assertEqual(
+ new_minimum,
+ json_output["minimum"],
+ )
+ self.assertEqual(
+ new_maximum,
+ json_output["maximum"],
+ )
+
+ raw_output_project = self.openstack(
+ 'project delete ' + self.PROJECT_NAME)
+ self.assertEqual('', raw_output_project)