[Fuego] [PATCH 05/30] ftc: divide cleanup into pre and postcleanup

Daniel Sangorrin daniel.sangorrin at toshiba.co.jp
Mon Jun 4 07:17:39 UTC 2018


Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
---
 engine/scripts/ftc | 67 +++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 49 insertions(+), 18 deletions(-)

diff --git a/engine/scripts/ftc b/engine/scripts/ftc
index 449b9cf..af399e1 100755
--- a/engine/scripts/ftc
+++ b/engine/scripts/ftc
@@ -25,7 +25,7 @@
 # - add do_run_request - to run a job request from the server
 #    if no arguments, run the next available request on the server
 # - finish do_run_test
-#    - support flags: Reboot, Target_Cleanup, Rebuild
+#    - support flags: Reboot, Rebuild
 #    - get log results into file (switch to subprocess?)
 #    - make Jenkins recognize ftc test result
 # - finish do_set
@@ -717,7 +717,7 @@ class run_class:
         # FIXTHIS - in run_class, convert build.xml startTime from seconds to timestamp
 
         # lower-case some things:
-        for key in ["TESTPLAN", "Reboot", "Rebuild", "Target_Cleanup", "Device"]:
+        for key in ["TESTPLAN", "Reboot", "Rebuild", "Target_PreCleanup", "Target_PostCleanup", "Device"]:
             lkey = key.lower()
             try:
                 self.__dict__[lkey] = self.__dict__[key]
@@ -746,7 +746,8 @@ class run_class:
                 ("testplan_name", "testplan"),
                 ("reboot_flag", "reboot"),
                 ("rebuild_flag", "rebuild"),
-                ("target_cleanup_flag", "target_cleanup"),
+                ("precleanup_flag", "precleanup"),
+                ("postcleanup_flag", "postcleanup"),
                 ("board_name", "device"),
         ]
 
@@ -770,7 +771,7 @@ class run_class:
         self.files = ["devlog.txt", "syslog.before.txt", "syslog.after.txt",
             "testlog.txt", "consolelog.txt", "build.xml"]
         keylist = ["test_name", "timestamp", "num", "host", "board",
-            "result", "device", "reboot", "rebuild", "testplan", "target_cleanup",
+            "result", "device", "reboot", "rebuild", "testplan", "precleanup", "postcleanup",
             "start_time", "description", "duration", "charset", "keep_log",
             "built_on", "workspace", "cause",
             "files"]
@@ -2648,7 +2649,7 @@ def do_run_request(conf, options):
     except:
         error_out("Request %s has invalid board %s" % (req_id, board_name))
 
-    # FIXTHIS - run_request: should process Reboot, Rebuild and Target_cleanup flags
+    # FIXTHIS - run_request: should process Reboot, Rebuild and Pre/Post cleanup flags
     print("Executing test %s on board %s (using %s)" % (test_name, board_name, testplan))
     do_run_test(conf, ['-b', board_name, '-t', test_name, '-p', testplan])
 
@@ -2712,11 +2713,11 @@ class data_class:
         else:
             return item
 
-
+# FIXTHIS: this is dead code
 def write_run_build_xml_file(run_dir, build_data):
     ### the format str needs build_data to have the following attributes:
     # board_name
-    # reboot_flag, rebuild_flag, target_cleanup_flag
+    # reboot_flag, rebuild_flag, precleanup_flag, postcleanup_flag
     #    the flags must be one of (lower case) 'true' or 'false'
     # testplan_name
     # build_number
@@ -2754,9 +2755,14 @@ def write_run_build_xml_file(run_dir, build_data):
           <value>%(rebuild_flag)s</value>
         </hudson.model.BooleanParameterValue>
         <hudson.model.BooleanParameterValue>
-          <name>Target_Cleanup</name>
+          <name>Target_PreCleanup</name>
+          <description></description>
+          <value>%(precleanup_flag)s</value>
+        </hudson.model.BooleanParameterValue>
+        <hudson.model.BooleanParameterValue>
+          <name>Target_PostCleanup</name>
           <description></description>
