diff options
Diffstat (limited to 'openstackclient/tests/functional/network')
15 files changed, 227 insertions, 118 deletions
diff --git a/openstackclient/tests/functional/network/v2/common.py b/openstackclient/tests/functional/network/v2/common.py index bed07878..e3835abf 100644 --- a/openstackclient/tests/functional/network/v2/common.py +++ b/openstackclient/tests/functional/network/v2/common.py @@ -18,5 +18,5 @@ class NetworkTests(base.TestCase): @classmethod def setUpClass(cls): - # super(NetworkTests, cls).setUp() + super(NetworkTests, cls).setUpClass() cls.haz_network = base.is_service_enabled('network') diff --git a/openstackclient/tests/functional/network/v2/test_floating_ip.py b/openstackclient/tests/functional/network/v2/test_floating_ip.py index 9e34622c..1d11fc5d 100644 --- a/openstackclient/tests/functional/network/v2/test_floating_ip.py +++ b/openstackclient/tests/functional/network/v2/test_floating_ip.py @@ -88,19 +88,22 @@ class FloatingIpTests(common.NetworkTests): @classmethod def tearDownClass(cls): - if cls.haz_network: - del_output = cls.openstack( - 'subnet delete ' + - cls.EXTERNAL_SUBNET_NAME + ' ' + - cls.PRIVATE_SUBNET_NAME - ) - cls.assertOutput('', del_output) - del_output = cls.openstack( - 'network delete ' + - cls.EXTERNAL_NETWORK_NAME + ' ' + - cls.PRIVATE_NETWORK_NAME - ) - cls.assertOutput('', del_output) + try: + if cls.haz_network: + del_output = cls.openstack( + 'subnet delete ' + + cls.EXTERNAL_SUBNET_NAME + ' ' + + cls.PRIVATE_SUBNET_NAME + ) + cls.assertOutput('', del_output) + del_output = cls.openstack( + 'network delete ' + + cls.EXTERNAL_NETWORK_NAME + ' ' + + cls.PRIVATE_NETWORK_NAME + ) + cls.assertOutput('', del_output) + finally: + super(FloatingIpTests, cls).tearDownClass() def setUp(self): super(FloatingIpTests, self).setUp() diff --git a/openstackclient/tests/functional/network/v2/test_ip_availability.py b/openstackclient/tests/functional/network/v2/test_ip_availability.py index cb4b8150..86a53c0c 100644 --- a/openstackclient/tests/functional/network/v2/test_ip_availability.py +++ b/openstackclient/tests/functional/network/v2/test_ip_availability.py @@ -41,17 +41,20 @@ class IPAvailabilityTests(common.NetworkTests): @classmethod def tearDownClass(cls): - if cls.haz_network: - raw_subnet = cls.openstack( - 'subnet delete ' + - cls.NAME - ) - raw_network = cls.openstack( - 'network delete ' + - cls.NETWORK_NAME - ) - cls.assertOutput('', raw_subnet) - cls.assertOutput('', raw_network) + try: + if cls.haz_network: + raw_subnet = cls.openstack( + 'subnet delete ' + + cls.NAME + ) + raw_network = cls.openstack( + 'network delete ' + + cls.NETWORK_NAME + ) + cls.assertOutput('', raw_subnet) + cls.assertOutput('', raw_network) + finally: + super(IPAvailabilityTests, cls).tearDownClass() def setUp(self): super(IPAvailabilityTests, self).setUp() diff --git a/openstackclient/tests/functional/network/v2/test_network.py b/openstackclient/tests/functional/network/v2/test_network.py index b23323a0..91939703 100644 --- a/openstackclient/tests/functional/network/v2/test_network.py +++ b/openstackclient/tests/functional/network/v2/test_network.py @@ -361,7 +361,7 @@ class NetworkTests(common.NetworkTests): self.assertNotIn(name2, col_name) def test_network_dhcp_agent(self): - if self.haz_network: + if not self.haz_network: self.skipTest("No Network service present") name1 = uuid.uuid4().hex @@ -408,7 +408,7 @@ class NetworkTests(common.NetworkTests): def test_network_set(self): """Tests create options, set, show, delete""" - if self.haz_network: + if not self.haz_network: self.skipTest("No Network service present") name = uuid.uuid4().hex 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 71b406b4..31bc0845 100644 --- a/openstackclient/tests/functional/network/v2/test_network_meter_rule.py +++ b/openstackclient/tests/functional/network/v2/test_network_meter_rule.py @@ -39,13 +39,15 @@ class TestMeterRule(common.NetworkTests): @classmethod def tearDownClass(cls): - common.NetworkTests.tearDownClass() - if cls.haz_network: - raw_output = cls.openstack( - 'network meter delete ' + - cls.METER_ID - ) - cls.assertOutput('', raw_output) + try: + if cls.haz_network: + raw_output = cls.openstack( + 'network meter delete ' + + cls.METER_ID + ) + cls.assertOutput('', raw_output) + finally: + common.NetworkTests.tearDownClass() def setUp(self): super(TestMeterRule, self).setUp() 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 ccbf437c..53c15ecf 100644 --- a/openstackclient/tests/functional/network/v2/test_network_qos_policy.py +++ b/openstackclient/tests/functional/network/v2/test_network_qos_policy.py @@ -39,12 +39,15 @@ class NetworkQosPolicyTests(common.NetworkTests): @classmethod def tearDownClass(cls): - if cls.haz_network: - raw_output = cls.openstack( - 'network qos policy delete ' + - cls.NAME - ) - cls.assertOutput('', raw_output) + try: + if cls.haz_network: + raw_output = cls.openstack( + 'network qos policy delete ' + + cls.NAME + ) + cls.assertOutput('', raw_output) + finally: + super(NetworkQosPolicyTests, cls).tearDownClass() def setUp(self): super(NetworkQosPolicyTests, self).setUp() 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 6e40d8e0..8b34422f 100644 --- a/openstackclient/tests/functional/network/v2/test_network_qos_rule.py +++ b/openstackclient/tests/functional/network/v2/test_network_qos_rule.py @@ -51,17 +51,20 @@ class NetworkQosRuleTestsMinimumBandwidth(common.NetworkTests): @classmethod def tearDownClass(cls): - if cls.haz_network: - raw_output = cls.openstack( - 'network qos rule delete ' + - cls.QOS_POLICY_NAME + ' ' + - cls.RULE_ID - ) - cls.openstack( - 'network qos policy delete ' + - cls.QOS_POLICY_NAME - ) - cls.assertOutput('', raw_output) + try: + if cls.haz_network: + raw_output = cls.openstack( + 'network qos rule delete ' + + cls.QOS_POLICY_NAME + ' ' + + cls.RULE_ID + ) + cls.openstack( + 'network qos policy delete ' + + cls.QOS_POLICY_NAME + ) + cls.assertOutput('', raw_output) + finally: + super(NetworkQosRuleTestsMinimumBandwidth, cls).tearDownClass() def setUp(self): super(NetworkQosRuleTestsMinimumBandwidth, self).setUp() @@ -123,14 +126,18 @@ class NetworkQosRuleTestsDSCPMarking(common.NetworkTests): @classmethod def tearDownClass(cls): - if cls.haz_network: - raw_output = cls.openstack( - 'network qos rule delete ' + - cls.QOS_POLICY_NAME + ' ' + - cls.RULE_ID - ) - cls.openstack('network qos policy delete ' + cls.QOS_POLICY_NAME) - cls.assertOutput('', raw_output) + try: + if cls.haz_network: + raw_output = cls.openstack( + 'network qos rule delete ' + + cls.QOS_POLICY_NAME + ' ' + + cls.RULE_ID + ) + cls.openstack( + 'network qos policy delete ' + cls.QOS_POLICY_NAME) + cls.assertOutput('', raw_output) + finally: + super(NetworkQosRuleTestsDSCPMarking, cls).tearDownClass() def setUp(self): super(NetworkQosRuleTestsDSCPMarking, self).setUp() @@ -198,14 +205,18 @@ class NetworkQosRuleTestsBandwidthLimit(common.NetworkTests): @classmethod def tearDownClass(cls): - if cls.haz_network: - raw_output = cls.openstack( - 'network qos rule delete ' + - cls.QOS_POLICY_NAME + ' ' + - cls.RULE_ID - ) - cls.openstack('network qos policy delete ' + cls.QOS_POLICY_NAME) - cls.assertOutput('', raw_output) + try: + if cls.haz_network: + raw_output = cls.openstack( + 'network qos rule delete ' + + cls.QOS_POLICY_NAME + ' ' + + cls.RULE_ID + ) + cls.openstack( + 'network qos policy delete ' + cls.QOS_POLICY_NAME) + cls.assertOutput('', raw_output) + finally: + super(NetworkQosRuleTestsBandwidthLimit, cls).tearDownClass() def setUp(self): super(NetworkQosRuleTestsBandwidthLimit, self).setUp() diff --git a/openstackclient/tests/functional/network/v2/test_network_rbac.py b/openstackclient/tests/functional/network/v2/test_network_rbac.py index 893f1993..2206761f 100644 --- a/openstackclient/tests/functional/network/v2/test_network_rbac.py +++ b/openstackclient/tests/functional/network/v2/test_network_rbac.py @@ -47,15 +47,18 @@ class NetworkRBACTests(common.NetworkTests): @classmethod def tearDownClass(cls): - if cls.haz_network: - raw_output_rbac = cls.openstack( - 'network rbac delete ' + cls.ID - ) - raw_output_network = cls.openstack( - 'network delete ' + cls.OBJECT_ID - ) - cls.assertOutput('', raw_output_rbac) - cls.assertOutput('', raw_output_network) + try: + if cls.haz_network: + raw_output_rbac = cls.openstack( + 'network rbac delete ' + cls.ID + ) + raw_output_network = cls.openstack( + 'network delete ' + cls.OBJECT_ID + ) + cls.assertOutput('', raw_output_rbac) + cls.assertOutput('', raw_output_network) + finally: + super(NetworkRBACTests, cls).tearDownClass() def setUp(self): super(NetworkRBACTests, self).setUp() diff --git a/openstackclient/tests/functional/network/v2/test_network_segment.py b/openstackclient/tests/functional/network/v2/test_network_segment.py index 6dec82d9..b34515fa 100644 --- a/openstackclient/tests/functional/network/v2/test_network_segment.py +++ b/openstackclient/tests/functional/network/v2/test_network_segment.py @@ -55,11 +55,14 @@ class NetworkSegmentTests(common.NetworkTests): @classmethod def tearDownClass(cls): - if cls.haz_network: - raw_output = cls.openstack( - 'network delete ' + cls.NETWORK_NAME - ) - cls.assertOutput('', raw_output) + try: + if cls.haz_network: + raw_output = cls.openstack( + 'network delete ' + cls.NETWORK_NAME + ) + cls.assertOutput('', raw_output) + finally: + super(NetworkSegmentTests, cls).tearDownClass() def setUp(self): super(NetworkSegmentTests, self).setUp() diff --git a/openstackclient/tests/functional/network/v2/test_port.py b/openstackclient/tests/functional/network/v2/test_port.py index 14454454..09ac3566 100644 --- a/openstackclient/tests/functional/network/v2/test_port.py +++ b/openstackclient/tests/functional/network/v2/test_port.py @@ -33,11 +33,14 @@ class PortTests(common.NetworkTests): @classmethod def tearDownClass(cls): - if cls.haz_network: - raw_output = cls.openstack( - 'network delete ' + cls.NETWORK_NAME - ) - cls.assertOutput('', raw_output) + try: + if cls.haz_network: + raw_output = cls.openstack( + 'network delete ' + cls.NETWORK_NAME + ) + cls.assertOutput('', raw_output) + finally: + super(PortTests, cls).tearDownClass() def setUp(self): super(PortTests, self).setUp() 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 6da7e204..b601c913 100644 --- a/openstackclient/tests/functional/network/v2/test_security_group.py +++ b/openstackclient/tests/functional/network/v2/test_security_group.py @@ -38,20 +38,23 @@ class SecurityGroupTests(common.NetworkTests): @classmethod def tearDownClass(cls): - if cls.haz_network: - # Rename test - raw_output = cls.openstack( - 'security group set --name ' + - cls.OTHER_NAME + ' ' + - cls.NAME - ) - cls.assertOutput('', raw_output) - # Delete test - raw_output = cls.openstack( - 'security group delete ' + - cls.OTHER_NAME - ) - cls.assertOutput('', raw_output) + try: + if cls.haz_network: + # Rename test + raw_output = cls.openstack( + 'security group set --name ' + + cls.OTHER_NAME + ' ' + + cls.NAME + ) + cls.assertOutput('', raw_output) + # Delete test + raw_output = cls.openstack( + 'security group delete ' + + cls.OTHER_NAME + ) + cls.assertOutput('', raw_output) + finally: + super(SecurityGroupTests, cls).tearDownClass() def setUp(self): super(SecurityGroupTests, self).setUp() 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 e153116b..40951a01 100644 --- a/openstackclient/tests/functional/network/v2/test_security_group_rule.py +++ b/openstackclient/tests/functional/network/v2/test_security_group_rule.py @@ -51,18 +51,20 @@ class SecurityGroupRuleTests(common.NetworkTests): @classmethod def tearDownClass(cls): - if cls.haz_network: - raw_output = cls.openstack( - 'security group rule delete ' + - cls.SECURITY_GROUP_RULE_ID - ) - cls.assertOutput('', raw_output) - - raw_output = cls.openstack( - 'security group delete ' + - cls.SECURITY_GROUP_NAME - ) - cls.assertOutput('', raw_output) + try: + if cls.haz_network: + raw_output = cls.openstack( + 'security group rule delete ' + + cls.SECURITY_GROUP_RULE_ID + ) + cls.assertOutput('', raw_output) + raw_output = cls.openstack( + 'security group delete ' + + cls.SECURITY_GROUP_NAME + ) + cls.assertOutput('', raw_output) + finally: + super(SecurityGroupRuleTests, cls).tearDownClass() def setUp(self): super(SecurityGroupRuleTests, self).setUp() diff --git a/openstackclient/tests/functional/network/v2/test_subnet.py b/openstackclient/tests/functional/network/v2/test_subnet.py index 41375415..040b645b 100644 --- a/openstackclient/tests/functional/network/v2/test_subnet.py +++ b/openstackclient/tests/functional/network/v2/test_subnet.py @@ -36,12 +36,15 @@ class SubnetTests(common.NetworkTests): @classmethod def tearDownClass(cls): - if cls.haz_network: - raw_output = cls.openstack( - 'network delete ' + - cls.NETWORK_NAME - ) - cls.assertOutput('', raw_output) + try: + if cls.haz_network: + raw_output = cls.openstack( + 'network delete ' + + cls.NETWORK_NAME + ) + cls.assertOutput('', raw_output) + finally: + super(SubnetTests, cls).tearDownClass() def setUp(self): super(SubnetTests, self).setUp() |
