Browse Source

HPCC-25341 Add option to regression suite to execute an arbitrary command/script before aborting

Add new parameter '--preAbort' with 'None' by default value

Handle when preAbort is not 'None', execute the command and store its stdout
and stderr in same place where the other regression logs are stored under the
'[WUID]-preAbort.log' name.

Tested manually.

Signed-off-by: Attila Vamos <attila.vamos@gmail.com>
Attila Vamos 4 years ago
parent
commit
73ed452419
2 changed files with 23 additions and 4 deletions
  1. 5 2
      testing/regress/ecl-test
  2. 18 2
      testing/regress/hpcc/util/util.py

+ 5 - 2
testing/regress/ecl-test

@@ -193,8 +193,7 @@ class RegressMain:
         helperParser.add_argument('--config', help="Config file to use. Default: ecl-test.json",
                             nargs='?', default=defaultConfigFile)
         helperParser.add_argument('--loglevel', help="Set the log level. Use debug for more detailed logfile.",
-                            nargs='?', default="info",
-                            choices=['info', 'debug'])
+                            nargs='?', default="info", choices=['info', 'debug'])
 
         commonParser=argparse.ArgumentParser(add_help=False)
         commonParser.add_argument('--suiteDir', '-s', help="SuiteDir to use. Default value is the current directory and it can handle relative path.",
@@ -237,6 +236,8 @@ class RegressMain:
                                 action = 'store_true')
         executionParser.add_argument('--createEclRunArg', help="Generate ECL tool command line.",
                                 action='store_true')
+        executionParser.add_argument('--preAbort', help="Execute an arbitrary command/script before aborting	.",
+                                default=None,  metavar='preAbortscriptName')
 
 
         parser = argparse.ArgumentParser(prog=prog, description=description,  parents=[helperParser, commonParser,  executionParser])
@@ -363,6 +364,8 @@ class RegressMain:
                 exit(err.getErrorCode())
         else:
             self.config.set('generateStackTrace', False)
+    
+        self.config.set('preAbort', self.args.preAbort)
 
         self.config.set('log',  self.log)
         setConfig(self.config)

+ 18 - 2
testing/regress/hpcc/util/util.py

@@ -222,11 +222,27 @@ def abortWorkunit(wuid, taskId = -1, engine = None):
                 pass
             else:
                 err = Error("7100")
-                logger.error("%s. clearOSCache error:%s" % (taskId,  err))
+                logger.error("%s. generateStackTrace error:%s" % (taskId,  err))
                 logger.error(traceback.format_exc())
                 raise Error(err)
                 pass
-
+        
+        if gConfig.preAbort != None:
+            try:
+                logger.error("%3d. Execute pre abort script '%s'", taskId, str(gConfig.preAbort))
+                outFile = os.path.expanduser(gConfig.logDir) + '/' + wuid +'-preAbort.log'
+                
+                command=gConfig.preAbort + " > " + outFile + " 2>&1"
+                myProc = subprocess.Popen([ command ],  shell=True,  bufsize=8192,  stdout=subprocess.PIPE,  stderr=subprocess.PIPE)
+                result = myProc.stdout.read() + myProc.stderr.read()
+                
+                logger.debug("%3d. Pre abort script result '%s'", taskId, wuid, str(result))
+                logger.error("%3d. Pre abort script result stored into '%s'", taskId, outFile)
+            except Exception as e:
+                printException("preAbort scrip:" + repr(e),  True)
+                logger.error("%3d. Exception in executing pre abort script: '%s'", taskId, repr(e))
+            pass
+            
         shell = Shell()
         cmd = 'ecl'
         defaults=[]