-
Notifications
You must be signed in to change notification settings - Fork 0
/
generic-test.schema.json
305 lines (305 loc) · 10.6 KB
/
generic-test.schema.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
{
"$id": "http://test-network-function.com/schemas/generic-test.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"version": "0.0.1",
"definitions": {
"identifier": {
"$id": "#identifier",
"description": "identifier is a per tnf.Test unique identifier. For more information, consult https://github.com/test-network-function/test-network-function/blob/main/DEVELOPING.md#test-identifiers.",
"properties": {
"url": {
"type": "string",
"description": "url stores the unique identifier for a test."
},
"version": {
"type": "string",
"description": "version stores the semantic version of the test."
}
},
"additionalProperties": false,
"required": [
"url",
"version"
]
},
"step": {
"$id": "#step",
"type": "object",
"description": "step is an instruction for a single REEL pass. To process a step, first send the execute string to the target subprocess (if supplied). Block until the subprocess output to stdout matches one of the regular expressions in expect (if any supplied).",
"properties": {
"execute": {
"type": "string",
"description": "execute is a Unix command to execute using the underlying subprocess."
},
"expect": {
"type": "array",
"description": "expect is an array of expected text regular expressions. Order is important, as the first matched expectation is used, and further expectations are disregarded.",
"items": {
"type": "string"
}
},
"timeout": {
"type": "integer",
"description": "timeout is the timeout for the Step. A positive timeout prevents blocking forever. Provide the timeout in nanoseconds."
}
},
"additionalProperties": false,
"required": [
"timeout"
]
},
"isIntCondition": {
"$id": "#isIntCondition",
"type": "object",
"description": "isIntCondition is an implementation of the condition.Condition interface which evaluates whether a match string is an integer.",
"properties": {
"type": {
"type": "string",
"description": "type stores the sentinel which represents the type of Condition implemented."
}
},
"additionalProperties": false,
"required": [
"type"
]
},
"intComparisonCondition": {
"$id": "#intComparisonCondition",
"type": "object",
"description": "intComparisonCondition is an implementation of the condition.Condition interface which converts a match string to an integer, then checks the integer comparison against input.",
"properties": {
"type": {
"type": "string",
"description": "type stores the sentinel which represents the type of Condition implemented."
},
"input": {
"type": "integer",
"description": "input is the right operand of the integer comparison. For example, int(match[groupIdx]) == input."
},
"comparison": {
"type": "string",
"description": "comparison is the sentinel string used to identify the integer comparison type. The following comparisons are supported: \"==\", \"<\", \"<=\", \">\", \">=\", \"!=\"."
}
},
"additionalProperties": false,
"required": [
"type",
"input",
"comparison"
]
},
"stringEqualsCondition": {
"$id": "#stringEqualsCondition",
"type": "object",
"description": "stringEqualsCondition is an implementation of the condition.Condition interface which evaluates string equality of a match against expected.",
"properties": {
"type": {
"type": "string",
"description": "type stores the sentinel which represents the type of Condition implemented."
},
"expected": {
"type": "string",
"description": "expected is the expected string value."
}
},
"additionalProperties": false,
"required": [
"type",
"expected"
]
},
"logic": {
"$id": "#logic",
"type": "object",
"description": "logic represents boolean logic. Given a set of conditions, it is useful to make assertions over the set using some sort of boolean logic (\"and\" and \"or\", for example).",
"properties": {
"type": {
"type": "string",
"description": "type stores the sentinel which represents the type of BooleanLogic implemented."
}
}
},
"assertion": {
"$id": "#assertion",
"type": "object",
"description": "assertion provides the ability to assert a Condition for the string extracted from GroupIdx of Match.",
"properties": {
"groupIdx": {
"type": "integer",
"description": "groupIdx is the index in the match string used in the Assertion."
},
"condition": {
"oneOf": [
{
"$ref": "#isIntCondition"
},
{
"$ref": "#intComparisonCondition"
},
{
"$ref": "#stringEqualsCondition"
}
],
"description": "condition is the condition.Condition asserted in this Assertion."
}
},
"additionalProperties": false,
"required": [
"groupIdx",
"condition"
]
},
"composedAssertion": {
"$id": "#composedAssertion",
"type": "object",
"description": "composedAssertions is a means of making many assertion.Assertion claims about the match.",
"properties": {
"assertions": {
"type": "array",
"description": "assertions provides the ability to compose BooleanLogic claims across any number of Assertion instances.",
"items": {
"$ref": "#assertion"
},
"additionalProperties": false,
"required": [
"matchIdx",
"condition"
]
},
"logic": {
"$ref": "#logic",
"definition": "logic is the BooleanLogic implementation to that is asserted over Assertions."
}
},
"additionalProperties": false,
"required": [
"assertions",
"logic"
]
},
"resultContext": {
"$id": "#resultContext",
"type": "object",
"description": "resultContexts provides the ability to make assertion.Assertions based on the given pattern matched.",
"properties": {
"pattern": {
"type": "string",
"description": "pattern is the pattern causing a match in reel.Handler ReelMatch."
},
"composedAssertions": {
"type": "array",
"description": "composedAssertions is a means of making many assertion.Assertion claims about the match.",
"items": {
"$ref": "#composedAssertion"
}
},
"defaultResult": {
"type": "integer",
"description": "defaultResult is the result of the test. This is only used if ComposedAssertions is not provided."
},
"nextStep": {
"$ref": "#step",
"description": "nextStep is an optional next step to take after an initial ReelMatch."
},
"nextResultContexts": {
"type": "array",
"description": "nextResultContexts is an optional array which provides the ability to make assertion.Assertions based on the next pattern match.",
"items": {
"$ref": "#resultContext"
}
}
},
"additionalProperties": false,
"required": [
"pattern",
"defaultResult"
]
},
"match": {
"$id": "#match",
"type": "object",
"properties": {
"pattern": {
"type": "string",
"description": "pattern is the pattern causing a match in reel.Handler ReelMatch."
},
"before": {
"type": "string",
"description": "before contains all output preceding match."
},
"match": {
"type": "string",
"description": "match is the matched string."
}
},
"additionalProperties": false,
"required": [
"pattern",
"match"
]
}
},
"type": "object",
"description": "generic-test is a construct for defining an arbitrary simple test with prescriptive confines. Essentially, the definition of the state machine for a Generic reel.Handler is restricted in this facade implementation, since most common use cases do not require too much heavy lifting.",
"properties": {
"identifier": {
"$ref": "#identifier",
"description": "identifier is a per tnf.Test unique identifier. For more information, consult https://github.com/test-network-function/test-network-function/blob/main/DEVELOPING.md#test-identifiers."
},
"arguments": {
"description": "arguments is the Unix command array.",
"type": "array",
"items": {
"type": "string"
}
},
"description": {
"type": "string",
"description": "description is a textual description of the overall functionality that is tested."
},
"failureReason": {
"type": "string",
"description": "failureReason optionally stores extra information pertaining to why the test failed."
},
"matches": {
"type": "array",
"description": "matches contains an in order array of matches.",
"items": {
"$ref": "#match",
"description": "match stores information about the matched regular expression, if one exists."
}
},
"reelFirstStep": {
"$ref": "#step",
"description": "reelFirstStep is the first step returned by reel.ReelFirst()."
},
"resultContexts": {
"type": "array",
"description": "resultContexts provides the ability to make assertion.Assertions based on the given pattern matched.",
"items": {
"$ref": "#resultContext"
}
},
"reelTimeoutStep": {
"$ref": "#step",
"description": "reelTimeoutStep is the reel.Step to take upon timeout."
},
"testResult": {
"type": "integer",
"description": "testResult is the result of running the tnf.Test. 0 indicates ERROR, 1 indicates SUCCESS, 2 indicates FAILURE."
},
"testTimeout": {
"type": "integer",
"description": "testTimeout prevents the Test from running forever. Provide the testTimeout in nanoseconds."
}
},
"additionalProperties": false,
"required": [
"description",
"identifier",
"reelFirstStep",
"resultContexts",
"testResult",
"testTimeout"
]
}