diff options
Diffstat (limited to 'openstackclient/tests/functional')
17 files changed, 152 insertions, 38 deletions
diff --git a/openstackclient/tests/functional/image/v2/test_image.py b/openstackclient/tests/functional/image/v2/test_image.py index 8fadd200..a93fa8cb 100644 --- a/openstackclient/tests/functional/image/v2/test_image.py +++ b/openstackclient/tests/functional/image/v2/test_image.py @@ -51,6 +51,24 @@ class ImageTests(base.TestCase): [img['Name'] for img in json_output] ) + def test_image_list_with_name_filter(self): + json_output = json.loads(self.openstack( + 'image list --name ' + self.NAME + ' -f json' + )) + self.assertIn( + self.NAME, + [img['Name'] for img in json_output] + ) + + def test_image_list_with_status_filter(self): + json_output = json.loads(self.openstack( + 'image list ' + ' --status active -f json' + )) + self.assertIn( + 'active', + [img['Status'] for img in json_output] + ) + def test_image_attributes(self): """Test set, unset, show on attributes, tags and properties""" diff --git a/openstackclient/tests/functional/network/v2/test_floating_ip.py b/openstackclient/tests/functional/network/v2/test_floating_ip.py index 96521f09..9e34622c 100644 --- a/openstackclient/tests/functional/network/v2/test_floating_ip.py +++ b/openstackclient/tests/functional/network/v2/test_floating_ip.py @@ -19,17 +19,18 @@ from openstackclient.tests.functional.network.v2 import common class FloatingIpTests(common.NetworkTests): """Functional tests for floating ip""" - EXTERNAL_NETWORK_NAME = uuid.uuid4().hex - EXTERNAL_SUBNET_NAME = uuid.uuid4().hex - PRIVATE_NETWORK_NAME = uuid.uuid4().hex - PRIVATE_SUBNET_NAME = uuid.uuid4().hex - ROUTER = uuid.uuid4().hex - PORT_NAME = uuid.uuid4().hex @classmethod def setUpClass(cls): common.NetworkTests.setUpClass() if cls.haz_network: + cls.EXTERNAL_NETWORK_NAME = uuid.uuid4().hex + cls.EXTERNAL_SUBNET_NAME = uuid.uuid4().hex + cls.PRIVATE_NETWORK_NAME = uuid.uuid4().hex + cls.PRIVATE_SUBNET_NAME = uuid.uuid4().hex + cls.ROUTER = uuid.uuid4().hex + cls.PORT_NAME = uuid.uuid4().hex + # Create a network for the floating ip json_output = json.loads(cls.openstack( 'network create -f json ' + diff --git a/openstackclient/tests/functional/network/v2/test_ip_availability.py b/openstackclient/tests/functional/network/v2/test_ip_availability.py index 1aa0f64a..cb4b8150 100644 --- a/openstackclient/tests/functional/network/v2/test_ip_availability.py +++ b/openstackclient/tests/functional/network/v2/test_ip_availability.py @@ -23,9 +23,10 @@ class IPAvailabilityTests(common.NetworkTests): def setUpClass(cls): common.NetworkTests.setUpClass() if cls.haz_network: - # Create a network for the subnet. cls.NAME = uuid.uuid4().hex cls.NETWORK_NAME = uuid.uuid4().hex + + # Create a network for the subnet cls.openstack( 'network create ' + cls.NETWORK_NAME diff --git a/openstackclient/tests/functional/network/v2/test_network_agent.py b/openstackclient/tests/functional/network/v2/test_network_agent.py index 16487955..0c74ea1d 100644 --- a/openstackclient/tests/functional/network/v2/test_network_agent.py +++ b/openstackclient/tests/functional/network/v2/test_network_agent.py @@ -137,3 +137,39 @@ class NetworkAgentListTests(common.NetworkTests): self.assertIn( agent_id, col_name ) + + def test_network_agent_list_routers(self): + """Add agent to router, list agents on router, delete.""" + name = uuid.uuid4().hex + cmd_output = json.loads(self.openstack( + 'router create -f json ' + name)) + + self.addCleanup(self.openstack, 'router delete ' + name) + # Get router ID + router_id = cmd_output['id'] + # Get l3 agent id + cmd_output = json.loads(self.openstack( + 'network agent list -f json --agent-type l3')) + + # Check at least one L3 agent is included in the response. + self.assertTrue(cmd_output) + agent_id = cmd_output[0]['ID'] + + # Add router to agent + self.openstack( + 'network agent add router --l3 ' + agent_id + ' ' + router_id) + + # Test router list --agent + cmd_output = json.loads(self.openstack( + 'network agent list -f json --router ' + router_id)) + + agent_ids = [x['ID'] for x in cmd_output] + self.assertIn(agent_id, agent_ids) + + # Remove router from agent + self.openstack( + 'network agent remove router --l3 ' + agent_id + ' ' + router_id) + cmd_output = json.loads(self.openstack( + 'network agent list -f json --router ' + router_id)) + agent_ids = [x['ID'] for x in cmd_output] + self.assertNotIn(agent_id, agent_ids) diff --git a/openstackclient/tests/functional/network/v2/test_network_meter_rule.py b/openstackclient/tests/functional/network/v2/test_network_meter_rule.py index b7090707..71b406b4 100644 --- a/openstackclient/tests/functional/network/v2/test_network_meter_rule.py +++ b/openstackclient/tests/functional/network/v2/test_network_meter_rule.py @@ -22,7 +22,6 @@ from openstackclient.tests.functional.network.v2 import common class TestMeterRule(common.NetworkTests): """Functional tests for meter rule""" - METER_NAME = uuid.uuid4().hex METER_ID = None METER_RULE_ID = None @@ -30,6 +29,8 @@ class TestMeterRule(common.NetworkTests): def setUpClass(cls): common.NetworkTests.setUpClass() if cls.haz_network: + cls.METER_NAME = uuid.uuid4().hex + json_output = json.loads(cls.openstack( 'network meter create -f json ' + cls.METER_NAME diff --git a/openstackclient/tests/functional/network/v2/test_network_qos_policy.py b/openstackclient/tests/functional/network/v2/test_network_qos_policy.py index 282efbfa..ccbf437c 100644 --- a/openstackclient/tests/functional/network/v2/test_network_qos_policy.py +++ b/openstackclient/tests/functional/network/v2/test_network_qos_policy.py @@ -19,8 +19,7 @@ from openstackclient.tests.functional.network.v2 import common class NetworkQosPolicyTests(common.NetworkTests): - """Functional tests for QoS policy. """ - NAME = uuid.uuid4().hex + """Functional tests for QoS policy""" HEADERS = ['Name'] FIELDS = ['name'] @@ -28,6 +27,8 @@ class NetworkQosPolicyTests(common.NetworkTests): def setUpClass(cls): common.NetworkTests.setUpClass() if cls.haz_network: + cls.NAME = uuid.uuid4().hex + opts = cls.get_opts(cls.FIELDS) raw_output = cls.openstack( 'network qos policy create ' + @@ -68,3 +69,16 @@ class NetworkQosPolicyTests(common.NetworkTests): raw_output = self.openstack('network qos policy show ' + self.NAME + opts) self.assertEqual("True\n", raw_output) + + def test_qos_policy_default(self): + self.openstack('network qos policy set --default ' + self.NAME) + opts = self.get_opts(['is_default']) + raw_output = self.openstack('network qos policy show ' + self.NAME + + opts) + self.assertEqual("True\n", raw_output) + + self.openstack('network qos policy set --no-default ' + self.NAME) + opts = self.get_opts(['is_default']) + raw_output = self.openstack('network qos policy show ' + self.NAME + + opts) + self.assertEqual("False\n", raw_output) diff --git a/openstackclient/tests/functional/network/v2/test_network_qos_rule.py b/openstackclient/tests/functional/network/v2/test_network_qos_rule.py index c6437d9c..6e40d8e0 100644 --- a/openstackclient/tests/functional/network/v2/test_network_qos_rule.py +++ b/openstackclient/tests/functional/network/v2/test_network_qos_rule.py @@ -21,7 +21,6 @@ from openstackclient.tests.functional.network.v2 import common class NetworkQosRuleTestsMinimumBandwidth(common.NetworkTests): """Functional tests for QoS minimum bandwidth rule""" RULE_ID = None - QOS_POLICY_NAME = 'qos_policy_' + uuid.uuid4().hex MIN_KBPS = 2800 MIN_KBPS_MODIFIED = 7500 DIRECTION = '--egress' @@ -33,6 +32,8 @@ class NetworkQosRuleTestsMinimumBandwidth(common.NetworkTests): def setUpClass(cls): common.NetworkTests.setUpClass() if cls.haz_network: + cls.QOS_POLICY_NAME = 'qos_policy_' + uuid.uuid4().hex + opts = cls.get_opts(cls.FIELDS) cls.openstack( 'network qos policy create ' + @@ -169,6 +170,8 @@ class NetworkQosRuleTestsBandwidthLimit(common.NetworkTests): MAX_KBPS_MODIFIED = 15000 MAX_BURST_KBITS = 1400 MAX_BURST_KBITS_MODIFIED = 1800 + RULE_DIRECTION = 'egress' + RULE_DIRECTION_MODIFIED = 'ingress' HEADERS = ['ID'] FIELDS = ['id'] TYPE = 'bandwidth-limit' @@ -187,6 +190,7 @@ class NetworkQosRuleTestsBandwidthLimit(common.NetworkTests): '--type ' + cls.TYPE + ' ' + '--max-kbps ' + str(cls.MAX_KBPS) + ' ' + '--max-burst-kbits ' + str(cls.MAX_BURST_KBITS) + ' ' + + '--' + cls.RULE_DIRECTION + ' ' + cls.QOS_POLICY_NAME + opts ) @@ -226,14 +230,13 @@ class NetworkQosRuleTestsBandwidthLimit(common.NetworkTests): self.openstack('network qos rule set --max-kbps ' + str(self.MAX_KBPS_MODIFIED) + ' --max-burst-kbits ' + str(self.MAX_BURST_KBITS_MODIFIED) + ' ' + + '--' + self.RULE_DIRECTION_MODIFIED + ' ' + self.QOS_POLICY_NAME + ' ' + self.RULE_ID) - opts = self.get_opts(['max_kbps']) - raw_output = self.openstack('network qos rule show ' + - self.QOS_POLICY_NAME + ' ' + self.RULE_ID + - opts) - self.assertEqual(str(self.MAX_KBPS_MODIFIED) + "\n", raw_output) - opts = self.get_opts(['max_burst_kbps']) + opts = self.get_opts(['direction', 'max_burst_kbps', 'max_kbps']) raw_output = self.openstack('network qos rule show ' + self.QOS_POLICY_NAME + ' ' + self.RULE_ID + opts) - self.assertEqual(str(self.MAX_BURST_KBITS_MODIFIED) + "\n", raw_output) + expected = (str(self.RULE_DIRECTION_MODIFIED) + "\n" + + str(self.MAX_BURST_KBITS_MODIFIED) + "\n" + + str(self.MAX_KBPS_MODIFIED) + "\n") + self.assertEqual(expected, raw_output) diff --git a/openstackclient/tests/functional/network/v2/test_network_rbac.py b/openstackclient/tests/functional/network/v2/test_network_rbac.py index 0d5492e5..893f1993 100644 --- a/openstackclient/tests/functional/network/v2/test_network_rbac.py +++ b/openstackclient/tests/functional/network/v2/test_network_rbac.py @@ -16,9 +16,7 @@ from openstackclient.tests.functional.network.v2 import common class NetworkRBACTests(common.NetworkTests): - """Functional tests for network rbac. """ - NET_NAME = uuid.uuid4().hex - PROJECT_NAME = uuid.uuid4().hex + """Functional tests for network rbac""" OBJECT_ID = None ID = None HEADERS = ['ID'] @@ -28,6 +26,9 @@ class NetworkRBACTests(common.NetworkTests): def setUpClass(cls): common.NetworkTests.setUpClass() if cls.haz_network: + cls.NET_NAME = uuid.uuid4().hex + cls.PROJECT_NAME = uuid.uuid4().hex + opts = cls.get_opts(cls.FIELDS) raw_output = cls.openstack( 'network create ' + cls.NET_NAME + opts diff --git a/openstackclient/tests/functional/network/v2/test_network_segment.py b/openstackclient/tests/functional/network/v2/test_network_segment.py index 7fc79746..6dec82d9 100644 --- a/openstackclient/tests/functional/network/v2/test_network_segment.py +++ b/openstackclient/tests/functional/network/v2/test_network_segment.py @@ -17,8 +17,6 @@ from openstackclient.tests.functional.network.v2 import common class NetworkSegmentTests(common.NetworkTests): """Functional tests for network segment""" - NETWORK_NAME = uuid.uuid4().hex - PHYSICAL_NETWORK_NAME = uuid.uuid4().hex NETWORK_SEGMENT_ID = None NETWORK_ID = None NETWORK_SEGMENT_EXTENSION = None @@ -27,7 +25,10 @@ class NetworkSegmentTests(common.NetworkTests): def setUpClass(cls): common.NetworkTests.setUpClass() if cls.haz_network: - # Create a network for the segment. + cls.NETWORK_NAME = uuid.uuid4().hex + cls.PHYSICAL_NETWORK_NAME = uuid.uuid4().hex + + # Create a network for the segment opts = cls.get_opts(['id']) raw_output = cls.openstack( 'network create ' + cls.NETWORK_NAME + opts diff --git a/openstackclient/tests/functional/network/v2/test_port.py b/openstackclient/tests/functional/network/v2/test_port.py index 6659e3e0..14454454 100644 --- a/openstackclient/tests/functional/network/v2/test_port.py +++ b/openstackclient/tests/functional/network/v2/test_port.py @@ -18,14 +18,15 @@ from openstackclient.tests.functional.network.v2 import common class PortTests(common.NetworkTests): """Functional tests for port""" - NAME = uuid.uuid4().hex - NETWORK_NAME = uuid.uuid4().hex @classmethod def setUpClass(cls): common.NetworkTests.setUpClass() if cls.haz_network: - # Create a network for the port + cls.NAME = uuid.uuid4().hex + cls.NETWORK_NAME = uuid.uuid4().hex + + # Create a network for the port tests cls.openstack( 'network create ' + cls.NETWORK_NAME ) diff --git a/openstackclient/tests/functional/network/v2/test_router.py b/openstackclient/tests/functional/network/v2/test_router.py index 313feefc..2e5cb5ef 100644 --- a/openstackclient/tests/functional/network/v2/test_router.py +++ b/openstackclient/tests/functional/network/v2/test_router.py @@ -151,6 +151,40 @@ class RouterTests(common.NetworkTests): self.assertIn(name1, names) self.assertIn(name2, names) + def test_router_list_l3_agent(self): + """Tests create router, add l3 agent, list, delete""" + name = uuid.uuid4().hex + cmd_output = json.loads(self.openstack( + 'router create -f json ' + name)) + + self.addCleanup(self.openstack, 'router delete ' + name) + # Get router ID + router_id = cmd_output['id'] + # Get l3 agent id + cmd_output = json.loads(self.openstack( + 'network agent list -f json --agent-type l3')) + + # Check at least one L3 agent is included in the response. + self.assertTrue(cmd_output) + agent_id = cmd_output[0]['ID'] + + # Add router to agent + self.openstack( + 'network agent add router --l3 ' + agent_id + ' ' + router_id) + + cmd_output = json.loads(self.openstack( + 'router list -f json --agent ' + agent_id)) + router_ids = [x['ID'] for x in cmd_output] + self.assertIn(router_id, router_ids) + + # Remove router from agent + self.openstack( + 'network agent remove router --l3 ' + agent_id + ' ' + router_id) + cmd_output = json.loads(self.openstack( + 'router list -f json --agent ' + agent_id)) + router_ids = [x['ID'] for x in cmd_output] + self.assertNotIn(router_id, router_ids) + def test_router_set_show_unset(self): """Tests create router, set, unset, show""" diff --git a/openstackclient/tests/functional/network/v2/test_security_group.py b/openstackclient/tests/functional/network/v2/test_security_group.py index 2a9c0b0a..6da7e204 100644 --- a/openstackclient/tests/functional/network/v2/test_security_group.py +++ b/openstackclient/tests/functional/network/v2/test_security_group.py @@ -17,8 +17,6 @@ from openstackclient.tests.functional.network.v2 import common class SecurityGroupTests(common.NetworkTests): """Functional tests for security group""" - NAME = uuid.uuid4().hex - OTHER_NAME = uuid.uuid4().hex HEADERS = ['Name'] FIELDS = ['name'] @@ -26,6 +24,9 @@ class SecurityGroupTests(common.NetworkTests): def setUpClass(cls): common.NetworkTests.setUpClass() if cls.haz_network: + cls.NAME = uuid.uuid4().hex + cls.OTHER_NAME = uuid.uuid4().hex + opts = cls.get_opts(cls.FIELDS) raw_output = cls.openstack( 'security group create ' + diff --git a/openstackclient/tests/functional/network/v2/test_security_group_rule.py b/openstackclient/tests/functional/network/v2/test_security_group_rule.py index 93f98642..e153116b 100644 --- a/openstackclient/tests/functional/network/v2/test_security_group_rule.py +++ b/openstackclient/tests/functional/network/v2/test_security_group_rule.py @@ -17,7 +17,6 @@ from openstackclient.tests.functional.network.v2 import common class SecurityGroupRuleTests(common.NetworkTests): """Functional tests for security group rule""" - SECURITY_GROUP_NAME = uuid.uuid4().hex SECURITY_GROUP_RULE_ID = None NAME_FIELD = ['name'] ID_FIELD = ['id'] @@ -27,7 +26,9 @@ class SecurityGroupRuleTests(common.NetworkTests): def setUpClass(cls): common.NetworkTests.setUpClass() if cls.haz_network: - # Create the security group to hold the rule. + cls.SECURITY_GROUP_NAME = uuid.uuid4().hex + + # Create the security group to hold the rule opts = cls.get_opts(cls.NAME_FIELD) raw_output = cls.openstack( 'security group create ' + diff --git a/openstackclient/tests/functional/network/v2/test_subnet.py b/openstackclient/tests/functional/network/v2/test_subnet.py index 93e0593d..41375415 100644 --- a/openstackclient/tests/functional/network/v2/test_subnet.py +++ b/openstackclient/tests/functional/network/v2/test_subnet.py @@ -24,8 +24,9 @@ class SubnetTests(common.NetworkTests): def setUpClass(cls): common.NetworkTests.setUpClass() if cls.haz_network: - # Create a network for the all subnet tests cls.NETWORK_NAME = uuid.uuid4().hex + + # Create a network for the all subnet tests cmd_output = json.loads(cls.openstack( 'network create -f json ' + cls.NETWORK_NAME diff --git a/openstackclient/tests/functional/object/v1/test_object.py b/openstackclient/tests/functional/object/v1/test_object.py index 776cf47c..0927d706 100644 --- a/openstackclient/tests/functional/object/v1/test_object.py +++ b/openstackclient/tests/functional/object/v1/test_object.py @@ -66,6 +66,10 @@ class ObjectTests(base.TestCase): + ' ' + object_file + ' --file ' + tmp_file) # TODO(stevemar): Assert returned fields + raw_output = self.openstack('object save ' + self.CONTAINER_NAME + + ' ' + object_file + ' --file -') + self.assertEqual(raw_output, 'test content') + self.openstack('object show ' + self.CONTAINER_NAME + ' ' + object_file) # TODO(stevemar): Assert returned fields diff --git a/openstackclient/tests/functional/volume/v1/test_service.py b/openstackclient/tests/functional/volume/v1/test_service.py index c921c46a..fee73f18 100644 --- a/openstackclient/tests/functional/volume/v1/test_service.py +++ b/openstackclient/tests/functional/volume/v1/test_service.py @@ -64,10 +64,7 @@ class VolumeServiceTests(common.BaseVolumeTests): 'enabled', cmd_output[0]['Status'] ) - self.assertEqual( - None, - cmd_output[0]['Disabled Reason'] - ) + self.assertIsNone(cmd_output[0]['Disabled Reason']) # Test volume service set --disable and --disable-reason disable_reason = 'disable_reason' diff --git a/openstackclient/tests/functional/volume/v2/test_service.py b/openstackclient/tests/functional/volume/v2/test_service.py index 8d1944e4..6986fde6 100644 --- a/openstackclient/tests/functional/volume/v2/test_service.py +++ b/openstackclient/tests/functional/volume/v2/test_service.py @@ -64,8 +64,7 @@ class VolumeServiceTests(common.BaseVolumeTests): 'enabled', cmd_output[0]['Status'] ) - self.assertEqual( - None, + self.assertIsNone( cmd_output[0]['Disabled Reason'] ) |
