aboutsummaryrefslogtreecommitdiffstats
path: root/ci/tier_builder.py
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-04-25 18:08:22 +0200
committerjose.lausuch <jose.lausuch@ericsson.com>2016-04-27 15:34:56 +0200
commit9c13968cdb32806da738dc520d45270e019f0ad3 (patch)
tree50eb0e0889dc72a1ce4dec0da60607c834d91fc0 /ci/tier_builder.py
parent790fa04f4503dbf60123bf9414db131580f2c45a (diff)
Create prepare_env.py from prepare_env.sh and config_functest.py
JIRA: FUNCTEST-227 Change-Id: I1aa890b9f91ec524c766ba3c460666ed227f2126 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'ci/tier_builder.py')
-rw-r--r--ci/tier_builder.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/ci/tier_builder.py b/ci/tier_builder.py
new file mode 100644
index 000000000..e66e97a38
--- /dev/null
+++ b/ci/tier_builder.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+#
+# jose.lausuch@ericsson.com
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+import yaml
+
+import tier_handler as th
+
+
+class TierBuilder:
+ def __init__(self, ci_installer, ci_scenario, testcases_file):
+ self.ci_installer = ci_installer
+ self.ci_scenario = ci_scenario
+ self.testcases_file = testcases_file
+ self.dic_tier_array = None
+ self.tier_objects = []
+ self.testcases_yaml = None
+ self.generate_tiers()
+
+ def read_test_yaml(self):
+ with open(self.testcases_file) as f:
+ self.testcases_yaml = yaml.safe_load(f)
+
+ self.dic_tier_array = []
+ for tier in self.testcases_yaml.get("tiers"):
+ self.dic_tier_array.append(tier)
+
+ def generate_tiers(self):
+ if self.dic_tier_array is None:
+ self.read_test_yaml()
+
+ del self.tier_objects[:]
+ for dic_tier in self.dic_tier_array:
+ tier = th.Tier(name=dic_tier['name'],
+ order=dic_tier['order'],
+ ci=dic_tier['ci'],
+ 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)
+
+ testcase = th.TestCase(name=dic_testcase['name'],
+ dependency=dep,
+ description=dic_testcase['description'])
+ if testcase.is_compatible(self.ci_installer, self.ci_scenario):
+ tier.add_test(testcase)
+
+ self.tier_objects.append(tier)
+
+ def __str__(self):
+ output = ""
+ for i in range(0, len(self.tier_objects)):
+ output += str(self.tier_objects[i]) + "\n"
+ return output