Skip to content

Commit 893145a

Browse files
committed
Add tests for contributing resources only when defined; fix che-code contribution test cases
Part of #1056 Signed-off-by: Andrew Obuchowicz <[email protected]>
1 parent 7bb97f0 commit 893145a

File tree

8 files changed

+242
-12
lines changed

8 files changed

+242
-12
lines changed

pkg/library/flatten/testdata/container-contributions/che-code-usecase.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ output:
115115
- name: checode
116116
path: /checode
117117
memoryLimit: 3Gi
118-
memoryRequest: 256Mi
119-
cpuLimit: 500m
120-
cpuRequest: 30m
121118
env:
122119
- name: GOPATH
123120
value: /projects:/home/user/go
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: "Only adds contributioon resources if they are defined in merge target"
2+
3+
input:
4+
devworkspace:
5+
components:
6+
- name: test-component
7+
attributes:
8+
controller.devfile.io/merge-contribution: true
9+
container:
10+
image: test-image
11+
memoryLimit: 1Gi
12+
# memoryRequest is not defined
13+
# cpuLimit is not defined
14+
cpuRequest: 15m
15+
- name: first-contribution
16+
plugin:
17+
uri: first-contribution.yaml
18+
- name: second-contribution
19+
plugin:
20+
uri: second-contribution.yaml
21+
22+
devfileResources:
23+
first-contribution.yaml:
24+
schemaVersion: 2.1.0
25+
metadata:
26+
name: first-contribution
27+
components:
28+
- name: first-contribution
29+
attributes:
30+
controller.devfile.io/container-contribution: true
31+
container:
32+
image: contribution-image
33+
memoryLimit: 512Mi
34+
memoryRequest: 1.5G
35+
cpuLimit: "0.5"
36+
# cpuRequest is not defined
37+
second-contribution.yaml:
38+
schemaVersion: 2.1.0
39+
metadata:
40+
name: second-contribution
41+
components:
42+
- name: second-contribution
43+
attributes:
44+
controller.devfile.io/container-contribution: true
45+
container:
46+
image: contribution-image
47+
# memoryLimit is not defined
48+
# memoryRequest is not defined
49+
# cpuLimit is not defined
50+
cpuRequest: 100m
51+
52+
output:
53+
devworkspace:
54+
components:
55+
- name: test-component
56+
attributes:
57+
controller.devfile.io/merged-contributions: "first-contribution,second-contribution"
58+
container:
59+
image: test-image
60+
memoryLimit: 1536Mi # 1Gi + 512Mi (from first-contribution)
61+
cpuRequest: 115m # 15m + 100m (from second-contributioon)
62+

pkg/library/flatten/testdata/implicit-container-contributions/che-code-usecase.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ output:
113113
- name: checode
114114
path: /checode
115115
memoryLimit: 3Gi
116-
memoryRequest: 256Mi
117-
cpuLimit: 500m
118-
cpuRequest: 30m
119116
env:
120117
- name: GOPATH
121118
value: /projects:/home/user/go
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: "Only adds contributioon resources if they are defined in merge target"
2+
3+
input:
4+
devworkspace:
5+
components:
6+
- name: test-component
7+
container:
8+
image: test-image
9+
memoryLimit: 1Gi
10+
# memoryRequest is not defined
11+
# cpuLimit is not defined
12+
cpuRequest: 15m
13+
- name: first-contribution
14+
plugin:
15+
uri: first-contribution.yaml
16+
- name: second-contribution
17+
plugin:
18+
uri: second-contribution.yaml
19+
20+
devfileResources:
21+
first-contribution.yaml:
22+
schemaVersion: 2.1.0
23+
metadata:
24+
name: first-contribution
25+
components:
26+
- name: first-contribution
27+
attributes:
28+
controller.devfile.io/container-contribution: true
29+
container:
30+
image: contribution-image
31+
memoryLimit: 512Mi
32+
memoryRequest: 1.5G
33+
cpuLimit: "0.5"
34+
# cpuRequest is not defined
35+
second-contribution.yaml:
36+
schemaVersion: 2.1.0
37+
metadata:
38+
name: second-contribution
39+
components:
40+
- name: second-contribution
41+
attributes:
42+
controller.devfile.io/container-contribution: true
43+
container:
44+
image: contribution-image
45+
# memoryLimit is not defined
46+
# memoryRequest is not defined
47+
# cpuLimit is not defined
48+
cpuRequest: 100m
49+
50+
output:
51+
devworkspace:
52+
components:
53+
- name: test-component
54+
attributes:
55+
controller.devfile.io/merged-contributions: "first-contribution,second-contribution"
56+
container:
57+
image: test-image
58+
memoryLimit: 1536Mi # 1Gi + 512Mi (from first-contribution)
59+
cpuRequest: 115m # 15m + 100m (from second-contributioon)
60+

