Skip to content

Commit 198a486

Browse files
committed
network functest: Remove condition for segment test
Previously fucntional tests for network segment feature are skipped as neutron 'segment' API extension was disabled in the gate. We now enable neutron 'segment' API extension, so we can safely drop the check for the segment extension from the test code. Also setup code in test_network_segment is moved from setUpClass to setUp. There is no good reason to do them in setUpClass and having them in setUp simplifies the test code. no user once this commit is applied. Change-Id: I183310b94d9b6d7f4311a3859b59dc22d36440db
1 parent ad21588 commit 198a486

2 files changed

Lines changed: 48 additions & 89 deletions

File tree

openstackclient/tests/functional/base.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ def get_openstack_configuration_value(cls, configuration):
6868
opts = cls.get_opts([configuration])
6969
return cls.openstack('configuration show ' + opts)
7070

71-
@classmethod
72-
def get_openstack_extension_names(cls):
73-
opts = cls.get_opts(['Name'])
74-
return cls.openstack('extension list ' + opts)
75-
7671
@classmethod
7772
def get_opts(cls, fields, output_format='value'):
7873
return ' -f {0} {1}'.format(output_format,

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

Lines changed: 48 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -17,101 +17,65 @@
1717

1818
class NetworkSegmentTests(common.NetworkTests):
1919
"""Functional tests for network segment"""
20-
NETWORK_SEGMENT_ID = None
21-
NETWORK_ID = None
22-
NETWORK_SEGMENT_EXTENSION = None
23-
24-
@classmethod
25-
def setUpClass(cls):
26-
common.NetworkTests.setUpClass()
27-
if cls.haz_network:
28-
cls.NETWORK_NAME = uuid.uuid4().hex
29-
cls.PHYSICAL_NETWORK_NAME = uuid.uuid4().hex
30-
31-
# Create a network for the segment
32-
opts = cls.get_opts(['id'])
33-
raw_output = cls.openstack(
34-
'network create ' + cls.NETWORK_NAME + opts
35-
)
36-
cls.NETWORK_ID = raw_output.strip('\n')
37-
38-
# NOTE(rtheis): The segment extension is not yet enabled
39-
# by default.
40-
# Skip the tests if not enabled.
41-
extensions = cls.get_openstack_extension_names()
42-
if 'Segment' in extensions:
43-
cls.NETWORK_SEGMENT_EXTENSION = 'Segment'
44-
45-
if cls.NETWORK_SEGMENT_EXTENSION:
46-
# Get the segment for the network.
47-
opts = cls.get_opts(['ID', 'Network'])
48-
raw_output = cls.openstack(
49-
'network segment list '
50-
'--network ' + cls.NETWORK_NAME + ' ' +
51-
opts
52-
)
53-
raw_output_row = raw_output.split('\n')[0]
54-
cls.NETWORK_SEGMENT_ID = raw_output_row.split(' ')[0]
55-
56-
@classmethod
57-
def tearDownClass(cls):
58-
try:
59-
if cls.haz_network:
60-
raw_output = cls.openstack(
61-
'network delete ' + cls.NETWORK_NAME
62-
)
63-
cls.assertOutput('', raw_output)
64-
finally:
65-
super(NetworkSegmentTests, cls).tearDownClass()
6620

6721
def setUp(self):
6822
super(NetworkSegmentTests, self).setUp()
6923
# Nothing in this class works with Nova Network
7024
if not self.haz_network:
7125
self.skipTest("No Network service present")
7226

27+
self.NETWORK_NAME = uuid.uuid4().hex
28+
self.PHYSICAL_NETWORK_NAME = uuid.uuid4().hex
29+
30+
# Create a network for the segment
31+
opts = self.get_opts(['id'])
32+
raw_output = self.openstack(
33+
'network create ' + self.NETWORK_NAME + opts
34+
)
35+
self.addCleanup(self.openstack,
36+
'network delete ' + self.NETWORK_NAME)
37+
self.NETWORK_ID = raw_output.strip('\n')
38+
39+
# Get the segment for the network.
40+
opts = self.get_opts(['ID', 'Network'])
41+
raw_output = self.openstack(
42+
'network segment list '
43+
'--network ' + self.NETWORK_NAME + ' ' +
44+
opts
45+
)
46+
raw_output_row = raw_output.split('\n')[0]
47+
self.NETWORK_SEGMENT_ID = raw_output_row.split(' ')[0]
48+
7349
def test_network_segment_create_delete(self):
74-
if self.NETWORK_SEGMENT_EXTENSION:
75-
opts = self.get_opts(['id'])
76-
raw_output = self.openstack(
77-
' network segment create --network ' + self.NETWORK_ID +
78-
' --network-type geneve ' +
79-
' --segment 2055 test_segment ' + opts
80-
)
81-
network_segment_id = raw_output.strip('\n')
82-
raw_output = self.openstack('network segment delete ' +
83-
network_segment_id)
84-
self.assertOutput('', raw_output)
85-
else:
86-
self.skipTest('Segment extension disabled')
50+
opts = self.get_opts(['id'])
51+
raw_output = self.openstack(
52+
' network segment create --network ' + self.NETWORK_ID +
53+
' --network-type geneve ' +
54+
' --segment 2055 test_segment ' + opts
55+
)
56+
network_segment_id = raw_output.strip('\n')
57+
raw_output = self.openstack('network segment delete ' +
58+
network_segment_id)
59+
self.assertOutput('', raw_output)
8760

8861
def test_network_segment_list(self):
89-
if self.NETWORK_SEGMENT_EXTENSION:
90-
opts = self.get_opts(['ID'])
91-
raw_output = self.openstack('network segment list' + opts)
92-
self.assertIn(self.NETWORK_SEGMENT_ID, raw_output)
93-
else:
94-
self.skipTest('Segment extension disabled')
62+
opts = self.get_opts(['ID'])
63+
raw_output = self.openstack('network segment list' + opts)
64+
self.assertIn(self.NETWORK_SEGMENT_ID, raw_output)
9565

9666
def test_network_segment_set(self):
97-
if self.NETWORK_SEGMENT_EXTENSION:
98-
new_description = 'new_description'
99-
raw_output = self.openstack('network segment set ' +
100-
'--description ' + new_description +
101-
' ' + self.NETWORK_SEGMENT_ID)
102-
self.assertOutput('', raw_output)
103-
opts = self.get_opts(['description'])
104-
raw_output = self.openstack('network segment show ' +
105-
self.NETWORK_SEGMENT_ID + opts)
106-
self.assertEqual(new_description + "\n", raw_output)
107-
else:
108-
self.skipTest('Segment extension disabled')
67+
new_description = 'new_description'
68+
raw_output = self.openstack('network segment set ' +
69+
'--description ' + new_description +
70+
' ' + self.NETWORK_SEGMENT_ID)
71+
self.assertOutput('', raw_output)
72+
opts = self.get_opts(['description'])
73+
raw_output = self.openstack('network segment show ' +
74+
self.NETWORK_SEGMENT_ID + opts)
75+
self.assertEqual(new_description + "\n", raw_output)
10976

11077
def test_network_segment_show(self):
111-
if self.NETWORK_SEGMENT_EXTENSION:
112-
opts = self.get_opts(['network_id'])
113-
raw_output = self.openstack('network segment show ' +
114-
self.NETWORK_SEGMENT_ID + opts)
115-
self.assertEqual(self.NETWORK_ID + "\n", raw_output)
116-
else:
117-
self.skipTest('Segment extension disabled')
78+
opts = self.get_opts(['network_id'])
79+
raw_output = self.openstack('network segment show ' +
80+
self.NETWORK_SEGMENT_ID + opts)
81+
self.assertEqual(self.NETWORK_ID + "\n", raw_output)

0 commit comments

Comments
 (0)