summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolodymyr Shypyguzov <vshypyguzov@mirantis.com>2016-12-07 16:42:43 +0200
committerVolodymyr Shypyguzov <vshypyguzov@mirantis.com>2016-12-07 16:42:43 +0200
commit493dc8b27aac4bd1c75f7cd33d82797d37a2b9a1 (patch)
treed3502cef04d51bfb7c653cb74bd527250351f2f0
parentb1fb1706d2a5bf9f8f52beef2f8a6ed3eaade5d7 (diff)
Refactor fixtures that check required files and settings
Refactor those fixtures in a more general way, so they can be used in any test, not only netchecker one. Just set class variables required_files and required_settings to use them In that way all required files and settings will be in the test class, and not in the fixture itself. Change-Id: I27eb98e46978205f4a4e9769e368d4720e2f8b55
Notes
Notes (review): Verified+1: Mirantis CCP CI <mirantis-fuel-ccp-ci@mirantis.com> Code-Review+1: tatyana-leontovich <tleontovich@mirantis.com> Code-Review+2: Artem Panchenko <apanchenko@mirantis.com> Workflow+1: Volodymyr Shypyguzov <vshypyguzov@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 07 Dec 2016 15:55:07 +0000 Reviewed-on: https://review.openstack.org/408147 Project: openstack/fuel-ccp-tests Branch: refs/heads/master
-rw-r--r--fuel_ccp_tests/fixtures/k8s_fixtures.py27
-rw-r--r--fuel_ccp_tests/tests/system/test_netchecker.py10
2 files changed, 17 insertions, 20 deletions
diff --git a/fuel_ccp_tests/fixtures/k8s_fixtures.py b/fuel_ccp_tests/fixtures/k8s_fixtures.py
index 068b452..3bcf0b0 100644
--- a/fuel_ccp_tests/fixtures/k8s_fixtures.py
+++ b/fuel_ccp_tests/fixtures/k8s_fixtures.py
@@ -85,28 +85,21 @@ def k8scluster(revert_snapshot, request, config,
85 85
86 86
87@pytest.fixture(scope='class') 87@pytest.fixture(scope='class')
88def check_netchecker_files(request): 88def check_files_missing(request):
89 files_missing = [] 89 LOG.info("Required files: {}".format(request.cls.required_files))
90 for arg in request.cls.netchecker_files: 90 files_missing = [f for f in request.cls.required_files
91 if not os.path.isfile(arg): 91 if not os.path.isfile(f)]
92 files_missing.append(arg)
93 assert len(files_missing) == 0, \ 92 assert len(files_missing) == 0, \
94 ("The following netchecker files not found: " 93 "Following files are not found {0}".format(files_missing)
95 "{0}!".format(', '.join(files_missing)))
96 94
97 95
98@pytest.fixture(scope='class') 96@pytest.fixture(scope='class')
99def check_netchecker_images_settings(): 97def check_settings_missing(request):
100 settings_missing = [] 98 LOG.info("Required settings: {}".format(request.cls.required_settings))
101 for setting in ('MCP_NETCHECKER_AGENT_IMAGE_REPO', 99 settings_missing = [s for s in request.cls.required_settings
102 'MCP_NETCHECKER_AGENT_VERSION', 100 if not getattr(settings, s, None)]
103 'MCP_NETCHECKER_SERVER_IMAGE_REPO',
104 'MCP_NETCHECKER_SERVER_VERSION'):
105 if not getattr(settings, setting, None):
106 settings_missing.append(setting)
107 assert len(settings_missing) == 0, \ 101 assert len(settings_missing) == 0, \
108 ("The following environment variables are not set: " 102 "Following env variables are not set {}". format(settings_missing)
109 "{0}!".format(', '.join(settings_missing)))
110 103
111 104
112@pytest.fixture(scope='class') 105@pytest.fixture(scope='class')
diff --git a/fuel_ccp_tests/tests/system/test_netchecker.py b/fuel_ccp_tests/tests/system/test_netchecker.py
index 28a947a..953d93a 100644
--- a/fuel_ccp_tests/tests/system/test_netchecker.py
+++ b/fuel_ccp_tests/tests/system/test_netchecker.py
@@ -27,6 +27,11 @@ LOG = logger.logger
27 27
28class TestFuelCCPNetCheckerMixin: 28class TestFuelCCPNetCheckerMixin:
29 29
30 required_settings = ('MCP_NETCHECKER_AGENT_IMAGE_REPO',
31 'MCP_NETCHECKER_AGENT_VERSION',
32 'MCP_NETCHECKER_SERVER_IMAGE_REPO',
33 'MCP_NETCHECKER_SERVER_VERSION')
34
30 kube_settings = settings.DEFAULT_CUSTOM_YAML 35 kube_settings = settings.DEFAULT_CUSTOM_YAML
31 kube_settings['deploy_netchecker'] = False 36 kube_settings['deploy_netchecker'] = False
32 37
@@ -38,7 +43,7 @@ class TestFuelCCPNetCheckerMixin:
38 'k8s_resources/netchecker-server_svc.yaml') 43 'k8s_resources/netchecker-server_svc.yaml')
39 ds_yaml_file = os.path.join( 44 ds_yaml_file = os.path.join(
40 settings.NETCHECKER_AGENT_DIR, 'netchecker-agent.yaml') 45 settings.NETCHECKER_AGENT_DIR, 'netchecker-agent.yaml')
41 netchecker_files = (pod_yaml_file, svc_yaml_file, ds_yaml_file) 46 required_files = (pod_yaml_file, svc_yaml_file, ds_yaml_file)
42 47
43 @property 48 @property
44 def pod_spec(self): 49 def pod_spec(self):
@@ -62,8 +67,7 @@ class TestFuelCCPNetCheckerMixin:
62 return [i for i in yaml.load_all(ds_conf)] 67 return [i for i in yaml.load_all(ds_conf)]
63 68
64 69
65@pytest.mark.usefixtures("check_netchecker_files") 70@pytest.mark.usefixtures("check_files_missing", "check_settings_missing")
66@pytest.mark.usefixtures("check_netchecker_images_settings")
67class TestFuelCCPNetChecker(base_test.SystemBaseTest, 71class TestFuelCCPNetChecker(base_test.SystemBaseTest,
68 TestFuelCCPNetCheckerMixin): 72 TestFuelCCPNetCheckerMixin):
69 """Test class for network connectivity verification in k8s""" 73 """Test class for network connectivity verification in k8s"""