pkg/library/flatten/testdata/implicit-spec-contributions/che-code-usecase.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ output:
113113
- name: checode
114114
path: /checode
115115
memoryLimit: 3Gi
116-
memoryRequest: 256Mi
117-
cpuLimit: 500m
118-
cpuRequest: 30m
119116
env:
120117
- name: GOPATH
121118
value: /projects:/home/user/go
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: "Only adds contributioon resources if they are defined in merge target"
2+
3+
input:
4+
devworkspace:
5+
components:
6+
- name: test-component
7+
container:
8+
image: test-image
9+
memoryLimit: 1Gi
10+
# memoryRequest is not defined
11+
# cpuLimit is not defined
12+
cpuRequest: 15m
13+
contributions:
14+
- name: first-contribution
15+
uri: first-contribution.yaml
16+
- name: second-contribution
17+
uri: second-contribution.yaml
18+
19+
devfileResources:
20+
first-contribution.yaml:
21+
schemaVersion: 2.1.0
22+
metadata:
23+
name: first-contribution
24+
components:
25+
- name: first-contribution
26+
attributes:
27+
controller.devfile.io/container-contribution: true
28+
container:
29+
image: contribution-image
30+
memoryLimit: 512Mi
31+
memoryRequest: 1.5G
32+
cpuLimit: "0.5"
33+
# cpuRequest is not defined
34+
second-contribution.yaml:
35+
schemaVersion: 2.1.0
36+
metadata:
37+
name: second-contribution
38+
components:
39+
- name: second-contribution
40+
attributes:
41+
controller.devfile.io/container-contribution: true
42+
container:
43+
image: contribution-image
44+
# memoryLimit is not defined
45+
# memoryRequest is not defined
46+
# cpuLimit is not defined
47+
cpuRequest: 100m
48+
49+
output:
50+
devworkspace:
51+
components:
52+
- name: test-component
53+
attributes:
54+
controller.devfile.io/merged-contributions: "first-contribution,second-contribution"
55+
container:
56+
image: test-image
57+
memoryLimit: 1536Mi # 1Gi + 512Mi (from first-contribution)
58+
cpuRequest: 115m # 15m + 100m (from second-contributioon)
59+

pkg/library/flatten/testdata/spec-contributions/che-code-usecase.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ output:
115115
- name: checode
116116
path: /checode
117117
memoryLimit: 3Gi
118-
memoryRequest: 256Mi
119-
cpuLimit: 500m
120-
cpuRequest: 30m
121118
env:
122119
- name: GOPATH
123120
value: /projects:/home/user/go
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: "Only adds contributioon resources if they are defined in merge target"
2+
3+
input:
4+
devworkspace:
5+
components:
6+
- name: test-component
7+
attributes:
8+
controller.devfile.io/merge-contribution: true
9+
container:
10+
image: test-image
11+
memoryLimit: 1Gi
12+
# memoryRequest is not defined
13+
# cpuLimit is not defined
14+
cpuRequest: 15m
15+
contributions:
16+
- name: first-contribution
17+
uri: first-contribution.yaml
18+
- name: second-contribution
19+
uri: second-contribution.yaml
20+
21+
devfileResources:
22+
first-contribution.yaml:
23+
schemaVersion: 2.1.0
24+
metadata:
25+
name: first-contribution
26+
components:
27+
- name: first-contribution
28+
attributes:
29+
controller.devfile.io/container-contribution: true
30+
container:
31+
image: contribution-image
32+
memoryLimit: 512Mi
33+
memoryRequest: 1.5G
34+
cpuLimit: "0.5"
35+
# cpuRequest is not defined
36+
second-contribution.yaml:
37+
schemaVersion: 2.1.0
38+
metadata:
39+
name: second-contribution
40+
components:
41+
- name: second-contribution
42+
attributes:
43+
controller.devfile.io/container-contribution: true
44+
container:
45+
image: contribution-image
46+
# memoryLimit is not defined
47+
# memoryRequest is not defined
48+
# cpuLimit is not defined
49+
cpuRequest: 100m
50+
51+
output:
52+
devworkspace:
53+
components:
54+
- name: test-component
55+
attributes:
56+
controller.devfile.io/merged-contributions: "first-contribution,second-contribution"
57+
container:
58+
image: test-image
59+
memoryLimit: 1536Mi # 1Gi + 512Mi (from first-contribution)
60+
cpuRequest: 115m # 15m + 100m (from second-contributioon)
61+

0 commit comments

Comments
 (0)