sigs.k8s.io/cluster-api-provider-azure@v1.17.0/azure/converters/managedagentpool_test.go (about) 1 /* 2 Copyright 2022 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package converters 18 19 import ( 20 "testing" 21 22 asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001" 23 asocontainerservicev1hub "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001/storage" 24 "github.com/Azure/azure-service-operator/v2/pkg/genruntime" 25 . "github.com/onsi/gomega" 26 "k8s.io/utils/ptr" 27 ) 28 29 func Test_AgentPoolToManagedClusterAgentPoolProfile(t *testing.T) { 30 cases := []struct { 31 name string 32 pool *asocontainerservicev1hub.ManagedClustersAgentPool 33 expect func(*GomegaWithT, asocontainerservicev1hub.ManagedClusterAgentPoolProfile) 34 }{ 35 { 36 name: "Should set all values correctly", 37 pool: &asocontainerservicev1hub.ManagedClustersAgentPool{ 38 Spec: asocontainerservicev1hub.ManagedClusters_AgentPool_Spec{ 39 AzureName: "agentpool1", 40 VmSize: ptr.To("Standard_D2s_v3"), 41 OsType: ptr.To(string(asocontainerservicev1.OSType_Linux)), 42 OsDiskSizeGB: ptr.To(100), 43 Count: ptr.To(2), 44 Type: ptr.To(string(asocontainerservicev1.AgentPoolType_VirtualMachineScaleSets)), 45 OrchestratorVersion: ptr.To("1.22.6"), 46 VnetSubnetReference: &genruntime.ResourceReference{ 47 ARMID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-123/providers/Microsoft.Network/virtualNetworks/vnet-123/subnets/subnet-123", 48 }, 49 Mode: ptr.To(string(asocontainerservicev1.AgentPoolMode_User)), 50 EnableAutoScaling: ptr.To(true), 51 MaxCount: ptr.To(5), 52 MinCount: ptr.To(2), 53 NodeTaints: []string{"key1=value1:NoSchedule"}, 54 AvailabilityZones: []string{"zone1"}, 55 MaxPods: ptr.To(60), 56 OsDiskType: ptr.To(string(asocontainerservicev1.OSDiskType_Managed)), 57 NodeLabels: map[string]string{ 58 "custom": "default", 59 }, 60 Tags: map[string]string{ 61 "custom": "default", 62 }, 63 EnableFIPS: ptr.To(true), 64 EnableEncryptionAtHost: ptr.To(true), 65 }, 66 }, 67 68 expect: func(g *GomegaWithT, result asocontainerservicev1hub.ManagedClusterAgentPoolProfile) { 69 g.Expect(result).To(Equal(asocontainerservicev1hub.ManagedClusterAgentPoolProfile{ 70 Name: ptr.To("agentpool1"), 71 VmSize: ptr.To("Standard_D2s_v3"), 72 OsType: ptr.To(string(asocontainerservicev1.OSType_Linux)), 73 OsDiskSizeGB: ptr.To(100), 74 Count: ptr.To(2), 75 Type: ptr.To(string(asocontainerservicev1.AgentPoolType_VirtualMachineScaleSets)), 76 OrchestratorVersion: ptr.To("1.22.6"), 77 VnetSubnetReference: &genruntime.ResourceReference{ 78 ARMID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-123/providers/Microsoft.Network/virtualNetworks/vnet-123/subnets/subnet-123", 79 }, 80 Mode: ptr.To(string(asocontainerservicev1.AgentPoolMode_User)), 81 EnableAutoScaling: ptr.To(true), 82 MaxCount: ptr.To(5), 83 MinCount: ptr.To(2), 84 NodeTaints: []string{"key1=value1:NoSchedule"}, 85 AvailabilityZones: []string{"zone1"}, 86 MaxPods: ptr.To(60), 87 OsDiskType: ptr.To(string(asocontainerservicev1.OSDiskType_Managed)), 88 NodeLabels: map[string]string{ 89 "custom": "default", 90 }, 91 Tags: map[string]string{ 92 "custom": "default", 93 }, 94 EnableFIPS: ptr.To(true), 95 EnableEncryptionAtHost: ptr.To(true), 96 })) 97 }, 98 }, 99 } 100 101 for _, c := range cases { 102 c := c 103 t.Run(c.name, func(t *testing.T) { 104 t.Parallel() 105 g := NewGomegaWithT(t) 106 result := AgentPoolToManagedClusterAgentPoolProfile(c.pool) 107 c.expect(g, result) 108 }) 109 } 110 }