Skip to content

Commit 5f624af

Browse files
committed
Add image-based config ISO integration tests
Signed-off-by: Michail Resvanis <[email protected]>
1 parent b2876fc commit 5f624af

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

cmd/openshift-install/agent_integration_test.go renamed to cmd/openshift-install/integration_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ func TestMain(m *testing.M) {
1919
func TestAgentIntegration(t *testing.T) {
2020
runAllIntegrationTests(t, "testdata/agent")
2121
}
22+
23+
func TestImageBasedIntegration(t *testing.T) {
24+
runAllIntegrationTests(t, "testdata/imagebased")
25+
}

cmd/openshift-install/agent_internal_integration_test.go renamed to cmd/openshift-install/internal_integration_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func runIntegrationTest(t *testing.T, testFolder string) {
122122
"unconfiguredIgnContains": unconfiguredIgnContains,
123123
"unconfiguredIgnCmp": unconfiguredIgnCmp,
124124
"expandFile": expandFile,
125+
"isoContains": isoContains,
125126
},
126127
})
127128
}
@@ -451,6 +452,27 @@ func initrdImgContains(ts *testscript.TestScript, neg bool, args []string) {
451452
ts.Check(err)
452453
}
453454

455+
// [!] isoContains `isoPath` `file` check if the specified `file` is stored
456+
// within the ISO `isoPath` image.
457+
func isoContains(ts *testscript.TestScript, neg bool, args []string) {
458+
if len(args) != 2 {
459+
ts.Fatalf("usage: isoContains isoPath file")
460+
}
461+
462+
workDir := ts.Getenv("WORK")
463+
isoPath, filePath := args[0], args[1]
464+
isoPathAbs := filepath.Join(workDir, isoPath)
465+
466+
disk, err := diskfs.Open(isoPathAbs, diskfs.WithOpenMode(diskfs.ReadOnly))
467+
ts.Check(err)
468+
469+
fs, err := disk.GetFilesystem(0)
470+
ts.Check(err)
471+
472+
_, err = fs.OpenFile(filePath, os.O_RDONLY)
473+
ts.Check(err)
474+
}
475+
454476
func checkFileFromInitrdImg(isoPath string, fileName string) error {
455477
disk, err := diskfs.Open(isoPath, diskfs.WithOpenMode(diskfs.ReadOnly))
456478
if err != nil {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Verify that the most relevant assets are properly generated in the config ISO
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+
11+
-- install-config.yaml --
12+
apiVersion: v1
13+
baseDomain: test.metalkube.org
14+
controlPlane:
15+
name: master
16+
replicas: 1
17+
compute:
18+
- name: worker
19+
replicas: 0
20+
metadata:
21+
name: ostest
22+
networking:
23+
clusterNetwork:
24+
- cidr: 10.128.0.0/14
25+
hostPrefix: 23
26+
networkType: OVNKubernetes
27+
machineNetwork:
28+
- cidr: 192.168.111.0/24
29+
serviceNetwork:
30+
- 172.30.0.0/16
31+
platform:
32+
none: {}
33+
sshKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDK6UTEydcEKzuNdPaofn8Z2DwgHqdcionLZBiPf/zIRNco++etLsat7Avv7yt04DINQd5zjxIFgG8jblaUB5E5C9ClUcMwb52GO0ay2Y9v1uBv1a4WhI3peKktAzYNk0EBMQlJtXPjRMrC9ylBPh+DsBHMu+KmDnfk7PIwyN4efC8k5kSRuPWoNdme1rz2+umU8FSmaWTHIajrbspf4GQbsntA5kuKEtDbfoNCU97o2KrRnUbeg3a8hwSjfh3u6MhlnGcg5K2Ij+zivEsWGCLKYUtE1ErqwfIzwWmJ6jnV66XCQGHf4Q1iIxqF7s2a1q24cgG2Z/iDXfqXrCIfy4P7b/Ztak3bdT9jfAdVZtdO5/r7I+O5hYhF86ayFlDWzZWP/ByiSb+q4CQbfVgK3BMmiAv2MqLHdhesmD/SmIcoOWUF6rFmRKZVFFpKpt5ATNTgUJ3JRowoXrrDruVXClUGRiCS6Zabd1rZ3VmTchaPJwtzQMdfIWISXj+Ig+C4UK0=
34+
pullSecret: '{"auths": {"quay.io": {"auth": "c3VwZXItc2VjcmV0Cg=="}}}'
35+
36+
-- image-based-config.yaml --
37+
apiVersion: v1beta1
38+
kind: ImageBasedConfig
39+
metadata:
40+
name: ostest
41+
namespace: cluster0
42+
hostname: ostest
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Verify the generated default template for image-based-config.yaml
2+
3+
exec openshift-install image-based create config-template --dir $WORK
4+
5+
stderr 'level=info msg=Config-Template created in:'
6+
7+
exists $WORK/image-based-config.yaml
8+
9+
cmp $WORK/image-based-config.yaml $WORK/expected/image-based-config.yaml
10+
11+
-- expected/image-based-config.yaml --
12+
#
13+
# Note: This is a sample ImageBasedConfig file showing
14+
# which fields are available to aid you in creating your
15+
# own image-based-config.yaml file.
16+
#
17+
apiVersion: v1beta1
18+
kind: ImageBasedConfig
19+
metadata:
20+
name: example-image-based-config
21+
additionalNTPSources:
22+
- 0.rhel.pool.ntp.org
23+
- 1.rhel.pool.ntp.org
24+
hostname: change-to-hostname
25+
releaseRegistry: quay.io
26+
# networkConfig contains the network configuration for the host in NMState format.
27+
# See https://nmstate.io/examples.html for examples.
28+
networkConfig:
29+
interfaces:
30+
- name: eth0
31+
type: ethernet
32+
state: up
33+
mac-address: 00:00:00:00:00:00
34+
ipv4:
35+
enabled: true
36+
address:
37+
- ip: 192.168.122.2
38+
prefix-length: 23
39+
dhcp: false

0 commit comments

Comments
 (0)