[Fuego] [PATCH] run packages: attach the files specified in run json

Daniel Sangorrin daniel.sangorrin at toshiba.co.jp
Tue Jan 15 07:57:20 UTC 2019


The implementation looks a bit redundant to me but it
follows the existing code guidelines of using the run class
methods.

Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
---
 engine/scripts/ftc              | 41 ++++++++++++++++++++++++++++++++++-------
 engine/scripts/parser/common.py |  8 ++++++++
 2 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/engine/scripts/ftc b/engine/scripts/ftc
index f399d05..bb7b2f3 100755
--- a/engine/scripts/ftc
+++ b/engine/scripts/ftc
@@ -763,6 +763,9 @@ class run_class:
     def get_devlog_path(self):
         return self.logpath+"/devlog.txt"
 
+    def get_machinesnapshot_path(self):
+        return self.logpath+"/machine-snapshot.txt"
+
     def get_systemlog_path(self, suffix):
         # suffix should be "before" or "after"
         return self.logpath+"/syslog.%s.txt" % suffix
@@ -776,6 +779,12 @@ class run_class:
     def get_consolelog_path(self):
         return self.logpath+"/consolelog.txt"
 
+    def get_strippedspec_path(self):
+        return self.logpath+"/spec.json"
+
+    def get_prolog_path(self):
+        return self.logpath+"/prolog.sh"
+
     # FIXTHIS - remove deprecated routine get_run_data_from_buildxml()
     # this routine is not called from anywhere, and is left over
     # from when we relied on Jenkins for run meta-data (to populate
@@ -4410,13 +4419,31 @@ def do_package_run(conf, options):
     copy2(jpath, tmp_run_dir+"/run.json")
 
     #print run.__dict__
-
-    copy2(run.get_testlog_path(), tmp_run_dir+"/testlog.txt")
-    copy2(run.get_devlog_path(), tmp_run_dir+"/devlog.txt")
-    copy2(run.get_systemlog_path("before"), tmp_run_dir+"/syslog.before.txt")
-    copy2(run.get_systemlog_path("after"), tmp_run_dir+"/devlog.after.txt")
-    copy2(run.get_consolelog_path(), tmp_run_dir+"/consolelog.txt")
-    copy2(run.get_buildxml_path(), tmp_run_dir+"/build.xml")
+    with open(tmp_run_dir+"/run.json") as f:
+        json_data = json.load(f)
+
+    for attachment in json_data['metadata']['attachments']:
+        name = attachment['name']
+        path = attachment['path']
+        abs_path = tmp_run_dir + os.sep + path
+        if name == "devlog":
+            copy2(run.get_devlog_path(), abs_path)
+        elif name == "snapshot":
+            copy2(run.get_machinesnapshot_path(), abs_path)
+        elif name in ["syslog.before", "syslog.after"]:
+            copy2(run.get_systemlog_path(name.split('.')[1]), abs_path)
+        elif name == "testlog":
+            copy2(run.get_testlog_path(), abs_path)
+        elif name == "build_xml":
+            copy2(run.get_buildxml_path(), abs_path)
+        elif name == "consolelog":
+            copy2(run.get_consolelog_path(), abs_path)
+        elif name == "test_spec":
+            copy2(run.get_strippedspec_path(), abs_path)
+        elif name == "prolog":
+            copy2(run.get_prolog_path(), abs_path)
+        else:
+            error_out("attachment %s not supported" % name)
 
     #print("some data should be in %s" % tmp_run_dir)
 
diff --git a/engine/scripts/parser/common.py b/engine/scripts/parser/common.py
index 63e3106..36f112d 100644
--- a/engine/scripts/parser/common.py
+++ b/engine/scripts/parser/common.py
@@ -609,12 +609,20 @@ def prepare_run_data(results, criteria_data):
                     "path":"testlog.txt"
                 },
                 {
+                    "name":"build_xml",
+                    "path":"build.xml"
+                },
+                {
                     "name":"consolelog",
                     "path":"consolelog.txt"
                 },
                 {
                     "name":"test_spec",
                     "path":"spec.json"
+                },
+                {
+                    "name":"prolog",
+                    "path":"prolog.sh"
                 }
             ]
         }
-- 
2.7.4



More information about the Fuego mailing list