3 # Copyright 2016 AT&T Intellectual Property, Inc
\r
5 # Licensed under the Apache License, Version 2.0 (the "License");
\r
6 # you may not use this file except in compliance with the License.
\r
7 # You may obtain a copy of the License at
\r
9 # http://www.apache.org/licenses/LICENSE-2.0
\r
11 # Unless required by applicable law or agreed to in writing, software
\r
12 # distributed under the License is distributed on an "AS IS" BASIS,
\r
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 # See the License for the specific language governing permissions and
\r
15 # limitations under the License.
\r
21 import functest.utils.functest_logger as ft_logger
\r
22 import functest.utils.functest_utils as functest_utils
\r
26 with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
\r
27 functest_yaml = yaml.safe_load(f)
\r
29 dirs = functest_yaml.get('general').get('directories')
\r
30 FUNCTEST_REPO = dirs.get('dir_repo_functest')
\r
31 COPPER_REPO = dirs.get('dir_repo_copper')
\r
32 TEST_DB_URL = functest_yaml.get('results').get('test_db_url')
\r
34 logger = ft_logger.Logger("copper").getLogger()
\r
38 cmd = "%s/tests/run.sh %s/tests" % (COPPER_REPO, COPPER_REPO)
\r
40 start_time = time.time()
\r
42 ret_val = functest_utils.execute_command(cmd, logger, exit_on_error=False)
\r
44 stop_time = time.time()
\r
45 duration = round(stop_time - start_time, 1)
\r
47 logger.info("COPPER PASSED")
\r
48 test_status = 'PASS'
\r
50 logger.info("COPPER FAILED")
\r
51 test_status = 'FAIL'
\r
54 'timestart': start_time,
\r
55 'duration': duration,
\r
56 'status': test_status,
\r
58 pod_name = functest_utils.get_pod_name(logger)
\r
59 scenario = functest_utils.get_scenario(logger)
\r
60 version = functest_utils.get_version(logger)
\r
61 build_tag = functest_utils.get_build_tag(logger)
\r
63 logger.info("Pushing COPPER results: TEST_DB_URL=%(db)s pod_name=%(pod)s "
\r
64 "version=%(v)s scenario=%(s)s criteria=%(c)s details=%(d)s" % {
\r
69 'c': details['status'],
\r
73 functest_utils.push_results_to_db("COPPER",
\r
74 "COPPER-notification",
\r
85 if __name__ == '__main__':
\r