- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2020 11:44 AM
I am building some ATF Tests to test out various workflows that we have. Some of them have Timers in them (i.e. wait 5 minutes, wait 10 days before expiration). How can I write ATF tests for those workflows which have timers in them that cause "a pause" in time, waiting for time to pass before proceeding to the next step? Is there some command we can add to the ATF testing to tell it that a certain amount of time has passed? Or will it just ignore timers and go to the next step in the workflow?
Thanks
Solved! Go to Solution.
- Labels:
-
Automated Test Framework

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 02:24 PM
Basically, I haven't built out the Description script, I was more interested in having the execution do what I was looking to do.
Here is a screen capture of the part of the test that will move the change request forward...update the timer...
The script that I wrote inside of the Test "Update Change Request Scheduled Job..." to execute the timer activity on the workflow is the following, and it only needs the sys_id of the change request form as the input to query its way thru tables to get to the correct sys_trigger table. There are no outputs. The step just updates the timer for 2 minutes past the time it gets when the step runs and then the step sleeps for 2 minutes to allow the trigger job to actually run.
(function executeStep(inputs, outputs, stepResult, timeout) {
var cntxID = '';
var wfVerID = '';
var actvID = '';
var execID = '';
var nextAction = 'No';
//----Get Current Date Time
var gdt = new GlideDateTime();
var schdt = new GlideDateTime();
gdt.addSeconds(-10680); //Convert Time to Central + 2 minutes
//---------------------------------
var wfcontext = new GlideRecord('wf_context');
wfcontext.addQuery('id', inputs.u_request);
wfcontext.query();
if (wfcontext.next()) {
cntxID = wfcontext.sys_id;
wfVerID = wfcontext.workflow_version;
}
var wfactivity = new GlideRecord('wf_activity');
wfactivity.addQuery('name', 'Wait for CR Planned Start Date');
wfactivity.addQuery('workflow_version.sys_id', wfVerID);
wfactivity.query();
if (wfactivity.next()) {
actvID = wfactivity.sys_id;
}
if (cntxID != '') {
var wfexec = new GlideRecord('wf_executing');
wfexec.addQuery('context.sys_id', cntxID);
wfexec.addQuery('activity', actvID);
wfexec.query();
if (wfexec.next()) {
execID = wfexec.sys_id;
}
}
if (execID != '') {
var sched = new GlideRecord('sys_trigger');
sched.addQuery('document_key', execID);
sched.query();
if (sched.next()) {
schdt = sched.next_action;
sched.next_action = gdt;
nextAction = 'Yes';
sched.update();
}
}
gs.sleep('120000'); //2 Minutes
if (nextAction == 'Yes') {
stepResult.setSuccess();
stepResult.setOutputMessage = "Original Planned Start of " + schdt + " changed to " + gdt;
} else {
stepResult.setFailed();
}
}(inputs, outputs, stepResult, timeout));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 02:39 PM
Hi jmiskey
Basically, I'm referring to sys_trigger table, when I mentioned "schedule". The workflow timer activity puts a transaction in this table for when the action should occur whether that be in a few minutes or few days. My ATF is to create an end to end change request for a single customized path. There are some rules built in the change request process that requires the Planned Start Date to be in the future for it to be a Normal Change, therefore, I built a step to update the dates to be a week out from the current date and the step is configurable to pick the number of days you want it to add. My test was good until the workflow got to the point where the workflow was waiting on a timer of the Planned Start Date, which was a week away. So I built another server step that will update the Next Action Date in the sys_trigger table for the specific transaction line to be 2 minutes away from the current date time. (that gives the trigger time to process it to run) I had to make the step wait for 2 minutes so that in the next step I could check to make sure that the change request had moved to a Deploy State...which it did! Does this help?
Thanks,
Trena
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2020 07:23 AM
That just might work for me.
Would you mind posting an example, with the steps and code shown?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2020 11:44 AM
I understand the basic premise of what you are doing, it is just some of the details that are tripping me up, such how to identify which sys_trigger records need updating (I have never worked with the sys_trigger table before, and do not see an obvious connection to the Task).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 12:32 PM
Hi Trena,
I think it would be very helpful if you were to provide us with your 'Description generation script', and 'Step execution script' for the new Step Configuration you say you built. Providing us with the Input and Output variables will also be very helpful as well.
Thanks,
- Gerald

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2020 02:24 PM
Basically, I haven't built out the Description script, I was more interested in having the execution do what I was looking to do.
Here is a screen capture of the part of the test that will move the change request forward...update the timer...
The script that I wrote inside of the Test "Update Change Request Scheduled Job..." to execute the timer activity on the workflow is the following, and it only needs the sys_id of the change request form as the input to query its way thru tables to get to the correct sys_trigger table. There are no outputs. The step just updates the timer for 2 minutes past the time it gets when the step runs and then the step sleeps for 2 minutes to allow the trigger job to actually run.
(function executeStep(inputs, outputs, stepResult, timeout) {
var cntxID = '';
var wfVerID = '';
var actvID = '';
var execID = '';
var nextAction = 'No';
//----Get Current Date Time
var gdt = new GlideDateTime();
var schdt = new GlideDateTime();
gdt.addSeconds(-10680); //Convert Time to Central + 2 minutes
//---------------------------------
var wfcontext = new GlideRecord('wf_context');
wfcontext.addQuery('id', inputs.u_request);
wfcontext.query();
if (wfcontext.next()) {
cntxID = wfcontext.sys_id;
wfVerID = wfcontext.workflow_version;
}
var wfactivity = new GlideRecord('wf_activity');
wfactivity.addQuery('name', 'Wait for CR Planned Start Date');
wfactivity.addQuery('workflow_version.sys_id', wfVerID);
wfactivity.query();
if (wfactivity.next()) {
actvID = wfactivity.sys_id;
}
if (cntxID != '') {
var wfexec = new GlideRecord('wf_executing');
wfexec.addQuery('context.sys_id', cntxID);
wfexec.addQuery('activity', actvID);
wfexec.query();
if (wfexec.next()) {
execID = wfexec.sys_id;
}
}
if (execID != '') {
var sched = new GlideRecord('sys_trigger');
sched.addQuery('document_key', execID);
sched.query();
if (sched.next()) {
schdt = sched.next_action;
sched.next_action = gdt;
nextAction = 'Yes';
sched.update();
}
}
gs.sleep('120000'); //2 Minutes
if (nextAction == 'Yes') {
stepResult.setSuccess();
stepResult.setOutputMessage = "Original Planned Start of " + schdt + " changed to " + gdt;
} else {
stepResult.setFailed();
}
}(inputs, outputs, stepResult, timeout));