github.com/openshift/installer@v1.4.17/pkg/asset/agent/image/kargs_test.go (about) 1 package image 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 9 10 "github.com/openshift/assisted-service/api/hiveextension/v1beta1" 11 "github.com/openshift/installer/pkg/asset" 12 "github.com/openshift/installer/pkg/asset/agent/joiner" 13 "github.com/openshift/installer/pkg/asset/agent/manifests" 14 "github.com/openshift/installer/pkg/asset/agent/workflow" 15 ) 16 17 func TestKargs_Generate(t *testing.T) { 18 cases := []struct { 19 name string 20 workflow workflow.AgentWorkflowType 21 agentClusterInstall *manifests.AgentClusterInstall 22 clusterInfo *joiner.ClusterInfo 23 expectedArgs string 24 expectedErr string 25 }{ 26 { 27 name: "install workflow - default", 28 workflow: workflow.AgentWorkflowTypeInstall, 29 expectedArgs: "", 30 }, 31 { 32 name: "install workflow - fips enabled", 33 workflow: workflow.AgentWorkflowTypeInstall, 34 agentClusterInstall: &manifests.AgentClusterInstall{ 35 Config: &v1beta1.AgentClusterInstall{ 36 ObjectMeta: v1.ObjectMeta{ 37 Annotations: map[string]string{ 38 "agent-install.openshift.io/install-config-overrides": `{"fips": true}`, 39 }, 40 }, 41 }, 42 }, 43 expectedArgs: " fips=1", 44 }, 45 { 46 name: "install workflow - oci with fips enabled", 47 workflow: workflow.AgentWorkflowTypeInstall, 48 agentClusterInstall: &manifests.AgentClusterInstall{ 49 Config: &v1beta1.AgentClusterInstall{ 50 ObjectMeta: v1.ObjectMeta{ 51 Annotations: map[string]string{ 52 "agent-install.openshift.io/install-config-overrides": `{"fips": true}`, 53 }, 54 }, 55 Spec: v1beta1.AgentClusterInstallSpec{ 56 ExternalPlatformSpec: &v1beta1.ExternalPlatformSpec{ 57 PlatformName: "oci", 58 }, 59 }, 60 }, 61 }, 62 expectedArgs: " console=ttyS0 fips=1", 63 }, 64 { 65 name: "add-nodes workflow - default", 66 workflow: workflow.AgentWorkflowTypeAddNodes, 67 expectedArgs: "", 68 }, 69 { 70 name: "add-nodes workflow - fips enabled", 71 workflow: workflow.AgentWorkflowTypeAddNodes, 72 clusterInfo: &joiner.ClusterInfo{ 73 FIPS: true, 74 }, 75 expectedArgs: " fips=1", 76 }, 77 } 78 for _, tc := range cases { 79 t.Run(tc.name, func(t *testing.T) { 80 dependencies := []asset.Asset{ 81 &workflow.AgentWorkflow{Workflow: tc.workflow}, 82 } 83 aci := &manifests.AgentClusterInstall{ 84 Config: &v1beta1.AgentClusterInstall{}, 85 } 86 if tc.agentClusterInstall != nil { 87 aci = tc.agentClusterInstall 88 } 89 ci := &joiner.ClusterInfo{} 90 if tc.clusterInfo != nil { 91 ci = tc.clusterInfo 92 } 93 94 dependencies = append(dependencies, ci) 95 dependencies = append(dependencies, aci) 96 parents := asset.Parents{} 97 parents.Add(dependencies...) 98 99 kargs := &Kargs{} 100 err := kargs.Generate(context.Background(), parents) 101 102 if tc.expectedErr == "" { 103 assert.NoError(t, err) 104 assert.Equal(t, tc.expectedArgs, kargs.KernelCmdLine()) 105 } else { 106 assert.Regexp(t, tc.expectedErr, err.Error()) 107 } 108 }) 109 } 110 }