Merge "Leverage on Xtesting"
[functest.git] / functest / opnfv_tests / openstack / snaps / snaps_test_runner.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
4 #
5 # This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10
11 """configuration params to run snaps tests"""
12
13 import logging
14
15 from snaps.openstack import create_flavor
16 from xtesting.core import unit
17
18 from functest.opnfv_tests.openstack.snaps import snaps_utils
19 from functest.utils import config
20 from functest.utils import env
21
22
23 class SnapsTestRunner(unit.Suite):
24     # pylint: disable=too-many-instance-attributes
25     """
26     This test executes the SNAPS Python Tests
27     """
28
29     def __init__(self, **kwargs):
30         super(SnapsTestRunner, self).__init__(**kwargs)
31         self.logger = logging.getLogger(__name__)
32         self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()
33
34         if 'ext_net_name' in kwargs:
35             self.ext_net_name = kwargs['ext_net_name']
36         else:
37             self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
38
39         self.netconf_override = None
40         if hasattr(config.CONF, 'snaps_network_config'):
41             self.netconf_override = getattr(
42                 config.CONF, 'snaps_network_config')
43
44         self.use_fip = (
45             getattr(config.CONF, 'snaps_use_floating_ips') == 'True')
46         self.use_keystone = (
47             getattr(config.CONF, 'snaps_use_keystone') == 'True')
48         scenario = env.get('DEPLOY_SCENARIO')
49
50         self.flavor_metadata = None
51         if 'ovs' in scenario or 'fdio' in scenario:
52             self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
53
54         self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)
55
56         self.image_metadata = None
57         if hasattr(config.CONF, 'snaps_images'):
58             self.image_metadata = getattr(config.CONF, 'snaps_images')