-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8760 from andfasano/day2-fips
AGENT-900: enable fips for add-nodes workflow
- Loading branch information
Showing
5 changed files
with
139 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package image | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/openshift/assisted-service/api/hiveextension/v1beta1" | ||
"github.com/openshift/installer/pkg/asset" | ||
"github.com/openshift/installer/pkg/asset/agent/joiner" | ||
"github.com/openshift/installer/pkg/asset/agent/manifests" | ||
"github.com/openshift/installer/pkg/asset/agent/workflow" | ||
) | ||
|
||
func TestKargs_Generate(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
workflow workflow.AgentWorkflowType | ||
agentClusterInstall *manifests.AgentClusterInstall | ||
clusterInfo *joiner.ClusterInfo | ||
expectedArgs string | ||
expectedErr string | ||
}{ | ||
{ | ||
name: "install workflow - default", | ||
workflow: workflow.AgentWorkflowTypeInstall, | ||
expectedArgs: "", | ||
}, | ||
{ | ||
name: "install workflow - fips enabled", | ||
workflow: workflow.AgentWorkflowTypeInstall, | ||
agentClusterInstall: &manifests.AgentClusterInstall{ | ||
Config: &v1beta1.AgentClusterInstall{ | ||
ObjectMeta: v1.ObjectMeta{ | ||
Annotations: map[string]string{ | ||
"agent-install.openshift.io/install-config-overrides": `{"fips": true}`, | ||
}, | ||
}, | ||
}, | ||
}, | ||
expectedArgs: " fips=1", | ||
}, | ||
{ | ||
name: "install workflow - oci with fips enabled", | ||
workflow: workflow.AgentWorkflowTypeInstall, | ||
agentClusterInstall: &manifests.AgentClusterInstall{ | ||
Config: &v1beta1.AgentClusterInstall{ | ||
ObjectMeta: v1.ObjectMeta{ | ||
Annotations: map[string]string{ | ||
"agent-install.openshift.io/install-config-overrides": `{"fips": true}`, | ||
}, | ||
}, | ||
Spec: v1beta1.AgentClusterInstallSpec{ | ||
ExternalPlatformSpec: &v1beta1.ExternalPlatformSpec{ | ||
PlatformName: "oci", | ||
}, | ||
}, | ||
}, | ||
}, | ||
expectedArgs: " console=ttyS0 fips=1", | ||
}, | ||
{ | ||
name: "add-nodes workflow - default", | ||
workflow: workflow.AgentWorkflowTypeAddNodes, | ||
expectedArgs: "", | ||
}, | ||
{ | ||
name: "add-nodes workflow - fips enabled", | ||
workflow: workflow.AgentWorkflowTypeAddNodes, | ||
clusterInfo: &joiner.ClusterInfo{ | ||
FIPS: true, | ||
}, | ||
expectedArgs: " fips=1", | ||
}, | ||
} | ||
for _, tc := range cases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
dependencies := []asset.Asset{ | ||
&workflow.AgentWorkflow{Workflow: tc.workflow}, | ||
} | ||
aci := &manifests.AgentClusterInstall{ | ||
Config: &v1beta1.AgentClusterInstall{}, | ||
} | ||
if tc.agentClusterInstall != nil { | ||
aci = tc.agentClusterInstall | ||
} | ||
ci := &joiner.ClusterInfo{} | ||
if tc.clusterInfo != nil { | ||
ci = tc.clusterInfo | ||
} | ||
|
||
dependencies = append(dependencies, ci) | ||
dependencies = append(dependencies, aci) | ||
parents := asset.Parents{} | ||
parents.Add(dependencies...) | ||
|
||
kargs := &Kargs{} | ||
err := kargs.Generate(context.Background(), parents) | ||
|
||
if tc.expectedErr == "" { | ||
assert.NoError(t, err) | ||
assert.Equal(t, tc.expectedArgs, string(kargs.KernelCmdLine())) | ||
} else { | ||
assert.Regexp(t, tc.expectedErr, err.Error()) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters