浏览代码

Merge pull request #14704 from AttilaVamos/HPCC-25341-impr-7.12.x

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

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 4 年之前
父节点
当前提交
275ce9251c
共有 2 个文件被更改,包括 23 次插入4 次删除
  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=[]