aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-07-12 08:31:31 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2018-08-07 05:40:36 +0200
commit12d8254ad80f974d9b733d5262af842c362fb95a (patch)
tree8fd14e0f606f90ee8af3a9ad4c1fd75433a4bfc9
parentf990bd3c8cbac17d4c0d36b18e5debb58a72402c (diff)
Improve dependency management
It avoids declaring dependencies if needed. Negative regex are correcty managed as well. Change-Id: I0e978823526246bc4a5192e63a8a893a4add0e2a Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com> (cherry picked from commit a507f38dc69019523ff02006622eb4ab84cd5ba1)
-rw-r--r--xtesting/ci/run_tests.py4
-rw-r--r--xtesting/ci/testcases.yaml16
-rw-r--r--xtesting/ci/tier_builder.py25
-rw-r--r--xtesting/ci/tier_handler.py12
-rw-r--r--xtesting/tests/unit/ci/test_tier_builder.py6
-rw-r--r--xtesting/utils/env.py2
6 files changed, 26 insertions, 39 deletions
diff --git a/xtesting/ci/run_tests.py b/xtesting/ci/run_tests.py
index ff100334..d77041d2 100644
--- a/xtesting/ci/run_tests.py
+++ b/xtesting/ci/run_tests.py
@@ -22,9 +22,9 @@ import os
import re
import sys
import textwrap
-import pkg_resources
import enum
+import pkg_resources
import prettytable
import six
import yaml
@@ -92,8 +92,6 @@ class Runner(object):
self.clean_flag = True
self.report_flag = False
self.tiers = tier_builder.TierBuilder(
- env.get('INSTALLER_TYPE'),
- env.get('DEPLOY_SCENARIO'),
pkg_resources.resource_filename('xtesting', 'ci/testcases.yaml'))
@staticmethod
diff --git a/xtesting/ci/testcases.yaml b/xtesting/ci/testcases.yaml
index 42e71936..d9ff36c6 100644
--- a/xtesting/ci/testcases.yaml
+++ b/xtesting/ci/testcases.yaml
@@ -13,9 +13,6 @@ tiers:
blocking: true
clean_flag: false
description: ''
- dependencies:
- installer: ''
- scenario: ''
run:
module: 'xtesting.samples.first'
class: 'Test'
@@ -27,9 +24,6 @@ tiers:
blocking: true
clean_flag: false
description: ''
- dependencies:
- installer: ''
- scenario: ''
run:
module: 'xtesting.samples.second'
class: 'Test'
@@ -41,9 +35,6 @@ tiers:
blocking: true
clean_flag: false
description: ''
- dependencies:
- installer: ''
- scenario: ''
run:
module: 'xtesting.core.feature'
class: 'BashFeature'
@@ -57,9 +48,6 @@ tiers:
blocking: true
clean_flag: false
description: ''
- dependencies:
- installer: ''
- scenario: ''
run:
module: 'xtesting.core.unit'
class: 'Suite'
@@ -72,10 +60,8 @@ tiers:
enabled: false
criteria: 100
blocking: false
+ clean_flag: false
description: ''
- dependencies:
- installer: ''
- scenario: ''
run:
module: 'xtesting.core.robotframework'
class: 'RobotFramework'
diff --git a/xtesting/ci/tier_builder.py b/xtesting/ci/tier_builder.py
index 2c7b0cab..a4169099 100644
--- a/xtesting/ci/tier_builder.py
+++ b/xtesting/ci/tier_builder.py
@@ -11,15 +11,16 @@
import yaml
-import xtesting.ci.tier_handler as th
+from xtesting.ci import tier_handler
+from xtesting.utils import env
class TierBuilder(object):
# pylint: disable=missing-docstring
- def __init__(self, ci_installer, ci_scenario, testcases_file):
- self.ci_installer = ci_installer
- self.ci_scenario = ci_scenario
+ def __init__(self, testcases_file):
+ self.ci_installer = env.get('INSTALLER_TYPE')
+ self.ci_scenario = env.get('DEPLOY_SCENARIO')
self.testcases_file = testcases_file
self.dic_tier_array = None
self.tier_objects = []
@@ -40,17 +41,23 @@ class TierBuilder(object):
del self.tier_objects[:]
for dic_tier in self.dic_tier_array:
- tier = th.Tier(
+ tier = tier_handler.Tier(
name=dic_tier['name'], order=dic_tier['order'],
ci_loop=dic_tier['ci_loop'],
description=dic_tier['description'])
for dic_testcase in dic_tier['testcases']:
- installer = dic_testcase['dependencies']['installer']
- scenario = dic_testcase['dependencies']['scenario']
- dep = th.Dependency(installer, scenario)
+ if not dic_testcase.get('dependencies'):
+ installer = '.*'
+ scenario = '.*'
+ else:
+ installer = dic_testcase['dependencies'].get(
+ 'installer', '.*')
+ scenario = dic_testcase['dependencies'].get(
+ 'scenario', '.*')
+ dep = tier_handler.Dependency(installer, scenario)
- testcase = th.TestCase(
+ testcase = tier_handler.TestCase(
name=dic_testcase['case_name'],
enabled=dic_testcase.get('enabled', True),
dependency=dep, criteria=dic_testcase['criteria'],
diff --git a/xtesting/ci/tier_handler.py b/xtesting/ci/tier_handler.py
index 915985f5..0adc9b81 100644
--- a/xtesting/ci/tier_handler.py
+++ b/xtesting/ci/tier_handler.py
@@ -115,15 +115,9 @@ class TestCase(object):
def is_compatible(self, ci_installer, ci_scenario):
try:
- if not ci_installer:
- if self.dependency.get_installer():
- return False
- elif not re.search(self.dependency.get_installer(), ci_installer):
+ if not re.search(self.dependency.get_installer(), ci_installer):
return False
- if not ci_scenario:
- if self.dependency.get_scenario():
- return False
- elif not re.search(self.dependency.get_scenario(), ci_scenario):
+ if not re.search(self.dependency.get_scenario(), ci_scenario):
return False
return True
except TypeError:
@@ -155,7 +149,7 @@ class TestCase(object):
class Dependency(object):
- def __init__(self, installer, scenario):
+ def __init__(self, installer='.*', scenario='.*'):
self.installer = installer
self.scenario = scenario
diff --git a/xtesting/tests/unit/ci/test_tier_builder.py b/xtesting/tests/unit/ci/test_tier_builder.py
index 58a9d9d0..402fc664 100644
--- a/xtesting/tests/unit/ci/test_tier_builder.py
+++ b/xtesting/tests/unit/ci/test_tier_builder.py
@@ -8,6 +8,7 @@
# pylint: disable=missing-docstring
import logging
+import os
import unittest
import mock
@@ -41,8 +42,9 @@ class TierBuilderTesting(unittest.TestCase):
with mock.patch('xtesting.ci.tier_builder.yaml.safe_load',
return_value=self.mock_yaml), \
mock.patch('six.moves.builtins.open', mock.mock_open()):
- self.tierbuilder = tier_builder.TierBuilder(
- 'test_installer', 'test_scenario', 'testcases_file')
+ os.environ["INSTALLER_TYPE"] = 'test_installer'
+ os.environ["DEPLOY_SCENARIO"] = 'test_scenario'
+ self.tierbuilder = tier_builder.TierBuilder('testcases_file')
self.tier_obj = self.tierbuilder.tier_objects[0]
def test_get_tiers(self):
diff --git a/xtesting/utils/env.py b/xtesting/utils/env.py
index 64e9a21d..f17d78a1 100644
--- a/xtesting/utils/env.py
+++ b/xtesting/utils/env.py
@@ -16,7 +16,7 @@ import prettytable
INPUTS = {
'CI_LOOP': 'daily',
'DEPLOY_SCENARIO': 'os-nosdn-nofeature-noha',
- 'INSTALLER_TYPE': None,
+ 'INSTALLER_TYPE': 'unknown',
'BUILD_TAG': None,
'NODE_NAME': None,
'TEST_DB_URL': 'http://testresults.opnfv.org/test/api/v1/results',