From 9c0576de0f9d88aca29c2feb46cd10e5e1aa19b2 Mon Sep 17 00:00:00 2001
From: Paul Breaux
Date: Tue, 19 Jul 2016 22:13:11 -0600
Subject: [PATCH 1/2] During functional testing in 11.5.4 in ltm/profile some
tests fail at setup
Issues:
Fixes #555
Problem:
We have 8 test failures against 11.5.4 and all but one have the same
signature: Found unexpected json pair at module
Analysis:
After further inspection, it's simply that these collections do not
exist on the 11.5.4 device. Added minimum tmos version to these
collections, so they will not be instantiated by a user. Added some
tests to ensure that the correct exception is raised if a user does try
to instantiate one of these collections.
Tests:
All profile tests are passing on 11.5.4 and 11.6.0
---
f5/bigip/tm/ltm/profile.py | 8 ++
test/functional/tm/ltm/test_profile.py | 156 +++++++++++++++++++++++--
2 files changed, 155 insertions(+), 9 deletions(-)
diff --git a/f5/bigip/tm/ltm/profile.py b/f5/bigip/tm/ltm/profile.py
index 2daea85cb..c22bd8557 100644
--- a/f5/bigip/tm/ltm/profile.py
+++ b/f5/bigip/tm/ltm/profile.py
@@ -235,6 +235,7 @@ def __init__(self, profile):
self._meta_data['allowed_lazy_attributes'] = [Client_Ldap]
self._meta_data['attribute_registry'] = \
{'tm:ltm:profile:client-ldap:client-ldapstate': Client_Ldap}
+ self._meta_data['minimum_version'] = '11.6.0'
class Client_Ldap(Resource):
@@ -252,6 +253,7 @@ def __init__(self, profile):
self._meta_data['allowed_lazy_attributes'] = [Dhcpv4]
self._meta_data['attribute_registry'] = \
{'tm:ltm:profile:dhcpv4:dhcpv4state': Dhcpv4}
+ self._meta_data['minimum_version'] = '11.6.0'
class Dhcpv4(Resource):
@@ -269,6 +271,7 @@ def __init__(self, profile):
self._meta_data['allowed_lazy_attributes'] = [Dhcpv6]
self._meta_data['attribute_registry'] = \
{'tm:ltm:profile:dhcpv6:dhcpv6state': Dhcpv6}
+ self._meta_data['minimum_version'] = '11.6.0'
class Dhcpv6(Resource):
@@ -407,6 +410,7 @@ def __init__(self, profile):
self._meta_data['allowed_lazy_attributes'] = [Gtp]
self._meta_data['attribute_registry'] = \
{'tm:ltm:profile:gtp:gtpstate': Gtp}
+ self._meta_data['minimum_version'] = '11.6.0'
class Gtp(Resource):
@@ -478,6 +482,7 @@ def __init__(self, profile):
self._meta_data['allowed_lazy_attributes'] = [Http2]
self._meta_data['attribute_registry'] = \
{'tm:ltm:profile:http2:http2state': Http2}
+ self._meta_data['minimum_version'] = '11.6.0'
class Http2(Resource):
@@ -600,6 +605,7 @@ def __init__(self, profile):
{'tm:ltm:profile:ocsp-stapling-params:ocsp-stapling-paramsstate':
Ocsp_Stapling_Params}
self._meta_data['attribute_registry'] = temp
+ self._meta_data['minimum_version'] = '11.6.0'
class Ocsp_Stapling_Params(Resource):
@@ -878,6 +884,7 @@ def __init__(self, profile):
self._meta_data['allowed_lazy_attributes'] = [Server_Ldap]
self._meta_data['attribute_registry'] = \
{'tm:ltm:profile:server-ldap:server-ldapstate': Server_Ldap}
+ self._meta_data['minimum_version'] = '11.6.0'
class Server_Ldap(Resource):
@@ -933,6 +940,7 @@ def __init__(self, profile):
self._meta_data['allowed_lazy_attributes'] = [Smtp]
self._meta_data['attribute_registry'] = \
{'tm:ltm:profile:smtp:smtpstate': Smtp}
+ self._meta_data['minimum_version'] = '11.6.0'
class Smtp(Resource):
diff --git a/test/functional/tm/ltm/test_profile.py b/test/functional/tm/ltm/test_profile.py
index ee584dfdf..08970f6ea 100644
--- a/test/functional/tm/ltm/test_profile.py
+++ b/test/functional/tm/ltm/test_profile.py
@@ -13,6 +13,9 @@
# limitations under the License.
#
+
+from distutils.version import LooseVersion
+from f5.bigip.mixins import UnsupportedTmosVersion
from pprint import pprint as pp
pp(__file__)
import pytest
@@ -210,10 +213,25 @@ def test_RUL(self, request, bigip):
class TestClientLdap(object):
- def test_CURDL(self, request, bigip):
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ < LooseVersion('11.6.0'),
+ reason='This collection exists on 11.6.0 or greater.'
+ )
+ def test_CURDL_11_6_and_greater(self, request, bigip):
ldap = HelperTest(end_lst, 2)
ldap.test_CURDL(request, bigip)
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ >= LooseVersion('11.6.0'),
+ reason='This collection does not exist on 11.5.4 or less.'
+ )
+ def test_CURDL_11_5_4_and_less(self, request, bigip):
+ ldap = HelperTest(end_lst, 2)
+ with pytest.raises(UnsupportedTmosVersion) as ex:
+ ldap.test_CURDL(request, bigip)
+ assert 'Minimum TMOS version supported is 11.6.0' in ex.value.message
# End ClientLdap tests
@@ -232,10 +250,26 @@ def test_CURDL(self, request, bigip):
class TestDhcpv4(object):
- def test_CURDL(self, request, bigip):
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ < LooseVersion('11.6.0'),
+ reason='This collection exists on 11.6.0 or greater.'
+ )
+ def test_CURDL_11_6_and_greater(self, request, bigip):
dhcpv4 = HelperTest(end_lst, 4)
dhcpv4.test_CURDL(request, bigip)
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ >= LooseVersion('11.6.0'),
+ reason='This collection does not exist on 11.5.4 or less.'
+ )
+ def test_CURDL_11_5_4_and_less(self, request, bigip):
+ dhcpv4 = HelperTest(end_lst, 4)
+ with pytest.raises(UnsupportedTmosVersion) as ex:
+ dhcpv4.test_CURDL(request, bigip)
+ assert 'Minimum TMOS version supported is 11.6.0' in ex.value.message
+
# End Dhcpv4 tests
@@ -243,11 +277,25 @@ def test_CURDL(self, request, bigip):
class TestDhcpv6(object):
- def test_CURDL(self, request, bigip):
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ < LooseVersion('11.6.0'),
+ reason='This collection exists on 11.6.0 or greater.'
+ )
+ def test_CURDL_11_6_and_greater(self, request, bigip):
dhcpv6 = HelperTest(end_lst, 5)
dhcpv6.test_CURDL(request, bigip)
-
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ >= LooseVersion('11.6.0'),
+ reason='This collection does not exist on 11.5.4 or less.'
+ )
+ def test_CURDL_11_5_4_and_less(self, request, bigip):
+ dhcpv4 = HelperTest(end_lst, 5)
+ with pytest.raises(UnsupportedTmosVersion) as ex:
+ dhcpv4.test_CURDL(request, bigip)
+ assert 'Minimum TMOS version supported is 11.6.0' in ex.value.message
# End Dhcpv6 tests
# Begin Diameter tests
@@ -374,10 +422,26 @@ def test_CURDL(self, request, bigip):
class TestGtp(object):
- def test_CURDL(self, request, bigip):
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ < LooseVersion('11.6.0'),
+ reason='This collection exists on 11.6.0 or greater.'
+ )
+ def test_CURDL_11_6_and_greater(self, request, bigip):
gtp = HelperTest(end_lst, 13)
gtp.test_CURDL(request, bigip)
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ >= LooseVersion('11.6.0'),
+ reason='This collection does not exist on 11.5.4 or less.'
+ )
+ def test_CURDL_11_5_4_and_less(self, request, bigip):
+ dhcpv4 = HelperTest(end_lst, 13)
+ with pytest.raises(UnsupportedTmosVersion) as ex:
+ dhcpv4.test_CURDL(request, bigip)
+ assert 'Minimum TMOS version supported is 11.6.0' in ex.value.message
+
# End GTP tests
@@ -418,10 +482,26 @@ def test_CURDL(self, request, bigip):
class TestHttp2(object):
- def test_CURDL(self, request, bigip):
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ < LooseVersion('11.6.0'),
+ reason='This collection exists on 11.6.0 or greater.'
+ )
+ def test_CURDL_11_6_and_greater(self, request, bigip):
http2 = HelperTest(end_lst, 17)
http2.test_CURDL(request, bigip)
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ >= LooseVersion('11.6.0'),
+ reason='This collection does not exist on 11.5.4 or less.'
+ )
+ def test_CURDL_11_5_4_and_less(self, request, bigip):
+ dhcpv4 = HelperTest(end_lst, 17)
+ with pytest.raises(UnsupportedTmosVersion) as ex:
+ dhcpv4.test_CURDL(request, bigip)
+ assert 'Minimum TMOS version supported is 11.6.0' in ex.value.message
+
# End HTTP tests
@@ -542,7 +622,12 @@ def teardown():
class TestOcspStaplingParams(object):
- def test_CURDL(self, request, bigip):
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ < LooseVersion('11.6.0'),
+ reason='This collection exists on 11.6.0 or greater.'
+ )
+ def test_CURDL_11_6_and_greater(self, request, bigip):
# Setup DNS resolver as prerequisite
dns = setup_dns_resolver(request, bigip, 'test_resolv')
@@ -577,6 +662,27 @@ def test_CURDL(self, request, bigip):
assert ocsp1.selfLink == ocsp2.selfLink
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ >= LooseVersion('11.6.0'),
+ reason='This collection does not exist on 11.5.4 or less.'
+ )
+ def test_CURDL_11_6_and_less(self, request, bigip):
+
+ # Setup DNS resolver as prerequisite
+ dns = setup_dns_resolver(request, bigip, 'test_resolv')
+
+ # Test CURDL
+ ocsp = HelperTest(end_lst, 24)
+
+ # Testing create
+ with pytest.raises(UnsupportedTmosVersion) as ex:
+ ocsp.setup_test(
+ request, bigip, dnsResolver=dns.name,
+ trustedCa='/Common/ca-bundle.crt',
+ useProxyServer='disabled'
+ )
+ assert 'Minimum TMOS version supported is 11.6.0' in ex.value.message
# End Ocsp Stapling Params tests
@@ -795,10 +901,26 @@ def test_CURDL(self, request, bigip):
class TestServerLdap(object):
- def test_CURDL(self, request, bigip):
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ < LooseVersion('11.6.0'),
+ reason='This collection exists on 11.6.0 or greater.'
+ )
+ def test_CURDL_11_6_and_greater(self, request, bigip):
sldap = HelperTest(end_lst, 35)
sldap.test_CURDL(request, bigip)
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ >= LooseVersion('11.6.0'),
+ reason='This collection does not exist on 11.5.4 or less.'
+ )
+ def test_CURDL_11_5_4_and_less(self, request, bigip):
+ dhcpv4 = HelperTest(end_lst, 35)
+ with pytest.raises(UnsupportedTmosVersion) as ex:
+ dhcpv4.test_CURDL(request, bigip)
+ assert 'Minimum TMOS version supported is 11.6.0' in ex.value.message
+
# End Server Ldap tests
@@ -828,10 +950,26 @@ def test_CURDL(self, request, bigip):
class TestSmtp(object):
- def test_CURDL(self, request, bigip):
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ < LooseVersion('11.6.0'),
+ reason='This collection exists on 11.6.0 or greater.'
+ )
+ def test_CURDL_11_6_and_greater(self, request, bigip):
smtp = HelperTest(end_lst, 38)
smtp.test_CURDL(request, bigip)
+ @pytest.mark.skipif(
+ LooseVersion(pytest.config.getoption('--release'))
+ >= LooseVersion('11.6.0'),
+ reason='This collection does not exist on 11.5.4 or less.'
+ )
+ def test_CURDL_11_5_4_and_less(self, request, bigip):
+ dhcpv4 = HelperTest(end_lst, 38)
+ with pytest.raises(UnsupportedTmosVersion) as ex:
+ dhcpv4.test_CURDL(request, bigip)
+ assert 'Minimum TMOS version supported is 11.6.0' in ex.value.message
+
# End Smtp tests
From 5d8be4bea5d2b7965a80b4b66dd901c8e889064b Mon Sep 17 00:00:00 2001
From: Paul Breaux
Date: Tue, 26 Jul 2016 12:06:08 -0600
Subject: [PATCH 2/2] Adding doc for user to understand how I am using the
pollster in the failover tests.
---
test/functional/tm/sys/test_failover.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/test/functional/tm/sys/test_failover.py b/test/functional/tm/sys/test_failover.py
index d2ebe3e0a..9a6930601 100644
--- a/test/functional/tm/sys/test_failover.py
+++ b/test/functional/tm/sys/test_failover.py
@@ -93,6 +93,9 @@ def test_exec_cmd(self, mgmt_root, teardown_device_failover_state):
f = mgmt_root.tm.sys.failover
f.exec_cmd('run', offline=True)
get_activation_state(mgmt_root)
+ # Use the pollster to check for expected state. The pollster uses
+ # a method which checks for any exception. If one is found, it keeps
+ # trying.
pollster(check_device_state_as_expected)(mgmt_root, 'forced-offline')
fl.refresh()
pp(fl.raw)