TA的每日心情 | 无聊 2024-7-12 13:16 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
2#
楼主 |
发表于 2017-7-19 16:17:07
|
只看该作者
任务列表处理流程
下面给出了 queuemgr.xml 中定义的函数 check-queue 的代码。它被 queuemgr.xml 的 main 函数在初始化各种全局变量后调用。实现自动执行任务队列的 STAX 脚本代码如下。
清单 1. queuemgr.xml 中的 check-queue 函数
<function name="check-queue">
<sequence>
<block name="'Queue Manager'">
<sequence>
<stafcmd name="'Check Queue'">
<location>'local'</location>
<service>'FS'</service>
<request>'LIST DIRECTORY %s TYPE F SORTBYNAME' % queueDir</request>
</stafcmd>
<script>dirList = STAFResult</script>
<script>taskCount = len(dirList)</script>
<script>
if (taskCount != 0): # skip an empty list
taskParam = dirList[0] # get first entry
else:
taskParam = "empty"
</script>
<if expr=" taskParam != 'empty'">
<if expr=" lastTaskParam != taskParam">
<sequence>
<if expr="TestRunInProgress[0] == 0">
<script>
TestRunInProgress[0] = 1
TestRunStartTime[0] = now()
</script>
</if>
<script>TestRunCtr[0] = TestRunCtr[0] + 1</script>
<script> lastTaskParam = taskParam </script>
<script> lastTaskParamJobID = taskParamJobID </script>
<log>'QueueMgr: Executing taskParam %s' %(taskParam)</log>
<stafcmd name="'Executing Task: %s' % taskParam">
<location>'local'</location>
<service>'STAX'</service>
<request>'EXECUTE FILE %s CLEARLOGS JOBNAME %s SCRIPT " taskParam=\'%s\'" WAIT
%s' %(TestExecuteFile, taskParam, taskParam,gblTestExecutionTimeoutMS)</request>
</stafcmd>
<script> taskParamJobID = STAFResult</script>
<log>'QueueMgr: taskParam %s JobID = %s' %( taskParam, taskParamJobID)</log>
<if expr="RC != STAFRC.Ok">
<sequence>
<log>'QueueMgr: Execute Test with Param File %s failed - RC: %s STAFResult: %s'
%( taskParam,RC,STAFResult)</log>
<terminate block="'main'"/>
</sequence>
</if>
</sequence>
<else>
<sequence>
<log>'QueueMgr: *** TERMINATING Queue Manager *** Task File %s is the same as the
last one' %( taskParam)</log>
<log>'QueueMgr: Please check the completion status of Test Record %s Job ID %s
and Re-Start the Queue Manager' %( lastTaskParam, lastTaskParamJobID)</log>
<terminate block="'main'"/>
</sequence>
</else>
</if>
<else>
<sequence>
<if expr="TestRunInProgress[0] == 1">
<sequence>
<script>
TestRunInProgress[0] = 0
TestRunStopTime[0] = now()
testTime = (TestRunStopTime[0] - TestRunStartTime[0])
testHrs = int((testTime) / 3600)
testMin = int((testTime - (testHrs * 3600)) / 60)
testSec = int((testTime - (testHrs * 3600)) - (testMin * 60))
TestRunCompletionDateTime = strftime('%a %b %d %Y %H:%M:%S', localtime())
</script>
<log>'All tests have been run; the testqueue is empty'</log>
<log>'Test Run Completed: %s' % TestRunCompletionDateTime</log>
<log>'%d Test Tasks Were Completed In %d Hrs %d Min %d Sec'
% (TestRunCtr[0],testHrs,testMin,testSec)</log>
<script>TestRunCtr[0] = 0</script>
<terminate block="'main'"/>
</sequence>
</if>
<block name="'Queue Check Delay'">
<stafcmd name="'Checking TestQueue Every 5000 Sec' % gblCheckQueueDelayTimeSec">
<location>'local'</location>
<service>'DELAY'</service>
<request>'DELAY 5000'</request>
</stafcmd>
</block>
</sequence>
</else>
</if>
<block name="'Queue Process Delay'">
<stafcmd name="'Checking TestQueue 5000 Sec After Last Task'">
<location>'local'</location>
<service>'DELAY'</service>
<request>'DELAY 5000'</request>
</stafcmd>
</block>
</sequence>
</block>
</sequence>
</function>
|
|