@@ -14,6 +14,7 @@ import (
1414 aiv1beta1 "github.com/openshift/assisted-service/api/v1beta1"
1515 "github.com/openshift/assisted-service/models"
1616 "github.com/openshift/installer/pkg/asset"
17+ agentconfig "github.com/openshift/installer/pkg/asset/agent"
1718 "github.com/openshift/installer/pkg/asset/agent/joiner"
1819 "github.com/openshift/installer/pkg/asset/agent/workflow"
1920 "github.com/openshift/installer/pkg/asset/mock"
@@ -28,6 +29,56 @@ func TestNMStateConfig_Generate(t *testing.T) {
2829 expectedConfig []* aiv1beta1.NMStateConfig
2930 expectedError string
3031 }{
32+ {
33+ name : "add-nodes workflow" ,
34+ dependencies : []asset.Asset {
35+ & workflow.AgentWorkflow {Workflow : workflow .AgentWorkflowTypeAddNodes },
36+ & joiner.ClusterInfo {},
37+ getAgentHostsNoHosts (),
38+ & agentconfig.OptionalInstallConfig {},
39+ },
40+ requiresNmstatectl : false ,
41+ expectedConfig : nil ,
42+ expectedError : "" ,
43+ },
44+ {
45+ name : "add-nodes workflow - agentHosts with some hosts without networkconfig" ,
46+ dependencies : []asset.Asset {
47+ & workflow.AgentWorkflow {Workflow : workflow .AgentWorkflowTypeAddNodes },
48+ & joiner.ClusterInfo {
49+ Namespace : "cluster0" ,
50+ ClusterName : "ostest" ,
51+ },
52+ getAgentHostsWithSomeHostsWithoutNetworkConfig (),
53+ & agentconfig.OptionalInstallConfig {},
54+ },
55+ requiresNmstatectl : true ,
56+ expectedConfig : []* aiv1beta1.NMStateConfig {
57+ {
58+ TypeMeta : metav1.TypeMeta {
59+ Kind : "NMStateConfig" ,
60+ APIVersion : "agent-install.openshift.io/v1beta1" ,
61+ },
62+ ObjectMeta : metav1.ObjectMeta {
63+ Name : "ostest-0" ,
64+ Namespace : "cluster0" ,
65+ Labels : getNMStateConfigLabels ("ostest" ),
66+ },
67+ Spec : aiv1beta1.NMStateConfigSpec {
68+ Interfaces : []* aiv1beta1.Interface {
69+ {
70+ Name : "enp2t0" ,
71+ MacAddress : "98:af:65:a5:8d:02" ,
72+ },
73+ },
74+ NetConfig : aiv1beta1.NetConfig {
75+ Raw : unmarshalJSON ([]byte (rawNMStateConfigNoIP )),
76+ },
77+ },
78+ },
79+ },
80+ expectedError : "" ,
81+ },
3182 {
3283 name : "agentHosts does not contain networkConfig" ,
3384 dependencies : []asset.Asset {
@@ -56,7 +107,7 @@ func TestNMStateConfig_Generate(t *testing.T) {
56107 APIVersion : "agent-install.openshift.io/v1beta1" ,
57108 },
58109 ObjectMeta : metav1.ObjectMeta {
59- Name : fmt .Sprint (getNMStateConfigName ( getValidOptionalInstallConfig ()), "-0" ),
110+ Name : fmt .Sprint (getValidOptionalInstallConfig (). ClusterName ( ), "-0" ),
60111 Namespace : getValidOptionalInstallConfig ().ClusterNamespace (),
61112 Labels : getNMStateConfigLabels (getValidOptionalInstallConfig ().ClusterName ()),
62113 },
@@ -91,7 +142,7 @@ func TestNMStateConfig_Generate(t *testing.T) {
91142 APIVersion : "agent-install.openshift.io/v1beta1" ,
92143 },
93144 ObjectMeta : metav1.ObjectMeta {
94- Name : fmt .Sprint (getNMStateConfigName ( getValidOptionalInstallConfig ()), "-0" ),
145+ Name : fmt .Sprint (getValidOptionalInstallConfig (). ClusterName ( ), "-0" ),
95146 Namespace : getValidOptionalInstallConfig ().ClusterNamespace (),
96147 Labels : getNMStateConfigLabels (getValidOptionalInstallConfig ().ClusterName ()),
97148 },
@@ -117,7 +168,7 @@ func TestNMStateConfig_Generate(t *testing.T) {
117168 APIVersion : "agent-install.openshift.io/v1beta1" ,
118169 },
119170 ObjectMeta : metav1.ObjectMeta {
120- Name : fmt .Sprint (getNMStateConfigName ( getValidOptionalInstallConfig ()), "-1" ),
171+ Name : fmt .Sprint (getValidOptionalInstallConfig (). ClusterName ( ), "-1" ),
121172 Namespace : getValidOptionalInstallConfig ().ClusterNamespace (),
122173 Labels : getNMStateConfigLabels (getValidOptionalInstallConfig ().ClusterName ()),
123174 },
@@ -139,7 +190,7 @@ func TestNMStateConfig_Generate(t *testing.T) {
139190 APIVersion : "agent-install.openshift.io/v1beta1" ,
140191 },
141192 ObjectMeta : metav1.ObjectMeta {
142- Name : fmt .Sprint (getNMStateConfigName ( getValidOptionalInstallConfig ()), "-2" ),
193+ Name : fmt .Sprint (getValidOptionalInstallConfig (). ClusterName ( ), "-2" ),
143194 Namespace : getValidOptionalInstallConfig ().ClusterNamespace (),
144195 Labels : getNMStateConfigLabels (getValidOptionalInstallConfig ().ClusterName ()),
145196 },
0 commit comments