|
| 1 | +// Copyright 2025 Microsoft Corporation |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package e2e |
| 16 | + |
| 17 | +import ( |
| 18 | + "context" |
| 19 | + "fmt" |
| 20 | + "strings" |
| 21 | + "time" |
| 22 | + |
| 23 | + . "github.com/onsi/ginkgo/v2" |
| 24 | + . "github.com/onsi/gomega" |
| 25 | + |
| 26 | + "github.com/Azure/ARO-HCP/test/util/framework" |
| 27 | + "github.com/Azure/ARO-HCP/test/util/labels" |
| 28 | + "github.com/Azure/ARO-HCP/test/util/verifiers" |
| 29 | +) |
| 30 | + |
| 31 | +var _ = Describe("Customer", func() { |
| 32 | + |
| 33 | + backlevelVersions := []string{"4.19"} |
| 34 | + |
| 35 | + for _, version := range backlevelVersions { |
| 36 | + version := version // capture loop variable |
| 37 | + It("should be able to create an HCP cluster with back-level version "+version, |
| 38 | + labels.RequireNothing, |
| 39 | + labels.Critical, |
| 40 | + labels.Positive, |
| 41 | + labels.AroRpApiCompatible, |
| 42 | + func(ctx context.Context) { |
| 43 | + const ( |
| 44 | + customerNetworkSecurityGroupName = "customer-nsg-name-" |
| 45 | + customerVnetName = "customer-vnet-name-" |
| 46 | + customerVnetSubnetName = "customer-vnet-subnet-" |
| 47 | + customerClusterName = "cluster-ver-" |
| 48 | + customerNodePoolName = "np-ver-" |
| 49 | + ) |
| 50 | + tc := framework.NewTestContext() |
| 51 | + |
| 52 | + if tc.UsePooledIdentities() { |
| 53 | + err := tc.AssignIdentityContainers(ctx, 1, 60*time.Second) |
| 54 | + Expect(err).NotTo(HaveOccurred()) |
| 55 | + } |
| 56 | + |
| 57 | + By("creating a resource group") |
| 58 | + resourceGroup, err := tc.NewResourceGroup(ctx, "rg-cluster-back-version", tc.Location()) |
| 59 | + Expect(err).NotTo(HaveOccurred()) |
| 60 | + |
| 61 | + clusterSuffix := strings.ReplaceAll(version, ".", "-") |
| 62 | + clusterName := customerClusterName + clusterSuffix |
| 63 | + |
| 64 | + clusterParams := framework.NewDefaultClusterParams() |
| 65 | + clusterParams.ClusterName = clusterName |
| 66 | + managedResourceGroupName := framework.SuffixName(*resourceGroup.Name+"-"+clusterSuffix, "-managed", 64) |
| 67 | + clusterParams.ManagedResourceGroupName = managedResourceGroupName |
| 68 | + clusterParams.OpenshiftVersionId = version |
| 69 | + |
| 70 | + // copied 4.19 defaults from 01/22/2026 snapshot of NewDefaultClusterParams |
| 71 | + clusterParams.Network = framework.NetworkConfig{ |
| 72 | + NetworkType: "OVNKubernetes", |
| 73 | + PodCIDR: "10.128.0.0/14", |
| 74 | + ServiceCIDR: "172.30.0.0/16", |
| 75 | + MachineCIDR: "10.0.0.0/16", |
| 76 | + HostPrefix: 23, |
| 77 | + } |
| 78 | + clusterParams.EncryptionKeyManagementMode = "CustomerManaged" |
| 79 | + clusterParams.EncryptionType = "KMS" |
| 80 | + clusterParams.APIVisibility = "Public" |
| 81 | + clusterParams.ImageRegistryState = "Enabled" |
| 82 | + clusterParams.ChannelGroup = "stable" |
| 83 | + |
| 84 | + clusterParams, err = tc.CreateClusterCustomerResources(ctx, |
| 85 | + resourceGroup, |
| 86 | + clusterParams, |
| 87 | + map[string]any{ |
| 88 | + "customerNsgName": customerNetworkSecurityGroupName + clusterSuffix, |
| 89 | + "customerVnetName": customerVnetName + clusterSuffix, |
| 90 | + "customerVnetSubnetName": customerVnetSubnetName + clusterSuffix, |
| 91 | + }, |
| 92 | + TestArtifactsFS, |
| 93 | + ) |
| 94 | + Expect(err).NotTo(HaveOccurred()) |
| 95 | + |
| 96 | + By("creating HCP cluster version " + version) |
| 97 | + err = tc.CreateHCPClusterFromParam( |
| 98 | + ctx, |
| 99 | + GinkgoLogr, |
| 100 | + *resourceGroup.Name, |
| 101 | + clusterParams, |
| 102 | + 45*time.Minute, |
| 103 | + ) |
| 104 | + Expect(err).NotTo(HaveOccurred()) |
| 105 | + |
| 106 | + adminRESTConfig, err := tc.GetAdminRESTConfigForHCPCluster( |
| 107 | + ctx, |
| 108 | + tc.Get20240610ClientFactoryOrDie(ctx).NewHcpOpenShiftClustersClient(), |
| 109 | + *resourceGroup.Name, |
| 110 | + clusterName, |
| 111 | + 10*time.Minute, |
| 112 | + ) |
| 113 | + Expect(err).NotTo(HaveOccurred()) |
| 114 | + |
| 115 | + err = verifiers.VerifyHCPCluster(ctx, adminRESTConfig) |
| 116 | + Expect(err).NotTo(HaveOccurred()) |
| 117 | + |
| 118 | + By("creating node pool with back-level version") |
| 119 | + backlevelNodePoolVersions := []string{"4.19.7"} |
| 120 | + |
| 121 | + var matchingNodePoolVersion string |
| 122 | + for _, nodePoolVersion := range backlevelNodePoolVersions { |
| 123 | + if strings.HasPrefix(nodePoolVersion, version+".") { |
| 124 | + matchingNodePoolVersion = nodePoolVersion |
| 125 | + break |
| 126 | + } |
| 127 | + } |
| 128 | + |
| 129 | + if matchingNodePoolVersion != "" { |
| 130 | + nodePoolSuffix := strings.ReplaceAll(matchingNodePoolVersion, ".", "-") |
| 131 | + nodePoolName := customerNodePoolName + nodePoolSuffix |
| 132 | + nodePoolParams := framework.NewDefaultNodePoolParams() |
| 133 | + nodePoolParams.ClusterName = clusterName |
| 134 | + nodePoolParams.NodePoolName = nodePoolName |
| 135 | + nodePoolParams.OpenshiftVersionId = matchingNodePoolVersion |
| 136 | + |
| 137 | + // copied 4.19 defaults from 01/22/2026 snapshot of NewDefaultNodePoolParams |
| 138 | + nodePoolParams.Replicas = int32(2) |
| 139 | + nodePoolParams.VMSize = "Standard_D8s_v3" |
| 140 | + nodePoolParams.OSDiskSizeGiB = int32(64) |
| 141 | + nodePoolParams.DiskStorageAccountType = "StandardSSD_LRS" |
| 142 | + nodePoolParams.ChannelGroup = "stable" |
| 143 | + |
| 144 | + By("creating node pool version " + matchingNodePoolVersion + " and verifying a simple web app can run") |
| 145 | + err = tc.CreateNodePoolFromParam(ctx, |
| 146 | + *resourceGroup.Name, |
| 147 | + clusterName, |
| 148 | + nodePoolParams, |
| 149 | + 45*time.Minute, |
| 150 | + ) |
| 151 | + Expect(err).NotTo(HaveOccurred()) |
| 152 | + |
| 153 | + nodePoolLabel := fmt.Sprintf("%s-%s", clusterName, nodePoolName) |
| 154 | + nodeSelector := map[string]string{"hypershift.openshift.io/nodePool": nodePoolLabel} |
| 155 | + err = verifiers.VerifySimpleWebApp(nodeSelector).Verify(ctx, adminRESTConfig) |
| 156 | + Expect(err).NotTo(HaveOccurred()) |
| 157 | + } |
| 158 | + |
| 159 | + }) |
| 160 | + } |
| 161 | +}) |
0 commit comments