-          <value>true</value>
+          <value>%(postcleanup_flag)s</value>
         </hudson.model.BooleanParameterValue>
         <hudson.model.StringParameterValue>
           <name>TESTPLAN</name>
@@ -2798,11 +2804,10 @@ def write_run_build_xml_file(run_dir, build_data):
 
     fd.close()
 
-
 def write_build_xml_file(run_dir, build_data):
     ### the format str needs build_data to have the following attributes:
     # board_name
-    # reboot_flag, rebuild_flag, target_cleanup_flag
+    # reboot_flag, rebuild_flag, precleanup_flag, postcleanup_flag
     #    the flags must be one of (lower case) 'true' or 'false'
     # testplan_name
     # build_number
@@ -2840,9 +2845,14 @@ def write_build_xml_file(run_dir, build_data):
           <value>%(rebuild_flag)s</value>
         </hudson.model.BooleanParameterValue>
         <hudson.model.BooleanParameterValue>
-          <name>Target_Cleanup</name>
+          <name>Target_PreCleanup</name>
+          <description></description>
+          <value>%(precleanup_flag)s</value>
+        </hudson.model.BooleanParameterValue>
+        <hudson.model.BooleanParameterValue>
+          <name>Target_PostCleanup</name>
           <description></description>
-          <value>true</value>
+          <value>%(postcleanup_flag)s</value>
         </hudson.model.BooleanParameterValue>
         <hudson.model.StringParameterValue>
           <name>TESTPLAN</name>
@@ -2994,7 +3004,8 @@ def do_put_request(conf, options):
             "board": board,
             "reboot": reboot,
             "rebuild": "False",
-            "target_cleanup": "False",
+            "precleanup": "True",
+            "postcleanup": "True",
             "testplan": plan,
             "requestor": "Tim",
             }
@@ -3146,6 +3157,26 @@ def do_run_test(conf, options):
         options.remove('-p')
         os.environ["FUEGO_TEST_PHASES"] = test_phases
 
+    if '--precleanup' in options:
+        try:
+            precleanup = options[options.index('--precleanup') + 1]
+        except IndexError:
+            error_out('Precleanup option not provided after --precleanup')
+        if precleanup not in ['true', 'false']:
+            error_out("Invalid precleanup option '%s'" % precleanup)
+    else:
+        precleanup = 'true'
+
+    if '--postcleanup' in options:
+        try:
+            postcleanup = options[options.index('--postcleanup') + 1]
+        except IndexError:
+            error_out('Postcleanup option not provided after --postcleanup')
+        if postcleanup not in ['true', 'false']:
+            error_out("Invalid postcleanup option '%s'" % postcleanup)
+    else:
+        postcleanup = 'true'
+
     # detect whether this is a Jenkins job or not:
     try:
         jenkins_url = os.environ("JENKINS_URL")
@@ -3193,7 +3224,8 @@ def do_run_test(conf, options):
     # FIXTHIS - do_run_test: read flag options (e.g. reboot) from command line (from 'options')
     build_data.reboot_flag = "false"
     build_data.rebuild_flag = "false"
-    build_data.target_cleanup_flag = "true"
+    build_data.precleanup_flag = precleanup
+    build_data.postcleanup_flag = postcleanup
 
     # FIXTHIS - do_run_test: set job description
     # set job description in run json file
@@ -3269,9 +3301,8 @@ def do_run_test(conf, options):
 
     os.environ["Reboot"] = build_data.reboot_flag
     os.environ["Rebuild"] = build_data.rebuild_flag
-    # FIXTHIS - do_run_test: support separate pre and post cleanup flags
-    os.environ["Target_PreCleanup"] = build_data.target_cleanup_flag
-    os.environ["Target_PostCleanup"] = build_data.target_cleanup_flag
+    os.environ["Target_PreCleanup"] = build_data.precleanup_flag
+    os.environ["Target_PostCleanup"] = build_data.postcleanup_flag
 
     # cd to buildzone directory
     saved_cur_dir = os.getcwd()
-- 
2.7.4




More information about the Fuego mailing list