@@ -1324,8 +1324,8 @@ func TestComputeMachineDeployment(t *testing.T) {
1324
1324
Build ()
1325
1325
workerBootstrapTemplate := builder .BootstrapTemplate (metav1 .NamespaceDefault , "linux-worker-bootstraptemplate" ).
1326
1326
Build ()
1327
- labels := map [string ]string {"fizz " : "buzz" , "foo " : "bar" }
1328
- annotations := map [string ]string {"annotation-1 " : "annotation-1-val " }
1327
+ labels := map [string ]string {"fizzLabel " : "buzz" , "fooLabel " : "bar" }
1328
+ annotations := map [string ]string {"fizzAnnotation " : "buzz" , "fooAnnotation" : "bar " }
1329
1329
1330
1330
unhealthyConditions := []clusterv1.UnhealthyCondition {
1331
1331
{
@@ -1410,7 +1410,17 @@ func TestComputeMachineDeployment(t *testing.T) {
1410
1410
}
1411
1411
mdTopology := clusterv1.MachineDeploymentTopology {
1412
1412
Metadata : clusterv1.ObjectMeta {
1413
- Labels : map [string ]string {"foo" : "baz" },
1413
+ Labels : map [string ]string {
1414
+ // Should overwrite the label from the MachineDeployment class.
1415
+ "fooLabel" : "baz" ,
1416
+ },
1417
+ Annotations : map [string ]string {
1418
+ // Should overwrite the annotation from the MachineDeployment class.
1419
+ "fooAnnotation" : "baz" ,
1420
+ // These annotations should not be propagated to the MachineDeployment.
1421
+ clusterv1 .ClusterTopologyDeferUpgradeAnnotation : "" ,
1422
+ clusterv1 .ClusterTopologyHoldUpgradeSequenceAnnotation : "" ,
1423
+ },
1414
1424
},
1415
1425
Class : "linux-worker" ,
1416
1426
Name : "big-pool-of-machines" ,
@@ -1457,18 +1467,28 @@ func TestComputeMachineDeployment(t *testing.T) {
1457
1467
g .Expect (actualMd .Name ).To (ContainSubstring ("cluster1" ))
1458
1468
g .Expect (actualMd .Name ).To (ContainSubstring ("big-pool-of-machines" ))
1459
1469
1460
- g .Expect (actualMd .Labels ).To (HaveKeyWithValue (clusterv1 .ClusterTopologyMachineDeploymentNameLabel , "big-pool-of-machines" ))
1461
- g .Expect (actualMd .Labels ).To (HaveKey (clusterv1 .ClusterTopologyOwnedLabel ))
1462
- for k , v := range mergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels ) {
1463
- g .Expect (actualMd .Labels ).To (HaveKeyWithValue (k , v ))
1464
- }
1465
-
1466
- g .Expect (actualMd .Spec .Selector .MatchLabels ).To (HaveKey (clusterv1 .ClusterTopologyOwnedLabel ))
1467
- g .Expect (actualMd .Spec .Selector .MatchLabels ).To (HaveKeyWithValue (clusterv1 .ClusterTopologyMachineDeploymentNameLabel , "big-pool-of-machines" ))
1470
+ expectedAnnotations := mergeMap (mdTopology .Metadata .Annotations , md1 .Template .Metadata .Annotations )
1471
+ delete (expectedAnnotations , clusterv1 .ClusterTopologyHoldUpgradeSequenceAnnotation )
1472
+ delete (expectedAnnotations , clusterv1 .ClusterTopologyDeferUpgradeAnnotation )
1473
+ g .Expect (actualMd .Annotations ).To (Equal (expectedAnnotations ))
1474
+ g .Expect (actualMd .Spec .Template .ObjectMeta .Annotations ).To (Equal (expectedAnnotations ))
1475
+
1476
+ g .Expect (actualMd .Labels ).To (Equal (mergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels , map [string ]string {
1477
+ clusterv1 .ClusterNameLabel : cluster .Name ,
1478
+ clusterv1 .ClusterTopologyOwnedLabel : "" ,
1479
+ clusterv1 .ClusterTopologyMachineDeploymentNameLabel : "big-pool-of-machines" ,
1480
+ })))
1481
+ g .Expect (actualMd .Spec .Selector .MatchLabels ).To (Equal (map [string ]string {
1482
+ clusterv1 .ClusterNameLabel : cluster .Name ,
1483
+ clusterv1 .ClusterTopologyOwnedLabel : "" ,
1484
+ clusterv1 .ClusterTopologyMachineDeploymentNameLabel : "big-pool-of-machines" ,
1485
+ }))
1486
+ g .Expect (actualMd .Spec .Template .ObjectMeta .Labels ).To (Equal (mergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels , map [string ]string {
1487
+ clusterv1 .ClusterNameLabel : cluster .Name ,
1488
+ clusterv1 .ClusterTopologyOwnedLabel : "" ,
1489
+ clusterv1 .ClusterTopologyMachineDeploymentNameLabel : "big-pool-of-machines" ,
1490
+ })))
1468
1491
1469
- g .Expect (actualMd .Spec .Template .ObjectMeta .Labels ).To (HaveKeyWithValue ("foo" , "baz" ))
1470
- g .Expect (actualMd .Spec .Template .ObjectMeta .Labels ).To (HaveKeyWithValue ("fizz" , "buzz" ))
1471
- g .Expect (actualMd .Spec .Template .ObjectMeta .Labels ).To (HaveKey (clusterv1 .ClusterTopologyOwnedLabel ))
1472
1492
g .Expect (actualMd .Spec .Template .Spec .InfrastructureRef .Name ).ToNot (Equal ("linux-worker-inframachinetemplate" ))
1473
1493
g .Expect (actualMd .Spec .Template .Spec .Bootstrap .ConfigRef .Name ).ToNot (Equal ("linux-worker-bootstraptemplate" ))
1474
1494
})
@@ -1540,15 +1560,28 @@ func TestComputeMachineDeployment(t *testing.T) {
1540
1560
g .Expect (* actualMd .Spec .Template .Spec .FailureDomain ).To (Equal (topologyFailureDomain ))
1541
1561
g .Expect (actualMd .Name ).To (Equal ("existing-deployment-1" ))
1542
1562
1543
- g .Expect (actualMd .Labels ).To (HaveKeyWithValue (clusterv1 .ClusterTopologyMachineDeploymentNameLabel , "big-pool-of-machines" ))
1544
- g .Expect (actualMd .Labels ).To (HaveKey (clusterv1 .ClusterTopologyOwnedLabel ))
1545
- for k , v := range mergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels ) {
1546
- g .Expect (actualMd .Labels ).To (HaveKeyWithValue (k , v ))
1547
- }
1563
+ expectedAnnotations := mergeMap (mdTopology .Metadata .Annotations , md1 .Template .Metadata .Annotations )
1564
+ delete (expectedAnnotations , clusterv1 .ClusterTopologyHoldUpgradeSequenceAnnotation )
1565
+ delete (expectedAnnotations , clusterv1 .ClusterTopologyDeferUpgradeAnnotation )
1566
+ g .Expect (actualMd .Annotations ).To (Equal (expectedAnnotations ))
1567
+ g .Expect (actualMd .Spec .Template .ObjectMeta .Annotations ).To (Equal (expectedAnnotations ))
1568
+
1569
+ g .Expect (actualMd .Labels ).To (Equal (mergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels , map [string ]string {
1570
+ clusterv1 .ClusterNameLabel : cluster .Name ,
1571
+ clusterv1 .ClusterTopologyOwnedLabel : "" ,
1572
+ clusterv1 .ClusterTopologyMachineDeploymentNameLabel : "big-pool-of-machines" ,
1573
+ })))
1574
+ g .Expect (actualMd .Spec .Selector .MatchLabels ).To (Equal (map [string ]string {
1575
+ clusterv1 .ClusterNameLabel : cluster .Name ,
1576
+ clusterv1 .ClusterTopologyOwnedLabel : "" ,
1577
+ clusterv1 .ClusterTopologyMachineDeploymentNameLabel : "big-pool-of-machines" ,
1578
+ }))
1579
+ g .Expect (actualMd .Spec .Template .ObjectMeta .Labels ).To (Equal (mergeMap (mdTopology .Metadata .Labels , md1 .Template .Metadata .Labels , map [string ]string {
1580
+ clusterv1 .ClusterNameLabel : cluster .Name ,
1581
+ clusterv1 .ClusterTopologyOwnedLabel : "" ,
1582
+ clusterv1 .ClusterTopologyMachineDeploymentNameLabel : "big-pool-of-machines" ,
1583
+ })))
1548
1584
1549
- g .Expect (actualMd .Spec .Template .ObjectMeta .Labels ).To (HaveKeyWithValue ("foo" , "baz" ))
1550
- g .Expect (actualMd .Spec .Template .ObjectMeta .Labels ).To (HaveKeyWithValue ("fizz" , "buzz" ))
1551
- g .Expect (actualMd .Spec .Template .ObjectMeta .Labels ).To (HaveKey (clusterv1 .ClusterTopologyOwnedLabel ))
1552
1585
g .Expect (actualMd .Spec .Template .Spec .InfrastructureRef .Name ).To (Equal ("linux-worker-inframachinetemplate" ))
1553
1586
g .Expect (actualMd .Spec .Template .Spec .Bootstrap .ConfigRef .Name ).To (Equal ("linux-worker-bootstraptemplate" ))
1554
1587
})
0 commit comments