Skip to content

Commit 91aef46

Browse files
Add test to ensure scenarios with preflight
1 parent c518f68 commit 91aef46

3 files changed

Lines changed: 310 additions & 6 deletions

File tree

internal/operator-controller/rukpak/preflights/crdupgradesafety/crdupgradesafety_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ func TestInstall(t *testing.T) {
192192
},
193193
},
194194
{
195-
name: "optional field addition should not fail (RHDH scenario)",
196-
oldCrdPath: "crd-rhdh-old.json",
195+
name: "optional field addition should not fail",
196+
oldCrdPath: "crd-optional-field-old.json",
197197
release: &release.Release{
198198
Name: "test-release",
199-
Manifest: getManifestString(t, "crd-rhdh-new-optional-field.json"),
199+
Manifest: getManifestString(t, "crd-optional-field-new.json"),
200200
},
201201
},
202202
}
@@ -379,11 +379,11 @@ func TestUpgrade(t *testing.T) {
379379
},
380380
},
381381
{
382-
name: "optional field addition should not fail (RHDH scenario)",
383-
oldCrdPath: "crd-rhdh-old.json",
382+
name: "optional field addition should not fail",
383+
oldCrdPath: "crd-optional-field-old.json",
384384
release: &release.Release{
385385
Name: "test-release",
386-
Manifest: getManifestString(t, "crd-rhdh-new-optional-field.json"),
386+
Manifest: getManifestString(t, "crd-optional-field-new.json"),
387387
},
388388
},
389389
}
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
{
2+
"apiVersion": "apiextensions.k8s.io/v1",
3+
"kind": "CustomResourceDefinition",
4+
"metadata": {
5+
"name": "myapps.apps.example.com"
6+
},
7+
"spec": {
8+
"group": "apps.example.com",
9+
"versions": [
10+
{
11+
"name": "v1alpha1",
12+
"served": true,
13+
"storage": true,
14+
"schema": {
15+
"openAPIV3Schema": {
16+
"type": "object",
17+
"properties": {
18+
"spec": {
19+
"type": "object",
20+
"properties": {
21+
"application": {
22+
"type": "object",
23+
"properties": {
24+
"extraFiles": {
25+
"type": "object",
26+
"properties": {
27+
"secrets": {
28+
"type": "array",
29+
"items": {
30+
"type": "object",
31+
"properties": {
32+
"key": {
33+
"description": "Key in the object",
34+
"type": "string"
35+
},
36+
"mountPath": {
37+
"description": "Path to mount the Object. If not specified default-path/Name will be used",
38+
"type": "string"
39+
},
40+
"name": {
41+
"description": "Name of the object\nSupported ConfigMaps and Secrets",
42+
"type": "string"
43+
}
44+
}
45+
}
46+
},
47+
"configMaps": {
48+
"type": "array",
49+
"items": {
50+
"type": "object",
51+
"properties": {
52+
"key": {
53+
"description": "Key in the object",
54+
"type": "string"
55+
},
56+
"mountPath": {
57+
"description": "Path to mount the Object. If not specified default-path/Name will be used",
58+
"type": "string"
59+
},
60+
"name": {
61+
"description": "Name of the object\nSupported ConfigMaps and Secrets",
62+
"type": "string"
63+
}
64+
}
65+
}
66+
}
67+
}
68+
}
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}
75+
}
76+
},
77+
{
78+
"name": "v1alpha3",
79+
"served": true,
80+
"storage": false,
81+
"schema": {
82+
"openAPIV3Schema": {
83+
"type": "object",
84+
"properties": {
85+
"spec": {
86+
"type": "object",
87+
"properties": {
88+
"application": {
89+
"type": "object",
90+
"properties": {
91+
"extraFiles": {
92+
"type": "object",
93+
"properties": {
94+
"secrets": {
95+
"type": "array",
96+
"items": {
97+
"type": "object",
98+
"properties": {
99+
"key": {
100+
"description": "Key in the object",
101+
"type": "string"
102+
},
103+
"mountPath": {
104+
"description": "Path to mount the Object. If not specified default-path/Name will be used",
105+
"type": "string"
106+
},
107+
"name": {
108+
"description": "Name of the object\nSupported ConfigMaps and Secrets",
109+
"type": "string"
110+
}
111+
}
112+
}
113+
},
114+
"configMaps": {
115+
"type": "array",
116+
"items": {
117+
"type": "object",
118+
"properties": {
119+
"key": {
120+
"description": "Key in the object",
121+
"type": "string"
122+
},
123+
"mountPath": {
124+
"description": "Path to mount the Object. If not specified default-path/Name will be used",
125+
"type": "string"
126+
},
127+
"name": {
128+
"description": "Name of the object\nSupported ConfigMaps and Secrets",
129+
"type": "string"
130+
}
131+
}
132+
}
133+
}
134+
}
135+
}
136+
}
137+
}
138+
}
139+
}
140+
}
141+
}
142+
}
143+
}
144+
],
145+
"scope": "Namespaced",
146+
"names": {
147+
"plural": "myapps",
148+
"singular": "myapp",
149+
"kind": "MyApp",
150+
"shortNames": [
151+
"bs"
152+
]
153+
}
154+
},
155+
"status": {
156+
"storedVersions": [
157+
"v1alpha1"
158+
]
159+
}
160+
}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
"apiVersion": "apiextensions.k8s.io/v1",
3+
"kind": "CustomResourceDefinition",
4+
"metadata": {
5+
"name": "myapps.apps.example.com"
6+
},
7+
"spec": {
8+
"group": "apps.example.com",
9+
"versions": [
10+
{
11+
"name": "v1alpha1",
12+
"served": true,
13+
"storage": true,
14+
"schema": {
15+
"openAPIV3Schema": {
16+
"type": "object",
17+
"properties": {
18+
"spec": {
19+
"type": "object",
20+
"properties": {
21+
"application": {
22+
"type": "object",
23+
"properties": {
24+
"extraFiles": {
25+
"type": "object",
26+
"properties": {
27+
"secrets": {
28+
"type": "array",
29+
"items": {
30+
"type": "object",
31+
"properties": {
32+
"key": {
33+
"description": "Key in the object",
34+
"type": "string"
35+
},
36+
"name": {
37+
"description": "Name of the object\nWe support only ConfigMaps and Secrets.",
38+
"type": "string"
39+
}
40+
}
41+
}
42+
},
43+
"configMaps": {
44+
"type": "array",
45+
"items": {
46+
"type": "object",
47+
"properties": {
48+
"key": {
49+
"description": "Key in the object",
50+
"type": "string"
51+
},
52+
"name": {
53+
"description": "Name of the object\nWe support only ConfigMaps and Secrets.",
54+
"type": "string"
55+
}
56+
}
57+
}
58+
}
59+
}
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}
66+
}
67+
}
68+
},
69+
{
70+
"name": "v1alpha3",
71+
"served": true,
72+
"storage": false,
73+
"schema": {
74+
"openAPIV3Schema": {
75+
"type": "object",
76+
"properties": {
77+
"spec": {
78+
"type": "object",
79+
"properties": {
80+
"application": {
81+
"type": "object",
82+
"properties": {
83+
"extraFiles": {
84+
"type": "object",
85+
"properties": {
86+
"secrets": {
87+
"type": "array",
88+
"items": {
89+
"type": "object",
90+
"properties": {
91+
"key": {
92+
"description": "Key in the object",
93+
"type": "string"
94+
},
95+
"name": {
96+
"description": "Name of the object\nWe support only ConfigMaps and Secrets.",
97+
"type": "string"
98+
}
99+
}
100+
}
101+
},
102+
"configMaps": {
103+
"type": "array",
104+
"items": {
105+
"type": "object",
106+
"properties": {
107+
"key": {
108+
"description": "Key in the object",
109+
"type": "string"
110+
},
111+
"name": {
112+
"description": "Name of the object\nWe support only ConfigMaps and Secrets.",
113+
"type": "string"
114+
}
115+
}
116+
}
117+
}
118+
}
119+
}
120+
}
121+
}
122+
}
123+
}
124+
}
125+
}
126+
}
127+
}
128+
],
129+
"scope": "Namespaced",
130+
"names": {
131+
"plural": "myapps",
132+
"singular": "myapp",
133+
"kind": "MyApp",
134+
"shortNames": [
135+
"bs"
136+
]
137+
}
138+
},
139+
"status": {
140+
"storedVersions": [
141+
"v1alpha1"
142+
]
143+
}
144+
}

0 commit comments

Comments
 (0)