Move copper.py to functest repo 45/16345/5
authorblsaws <bryan.sullivan@att.com>
Mon, 4 Jul 2016 23:21:45 +0000 (16:21 -0700)
committerJose Lausuch <jose.lausuch@ericsson.com>
Wed, 6 Jul 2016 06:17:40 +0000 (06:17 +0000)
JIRA:COPPER-4

Fix minor flake8 issues
Fix PASS|FAIL to match requirements

Change-Id: I91d5ace36c31e4aa189422d8ec20467565e3c4d7
Signed-off-by: blsaws <bryan.sullivan@att.com>
testcases/features/copper.py [new file with mode: 0755]

diff --git a/testcases/features/copper.py b/testcases/features/copper.py
new file mode 100755 (executable)
index 0000000..54136a8
--- /dev/null
@@ -0,0 +1,80 @@
+#!/usr/bin/python\r
+#\r
+# Copyright 2016 AT&T Intellectual Property, Inc\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+#\r
+\r
+import os\r
+import time\r
+import yaml\r
+\r
+import functest.utils.functest_logger as ft_logger\r
+import functest.utils.functest_utils as functest_utils\r
+\r
+with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:\r
+    functest_yaml = yaml.safe_load(f)\r
+\r
+dirs = functest_yaml.get('general').get('directories')\r
+FUNCTEST_REPO = dirs.get('dir_repo_functest')\r
+COPPER_REPO = dirs.get('dir_repo_copper')\r
+TEST_DB_URL = functest_yaml.get('results').get('test_db_url')\r
+\r
+logger = ft_logger.Logger("copper").getLogger()\r
+\r
+\r
+def main():\r
+    cmd = ('%s/tests/run.sh' % COPPER_REPO)\r
+    start_time = time.time()\r
+\r
+    ret = functest_utils.execute_command(cmd, logger, exit_on_error=False)\r
+\r
+    stop_time = time.time()\r
+    duration = round(stop_time - start_time, 1)\r
+    if ret == 0:\r
+        logger.info("COPPER PASSED")\r
+        test_status = 'PASS'\r
+    else:\r
+        logger.info("COPPER FAILED")\r
+        test_status = 'FAIL'\r
+\r
+    details = {\r
+        'timestart': start_time,\r
+        'duration': duration,\r
+        'status': test_status,\r
+    }\r
+    pod_name = functest_utils.get_pod_name(logger)\r
+    scenario = functest_utils.get_scenario(logger)\r
+    version = functest_utils.get_version(logger)\r
+    build_tag = functest_utils.get_build_tag(logger)\r
+\r
+    logger.info("Pushing COPPER results: TEST_DB_URL=%(db)s pod_name=%(pod)s "\r
+                "version=%(v)s scenario=%(s)s criteria=%(c)s details=%(d)s" % {\r
+                    'db': TEST_DB_URL,\r
+                    'pod': pod_name,\r
+                    'v': version,\r
+                    's': scenario,\r
+                    'c': details['status'],\r
+                    'b': build_tag,\r
+                    'd': details,\r
+                })\r
+    functest_utils.push_results_to_db("COPPER",\r
+                                      "COPPER-notification",\r
+                                      logger,\r
+                                      start_time,\r
+                                      stop_time,\r
+                                      details['status'],\r
+                                      details)\r
+\r
+if __name__ == '__main__':\r
+    main()\r