summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Pavlov <andrey.mp@gmail.com>2016-10-11 15:07:38 +0300
committerAndrey Pavlov <andrey.mp@gmail.com>2016-10-11 19:28:33 +0300
commita8d762a54c2705a1c564a625107d1850efc95e11 (patch)
treeea07803a9cbc16bc846d4774907ce21171988df3
parentfc10779f0e9be5903432877b2c2d0dd046c7c47d (diff)
skip vpn tests if vpnaas is not in network features list3.0.1
-rw-r--r--ec2api/tests/functional/api/test_customer_gateways.py1
-rw-r--r--ec2api/tests/functional/api/test_tags.py2
-rw-r--r--ec2api/tests/functional/api/test_vpn_connections.py1
-rw-r--r--ec2api/tests/functional/api/test_vpn_gateways.py1
-rw-r--r--ec2api/tests/functional/base.py18
-rw-r--r--ec2api/tests/functional/scenario/test_vpn.py1
6 files changed, 24 insertions, 0 deletions
diff --git a/ec2api/tests/functional/api/test_customer_gateways.py b/ec2api/tests/functional/api/test_customer_gateways.py
index 41ee24a..8d1a735 100644
--- a/ec2api/tests/functional/api/test_customer_gateways.py
+++ b/ec2api/tests/functional/api/test_customer_gateways.py
@@ -31,6 +31,7 @@ class CustomerGatewayTest(base.EC2TestCase):
31 super(CustomerGatewayTest, cls).setUpClass() 31 super(CustomerGatewayTest, cls).setUpClass()
32 if not base.TesterStateHolder().get_vpc_enabled(): 32 if not base.TesterStateHolder().get_vpc_enabled():
33 raise cls.skipException('VPC is disabled') 33 raise cls.skipException('VPC is disabled')
34 base.check_network_feature_enabled('vpnaas')
34 35
35 def test_create_delete_customer_gateway(self): 36 def test_create_delete_customer_gateway(self):
36 data = self.client.create_customer_gateway( 37 data = self.client.create_customer_gateway(
diff --git a/ec2api/tests/functional/api/test_tags.py b/ec2api/tests/functional/api/test_tags.py
index 8645fc1..2733684 100644
--- a/ec2api/tests/functional/api/test_tags.py
+++ b/ec2api/tests/functional/api/test_tags.py
@@ -441,6 +441,7 @@ class TagTest(base.EC2TestCase):
441 self._test_tag_resource(cgw_id, 'customer-gateway', describe_func) 441 self._test_tag_resource(cgw_id, 'customer-gateway', describe_func)
442 442
443 @base.skip_without_vpc() 443 @base.skip_without_vpc()
444 @base.skip_without_network_feature('vpnaas')
444 def test_tag_vpn_gateway(self): 445 def test_tag_vpn_gateway(self):
445 data = self.client.create_vpn_gateway(Type='ipsec.1') 446 data = self.client.create_vpn_gateway(Type='ipsec.1')
446 vgw_id = data['VpnGateway']['VpnGatewayId'] 447 vgw_id = data['VpnGateway']['VpnGatewayId']
@@ -456,6 +457,7 @@ class TagTest(base.EC2TestCase):
456 self._test_tag_resource(vgw_id, 'vpn-gateway', describe_func) 457 self._test_tag_resource(vgw_id, 'vpn-gateway', describe_func)
457 458
458 @base.skip_without_vpc() 459 @base.skip_without_vpc()
460 @base.skip_without_network_feature('vpnaas')
459 def test_tag_vpn_connection(self): 461 def test_tag_vpn_connection(self):
460 data = self.client.create_customer_gateway( 462 data = self.client.create_customer_gateway(
461 Type='ipsec.1', PublicIp='198.51.100.77', BgpAsn=65000) 463 Type='ipsec.1', PublicIp='198.51.100.77', BgpAsn=65000)
diff --git a/ec2api/tests/functional/api/test_vpn_connections.py b/ec2api/tests/functional/api/test_vpn_connections.py
index 105a827..e4d2fbc 100644
--- a/ec2api/tests/functional/api/test_vpn_connections.py
+++ b/ec2api/tests/functional/api/test_vpn_connections.py
@@ -35,6 +35,7 @@ class VpnConnectionTest(base.EC2TestCase):
35 super(VpnConnectionTest, cls).setUpClass() 35 super(VpnConnectionTest, cls).setUpClass()
36 if not base.TesterStateHolder().get_vpc_enabled(): 36 if not base.TesterStateHolder().get_vpc_enabled():
37 raise cls.skipException('VPC is disabled') 37 raise cls.skipException('VPC is disabled')
38 base.check_network_feature_enabled('vpnaas')
38 39
39 data = cls.client.create_customer_gateway( 40 data = cls.client.create_customer_gateway(
40 Type='ipsec.1', PublicIp=cls.CUSTOMER_GATEWAY_IP, BgpAsn=65000) 41 Type='ipsec.1', PublicIp=cls.CUSTOMER_GATEWAY_IP, BgpAsn=65000)
diff --git a/ec2api/tests/functional/api/test_vpn_gateways.py b/ec2api/tests/functional/api/test_vpn_gateways.py
index b92a859..148ef32 100644
--- a/ec2api/tests/functional/api/test_vpn_gateways.py
+++ b/ec2api/tests/functional/api/test_vpn_gateways.py
@@ -32,6 +32,7 @@ class VpnGatewayTest(base.EC2TestCase):
32 super(VpnGatewayTest, cls).setUpClass() 32 super(VpnGatewayTest, cls).setUpClass()
33 if not base.TesterStateHolder().get_vpc_enabled(): 33 if not base.TesterStateHolder().get_vpc_enabled():
34 raise cls.skipException('VPC is disabled') 34 raise cls.skipException('VPC is disabled')
35 base.check_network_feature_enabled('vpnaas')
35 36
36 data = cls.client.create_vpc(CidrBlock=cls.VPC_CIDR) 37 data = cls.client.create_vpc(CidrBlock=cls.VPC_CIDR)
37 cls.vpc_id = data['Vpc']['VpcId'] 38 cls.vpc_id = data['Vpc']['VpcId']
diff --git a/ec2api/tests/functional/base.py b/ec2api/tests/functional/base.py
index 33db487..a24503c 100644
--- a/ec2api/tests/functional/base.py
+++ b/ec2api/tests/functional/base.py
@@ -241,6 +241,24 @@ def skip_without_vpc(*args, **kwargs):
241 return decorator 241 return decorator
242 242
243 243
244def check_network_feature_enabled(ext_name):
245 ext_list = CONF['network-feature-enabled']['api_extensions']
246 if 'all' not in ext_list and ext_name not in ext_list:
247 msg = ("Skipped network test as %s is not available" % ext_name)
248 raise testtools.TestCase.skipException(msg)
249
250
251def skip_without_network_feature(ext_name, *args, **kwargs):
252 """A decorator useful to skip tests without specified network extension."""
253 def decorator(f):
254 @functools.wraps(f)
255 def wrapper(self, *func_args, **func_kwargs):
256 check_network_feature_enabled(ext_name)
257 return f(self, *func_args, **func_kwargs)
258 return wrapper
259 return decorator
260
261
244class EC2TestCase(base.BaseTestCase): 262class EC2TestCase(base.BaseTestCase):
245 """Recommended to use as base class for boto related test.""" 263 """Recommended to use as base class for boto related test."""
246 264
diff --git a/ec2api/tests/functional/scenario/test_vpn.py b/ec2api/tests/functional/scenario/test_vpn.py
index 362daf6..7b0268d 100644
--- a/ec2api/tests/functional/scenario/test_vpn.py
+++ b/ec2api/tests/functional/scenario/test_vpn.py
@@ -46,6 +46,7 @@ class VpnTest(scenario_base.BaseScenarioTest):
46 super(VpnTest, cls).setUpClass() 46 super(VpnTest, cls).setUpClass()
47 if not base.TesterStateHolder().get_vpc_enabled(): 47 if not base.TesterStateHolder().get_vpc_enabled():
48 raise cls.skipException('VPC is disabled') 48 raise cls.skipException('VPC is disabled')
49 base.check_network_feature_enabled('vpnaas')
49 50
50 def test_vpn_routing(self): 51 def test_vpn_routing(self):
51 vpc_id, _subnet_id = self.create_vpc_and_subnet('10.42.0.0/20') 52 vpc_id, _subnet_id = self.create_vpc_and_subnet('10.42.0.0/20')