Skip to content

Commit a53f036

Browse files
asn1809raghavendra-talur
authored andcommitted
recipe: adding TCs for RamenDR#1906
Signed-off-by: Annaraya Narasagond <[email protected]>
1 parent 36841fe commit a53f036

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

internal/controller/hooks/json_util_test.go

+65
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,49 @@ var testCasesData = []testCases{
113113
result: false,
114114
jsonText: jsonStatefulset,
115115
},
116+
/* The json expression that can be provided as a condition in the check hook spec follows the format
117+
118+
<expression1> op <expression2>
119+
With some of the conditions below:
120+
121+
1. Both the expressions should individually comply to be a valid json expression.
122+
2. An expression should be enclosed with curly braces {}.
123+
3. An expression could either be a json expression that can be evaluated from the pod/deployment/statefulset json
124+
content or a literal which can be either string or number.
125+
Some improvements needs to be done which are added as sub-issues linked to this one.
126+
127+
Adding the commented TCs which are to pass when the improvements are done.
128+
*/
129+
// {
130+
// jsonPathExprs: "{$.status.conditions[0].status} == {True}",
131+
// result: true,
132+
// jsonText: jsonStatefulset,
133+
// },
134+
// {
135+
// jsonPathExprs: "{$.spec.replicas} == {1}",
136+
// result: true,
137+
// jsonText: jsonPod,
138+
// },
139+
// {
140+
// jsonPathExprs: "{$.status.conditions[0].status} == {\"True\"}",
141+
// result: true,
142+
// jsonText: jsonStatefulset,
143+
// },
144+
// {
145+
// jsonPathExprs: "{$.status.conditions[?(@type.==\"Progressing\")].status} == {True}",
146+
// result: true,
147+
// jsonText: jsonPod,
148+
// },
149+
// {
150+
// jsonPathExprs: "{$.spec.replicas} == {1} || $.status.conditions[0].status == {True}",
151+
// result: true,
152+
// jsonText: jsonPod,
153+
// },
154+
// {
155+
// jsonPathExprs: "{$.spec.replicas} == {1} && $.status.conditions[0].status == {True}",
156+
// result: true,
157+
// jsonText: jsonPod,
158+
// },
116159
}
117160

118161
var testCasesObjectData = []testCasesObject{
@@ -200,6 +243,28 @@ func Test_isValidJsonPathExpression(t *testing.T) {
200243
args args
201244
want bool
202245
}{
246+
/* Same comments as above */
247+
// {
248+
// name: "String expression",
249+
// args: args{
250+
// expr: "{True}",
251+
// },
252+
// want: true,
253+
// },
254+
// {
255+
// name: "String expression 1",
256+
// args: args{
257+
// expr: "{\"Ready\"}",
258+
// },
259+
// want: true,
260+
// },
261+
// {
262+
// name: "Number expression",
263+
// args: args{
264+
// expr: "{10}",
265+
// },
266+
// want: true,
267+
// },
203268
{
204269
name: "Simple expression",
205270
args: args{

0 commit comments

Comments
 (0)