-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathmaster_ignition_customizations_test.go
More file actions
84 lines (73 loc) · 2.49 KB
/
Copy pathmaster_ignition_customizations_test.go
File metadata and controls
84 lines (73 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package machine
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/ignition"
"github.com/openshift/installer/pkg/asset/installconfig"
"github.com/openshift/installer/pkg/asset/tls"
"github.com/openshift/installer/pkg/ipnet"
"github.com/openshift/installer/pkg/types"
"github.com/openshift/installer/pkg/types/aws"
)
// TestMasterIgnitionCustomizationsGenerate tests generating the master ignition check asset.
func TestMasterIgnitionCustomizationsGenerate(t *testing.T) {
cases := []struct {
name string
customize bool
assetExpected bool
}{
{
name: "not customized",
customize: false,
assetExpected: false,
},
{
name: "pointer customized",
customize: true,
assetExpected: true,
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
installConfig := installconfig.MakeAsset(
&types.InstallConfig{
Networking: &types.Networking{
ServiceNetwork: []ipnet.IPNet{*ipnet.MustParseCIDR("10.0.1.0/24")},
},
Platform: types.Platform{
AWS: &aws.Platform{
Region: "us-east",
},
},
})
rootCAParents := asset.Parents{}
rootCAParents.Add(installConfig)
rootCA := &tls.RootCA{}
err := rootCA.Generate(context.Background(), rootCAParents)
assert.NoError(t, err, "unexpected error generating root CA")
parents := asset.Parents{}
parents.Add(installConfig, rootCA)
master := &Master{}
err = master.Generate(context.Background(), parents)
assert.NoError(t, err, "unexpected error generating master asset")
if tc.customize == true {
// Modify the master config, emulating a customization to the pointer
master.Config.Storage.Files = append(master.Config.Storage.Files,
ignition.FileFromString("/etc/foo", "root", 0644, "foo"))
}
parents.Add(master)
masterIgnCheck := &MasterIgnitionCustomizations{}
err = masterIgnCheck.Generate(context.Background(), parents)
assert.NoError(t, err, "unexpected error generating master ignition check asset")
actualFiles := masterIgnCheck.Files()
if tc.assetExpected == true {
assert.Equal(t, 1, len(actualFiles), "unexpected number of files in master state")
assert.Equal(t, masterMachineConfigFileName, actualFiles[0].Filename, "unexpected name for master ignition config")
} else {
assert.Equal(t, 0, len(actualFiles), "unexpected number of files in master state")
}
})
}
}