Skip to content

Commit f13c174

Browse files
datajsonbuilder
1 parent 826fa94 commit f13c174

File tree

1 file changed

+93
-47
lines changed

1 file changed

+93
-47
lines changed

docs/deep-dive-into-hyperexecute-yaml.md

Lines changed: 93 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,72 +1016,118 @@ dataJsonBuilder:
10161016
```yaml
10171017
index: username
10181018
```
1019-
- **filters (optional) :** Applies filtering on the JSON objects before indexing.
1020-
- **query:** A logical expression to filter JSON objects based on their attributes. It supports complex queries using logical operators. Example:
1019+
- **filters (optional) :** Applies filtering on the JSON objects before indexing. Either `query` or `attributes` can be used, if both are mentioned then the `attributes` will have higher precedence.
1020+
- **query:** These are used for more complex filtering operations. If both attributes and queries are provided, attributes take precedence. This means that if there’s a conflict, the filter based on attributes will be used. Example:
10211021
```yaml
10221022
query: (username == "abc" or username == "bcd")
10231023
```
1024-
- **attributes:** A list of key-value pairs to filter JSON objects. It has higher precedence over `query`. Example:
1024+
- **attributes:** These are key-value pairs used for filtering. You can provide a list of attributes with their corresponding values, and the filtering will include only those JSON objects where each specified attribute matches one of the provided values. Attributes are applied with an "AND" logic between different keys and an "OR" logic within the same key. Example:
10251025
```yaml
10261026
attributes:
10271027
- key: username
10281028
value: ["abc", "bcd"]
1029+
- key: tags
1030+
values: ["@x", "@y"]
10291031
```
10301032

1031-
#### Input data
1032-
The input JSON data should follow this format:
1033-
```javascript title="sample.json"
1034-
[
1035-
{
1033+
#### Working of `dataJsonBuilder`
1034+
1035+
- The **input JSON data** should follow this format:
1036+
```javascript title="sample.json"
1037+
[
1038+
{
1039+
"accesskey": "jhscuystc7ewgucu79as8yc9",
10361040
"username": "abc",
1037-
},
1038-
{
1041+
"tags": "@x"
1042+
},
1043+
{
1044+
"accesskey": "cjdy87328yeiqhd93urd28hh",
10391045
"username": "bcd",
1040-
},
1041-
{
1042-
"username": "def",
1043-
},
1044-
{
1045-
"username": "def",
1046-
}
1047-
]
1048-
```
1046+
"tags": "@y"
1047+
},
1048+
{
1049+
"accesskey": "jhscuystc7ewgucu79as8yc9",
1050+
"username": "abc",
1051+
"tags": "@y"
1052+
},
1053+
{
1054+
"accesskey": "cjdy87328yeiqhd93urd28hh",
1055+
"username": "bcd",
1056+
"tags": "@a"
1057+
}
1058+
]
1059+
```
10491060

1050-
#### Output data
1051-
The processed data includes additional fields `HYPERTEST_INDEX` and `HYPERTEST_CONCURRENCY` for indexing and concurrency information:
1052-
```javascript title="sample.json
1053-
[
1061+
- **`dataJsonBuilder`** flag passed in the HyperExecute YAML file:
1062+
1063+
```yaml title="hyperexecute.yaml"
1064+
dataJsonBuilder:
1065+
path: sample.json
1066+
filters:
1067+
attributes:
1068+
- key: username
1069+
values: ["abc", "bcd"]
1070+
- key: tags
1071+
values: ["@x", "@y"]
1072+
```
1073+
1074+
- The **filtered JSON data** will be:
1075+
```javascript title="sample.json"
1076+
[
1077+
{
1078+
"accesskey": "jhscuystc7ewgucu79as8yc9",
1079+
"username": "abc",
1080+
"tags": "@x"
1081+
},
1082+
{
1083+
"accesskey": "cjdy87328yeiqhd93urd28hh",
1084+
"username": "bcd",
1085+
"tags": "@y"
1086+
},
1087+
{
1088+
"accesskey": "jhscuystc7ewgucu79as8yc9",
1089+
"username": "abc",
1090+
"tags": "@y"
1091+
}
1092+
]
1093+
```
1094+
The objects with **usernames** `"abc"` and `"bcd"` and **tags** `"@x"` and `"@y"` are selected as they meet the criteria defined by the attributes filter.
1095+
1096+
#### Indexing and Test Case Distribution:
1097+
After filtering, the JSON data is indexed to distribute test cases. Here’s how the distribution works:
1098+
- **VM Allocation:** Each filtered JSON object corresponds to a separate VM. If the filtered JSON contains 3 objects, 3 VMs are allocated.
1099+
- **Test Case Distribution:** Test cases are then distributed across these VMs. For each VM, test cases are distributed based on the `username` present in the filtered JSON objects. All test cases related to the same `username` are assigned to the VMs containing that `username`.
1100+
1101+
So as per the above filtered JSON data:
1102+
1103+
- **VM1** will receive all test cases related to `username: "abc"`
1104+
```javascript
10541105
{
1106+
"accesskey": "jhscuystc7ewgucu79as8yc9",
10551107
"username": "abc",
1056-
"HYPERTEST_INDEX": 0,
1057-
"HYPERTEST_CONCURRENCY": 1
1058-
},
1108+
"tags": "@x"
1109+
}
1110+
```
1111+
1112+
- **VM2** will receive all test cases related to `username: "bcd"`.
1113+
```javascript
10591114
{
1115+
"accesskey": "cjdy87328yeiqhd93urd28hh",
10601116
"username": "bcd",
1061-
"HYPERTEST_INDEX": 0,
1062-
"HYPERTEST_CONCURRENCY": 1
1063-
},
1064-
{
1065-
"username": "def",
1066-
"HYPERTEST_INDEX": 0,
1067-
"HYPERTEST_CONCURRENCY": 2
1068-
},
1069-
{
1070-
"username": "def",
1071-
"HYPERTEST_INDEX": 1,
1072-
"HYPERTEST_CONCURRENCY": 2
1117+
"tags": "@y"
10731118
}
1074-
]
1075-
```
1119+
```
10761120

1077-
#### Working of `dataJsonBuilder`
1121+
- **VM3** will handle the JSON object:
1122+
```javascript
1123+
{
1124+
"accesskey": "jhscuystc7ewgucu79as8yc9",
1125+
"username": "abc",
1126+
"tags": "@y"
1127+
}
1128+
```
10781129

1079-
- **Reading JSON Data:** The JSON data is read from the file specified in the path configuration.
1080-
- **Applying Filters:**
1081-
If filters are specified, the JSON objects are filtered according to the rules:
1082-
- **Attributes:** Filters based on specified key-value pairs are applied first.
1083-
- **Query:** A logical query filter is applied if the attributes filter is not specified or after the attributes filter is applied.
1084-
- **Indexing:** The JSON objects are then indexed based on the key specified in the index configuration. This indexing helps in determining the distribution pattern for test execution.
1130+
Test cases related to `username: "abc"` will be split between **VM1** and **VM3**, while test cases related to `username: "bcd"` will be handled by **VM2**.
10851131

10861132
#### Use Cases
10871133
- **Filtering and Indexing :** When both filtering and indexing are required, filters are applied first, followed by indexing of the filtered results.

0 commit comments

Comments
 (0)