Skip to content

Commit 1469c57

Browse files
authored
Business Rule for Atf duplicate execution order identification (#814)
* Create ATF_Duplicate_Execution_order.js Executes a business rule to find duplicate execution orders in ATF. * Create readme.md Readme file for executes a business rule to find duplicate execution orders in ATF.
1 parent 33bd214 commit 1469c57

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Executes a business rule to find duplicate execution orders in ATF.
3+
* @Table sys_atf_test
4+
* @param {GlideRecord} current - The current GlideRecord object.
5+
* @param {GlideRecord} previous - The previous GlideRecord object. (null when async)
6+
* @returns {undefined}
7+
*/
8+
9+
(function executeRule(current, previous /*null when async*/) {
10+
var order_array = testDuplicateTestStepExectionOrder(current.sys_id);
11+
12+
if (order_array.length > 0)
13+
gs.addErrorMessage('WARNING: Test steps with duplicate Execution order: [' + order_array + '].');
14+
15+
})(current, previous);
16+
17+
18+
/**
19+
* Returns an array of active tests that have at least two active test steps with the same execution order.
20+
* @param {string} testSysId - The sys_id of the test.
21+
* @returns {Array} An array of sys_ids or order numbers.
22+
*/
23+
24+
function testDuplicateTestStepExectionOrder (testSysId) {
25+
26+
//if tests_sys_id has a value then return itself if the test fails
27+
var result = [];
28+
29+
var ga = new GlideAggregate('sys_atf_step');
30+
31+
if (test_sys_id)
32+
ga.addQuery('test.sys_id', test_sys_id);
33+
34+
ga.addQuery('active', 'true');
35+
36+
ga.addAggregate('COUNT');
37+
38+
ga.groupBy('test');
39+
ga.groupBy('order');
40+
41+
ga.query();
42+
43+
while (ga.next()) {
44+
if (ga.getAggregate('COUNT') > 1)
45+
if (test_sys_id)
46+
result.push(ga.getValue('order'));
47+
else
48+
result.push(ga.getValue('test'));
49+
}
50+
51+
return result;
52+
53+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Usage : Executes a business rule to find duplicate execution orders in ATF.
2+
Executes on table sys_atf_test
3+
4+
The business rule consists of two main parts:
5+
6+
executeRule Function:
7+
Executes the business rule logic when a specific event occurs.
8+
It checks for duplicate execution orders within ATF and generates an error message if duplicates are found.
9+
10+
testDuplicateTestStepExectionOrder Function:
11+
A helper function responsible for identifying duplicate execution orders.
12+
Returns an array of active tests that contain at least two active test steps with the same execution order.

0 commit comments

Comments
 (0)