Skip to content

Commit d335ff3

Browse files
authored
refactor: enable more acceptance tests (#2540)
Signed-off-by: Stoyan Zhelyazkov <[email protected]>
1 parent f4a2f87 commit d335ff3

27 files changed

+94
-273
lines changed

vsphere/host_network_policy_structure.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ func schemaHostNetworkPolicy() map[string]*schema.Schema {
110110
// expandHostNicFailureCriteria reads certain ResourceData keys and returns a
111111
// HostNicFailureCriteria.
112112
func expandHostNicFailureCriteria(d *schema.ResourceData) *types.HostNicFailureCriteria {
113-
obj := &types.HostNicFailureCriteria{}
113+
obj := &types.HostNicFailureCriteria{
114+
CheckBeacon: structure.BoolPtr(false),
115+
}
114116

115117
if v, ok := d.GetOk("check_beacon"); ok {
116118
obj.CheckBeacon = structure.BoolPtr(v.(bool))
@@ -166,7 +168,9 @@ func flattenHostNicOrderPolicy(d *schema.ResourceData, obj *types.HostNicOrderPo
166168
// HostNicTeamingPolicy.
167169
func expandHostNicTeamingPolicy(d *schema.ResourceData) *types.HostNicTeamingPolicy {
168170
obj := &types.HostNicTeamingPolicy{
169-
Policy: d.Get("teaming_policy").(string),
171+
Policy: d.Get("teaming_policy").(string),
172+
RollingOrder: structure.BoolPtr(false),
173+
NotifySwitches: structure.BoolPtr(false),
170174
}
171175
if v, ok := d.GetOk("failback"); ok {
172176
obj.RollingOrder = structure.BoolPtr(!v.(bool))
@@ -189,7 +193,7 @@ func expandHostNicTeamingPolicy(d *schema.ResourceData) *types.HostNicTeamingPol
189193
func flattenHostNicTeamingPolicy(d *schema.ResourceData, obj *types.HostNicTeamingPolicy) error {
190194
if obj.RollingOrder != nil {
191195
v := *obj.RollingOrder
192-
_ = d.Set("failback", !v)
196+
_ = d.Set("failback", v)
193197
}
194198
if obj.NotifySwitches != nil {
195199
_ = d.Set("notify_switches", obj.NotifySwitches)
@@ -205,7 +209,11 @@ func flattenHostNicTeamingPolicy(d *schema.ResourceData, obj *types.HostNicTeami
205209
// expandHostNetworkSecurityPolicy reads certain ResourceData keys and returns
206210
// a HostNetworkSecurityPolicy.
207211
func expandHostNetworkSecurityPolicy(d *schema.ResourceData) *types.HostNetworkSecurityPolicy {
208-
obj := &types.HostNetworkSecurityPolicy{}
212+
obj := &types.HostNetworkSecurityPolicy{
213+
AllowPromiscuous: structure.BoolPtr(false),
214+
ForgedTransmits: structure.BoolPtr(false),
215+
MacChanges: structure.BoolPtr(false),
216+
}
209217
if v, ok := d.GetOk("allow_promiscuous"); ok {
210218
obj.AllowPromiscuous = structure.BoolPtr(v.(bool))
211219
}
@@ -240,6 +248,7 @@ func expandHostNetworkTrafficShapingPolicy(d *schema.ResourceData) *types.HostNe
240248
AverageBandwidth: int64(d.Get("shaping_average_bandwidth").(int)),
241249
BurstSize: int64(d.Get("shaping_burst_size").(int)),
242250
PeakBandwidth: int64(d.Get("shaping_peak_bandwidth").(int)),
251+
Enabled: structure.BoolPtr(false),
243252
}
244253
if v, ok := d.GetOk("shaping_enabled"); ok {
245254
obj.Enabled = structure.BoolPtr(v.(bool))

vsphere/resource_vsphere_compute_cluster_host_group_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ import (
2323
)
2424

2525
func TestAccResourceVSphereComputeClusterHostGroup_basic(t *testing.T) {
26-
testAccSkipUnstable(t)
2726
resource.Test(t, resource.TestCase{
2827
PreCheck: func() {
2928
RunSweepers()
3029
testAccPreCheck(t)
31-
testAccResourceVSphereComputeClusterHostGroupPreCheck(t)
3230
},
3331
Providers: testAccProviders,
3432
CheckDestroy: testAccResourceVSphereComputeClusterHostGroupExists(false),
@@ -80,12 +78,10 @@ func TestAccResourceVSphereComputeClusterHostGroup_basic(t *testing.T) {
8078
}
8179

8280
func TestAccResourceVSphereComputeClusterHostGroup_update(t *testing.T) {
83-
testAccSkipUnstable(t)
8481
resource.Test(t, resource.TestCase{
8582
PreCheck: func() {
8683
RunSweepers()
8784
testAccPreCheck(t)
88-
testAccResourceVSphereComputeClusterHostGroupPreCheck(t)
8985
},
9086
Providers: testAccProviders,
9187
CheckDestroy: testAccResourceVSphereComputeClusterHostGroupExists(false),
@@ -108,18 +104,6 @@ func TestAccResourceVSphereComputeClusterHostGroup_update(t *testing.T) {
108104
})
109105
}
110106

111-
func testAccResourceVSphereComputeClusterHostGroupPreCheck(t *testing.T) {
112-
if os.Getenv("TF_VAR_VSPHERE_DATACENTER") == "" {
113-
t.Skip("set TF_VAR_VSPHERE_DATACENTER to run vsphere_compute_cluster_host_group acceptance tests")
114-
}
115-
if os.Getenv("TF_VAR_VSPHERE_ESXI1") == "" {
116-
t.Skip("set TF_VAR_VSPHERE_ESXI1 to run vsphere_compute_cluster_host_group acceptance tests")
117-
}
118-
if os.Getenv("TF_VAR_VSPHERE_ESXI2") == "" {
119-
t.Skip("set TF_VAR_VSPHERE_ESXI2 to run vsphere_compute_cluster_host_group acceptance tests")
120-
}
121-
}
122-
123107
func testAccResourceVSphereComputeClusterHostGroupExists(expected bool) resource.TestCheckFunc {
124108
return func(s *terraform.State) error {
125109
info, err := testGetComputeClusterHostGroup(s, "cluster_host_group")

vsphere/resource_vsphere_compute_cluster_vm_affinity_rule_test.go

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"encoding/json"
99
"errors"
1010
"fmt"
11-
"os"
1211
"reflect"
1312
"sort"
1413
"testing"
@@ -24,12 +23,10 @@ import (
2423
)
2524

2625
func TestAccResourceVSphereComputeClusterVMAffinityRule_basic(t *testing.T) {
27-
testAccSkipUnstable(t)
2826
resource.Test(t, resource.TestCase{
2927
PreCheck: func() {
3028
RunSweepers()
3129
testAccPreCheck(t)
32-
testAccResourceVSphereComputeClusterVMAffinityRulePreCheck(t)
3330
},
3431
Providers: testAccProviders,
3532
CheckDestroy: testAccResourceVSphereComputeClusterVMAffinityRuleExists(false),
@@ -86,12 +83,10 @@ func TestAccResourceVSphereComputeClusterVMAffinityRule_basic(t *testing.T) {
8683
}
8784

8885
func TestAccResourceVSphereComputeClusterVMAffinityRule_updateEnabled(t *testing.T) {
89-
testAccSkipUnstable(t)
9086
resource.Test(t, resource.TestCase{
9187
PreCheck: func() {
9288
RunSweepers()
9389
testAccPreCheck(t)
94-
testAccResourceVSphereComputeClusterVMAffinityRulePreCheck(t)
9590
},
9691
Providers: testAccProviders,
9792
CheckDestroy: testAccResourceVSphereComputeClusterVMAffinityRuleExists(false),
@@ -125,12 +120,10 @@ func TestAccResourceVSphereComputeClusterVMAffinityRule_updateEnabled(t *testing
125120
}
126121

127122
func TestAccResourceVSphereComputeClusterVMAffinityRule_updateCount(t *testing.T) {
128-
testAccSkipUnstable(t)
129123
resource.Test(t, resource.TestCase{
130124
PreCheck: func() {
131125
RunSweepers()
132126
testAccPreCheck(t)
133-
testAccResourceVSphereComputeClusterVMAffinityRulePreCheck(t)
134127
},
135128
Providers: testAccProviders,
136129
CheckDestroy: testAccResourceVSphereComputeClusterVMAffinityRuleExists(false),
@@ -163,21 +156,6 @@ func TestAccResourceVSphereComputeClusterVMAffinityRule_updateCount(t *testing.T
163156
})
164157
}
165158

166-
func testAccResourceVSphereComputeClusterVMAffinityRulePreCheck(t *testing.T) {
167-
if os.Getenv("TF_VAR_VSPHERE_DATACENTER") == "" {
168-
t.Skip("set TF_VAR_VSPHERE_DATACENTER to run vsphere_compute_cluster_vm_affinity_rule acceptance tests")
169-
}
170-
if os.Getenv("TF_VAR_VSPHERE_NFS_DS_NAME") == "" {
171-
t.Skip("set TF_VAR_VSPHERE_NFS_DS_NAME to run vsphere_compute_cluster_vm_affinity_rule acceptance tests")
172-
}
173-
if os.Getenv("TF_VAR_VSPHERE_CLUSTER") == "" {
174-
t.Skip("set TF_VAR_VSPHERE_CLUSTER to run vsphere_compute_cluster_vm_affinity_rule acceptance tests")
175-
}
176-
if os.Getenv("TF_VAR_VSPHERE_PG_NAME") == "" {
177-
t.Skip("set TF_VAR_VSPHERE_PG_NAME to run vsphere_compute_cluster_vm_affinity_rule acceptance tests")
178-
}
179-
}
180-
181159
func testAccResourceVSphereComputeClusterVMAffinityRuleExists(expected bool) resource.TestCheckFunc {
182160
return func(s *terraform.State) error {
183161
info, err := testGetComputeClusterVMAffinityRule(s, "cluster_vm_affinity_rule")
@@ -323,21 +301,22 @@ resource "vsphere_virtual_machine" "vm" {
323301
count = var.vm_count
324302
name = "terraform-test-${count.index}"
325303
resource_pool_id = data.vsphere_compute_cluster.rootcompute_cluster1.resource_pool_id
326-
datastore_id = vsphere_nas_datastore.ds1.id
304+
datastore_id = data.vsphere_datastore.rootds1.id
327305
328306
num_cpus = 2
329307
memory = 2048
330308
guest_id = "other3xLinuxGuest"
331309
332-
wait_for_guest_net_timeout = -1
310+
wait_for_guest_net_timeout = 0
333311
334312
network_interface {
335313
network_id = data.vsphere_network.network1.id
336314
}
337315
338316
disk {
339317
label = "disk0"
340-
size = 20
318+
size = 1
319+
io_reservation = 1
341320
}
342321
}
343322
@@ -351,7 +330,7 @@ resource "vsphere_compute_cluster_vm_affinity_rule" "cluster_vm_affinity_rule" {
351330
testhelper.ConfigDataRootDC1(),
352331
testhelper.ConfigDataRootHost1(),
353332
testhelper.ConfigDataRootHost2(),
354-
testhelper.ConfigResDS1(),
333+
testhelper.ConfigDataRootDS1(),
355334
testhelper.ConfigDataRootComputeCluster1(),
356335
testhelper.ConfigResResourcePool1(),
357336
testhelper.ConfigDataRootPortGroup1()),

vsphere/resource_vsphere_compute_cluster_vm_anti_affinity_rule_test.go

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"encoding/json"
99
"errors"
1010
"fmt"
11-
"os"
1211
"reflect"
1312
"sort"
1413
"testing"
@@ -24,12 +23,10 @@ import (
2423
)
2524

2625
func TestAccResourceVSphereComputeClusterVMAntiAffinityRule_basic(t *testing.T) {
27-
testAccSkipUnstable(t)
2826
resource.Test(t, resource.TestCase{
2927
PreCheck: func() {
3028
RunSweepers()
3129
testAccPreCheck(t)
32-
testAccResourceVSphereComputeClusterVMAntiAffinityRulePreCheck(t)
3330
},
3431
Providers: testAccProviders,
3532
CheckDestroy: testAccResourceVSphereComputeClusterVMAntiAffinityRuleExists(false),
@@ -86,12 +83,10 @@ func TestAccResourceVSphereComputeClusterVMAntiAffinityRule_basic(t *testing.T)
8683
}
8784

8885
func TestAccResourceVSphereComputeClusterVMAntiAffinityRule_updateEnabled(t *testing.T) {
89-
testAccSkipUnstable(t)
9086
resource.Test(t, resource.TestCase{
9187
PreCheck: func() {
9288
RunSweepers()
9389
testAccPreCheck(t)
94-
testAccResourceVSphereComputeClusterVMAntiAffinityRulePreCheck(t)
9590
},
9691
Providers: testAccProviders,
9792
CheckDestroy: testAccResourceVSphereComputeClusterVMAntiAffinityRuleExists(false),
@@ -125,12 +120,10 @@ func TestAccResourceVSphereComputeClusterVMAntiAffinityRule_updateEnabled(t *tes
125120
}
126121

127122
func TestAccResourceVSphereComputeClusterVMAntiAffinityRule_updateCount(t *testing.T) {
128-
testAccSkipUnstable(t)
129123
resource.Test(t, resource.TestCase{
130124
PreCheck: func() {
131125
RunSweepers()
132126
testAccPreCheck(t)
133-
testAccResourceVSphereComputeClusterVMAntiAffinityRulePreCheck(t)
134127
},
135128
Providers: testAccProviders,
136129
CheckDestroy: testAccResourceVSphereComputeClusterVMAntiAffinityRuleExists(false),
@@ -163,21 +156,6 @@ func TestAccResourceVSphereComputeClusterVMAntiAffinityRule_updateCount(t *testi
163156
})
164157
}
165158

166-
func testAccResourceVSphereComputeClusterVMAntiAffinityRulePreCheck(t *testing.T) {
167-
if os.Getenv("TF_VAR_VSPHERE_DATACENTER") == "" {
168-
t.Skip("set TF_VAR_VSPHERE_DATACENTER to run vsphere_compute_cluster_vm_anti_affinity_rule acceptance tests")
169-
}
170-
if os.Getenv("TF_VAR_VSPHERE_NFS_DS_NAME") == "" {
171-
t.Skip("set TF_VAR_VSPHERE_NFS_DS_NAME to run vsphere_compute_cluster_vm_anti_affinity_rule acceptance tests")
172-
}
173-
if os.Getenv("TF_VAR_VSPHERE_CLUSTER") == "" {
174-
t.Skip("set TF_VAR_VSPHERE_CLUSTER to run vsphere_compute_cluster_vm_anti_affinity_rule acceptance tests")
175-
}
176-
if os.Getenv("TF_VAR_VSPHERE_PG_NAME") == "" {
177-
t.Skip("set TF_VAR_VSPHERE_PG_NAME to run vsphere_compute_cluster_vm_anti_affinity_rule acceptance tests")
178-
}
179-
}
180-
181159
func testAccResourceVSphereComputeClusterVMAntiAffinityRuleExists(expected bool) resource.TestCheckFunc {
182160
return func(s *terraform.State) error {
183161
info, err := testGetComputeClusterVMAntiAffinityRule(s, "cluster_vm_anti_affinity_rule")
@@ -323,21 +301,22 @@ resource "vsphere_virtual_machine" "vm" {
323301
count = var.vm_count
324302
name = "terraform-test-${count.index}"
325303
resource_pool_id = data.vsphere_compute_cluster.rootcompute_cluster1.resource_pool_id
326-
datastore_id = vsphere_nas_datastore.ds1.id
304+
datastore_id = data.vsphere_datastore.rootds1.id
327305
328306
num_cpus = 2
329307
memory = 2048
330308
guest_id = "other3xLinuxGuest"
331309
332-
wait_for_guest_net_timeout = -1
310+
wait_for_guest_net_timeout = 0
333311
334312
network_interface {
335313
network_id = data.vsphere_network.network1.id
336314
}
337315
338316
disk {
339317
label = "disk0"
340-
size = 20
318+
size = 1
319+
io_reservation = 1
341320
}
342321
}
343322
@@ -351,7 +330,7 @@ resource "vsphere_compute_cluster_vm_anti_affinity_rule" "cluster_vm_anti_affini
351330
testhelper.ConfigDataRootDC1(),
352331
testhelper.ConfigDataRootHost1(),
353332
testhelper.ConfigDataRootHost2(),
354-
testhelper.ConfigResDS1(),
333+
testhelper.ConfigDataRootDS1(),
355334
testhelper.ConfigDataRootComputeCluster1(),
356335
testhelper.ConfigResResourcePool1(),
357336
testhelper.ConfigDataRootPortGroup1()),

vsphere/resource_vsphere_compute_cluster_vm_group_test.go

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"encoding/json"
99
"errors"
1010
"fmt"
11-
"os"
1211
"reflect"
1312
"sort"
1413
"testing"
@@ -24,12 +23,10 @@ import (
2423
)
2524

2625
func TestAccResourceVSphereComputeClusterVMGroup_basic(t *testing.T) {
27-
testAccSkipUnstable(t)
2826
resource.Test(t, resource.TestCase{
2927
PreCheck: func() {
3028
RunSweepers()
3129
testAccPreCheck(t)
32-
testAccResourceVSphereComputeClusterVMGroupPreCheck(t)
3330
},
3431
Providers: testAccProviders,
3532
CheckDestroy: testAccResourceVSphereComputeClusterVMGroupExists(false),
@@ -81,12 +78,10 @@ func TestAccResourceVSphereComputeClusterVMGroup_basic(t *testing.T) {
8178
}
8279

8380
func TestAccResourceVSphereComputeClusterVMGroup_update(t *testing.T) {
84-
testAccSkipUnstable(t)
8581
resource.Test(t, resource.TestCase{
8682
PreCheck: func() {
8783
RunSweepers()
8884
testAccPreCheck(t)
89-
testAccResourceVSphereComputeClusterVMGroupPreCheck(t)
9085
},
9186
Providers: testAccProviders,
9287
CheckDestroy: testAccResourceVSphereComputeClusterVMGroupExists(false),
@@ -109,21 +104,6 @@ func TestAccResourceVSphereComputeClusterVMGroup_update(t *testing.T) {
109104
})
110105
}
111106

112-
func testAccResourceVSphereComputeClusterVMGroupPreCheck(t *testing.T) {
113-
if os.Getenv("TF_VAR_VSPHERE_DATACENTER") == "" {
114-
t.Skip("set TF_VAR_VSPHERE_DATACENTER to run vsphere_compute_cluster_vm_group acceptance tests")
115-
}
116-
if os.Getenv("TF_VAR_VSPHERE_NFS_DS_NAME") == "" {
117-
t.Skip("set TF_VAR_VSPHERE_NFS_DS_NAME to run vsphere_compute_cluster_vm_group acceptance tests")
118-
}
119-
if os.Getenv("TF_VAR_VSPHERE_CLUSTER") == "" {
120-
t.Skip("set TF_VAR_VSPHERE_CLUSTER to run vsphere_compute_cluster_vm_group acceptance tests")
121-
}
122-
if os.Getenv("TF_VAR_VSPHERE_PG_NAME") == "" {
123-
t.Skip("set TF_VAR_VSPHERE_PG_NAME to run vsphere_compute_cluster_vm_group acceptance tests")
124-
}
125-
}
126-
127107
func testAccResourceVSphereComputeClusterVMGroupExists(expected bool) resource.TestCheckFunc {
128108
return func(s *terraform.State) error {
129109
info, err := testGetComputeClusterVMGroup(s, "cluster_vm_group")
@@ -235,21 +215,22 @@ resource "vsphere_virtual_machine" "vm" {
235215
count = var.vm_count
236216
name = "terraform-test-${count.index}"
237217
resource_pool_id = data.vsphere_compute_cluster.rootcompute_cluster1.resource_pool_id
238-
datastore_id = vsphere_nas_datastore.ds1.id
218+
datastore_id = data.vsphere_datastore.rootds1.id
239219
240220
num_cpus = 2
241221
memory = 2048
242222
guest_id = "other3xLinuxGuest"
243223
244-
wait_for_guest_net_timeout = -1
224+
wait_for_guest_net_timeout = 0
245225
246226
network_interface {
247227
network_id = data.vsphere_network.network1.id
248228
}
249229
250230
disk {
251231
label = "disk0"
252-
size = 20
232+
size = 1
233+
io_reservation = 1
253234
}
254235
}
255236
@@ -262,7 +243,7 @@ resource "vsphere_compute_cluster_vm_group" "cluster_vm_group" {
262243
testhelper.ConfigDataRootDC1(),
263244
testhelper.ConfigDataRootHost1(),
264245
testhelper.ConfigDataRootHost2(),
265-
testhelper.ConfigResDS1(),
246+
testhelper.ConfigDataRootDS1(),
266247
testhelper.ConfigDataRootComputeCluster1(),
267248
testhelper.ConfigResResourcePool1(),
268249
testhelper.ConfigDataRootPortGroup1()),

0 commit comments

Comments
 (0)