Skip to content

Commit 449b054

Browse files
author
Paul Breaux
committed
During functional testing against 11.5.4,
test/functional/tm/ltm/test_virtual.py test fails Issues: Fixes #589 Problem: A profile cannot be created or loaded on 11.5.4 under a virtual without specifying the partition. Analysis: Added a tmos version check in the __init__ of the Profiles resource under Virtual. If the tmos version is less than 11.6.0, the partition is required for creation and load. Tests: Virtual tests pass against 11.5.4 and 11.6.0
1 parent e9bd3bf commit 449b054

2 files changed

Lines changed: 68 additions & 14 deletions

File tree

f5/bigip/tm/ltm/virtual.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
from f5.bigip.resource import Collection
3131
from f5.bigip.resource import Resource
3232

33+
from distutils.version import LooseVersion
34+
3335

3436
class Virtuals(Collection):
3537
"""BIG-IP® LTM virtual collection"""
@@ -55,6 +57,14 @@ class Profiles(Resource):
5557
def __init__(self, Profiles_s):
5658
'''Autogenerated constructor.'''
5759
super(Profiles, self).__init__(Profiles_s)
60+
if LooseVersion(self._meta_data['bigip']._meta_data['tmos_version']) \
61+
< LooseVersion('11.6.0'):
62+
self._meta_data['required_creation_parameters'].update(
63+
('partition',)
64+
)
65+
self._meta_data['required_load_parameters'].update(
66+
('partition',)
67+
)
5868
self._meta_data['template_generated'] = True
5969
self._meta_data['required_json_kind'] =\
6070
u"tm:ltm:virtual:profiles:profilesstate"

test/functional/tm/ltm/test_virtual.py

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# limitations under the License.
1414
#
1515

16+
from f5.bigip.resource import MissingRequiredCreationParameter
17+
from f5.bigip.resource import MissingRequiredReadParameter
18+
1619
from distutils.version import LooseVersion
1720
from pprint import pprint as pp
1821
import pytest
@@ -25,19 +28,23 @@ def delete_resource(resources):
2528
resource.delete()
2629

2730

28-
def setup_virtual_test(request, bigip, partition, name):
31+
def setup_virtual_test(request, mgmt_root, partition, name):
2932
def teardown():
3033
delete_resource(vc1)
3134
request.addfinalizer(teardown)
32-
vc1 = bigip.ltm.virtuals
35+
vc1 = mgmt_root.tm.ltm.virtuals
3336
pp('****')
3437
virtual1 = vc1.virtual.create(name=name, partition=partition)
3538
return virtual1, vc1
3639

3740

3841
class TestVirtual(object):
39-
def test_virtual_create_refresh_update_delete_load(self, request, bigip):
40-
virtual1, vc1 = setup_virtual_test(request, bigip, 'Common', 'vstest1')
42+
def test_virtual_create_refresh_update_delete_load(
43+
self, request, mgmt_root, setup_device_snapshot
44+
):
45+
virtual1, vc1 = setup_virtual_test(
46+
request, mgmt_root, 'Common', 'vstest1'
47+
)
4148
assert virtual1.name == 'vstest1'
4249
virtual1.description = TESTDESCRIPTION
4350
virtual1.update()
@@ -49,19 +56,20 @@ def test_virtual_create_refresh_update_delete_load(self, request, bigip):
4956
assert virtual2.selfLink == virtual1.selfLink
5057

5158

52-
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) <
53-
LooseVersion('11.6.0'),
54-
reason='This test fails in 11.5.4. Will '
55-
'revert this change in next PR.'
56-
)
57-
def test_profiles_CE(bigip, opt_release):
58-
v1 = bigip.ltm.virtuals.virtual.create(name="tv1", partition="Common")
59+
@pytest.mark.skipif(
60+
LooseVersion(pytest.config.getoption('--release'))
61+
< LooseVersion('11.6.0'),
62+
reason='Profiles do not need a partition in 11.6.0 and up.'
63+
)
64+
def test_profiles_CE_and_greater(
65+
mgmt_root, opt_release, setup_device_snapshot
66+
):
67+
v1 = mgmt_root.tm.ltm.virtuals.virtual.create(
68+
name="tv1", partition="Common"
69+
)
5970
p1 = v1.profiles_s.profiles.create(name="http")
60-
pp(p1.raw)
6171
test_profiles_s = v1.profiles_s
62-
pp(test_profiles_s.raw)
6372
test_profiles_s.context = 'all'
64-
pp(test_profiles_s.raw)
6573
assert p1.selfLink ==\
6674
u"https://localhost/mgmt/tm/ltm/virtual/"\
6775
"~Common~tv1/profiles/http?ver="+opt_release
@@ -70,3 +78,39 @@ def test_profiles_CE(bigip, opt_release):
7078
assert p2.exists(name='http')
7179

7280
v1.delete()
81+
82+
83+
@pytest.mark.skipif(
84+
LooseVersion(pytest.config.getoption('--release'))
85+
>= LooseVersion('11.6.0'),
86+
reason='Profiles are created with a partition in 11.5.4.'
87+
)
88+
def test_profiles_CE_11_5_4_and_less(
89+
mgmt_root, opt_release, setup_device_snapshot
90+
):
91+
v1 = mgmt_root.tm.ltm.virtuals.virtual.create(
92+
name="tv2", partition="Common"
93+
)
94+
# Ensure we cannot create a profile without partition in 11.5.4
95+
with pytest.raises(MissingRequiredCreationParameter) as ex:
96+
v1.profiles_s.profiles.create(name="http")
97+
assert "Missing required params: ['partition']" in ex.value.message
98+
99+
# Create the profile with the partition given
100+
p1 = v1.profiles_s.profiles.create(name="http", partition="Common")
101+
test_profiles_s = v1.profiles_s
102+
test_profiles_s.context = 'all'
103+
assert p1.selfLink ==\
104+
u"https://localhost/mgmt/tm/ltm/virtual/"\
105+
"~Common~tv2/profiles/~Common~http?ver="+opt_release
106+
107+
p2 = v1.profiles_s.profiles
108+
# Ensure we cannot check for existence without partition in 11.5.4
109+
with pytest.raises(MissingRequiredReadParameter) as ex:
110+
assert p2.exists(name='http')
111+
assert "Missing required params: ['partition']" in ex.value.message
112+
113+
# Check for existence with partition given
114+
p2.exists(name='http', partition='Common')
115+
116+
v1.delete()

0 commit comments

Comments
 (0)