Skip to content

Commit e0a6c0d

Browse files
authored
test: moved all mutlitenant test to other (#658)
1 parent 9e6b1f8 commit e0a6c0d

File tree

11 files changed

+261
-101
lines changed

11 files changed

+261
-101
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ An IBM Provider [issue](https://github.com/IBM-Cloud/terraform-provider-ibm/issu
2626
* [Examples](./examples)
2727
* [Advanced dedicated service VPE gateway](./examples/advanced)
2828
* [Basic multi-tenant VPE gateway](./examples/basic)
29+
* [Every supported multi-tenant ("provider_cloud_service") VPE gateway](./examples/every-multi-tenant-svc)
2930
* [Existing Reserved IPs example](./examples/reserved-ips)
3031
* [Contributing](#contributing)
3132
<!-- END OVERVIEW HOOK -->

examples/basic/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ This example creates the following infrastructure:
44
- A resource group, if one is not passed in.
55
- A VPC
66
- The VPC is created with three subnets across the three availability zones of the region that is passed as input.
7-
- A virtual private endpoint (VPE) gateways for every multitenant service supported
7+
- A virtual private endpoint (VPE) gateways for a couple of the multitenant services

examples/basic/main.tf

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -38,107 +38,11 @@ module "vpes" {
3838
subnet_zone_list = module.vpc.subnet_zone_list
3939
resource_group_id = module.resource_group.resource_group_id
4040
cloud_services = [
41-
{
42-
service_name = "account-management"
43-
},
44-
{
45-
service_name = "billing"
46-
},
47-
{
48-
service_name = "cloud-object-storage"
49-
vpe_name = "${var.prefix}-cos"
50-
},
51-
{
52-
service_name = "cloud-object-storage-config"
53-
vpe_name = "${var.prefix}-cos-config"
54-
},
55-
{
56-
service_name = "codeengine"
57-
},
58-
{
59-
service_name = "container-registry"
60-
},
61-
{
62-
service_name = "containers-kubernetes"
63-
vpe_name = "${var.prefix}-kubernetes"
64-
},
65-
{
66-
service_name = "context-based-restrictions"
67-
vpe_name = "${var.prefix}-cbr"
68-
},
69-
{
70-
service_name = "directlink"
71-
},
72-
{
73-
service_name = "dns-svcs"
74-
},
75-
{
76-
service_name = "enterprise"
77-
},
78-
{
79-
service_name = "global-search"
80-
vpe_name = "${var.prefix}-search"
81-
},
82-
{
83-
service_name = "global-tagging"
84-
vpe_name = "${var.prefix}-tagging"
85-
},
86-
{
87-
service_name = "globalcatalog"
88-
},
89-
{
90-
service_name = "hs-crypto"
91-
},
92-
{
93-
service_name = "hs-crypto-cert-mgr"
94-
},
95-
{
96-
service_name = "hs-crypto-ep11"
97-
},
98-
{
99-
service_name = "hs-crypto-ep11-az1"
100-
},
101-
{
102-
service_name = "hs-crypto-ep11-az2"
103-
},
104-
{
105-
service_name = "hs-crypto-ep11-az3"
106-
},
107-
{
108-
service_name = "hs-crypto-kmip"
109-
},
110-
{
111-
service_name = "hs-crypto-tke"
112-
},
113-
{
114-
service_name = "iam-svcs"
115-
},
11641
{
11742
service_name = "is"
11843
},
11944
{
12045
service_name = "kms"
121-
},
122-
{
123-
service_name = "messaging"
124-
},
125-
{
126-
service_name = "resource-controller"
127-
},
128-
{
129-
service_name = "support-center"
130-
},
131-
{
132-
service_name = "transit"
133-
},
134-
{
135-
service_name = "user-management"
136-
},
137-
{
138-
service_name = "vmware"
139-
},
140-
{
141-
service_name = "ntp"
14246
}
14347
]
14448
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Every supported multi-tenant ("provider_cloud_service") VPE gateway
2+
3+
This example creates the following infrastructure:
4+
- A resource group, if one is not passed in.
5+
- A VPC
6+
- The VPC is created with three subnets across the three availability zones of the region that is passed as input.
7+
- A virtual private endpoint (VPE) gateways for EVERY multitenant service supported
8+
9+
> [!WARNING]
10+
> Creating all service VPEs in one apply may cause the VPC to enter "locked" state, and some endpoints may fail to be created.
11+
> In this scenario you can keep re-applying until all endpoints are created, or execute your `terraform apply` using the
12+
> `-parallelism=n` option with a small thread number to avoid the lock.
13+
>
14+
> [IBM Terraform provider issue reporting this issue](https://github.com/IBM-Cloud/terraform-provider-ibm/issues/6224)
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
##############################################################################
2+
# Resource Group
3+
##############################################################################
4+
module "resource_group" {
5+
source = "terraform-ibm-modules/resource-group/ibm"
6+
version = "1.1.6"
7+
# if an existing resource group is not set (null) create a new one using prefix
8+
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
9+
existing_resource_group_name = var.resource_group
10+
}
11+
12+
##############################################################################
13+
# Create a VPC for this example using defaults from terraform-ibm-landing-zone-vpc
14+
# ( 3 subnets across the 3 AZs in the region )
15+
##############################################################################
16+
17+
module "vpc" {
18+
source = "terraform-ibm-modules/landing-zone-vpc/ibm"
19+
version = "7.20.2"
20+
resource_group_id = module.resource_group.resource_group_id
21+
region = var.region
22+
prefix = var.prefix
23+
name = "vpc"
24+
tags = var.resource_tags
25+
}
26+
27+
##############################################################################
28+
# Create every multi-tenant VPEs in the VPC
29+
# NOTE: forcing a shorter VPE name for some services due to length limitations
30+
# on VPE service side
31+
##############################################################################
32+
module "vpes" {
33+
source = "../../"
34+
region = var.region
35+
prefix = var.prefix
36+
vpc_name = module.vpc.vpc_name
37+
vpc_id = module.vpc.vpc_id
38+
subnet_zone_list = module.vpc.subnet_zone_list
39+
resource_group_id = module.resource_group.resource_group_id
40+
cloud_services = [
41+
{
42+
service_name = "account-management"
43+
},
44+
{
45+
service_name = "billing"
46+
},
47+
{
48+
service_name = "cloud-object-storage"
49+
vpe_name = "${var.prefix}-cos"
50+
},
51+
{
52+
service_name = "cloud-object-storage-config"
53+
vpe_name = "${var.prefix}-cos-config"
54+
},
55+
{
56+
service_name = "codeengine"
57+
},
58+
{
59+
service_name = "container-registry"
60+
},
61+
{
62+
service_name = "containers-kubernetes"
63+
vpe_name = "${var.prefix}-kubernetes"
64+
},
65+
{
66+
service_name = "context-based-restrictions"
67+
vpe_name = "${var.prefix}-cbr"
68+
},
69+
{
70+
service_name = "directlink"
71+
},
72+
{
73+
service_name = "dns-svcs"
74+
},
75+
{
76+
service_name = "enterprise"
77+
},
78+
{
79+
service_name = "global-search"
80+
vpe_name = "${var.prefix}-search"
81+
},
82+
{
83+
service_name = "global-tagging"
84+
vpe_name = "${var.prefix}-tagging"
85+
},
86+
{
87+
service_name = "globalcatalog"
88+
},
89+
{
90+
service_name = "hs-crypto"
91+
},
92+
{
93+
service_name = "hs-crypto-cert-mgr"
94+
},
95+
{
96+
service_name = "hs-crypto-ep11"
97+
},
98+
{
99+
service_name = "hs-crypto-ep11-az1"
100+
},
101+
{
102+
service_name = "hs-crypto-ep11-az2"
103+
},
104+
{
105+
service_name = "hs-crypto-ep11-az3"
106+
},
107+
{
108+
service_name = "hs-crypto-kmip"
109+
},
110+
{
111+
service_name = "hs-crypto-tke"
112+
},
113+
{
114+
service_name = "iam-svcs"
115+
},
116+
{
117+
service_name = "is"
118+
},
119+
{
120+
service_name = "kms"
121+
},
122+
{
123+
service_name = "messaging"
124+
},
125+
{
126+
service_name = "resource-controller"
127+
},
128+
{
129+
service_name = "support-center"
130+
},
131+
{
132+
service_name = "transit"
133+
},
134+
{
135+
service_name = "user-management"
136+
},
137+
{
138+
service_name = "vmware"
139+
},
140+
{
141+
service_name = "ntp"
142+
}
143+
]
144+
}
145+
146+
147+
##############################################################################
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "vpe_ips" {
2+
description = "The endpoint gateway reserved ips"
3+
value = module.vpes.vpe_ips
4+
}
5+
6+
output "crn" {
7+
description = "The CRN of the endpoint gateway"
8+
value = module.vpes.crn
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "ibm" {
2+
ibmcloud_api_key = var.ibmcloud_api_key
3+
region = var.region
4+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
variable "ibmcloud_api_key" {
2+
type = string
3+
description = "The IBM Cloud API Key"
4+
sensitive = true
5+
}
6+
7+
variable "region" {
8+
description = "The region where VPC and services are deployed"
9+
type = string
10+
}
11+
12+
variable "prefix" {
13+
description = "The prefix that you would like to append to your resources"
14+
type = string
15+
}
16+
17+
variable "resource_group" {
18+
type = string
19+
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
20+
default = null
21+
}
22+
23+
variable "resource_tags" {
24+
type = list(string)
25+
description = "Optional list of tags to be added to created resources"
26+
default = []
27+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
##############################################################################
2+
# Terraform Providers
3+
##############################################################################
4+
5+
terraform {
6+
required_version = ">= 1.3.0"
7+
# Ensure that there is always 1 example locked into the lowest provider version of the range defined in the main
8+
# module's version.tf (basic or default), and 1 example that will always use the latest provider version.
9+
required_providers {
10+
ibm = {
11+
source = "IBM-Cloud/ibm"
12+
# pin to lowest vesion, required for IAM auth policy
13+
version = "1.61.0"
14+
}
15+
}
16+
}
17+
18+
##############################################################################

tests/other_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,40 @@ func TestRunReservedIpExample(t *testing.T) {
3535
assert.NoErrorf(t, outputErrMap, "Some outputs not having the expected structure")
3636
options.TestTearDown()
3737
}
38+
39+
// TEST NOTE:
40+
// This test will deploy all 30+ multitenant services in order to test that our current CRN mappings are correct
41+
// for these service names.
42+
// However there is an issue with the provider currently that prevents all 30+ VPEs to deploy at once, resulting in a
43+
// "VPC Locked" error.
44+
// In order to test all 30+ services, we will run this other test single-threaded (parallelism=1).
45+
//
46+
// IBM Terraform provider issue for this issue: https://github.com/IBM-Cloud/terraform-provider-ibm/issues/6224
47+
func TestRunEveryMultiTenantExample(t *testing.T) {
48+
t.Parallel()
49+
50+
options := setupOptions(t, "vpe-allmt", "examples/every-multi-tenant-svc")
51+
52+
// need to do setup so that TerraformOptions is created
53+
options.TestSetup()
54+
55+
// save the current parallelism value, we will reset to this value later
56+
currentParallelValue := options.TerraformOptions.Parallelism
57+
t.Logf("Terratest Parallelism currently set to %d, replacing with 1 for single-threaded apply", currentParallelValue)
58+
options.TerraformOptions.Parallelism = 1
59+
60+
// after apply, set parallelism back to default to help quicken remaining steps
61+
options.PostApplyHook = func(options *testhelper.TestOptions) error {
62+
t.Logf("Terratest Parallelism will be switched back to %d from single-threaded", currentParallelValue)
63+
options.TerraformOptions.Parallelism = currentParallelValue
64+
return nil
65+
}
66+
67+
// turn off test setup, already done
68+
options.SkipTestSetup = true
69+
70+
// now do full test single-threaded
71+
output, err := options.RunTestConsistency()
72+
assert.Nil(t, err, "This should not have errored.")
73+
assert.NotNil(t, output, "Expected some output")
74+
}

0 commit comments

Comments
 (0)