Skip to content

Commit 8322f8c

Browse files
committed
updated extramanifsts_test.go to make easier to read and added an integration test to validate exta files are added to iso
Signed-off-by: xphyr <[email protected]>
1 parent 0b4a65d commit 8322f8c

File tree

2 files changed

+82
-23
lines changed

2 files changed

+82
-23
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Verify that the extra-manifests directory populates with the appropriate files
2+
3+
exec openshift-install image-based create config-image --dir $WORK
4+
5+
exists $WORK/imagebasedconfig.iso
6+
exists $WORK/auth/kubeconfig
7+
exists $WORK/auth/kubeadmin-password
8+
9+
isoContains imagebasedconfig.iso /cluster-configuration/manifest.json
10+
isoContains imagebasedconfig.iso /extra-manifests/test.yaml
11+
isoContains imagebasedconfig.iso /extra-manifests/test.yml
12+
isoContains imagebasedconfig.iso /extra-manifests/test.json
13+
14+
-- install-config.yaml --
15+
apiVersion: v1
16+
baseDomain: test.metalkube.org
17+
controlPlane:
18+
name: master
19+
replicas: 1
20+
compute:
21+
- name: worker
22+
replicas: 0
23+
metadata:
24+
name: ostest
25+
networking:
26+
clusterNetwork:
27+
- cidr: 10.128.0.0/14
28+
hostPrefix: 23
29+
networkType: OVNKubernetes
30+
machineNetwork:
31+
- cidr: 192.168.111.0/24
32+
serviceNetwork:
33+
- 172.30.0.0/16
34+
platform:
35+
none: {}
36+
sshKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDK6UTEydcEKzuNdPaofn8Z2DwgHqdcionLZBiPf/zIRNco++etLsat7Avv7yt04DINQd5zjxIFgG8jblaUB5E5C9ClUcMwb52GO0ay2Y9v1uBv1a4WhI3peKktAzYNk0EBMQlJtXPjRMrC9ylBPh+DsBHMu+KmDnfk7PIwyN4efC8k5kSRuPWoNdme1rz2+umU8FSmaWTHIajrbspf4GQbsntA5kuKEtDbfoNCU97o2KrRnUbeg3a8hwSjfh3u6MhlnGcg5K2Ij+zivEsWGCLKYUtE1ErqwfIzwWmJ6jnV66XCQGHf4Q1iIxqF7s2a1q24cgG2Z/iDXfqXrCIfy4P7b/Ztak3bdT9jfAdVZtdO5/r7I+O5hYhF86ayFlDWzZWP/ByiSb+q4CQbfVgK3BMmiAv2MqLHdhesmD/SmIcoOWUF6rFmRKZVFFpKpt5ATNTgUJ3JRowoXrrDruVXClUGRiCS6Zabd1rZ3VmTchaPJwtzQMdfIWISXj+Ig+C4UK0=
37+
pullSecret: '{"auths": {"quay.io": {"auth": "c3VwZXItc2VjcmV0Cg=="}}}'
38+
39+
-- image-based-config.yaml --
40+
apiVersion: v1beta1
41+
kind: ImageBasedConfig
42+
metadata:
43+
name: ostest
44+
namespace: cluster0
45+
hostname: ostest
46+
47+
-- extra-manifests/test.yaml --
48+
apiVersion: v1beta1
49+
kind: DummyData
50+
metadata:
51+
name: test.yaml
52+
53+
-- extra-manifests/test.yml --
54+
apiVersion: v1beta1
55+
kind: DummyData
56+
metadata:
57+
name: test.yml
58+
59+
-- extra-manifests/test.json --
60+
{
61+
"apiVersion": "v1beta1",
62+
"kind": "DummyData",
63+
"metadata": {
64+
"name": "test.json"
65+
}
66+
}

pkg/asset/imagebased/configimage/extramanifests_test.go

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ func TestExtraManifests_Load(t *testing.T) {
8888
},
8989
}
9090

91+
yamlPattern := "extra-manifests/*.yaml"
92+
ymlPattern := "extra-manifests/*.yml"
93+
jsonPattern := "extra-manifests/*.json"
94+
9195
for _, tc := range cases {
9296
t.Run(tc.name, func(t *testing.T) {
9397
yamlFiles := []*asset.File{}
@@ -115,33 +119,22 @@ func TestExtraManifests_Load(t *testing.T) {
115119
defer mockCtrl.Finish()
116120

117121
fileFetcher := mock.NewMockFileFetcher(mockCtrl)
122+
118123
if tc.yamlFetchError != nil {
119-
fileFetcher.EXPECT().FetchByPattern("extra-manifests/*.yaml").Return(
120-
[]*asset.File{},
121-
tc.yamlFetchError,
122-
)
123-
} else if tc.ymlFetchError != nil {
124-
fileFetcher.EXPECT().FetchByPattern("extra-manifests/*.yaml").Return(yamlFiles, nil)
124+
fileFetcher.EXPECT().FetchByPattern(yamlPattern).Return([]*asset.File{}, tc.yamlFetchError)
125+
} else {
126+
fileFetcher.EXPECT().FetchByPattern(yamlPattern).Return(yamlFiles, nil)
125127

126128
if tc.ymlFetchError != nil {
127-
fileFetcher.EXPECT().FetchByPattern("extra-manifests/*.yml").Return(
128-
[]*asset.File{},
129-
tc.ymlFetchError,
130-
)
131-
} else {
132-
fileFetcher.EXPECT().FetchByPattern("extra-manifests/*.yml").Return(ymlFiles, nil)
133-
}
134-
} else {
135-
fileFetcher.EXPECT().FetchByPattern("extra-manifests/*.yaml").Return(yamlFiles, nil)
136-
fileFetcher.EXPECT().FetchByPattern("extra-manifests/*.yml").Return(ymlFiles, nil)
137-
138-
if tc.jsonFetchError != nil {
139-
fileFetcher.EXPECT().FetchByPattern("extra-manifests/*.json").Return(
140-
[]*asset.File{},
141-
tc.jsonFetchError,
142-
)
129+
fileFetcher.EXPECT().FetchByPattern(ymlPattern).Return([]*asset.File{}, tc.ymlFetchError)
143130
} else {
144-
fileFetcher.EXPECT().FetchByPattern("extra-manifests/*.json").Return(jsonFiles, nil)
131+
fileFetcher.EXPECT().FetchByPattern(ymlPattern).Return(ymlFiles, nil)
132+
133+
if tc.jsonFetchError != nil {
134+
fileFetcher.EXPECT().FetchByPattern(jsonPattern).Return([]*asset.File{}, tc.jsonFetchError)
135+
} else {
136+
fileFetcher.EXPECT().FetchByPattern(jsonPattern).Return(jsonFiles, nil)
137+
}
145138
}
146139
}
147140

0 commit comments

Comments
 (0)