Skip to content

Commit e0d1af9

Browse files
author
Dean Troyer
committed
Nova net functional tests round 1
* address scope * network agent * network flavor * network flavor profile * network meter * network meter rule Also create a new common network functional test class NetworkTests to house the setting of haz_network in a single place. The individual test skipping stays in the final classes to re-enforce the idea that some tests work with both Nova-net and Neutron. Change-Id: Ie3910231c6fc9e2031438c599afa904f43c874a7
1 parent 7b609eb commit e0d1af9

7 files changed

Lines changed: 286 additions & 136 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
from openstackclient.tests.functional import base
14+
15+
16+
class NetworkTests(base.TestCase):
17+
"""Functional tests for Network commands"""
18+
19+
@classmethod
20+
def setUpClass(cls):
21+
# super(NetworkTests, cls).setUp()
22+
cls.haz_network = base.is_service_enabled('network')

openstackclient/tests/functional/network/v2/test_address_scope.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,23 @@
1313
import json
1414
import uuid
1515

16-
from openstackclient.tests.functional import base
16+
from openstackclient.tests.functional.network.v2 import common
1717

1818

19-
class AddressScopeTests(base.TestCase):
19+
class AddressScopeTests(common.NetworkTests):
2020
"""Functional tests for address scope. """
2121

2222
# NOTE(dtroyer): Do not normalize the setup and teardown of the resource
2323
# creation and deletion. Little is gained when each test
2424
# has its own needs and there are collisions when running
2525
# tests in parallel.
2626

27+
def setUp(self):
28+
super(AddressScopeTests, self).setUp()
29+
# Nothing in this class works with Nova Network
30+
if not self.haz_network:
31+
self.skipTest("No Network service present")
32+
2733
def test_address_scope_delete(self):
2834
"""Test create, delete multiple"""
2935
name1 = uuid.uuid4().hex

openstackclient/tests/functional/network/v2/test_network_agent.py

Lines changed: 79 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,85 @@
1313
import json
1414
import uuid
1515

16-
from openstackclient.tests.functional import base
17-
18-
19-
class NetworkAgentTests(base.TestCase):
20-
"""Functional tests for network agent. """
21-
IDs = None
22-
HEADERS = ['ID']
23-
FIELDS = ['id']
24-
25-
@classmethod
26-
def test_network_agent_list(cls):
27-
opts = cls.get_opts(cls.HEADERS)
28-
raw_output = cls.openstack('network agent list' + opts)
29-
# get the list of network agent IDs.
30-
cls.IDs = raw_output.split('\n')
31-
32-
def test_network_agent_show(self):
33-
opts = self.get_opts(self.FIELDS)
34-
raw_output = self.openstack('network agent show ' + self.IDs[0] + opts)
35-
self.assertEqual(self.IDs[0] + "\n", raw_output)
36-
37-
def test_network_agent_set(self):
38-
opts = self.get_opts(['admin_state_up'])
39-
self.openstack('network agent set --disable ' + self.IDs[0])
40-
raw_output = self.openstack('network agent show ' + self.IDs[0] + opts)
41-
self.assertEqual("DOWN\n", raw_output)
42-
self.openstack('network agent set --enable ' + self.IDs[0])
43-
raw_output = self.openstack('network agent show ' + self.IDs[0] + opts)
44-
self.assertEqual("UP\n", raw_output)
45-
46-
47-
class NetworkAgentListTests(base.TestCase):
48-
"""Functional test for network agent list --network. """
16+
from openstackclient.tests.functional.network.v2 import common
17+
18+
19+
class NetworkAgentTests(common.NetworkTests):
20+
"""Functional tests for network agent"""
21+
22+
def setUp(self):
23+
super(NetworkAgentTests, self).setUp()
24+
# Nothing in this class works with Nova Network
25+
if not self.haz_network:
26+
self.skipTest("No Network service present")
27+
28+
def test_network_agent_list_show_set(self):
29+
"""Test network agent list, set, show commands
30+
31+
Do these serially because show and set rely on the existing agent IDs
32+
from the list output and we had races when run in parallel.
33+
"""
34+
35+
# agent list
36+
agent_list = json.loads(self.openstack(
37+
'network agent list -f json'
38+
))
39+
self.assertIsNotNone(agent_list[0])
40+
41+
agent_ids = list([row["ID"] for row in agent_list])
42+
43+
# agent show
44+
cmd_output = json.loads(self.openstack(
45+
'network agent show -f json ' +
46+
agent_ids[0]
47+
))
48+
self.assertEqual(
49+
agent_ids[0],
50+
cmd_output['id'],
51+
)
52+
53+
# agent set
54+
raw_output = self.openstack(
55+
'network agent set ' +
56+
'--disable ' +
57+
agent_ids[0]
58+
)
59+
self.assertOutput('', raw_output)
60+
61+
cmd_output = json.loads(self.openstack(
62+
'network agent show -f json ' +
63+
agent_ids[0]
64+
))
65+
self.assertEqual(
66+
"DOWN",
67+
cmd_output['admin_state_up'],
68+
)
69+
70+
raw_output = self.openstack(
71+
'network agent set ' +
72+
'--enable ' +
73+
agent_ids[0]
74+
)
75+
self.assertOutput('', raw_output)
76+
77+
cmd_output = json.loads(self.openstack(
78+
'network agent show -f json ' +
79+
agent_ids[0]
80+
))
81+
self.assertEqual(
82+
"UP",
83+
cmd_output['admin_state_up'],
84+
)
85+
86+
87+
class NetworkAgentListTests(common.NetworkTests):
88+
"""Functional test for network agent"""
89+
90+
def setUp(self):
91+
super(NetworkAgentListTests, self).setUp()
92+
# Nothing in this class works with Nova Network
93+
if not self.haz_network:
94+
self.skipTest("No Network service present")
4995

5096
def test_network_dhcp_agent_list(self):
5197
"""Test network agent list"""

openstackclient/tests/functional/network/v2/test_network_flavor.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@
1414
import json
1515
import uuid
1616

17-
from openstackclient.tests.functional import base
17+
from openstackclient.tests.functional.network.v2 import common
1818

1919

20-
class NetworkFlavorTests(base.TestCase):
21-
"""Functional tests for network flavor."""
20+
class NetworkFlavorTests(common.NetworkTests):
21+
"""Functional tests for network flavor"""
2222

23-
def test_add_remove_network_flavor_profile(self):
24-
"""Test add and remove network flavor to/from profile"""
23+
def setUp(self):
24+
super(NetworkFlavorTests, self).setUp()
25+
# Nothing in this class works with Nova Network
26+
if not self.haz_network:
27+
self.skipTest("No Network service present")
2528

29+
def test_network_flavor_add_remove_profile(self):
30+
"""Test add and remove network flavor to/from profile"""
2631
# Create Flavor
2732
name1 = uuid.uuid4().hex
2833
cmd_output1 = json.loads(self.openstack(

0 commit comments

Comments
 (0)