Skip to content

Commit 15e4757

Browse files
z0zaZoltan Illes
andauthored
ibm_container_vpc_worker_pool - remove Computed for secondary_storage property (IBM-Cloud#5720)
* remove Computed from secondary_storage, workerpool test renamings * worker pool resource test fixes * workerpool datasource test fixes --------- Co-authored-by: Zoltan Illes <[email protected]>
1 parent d5a0804 commit 15e4757

File tree

4 files changed

+460
-279
lines changed

4 files changed

+460
-279
lines changed

ibm/acctest/acctest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,7 @@ func init() {
16671667
}
16681668

16691669
KmsAccountID = os.Getenv("IBM_KMS_ACCOUNT_ID")
1670-
if CrkID == "" {
1670+
if KmsAccountID == "" {
16711671
fmt.Println("[INFO] Set the environment variable IBM_KMS_ACCOUNT_ID for ibm_container_vpc_cluster resource or datasource else tests will fail if this is not set correctly")
16721672
}
16731673

ibm/service/kubernetes/data_source_ibm_container_vpc_worker_pool_test.go

Lines changed: 120 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,44 @@ import (
1313
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1414
)
1515

16-
func TestAccIBMContainerVPCClusterWorkerPoolDataSource_basic(t *testing.T) {
17-
name := fmt.Sprintf("tf-vpc-worker-%d", acctest.RandIntRange(10, 100))
16+
func testAccIBMContainerVPCClusterWorkerPoolDataSourceBase(cluster_name string) string {
17+
return fmt.Sprintf(`
18+
data "ibm_resource_group" "resource_group" {
19+
is_default=true
20+
}
21+
22+
resource "ibm_container_vpc_cluster" "cluster" {
23+
name = "%[3]s"
24+
vpc_id = "%[1]s"
25+
flavor = "cx2.2x4"
26+
worker_count = 1
27+
resource_group_id = data.ibm_resource_group.resource_group.id
28+
wait_till = "MasterNodeReady"
29+
zones {
30+
subnet_id = "%[2]s"
31+
name = "us-south-1"
32+
}
33+
}
34+
35+
resource "ibm_container_vpc_worker_pool" "test_pool" {
36+
cluster = ibm_container_vpc_cluster.cluster.id
37+
vpc_id = "%[1]s"
38+
flavor = "cx2.2x4"
39+
worker_count = 1
40+
worker_pool_name = "default"
41+
zones {
42+
subnet_id = "%[2]s"
43+
name = "us-south-1"
44+
}
45+
import_on_create = "true"
46+
orphan_on_delete = "true"
47+
}
48+
`, acc.IksClusterVpcID, acc.IksClusterSubnetID, cluster_name)
49+
}
50+
51+
// TestAccIBMContainerVpcClusterWorkerPoolDataSourceBasic ...
52+
func TestAccIBMContainerVpcClusterWorkerPoolDataSourceBasic(t *testing.T) {
53+
name := fmt.Sprintf("tf-vpc-wp-ds-basic-%d", acctest.RandIntRange(10, 100))
1854
resource.Test(t, resource.TestCase{
1955
PreCheck: func() { acc.TestAccPreCheck(t) },
2056
Providers: acc.TestAccProviders,
@@ -29,8 +65,23 @@ func TestAccIBMContainerVPCClusterWorkerPoolDataSource_basic(t *testing.T) {
2965
})
3066
}
3167

32-
func TestAccIBMContainerVPCClusterWorkerPoolDataSource_dedicatedhost(t *testing.T) {
33-
name := fmt.Sprintf("tf-vpc-worker-%d", acctest.RandIntRange(10, 100))
68+
func testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceConfig(name string) string {
69+
return testAccIBMContainerVPCClusterWorkerPoolDataSourceBase(name) + `
70+
data "ibm_container_vpc_cluster_worker_pool" "testacc_ds_worker_pool" {
71+
cluster = "${ibm_container_vpc_cluster.cluster.id}"
72+
worker_pool_name = "${ibm_container_vpc_worker_pool.test_pool.worker_pool_name}"
73+
}
74+
`
75+
}
76+
77+
// TestAccIBMContainerVpcClusterWorkerPoolDataSourceDedicatedHost ...
78+
func TestAccIBMContainerVpcClusterWorkerPoolDataSourceDedicatedHost(t *testing.T) {
79+
if acc.HostPoolID == "" {
80+
fmt.Println("[WARN] Skipping TestAccIBMContainerVpcClusterWorkerPoolResourceDedicatedHost - IBM_CONTAINER_DEDICATEDHOST_POOL_ID is unset")
81+
return
82+
}
83+
84+
name := fmt.Sprintf("tf-vpc-wp-ds-dhost-%d", acctest.RandIntRange(10, 100))
3485
hostpoolID := acc.HostPoolID
3586
resource.Test(t, resource.TestCase{
3687
PreCheck: func() { acc.TestAccPreCheck(t) },
@@ -46,86 +97,104 @@ func TestAccIBMContainerVPCClusterWorkerPoolDataSource_dedicatedhost(t *testing.
4697
})
4798
}
4899

49-
func testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceConfig(name string) string {
50-
return testAccCheckIBMVpcContainerWorkerPoolBasic(name) + `
51-
data "ibm_container_vpc_cluster_worker_pool" "testacc_ds_worker_pool" {
52-
cluster = "${ibm_container_vpc_cluster.cluster.id}"
53-
worker_pool_name = "${ibm_container_vpc_worker_pool.test_pool.worker_pool_name}"
100+
func testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceConfigDedicatedHost(name, hostpoolID string) string {
101+
return testAccCheckIBMVpcContainerWorkerPoolDedicatedHostCreate(
102+
acc.ClusterName, name, "bx2d.4x16", acc.IksClusterSubnetID, acc.IksClusterVpcID, acc.IksClusterResourceGroupID, hostpoolID) + `
103+
data "ibm_container_vpc_worker_pool" "vpc_worker_pool" {
104+
cluster = "${ibm_container_vpc_worker_pool.vpc_worker_pool.cluster}"
105+
worker_pool_name = "${ibm_container_vpc_worker_pool.vpc_worker_pool.worker_pool_name}"
106+
depends_on = [
107+
ibm_container_vpc_worker_pool.vpc_worker_pool
108+
]
54109
}
55110
`
56111
}
57112

58-
func TestAccIBMContainerVPCClusterWorkerPoolDataSourceEnvvar(t *testing.T) {
59-
name := fmt.Sprintf("tf-vpc-wp-%d", acctest.RandIntRange(10, 100))
60-
testChecks := []resource.TestCheckFunc{
61-
resource.TestCheckResourceAttrSet("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_worker_pool", "id"),
62-
resource.TestCheckResourceAttr("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_worker_pool", "autoscale_enabled", "false"),
63-
}
64-
if acc.CrkID != "" {
65-
testChecks = append(testChecks,
66-
resource.TestCheckResourceAttr("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_worker_pool", "crk", acc.CrkID),
67-
resource.TestCheckResourceAttr("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_worker_pool", "kms_instance_id", acc.KmsInstanceID),
68-
)
69-
}
70-
if acc.WorkerPoolSecondaryStorage != "" {
71-
testChecks = append(testChecks, resource.TestCheckResourceAttr(
72-
"data.ibm_container_vpc_cluster_worker_pool.testacc_ds_worker_pool", "secondary_storage.0.name", acc.WorkerPoolSecondaryStorage))
73-
}
113+
// TestAccIBMContainerVpcClusterWorkerPoolDataSourceSecondaryStorage ...
114+
func TestAccIBMContainerVpcClusterWorkerPoolDataSourceSecondaryStorage(t *testing.T) {
115+
name := fmt.Sprintf("tf-vpc-wp-ds-secstorage-%d", acctest.RandIntRange(10, 100))
74116
resource.Test(t, resource.TestCase{
75117
PreCheck: func() { acc.TestAccPreCheck(t) },
76118
Providers: acc.TestAccProviders,
77119
Steps: []resource.TestStep{
78120
{
79-
Config: testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceEnvvar(name),
80-
Check: resource.ComposeTestCheckFunc(testChecks...),
121+
Config: testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceSecStorage(name),
122+
Check: resource.ComposeTestCheckFunc(
123+
resource.TestCheckResourceAttrSet("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_worker_pool", "id"),
124+
resource.TestCheckResourceAttr(
125+
"data.ibm_container_vpc_cluster_worker_pool.testacc_ds_worker_pool", "secondary_storage.0.name", acc.WorkerPoolSecondaryStorage)),
81126
},
82127
},
83128
})
84129
}
85130

86-
func TestAccIBMContainerVPCClusterWorkerPoolDataSourceKmsAccountEnvvar(t *testing.T) {
87-
name := fmt.Sprintf("tf-vpc-wp-%d", acctest.RandIntRange(10, 100))
131+
func testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceSecStorage(name string) string {
132+
return testAccCheckIBMVpcContainerWorkerPoolSecStorage(name) + `
133+
data "ibm_container_vpc_cluster_worker_pool" "testacc_ds_worker_pool" {
134+
cluster = "${ibm_container_vpc_worker_pool.test_pool.cluster}"
135+
worker_pool_name = "${ibm_container_vpc_worker_pool.test_pool.worker_pool_name}"
136+
}
137+
`
138+
}
139+
140+
// TestAccIBMContainerVpcClusterWorkerPoolDataSourceKMS ...
141+
func TestAccIBMContainerVpcClusterWorkerPoolDataSourceKMS(t *testing.T) {
142+
if acc.CrkID == "" {
143+
fmt.Println("[WARN] Skipping TestAccIBMContainerVpcClusterWorkerPoolDataSourceKMS - IBM_CRK_ID is unset")
144+
return
145+
}
146+
name := fmt.Sprintf("tf-vpc-wp-ds-kms-%d", acctest.RandIntRange(10, 100))
88147
resource.Test(t, resource.TestCase{
89148
PreCheck: func() { acc.TestAccPreCheck(t) },
90149
Providers: acc.TestAccProviders,
91150
Steps: []resource.TestStep{
92151
{
93-
Config: testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceKmsAccountEnvvar(name),
152+
Config: testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceKMS(name),
94153
Check: resource.ComposeTestCheckFunc(
95-
resource.TestCheckResourceAttrSet("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_kms_worker_pool", "id"),
96-
resource.TestCheckResourceAttr("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_kms_worker_pool", "crk", acc.CrkID),
97-
resource.TestCheckResourceAttr("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_kms_worker_pool", "kms_instance_id", acc.KmsInstanceID),
98-
resource.TestCheckResourceAttr("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_kms_worker_pool", "kms_account_id", acc.KmsAccountID),
154+
resource.TestCheckResourceAttrSet("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_worker_pool", "id"),
155+
resource.TestCheckResourceAttr("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_worker_pool", "autoscale_enabled", "false"),
156+
resource.TestCheckResourceAttr("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_worker_pool", "crk", acc.CrkID),
157+
resource.TestCheckResourceAttr("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_worker_pool", "kms_instance_id", acc.KmsInstanceID),
99158
),
100159
},
101160
},
102161
})
103162
}
104163

105-
func testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceConfigDedicatedHost(name, hostpoolID string) string {
106-
return testAccCheckIBMVpcContainerWorkerPoolDedicatedHostCreate(
107-
acc.ClusterName, name, "bx2d.4x16", acc.IksClusterSubnetID, acc.IksClusterVpcID, acc.IksClusterResourceGroupID, hostpoolID) + `
108-
data "ibm_container_vpc_worker_pool" "vpc_worker_pool" {
109-
cluster = "${ibm_container_vpc_worker_pool.vpc_worker_pool.cluster}"
110-
worker_pool_name = "${ibm_container_vpc_worker_pool.vpc_worker_pool.worker_pool_name}"
111-
depends_on = [
112-
ibm_container_vpc_worker_pool.vpc_worker_pool
113-
]
114-
}
115-
`
116-
}
117-
118-
func testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceEnvvar(name string) string {
119-
return testAccCheckIBMVpcContainerWorkerPoolEnvvar(name) + `
164+
func testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceKMS(name string) string {
165+
return testAccCheckIBMVpcContainerWorkerPoolKMS(name) + `
120166
data "ibm_container_vpc_cluster_worker_pool" "testacc_ds_worker_pool" {
121167
cluster = "${ibm_container_vpc_worker_pool.test_pool.cluster}"
122168
worker_pool_name = "${ibm_container_vpc_worker_pool.test_pool.worker_pool_name}"
123169
}
124170
`
125171
}
126172

127-
func testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceKmsAccountEnvvar(name string) string {
128-
return testAccCheckIBMVpcContainerWorkerPoolKmsAccountEnvvar(name) + `
173+
// TestAccIBMContainerVpcClusterWorkerPoolDataSourceKmsAccount ...
174+
func TestAccIBMContainerVpcClusterWorkerPoolDataSourceKmsAccount(t *testing.T) {
175+
if acc.KmsAccountID == "" {
176+
fmt.Println("[WARN] Skipping TestAccIBMContainerVpcClusterWorkerPoolDataSourceKmsAccount - IBM_KMS_ACCOUNT_ID is unset")
177+
return
178+
}
179+
name := fmt.Sprintf("tf-vpc-wp-ds-kmsacc-%d", acctest.RandIntRange(10, 100))
180+
resource.Test(t, resource.TestCase{
181+
PreCheck: func() { acc.TestAccPreCheck(t) },
182+
Providers: acc.TestAccProviders,
183+
Steps: []resource.TestStep{
184+
{
185+
Config: testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceKmsAccount(name),
186+
Check: resource.ComposeTestCheckFunc(
187+
resource.TestCheckResourceAttrSet("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_kms_worker_pool", "id"),
188+
resource.TestCheckResourceAttr("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_kms_worker_pool", "crk", acc.CrkID),
189+
resource.TestCheckResourceAttr("data.ibm_container_vpc_cluster_worker_pool.testacc_ds_kms_worker_pool", "kms_instance_id", acc.KmsInstanceID),
190+
),
191+
},
192+
},
193+
})
194+
}
195+
196+
func testAccCheckIBMContainerVPCClusterWorkerPoolDataSourceKmsAccount(name string) string {
197+
return testAccCheckIBMVpcContainerWorkerPoolKmsAccount(name) + `
129198
data "ibm_container_vpc_cluster_worker_pool" "testacc_ds_kms_worker_pool" {
130199
cluster = "${ibm_container_vpc_worker_pool.test_pool.cluster}"
131200
worker_pool_name = "${ibm_container_vpc_worker_pool.test_pool.worker_pool_name}"

ibm/service/kubernetes/resource_ibm_container_vpc_worker_pool.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ func ResourceIBMContainerVpcWorkerPool() *schema.Resource {
165165
"secondary_storage": {
166166
Type: schema.TypeString,
167167
Optional: true,
168-
Computed: true,
169168
ForceNew: true,
170169
Description: "The secondary storage option for the workers in the worker pool.",
171170
},

0 commit comments

Comments
 (0)