@@ -74,6 +74,7 @@ func TestValidate(t *testing.T) {
7474 subnetsInVPC * SubnetGroups
7575 vpcTags Tags
7676 instanceTypes map [string ]InstanceType
77+ hosts map [string ]Host
7778 proxy string
7879 publicOnly bool
7980 expectErr string
@@ -1200,6 +1201,44 @@ func TestValidate(t *testing.T) {
12001201 },
12011202 expectErr : `^\Qplatform.aws.vpc.subnets: Forbidden: subnet subnet-valid-public-a1 is owned by other clusters [another-cluster] and cannot be used for new installations, another subnet must be created separately\E$` ,
12021203 },
1204+ {
1205+ name : "valid dedicated host placement on compute" ,
1206+ installConfig : icBuild .build (
1207+ icBuild .withComputePlatformZones ([]string {"a" }, true , 0 ),
1208+ icBuild .withComputeHostPlacement ([]string {"h-1234567890abcdef0" }, 0 ),
1209+ ),
1210+ availRegions : validAvailRegions (),
1211+ availZones : validAvailZones (),
1212+ hosts : map [string ]Host {
1213+ "h-1234567890abcdef0" : {ID : "h-1234567890abcdef0" , Zone : "a" },
1214+ },
1215+ },
1216+ {
1217+ name : "invalid dedicated host not found" ,
1218+ installConfig : icBuild .build (
1219+ icBuild .withComputePlatformZones ([]string {"a" }, true , 0 ),
1220+ icBuild .withComputeHostPlacement ([]string {"h-aaaaaaaaaaaaaaaaa" }, 0 ),
1221+ ),
1222+ availRegions : validAvailRegions (),
1223+ availZones : validAvailZones (),
1224+ hosts : map [string ]Host {
1225+ "h-1234567890abcdef0" : {ID : "h-1234567890abcdef0" , Zone : "a" },
1226+ },
1227+ expectErr : "dedicated host h-aaaaaaaaaaaaaaaaa not found" ,
1228+ },
1229+ {
1230+ name : "invalid dedicated host zone not in pool zones" ,
1231+ installConfig : icBuild .build (
1232+ icBuild .withComputePlatformZones ([]string {"a" }, true , 0 ),
1233+ icBuild .withComputeHostPlacement ([]string {"h-bbbbbbbbbbbbbbbbb" }, 0 ),
1234+ ),
1235+ availRegions : validAvailRegions (),
1236+ availZones : validAvailZones (),
1237+ hosts : map [string ]Host {
1238+ "h-bbbbbbbbbbbbbbbbb" : {ID : "h-bbbbbbbbbbbbbbbbb" , Zone : "b" },
1239+ },
1240+ expectErr : "is not available in pool's zone list" ,
1241+ },
12031242 }
12041243
12051244 // Register mock http(s) responses for tests.
@@ -1232,6 +1271,7 @@ func TestValidate(t *testing.T) {
12321271 Tags : test .vpcTags ,
12331272 },
12341273 instanceTypes : test .instanceTypes ,
1274+ Hosts : test .hosts ,
12351275 ProvidedSubnets : test .installConfig .Platform .AWS .VPC .Subnets ,
12361276 }
12371277
@@ -1952,6 +1992,20 @@ func (icBuild icBuildForAWS) withComputePlatformZones(zones []string, overwrite
19521992 }
19531993}
19541994
1995+ func (icBuild icBuildForAWS ) withComputeHostPlacement (hostIDs []string , index int ) icOption {
1996+ return func (ic * types.InstallConfig ) {
1997+ aff := aws .HostAffinityDedicatedHost
1998+ dhs := make ([]aws.DedicatedHost , 0 , len (hostIDs ))
1999+ for _ , id := range hostIDs {
2000+ dhs = append (dhs , aws.DedicatedHost {ID : id })
2001+ }
2002+ ic .Compute [index ].Platform .AWS .HostPlacement = & aws.HostPlacement {
2003+ Affinity : & aff ,
2004+ DedicatedHost : dhs ,
2005+ }
2006+ }
2007+ }
2008+
19552009func (icBuild icBuildForAWS ) withControlPlanePlatformAMI (amiID string ) icOption {
19562010 return func (ic * types.InstallConfig ) {
19572011 ic .ControlPlane .Platform .AWS .AMIID = amiID
0 commit comments