diff options
Diffstat (limited to 'openstackclient/tests/functional')
| -rw-r--r-- | openstackclient/tests/functional/network/v2/test_network.py | 43 | ||||
| -rw-r--r-- | openstackclient/tests/functional/network/v2/test_network_agent.py | 52 |
2 files changed, 95 insertions, 0 deletions
diff --git a/openstackclient/tests/functional/network/v2/test_network.py b/openstackclient/tests/functional/network/v2/test_network.py index 12636558..0e10bfce 100644 --- a/openstackclient/tests/functional/network/v2/test_network.py +++ b/openstackclient/tests/functional/network/v2/test_network.py @@ -238,6 +238,49 @@ class NetworkTests(base.TestCase): self.assertIn(name1, col_name) self.assertNotIn(name2, col_name) + def test_network_dhcp_agent(self): + name1 = uuid.uuid4().hex + cmd_output1 = json.loads(self.openstack( + 'network create -f json ' + + '--description aaaa ' + + name1 + )) + + self.addCleanup(self.openstack, 'network delete ' + name1) + + # Get network ID + network_id = cmd_output1['id'] + + # Get DHCP Agent ID + cmd_output2 = json.loads(self.openstack( + 'network agent list -f json --agent-type dhcp' + )) + agent_id = cmd_output2[0]['ID'] + + # Add Agent to Network + self.openstack( + 'network agent add network --dhcp ' + + agent_id + ' ' + network_id + ) + + # Test network list --agent + cmd_output3 = json.loads(self.openstack( + 'network list -f json --agent ' + agent_id + )) + + # Cleanup + # Remove Agent from Network + self.openstack( + 'network agent remove network --dhcp ' + + agent_id + ' ' + network_id + ) + + # Assert + col_name = [x["ID"] for x in cmd_output3] + self.assertIn( + network_id, col_name + ) + def test_network_set(self): """Tests create options, set, show, delete""" 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 dd6112e7..6da721d1 100644 --- a/openstackclient/tests/functional/network/v2/test_network_agent.py +++ b/openstackclient/tests/functional/network/v2/test_network_agent.py @@ -10,6 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. +import json +import uuid + from openstackclient.tests.functional import base @@ -39,3 +42,52 @@ class NetworkAgentTests(base.TestCase): self.openstack('network agent set --enable ' + self.IDs[0]) raw_output = self.openstack('network agent show ' + self.IDs[0] + opts) self.assertEqual("UP\n", raw_output) + + +class NetworkAgentListTests(base.TestCase): + """Functional test for network agent list --network. """ + + def test_network_dhcp_agent_list(self): + """Test network agent list""" + + name1 = uuid.uuid4().hex + cmd_output1 = json.loads(self.openstack( + 'network create -f json ' + + '--description aaaa ' + + name1 + )) + + self.addCleanup(self.openstack, 'network delete ' + name1) + + # Get network ID + network_id = cmd_output1['id'] + + # Get DHCP Agent ID + cmd_output2 = json.loads(self.openstack( + 'network agent list -f json --agent-type dhcp' + )) + agent_id = cmd_output2[0]['ID'] + + # Add Agent to Network + self.openstack( + 'network agent add network --dhcp ' + + agent_id + ' ' + network_id + ) + + # Test network agent list --network + cmd_output3 = json.loads(self.openstack( + 'network agent list -f json --network ' + network_id + )) + + # Cleanup + # Remove Agent from Network + self.openstack( + 'network agent remove network --dhcp ' + + agent_id + ' ' + network_id + ) + + # Assert + col_name = [x["ID"] for x in cmd_output3] + self.assertIn( + agent_id, col_name + ) |
