Skip to content

Commit 7b070a2

Browse files
Merge pull request #3747 from Azure/mvacula/aro-22425
New negative E2E test case: subnet and NSG reuse between clusters should not be possible
2 parents b88312b + cd43d24 commit 7b070a2

6 files changed

+150
-0
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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+
"time"
20+
21+
. "github.com/onsi/ginkgo/v2"
22+
. "github.com/onsi/gomega"
23+
24+
"github.com/Azure/ARO-HCP/test/util/framework"
25+
"github.com/Azure/ARO-HCP/test/util/labels"
26+
)
27+
28+
var _ = Describe("Customer", func() {
29+
30+
It("should not be able to reuse subnets and NSGs between clusters",
31+
labels.RequireNothing,
32+
labels.Medium,
33+
labels.Negative,
34+
labels.AroRpApiCompatible,
35+
func(ctx context.Context) {
36+
const (
37+
customerNetworkSecurityGroupName = "customer-nsg-name"
38+
customerVnetName = "customer-vnet-name"
39+
customerVnetSubnetName = "customer-vnet-subnet"
40+
)
41+
tc := framework.NewTestContext()
42+
43+
if tc.UsePooledIdentities() {
44+
err := tc.AssignIdentityContainers(ctx, 3, 60*time.Second)
45+
Expect(err).NotTo(HaveOccurred())
46+
}
47+
48+
By("creating a resource group")
49+
resourceGroup, err := tc.NewResourceGroup(ctx, "rg-cluster-nsg-subnet-reuse", tc.Location())
50+
Expect(err).NotTo(HaveOccurred())
51+
52+
By("creating customer resources")
53+
clusterParams1 := framework.NewDefaultClusterParams()
54+
clusterParams1.ClusterName = "basic-cluster"
55+
managedResourceGroupName1 := framework.SuffixName(*resourceGroup.Name, "-managed-1", 64)
56+
clusterParams1.ManagedResourceGroupName = managedResourceGroupName1
57+
58+
clusterParams1, err = tc.CreateClusterCustomerResources(ctx,
59+
resourceGroup,
60+
clusterParams1,
61+
map[string]any{
62+
"customerNsgName": customerNetworkSecurityGroupName + "1",
63+
"customerVnetName": customerVnetName + "1",
64+
"customerVnetSubnetName": customerVnetSubnetName + "1",
65+
},
66+
TestArtifactsFS,
67+
)
68+
Expect(err).NotTo(HaveOccurred())
69+
70+
By("creating HCP cluster")
71+
err = tc.CreateHCPClusterFromParam(
72+
ctx,
73+
GinkgoLogr,
74+
*resourceGroup.Name,
75+
clusterParams1,
76+
45*time.Minute,
77+
)
78+
Expect(err).NotTo(HaveOccurred())
79+
80+
By("creating customer resources with the same subnet resource ID")
81+
clusterParams2 := framework.NewDefaultClusterParams()
82+
clusterParams2.ClusterName = "cluster-subnet-reuse"
83+
managedResourceGroupName2 := framework.SuffixName(*resourceGroup.Name, "-managed-2", 64)
84+
clusterParams2.ManagedResourceGroupName = managedResourceGroupName2
85+
86+
clusterParams2, err = tc.CreateClusterCustomerResources(ctx,
87+
resourceGroup,
88+
clusterParams2,
89+
map[string]any{
90+
"customerNsgName": customerNetworkSecurityGroupName + "2",
91+
"customerVnetName": customerVnetName + "2",
92+
"customerVnetSubnetName": customerVnetSubnetName + "2",
93+
},
94+
TestArtifactsFS,
95+
)
96+
Expect(err).NotTo(HaveOccurred())
97+
98+
clusterParams2.SubnetResourceID = clusterParams1.SubnetResourceID
99+
100+
By("attempting to create HCP cluster with already used subnet resource")
101+
err = tc.CreateHCPClusterFromParam(
102+
ctx,
103+
GinkgoLogr,
104+
*resourceGroup.Name,
105+
clusterParams2,
106+
5*time.Minute,
107+
)
108+
Expect(err).To(HaveOccurred())
109+
GinkgoLogr.Error(err, "cluster deployment error")
110+
Expect(err.Error()).To(MatchRegexp("Subnet .* is already in use by another cluster"))
111+
112+
By("creating customer resources with the same NSG resource ID")
113+
clusterParams3 := framework.NewDefaultClusterParams()
114+
clusterParams3.ClusterName = "cluster-nsg-reuse"
115+
managedResourceGroupName3 := framework.SuffixName(*resourceGroup.Name, "-managed-3", 64)
116+
clusterParams3.ManagedResourceGroupName = managedResourceGroupName3
117+
118+
clusterParams3, err = tc.CreateClusterCustomerResources(ctx,
119+
resourceGroup,
120+
clusterParams3,
121+
map[string]any{
122+
"customerNsgName": customerNetworkSecurityGroupName + "3",
123+
"customerVnetName": customerVnetName + "3",
124+
"customerVnetSubnetName": customerVnetSubnetName + "3",
125+
},
126+
TestArtifactsFS,
127+
)
128+
Expect(err).NotTo(HaveOccurred())
129+
130+
clusterParams3.NsgResourceID = clusterParams1.NsgResourceID
131+
132+
By("attempting to create HCP cluster with already used NSG resource")
133+
err = tc.CreateHCPClusterFromParam(
134+
ctx,
135+
GinkgoLogr,
136+
*resourceGroup.Name,
137+
clusterParams3,
138+
5*time.Minute,
139+
)
140+
Expect(err).To(HaveOccurred())
141+
GinkgoLogr.Error(err, "cluster deployment error")
142+
Expect(err.Error()).To(MatchRegexp("Network Security Group .* is already in use by another cluster"))
143+
144+
})
145+
})

test/testdata/zz_fixture_TestMainListSuitesForEachSuite_integration_parallelintegration_parallel.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Customer should be able to create a HCP cluster without CNI
88
Customer should be able to create an HCP cluster and custom node pool osDisk size using bicep template
99
Customer should be able to list HCP clusters without node pools at both subscription and resource group levels
1010
Customer should not be able to deploy 2 identically named clusters within the same resource group
11+
Customer should not be able to reuse subnets and NSGs between clusters
1112
Customer should create an HCP cluster and validate TLS certificates
1213
Update HCPOpenShiftCluster Negative creates a cluster and fails to update its name with a PATCH request
1314
Update HCPOpenShiftCluster Positive creates a cluster and updates tags with a PATCH request

test/testdata/zz_fixture_TestMainListSuitesForEachSuite_prod_parallelprod_parallel.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Customer should be able to create a HCP cluster without CNI
77
Customer should be able to create an HCP cluster and custom node pool osDisk size using bicep template
88
Customer should be able to list HCP clusters without node pools at both subscription and resource group levels
99
Customer should not be able to deploy 2 identically named clusters within the same resource group
10+
Customer should not be able to reuse subnets and NSGs between clusters
1011
Customer should create an HCP cluster and validate TLS certificates
1112
Update HCPOpenShiftCluster Negative creates a cluster and fails to update its name with a PATCH request
1213
Update HCPOpenShiftCluster Positive creates a cluster and updates tags with a PATCH request

test/testdata/zz_fixture_TestMainListSuitesForEachSuite_rp_api_compat_all_parallel_01rp_api_compat_all_parallel_development.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Customer should not be able to create a 4.18 HCP cluster
66
Customer should be able to create a HCP cluster without CNI
77
Customer should be able to list HCP clusters without node pools at both subscription and resource group levels
88
Customer should not be able to deploy 2 identically named clusters within the same resource group
9+
Customer should not be able to reuse subnets and NSGs between clusters
910
Update HCPOpenShiftCluster Positive creates a cluster and updates tags with a PATCH request
1011
Customer should be able to create several HCP clusters in their customer resource group, but not in the same managed resource group
1112
Customer should be able to create an HCP cluster using bicep templates

test/testdata/zz_fixture_TestMainListSuitesForEachSuite_rp_api_compat_all_parallelrp_api_compat_all_parallel.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Customer should not be able to create a 4.18 HCP cluster
66
Customer should be able to create a HCP cluster without CNI
77
Customer should be able to list HCP clusters without node pools at both subscription and resource group levels
88
Customer should not be able to deploy 2 identically named clusters within the same resource group
9+
Customer should not be able to reuse subnets and NSGs between clusters
910
Update HCPOpenShiftCluster Positive creates a cluster and updates tags with a PATCH request
1011
Customer should be able to create several HCP clusters in their customer resource group, but not in the same managed resource group
1112
Customer should be able to create an HCP cluster using bicep templates

test/testdata/zz_fixture_TestMainListSuitesForEachSuite_stage_parallelstage_parallel.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Customer should be able to create a HCP cluster without CNI
77
Customer should be able to create an HCP cluster and custom node pool osDisk size using bicep template
88
Customer should be able to list HCP clusters without node pools at both subscription and resource group levels
99
Customer should not be able to deploy 2 identically named clusters within the same resource group
10+
Customer should not be able to reuse subnets and NSGs between clusters
1011
Customer should create an HCP cluster and validate TLS certificates
1112
Update HCPOpenShiftCluster Negative creates a cluster and fails to update its name with a PATCH request
1213
Update HCPOpenShiftCluster Positive creates a cluster and updates tags with a PATCH request

0 commit comments

Comments
 (0)