Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update support for network block in vcd_vapp_vm, allow force guest customization #310

Merged
merged 34 commits into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
26dec49
vm.network block supports update (with VM shutdown)
Didainius Jul 31, 2019
8fbaaf5
WIP
Didainius Aug 7, 2019
7de6ab5
Tests for network update
Didainius Aug 7, 2019
94255fd
make fmt
Didainius Aug 8, 2019
7b5fcbf
Stuck
Didainius Aug 9, 2019
312e25a
Working example
Didainius Aug 12, 2019
f97e151
Update website
Didainius Aug 12, 2019
643e85b
merge master
Didainius Aug 12, 2019
64b4aba
make fmt
Didainius Aug 12, 2019
ae97686
CHANGELOG
Didainius Aug 12, 2019
b0ae2aa
Pull in govcd
Didainius Aug 12, 2019
2d4d762
bump govcd
Didainius Aug 14, 2019
727a956
merge master
Didainius Aug 14, 2019
82416f4
bump govcd
Didainius Aug 14, 2019
1e6ee4d
Add function for handling maxRetryTimeout minimum value
Didainius Aug 16, 2019
061dfcb
cleanup changelog
Didainius Aug 16, 2019
3871106
Hack - WIP
Didainius Aug 16, 2019
311c072
Fix in place
Didainius Aug 19, 2019
2e5e5b7
Remove commented block
Didainius Aug 19, 2019
85757ad
Tune docs
Didainius Aug 19, 2019
066aa7f
Update description
Didainius Aug 19, 2019
f52752f
WIP docs
Didainius Aug 19, 2019
8e7525e
Add forced customization demo steps
Didainius Aug 21, 2019
348612b
Merge master
Didainius Aug 21, 2019
db66f6a
Fix for latest govcd master
Didainius Aug 21, 2019
16dbffa
Paralellize guest customization tests
Didainius Aug 21, 2019
af9fe0f
With parallel tests
Didainius Aug 21, 2019
1744902
isForcedConfiguration() -> isForcedCustomization()
Didainius Aug 21, 2019
9bc4db8
Add 'make seqtestacc' for forcing sequential acceptance tests
Didainius Aug 22, 2019
cdb7101
Improve runtest.sh
Didainius Aug 22, 2019
255479b
Add note to testing.md
Didainius Aug 22, 2019
ed6b2be
Add reboot warning for 'terraform plan'
Didainius Aug 22, 2019
3eb1839
Tune documentation
Didainius Aug 22, 2019
72b86f9
Point correct govcd
Didainius Aug 22, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ IMPROVEMENTS:
* `resource/vcd_catalog_item`: CatalogItem state ID changed from colon separated list of catalog name and item name to vCD ID
* `resource/catalog_item` added catalog item metadata support [#298]
* `resource/catalog_media` added catalog media item metadata support [#298]
* `resource/vcd_vapp_vm` supports update for `network` block [#310]
* `resource/vcd_vapp_vm` allows to force guest customization [#310]
* Upgrade Terraform SDK dependency to 0.12.6 [#302]

BUG FIXES:
Expand Down
6 changes: 5 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ test: testunit
testacc: testunit
@sh -c "'$(CURDIR)/scripts/runtest.sh' acceptance"

# Runs full acceptance test sequentially (using "-parallel 1" flag for go test)
seqtestacc: testunit
@sh -c "'$(CURDIR)/scripts/runtest.sh' sequential-acceptance"

# Runs the acceptance test with tag 'multiple'
testmulti: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' multiple"
Expand Down Expand Up @@ -141,5 +145,5 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

.PHONY: build test testacc vet fmt fmtcheck errcheck vendor-check test-compile website website-test
.PHONY: build test seqtestacc testacc vet fmt fmtcheck errcheck vendor-check test-compile website website-test

12 changes: 12 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [Running tests](#running-tests)
- [Tests split by feature set](#tests-split-by-feature-set)
- [Adding new tests](#adding-new-tests)
- [Parallelism considerations](#parallelism-considerations)
- [Binary testing](#binary-testing)
- [Custom terraform scripts](#custom-terraform-scripts)
- [Environment variables](#environment-variables)
Expand Down Expand Up @@ -279,6 +280,17 @@ testacc: testunit
@sh -c "'$(CURDIR)/scripts/runtest.sh' acceptance"
```

### Parallelism considerations

When writing Terraform acceptance tests there are two ways to define tests. Either using
`resource.Test` or `resource.ParallelTest`. The former runs tests sequentially one by one while the
later runs all the tests (which are defined to be run in parallel) instantiated this way in
parallel. This is useful because it can speed up total test execution time. However one must be sure
that the tests defined for parallel run are not clashing with each other.

By default `make testacc` runs acceptance tests with parallelism enabled (for the tests which are
defined with `resource.ParallelTest`). If there is a need to troubleshoot or simply force the tests
to run sequentially - `make seqtestacc` can be used to achieve it.

## Binary testing

Expand Down
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@ go 1.12

require (
github.com/hashicorp/terraform v0.12.6
github.com/vmware/go-vcloud-director/v2 v2.4.0-alpha.3
github.com/vmware/go-vcloud-director/v2 v2.4.0-alpha.5
)

// replace github.com/vmware/go-vcloud-director/v2 => github.com/dataclouder/go-vcloud-director/v2 v2.4.0-alpha-4

// replace github.com/vmware/go-vcloud-director/v2 => ../go-vcloud-director
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4A
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU=
github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmware/go-vcloud-director/v2 v2.4.0-alpha.3 h1:W7EVVlITB8G0CMXPuoVxLNkznlMhL2+3fWhGWpf/BF8=
github.com/vmware/go-vcloud-director/v2 v2.4.0-alpha.3/go.mod h1:+Hq7ryFfgZqsO6mXH29RQFnpIMSujCOMI57otHoXHhQ=
github.com/vmware/go-vcloud-director/v2 v2.4.0-alpha.5 h1:bj07gO1M9wxx0GYxj+xgqR3AprvuzqZNLLvFpOJTULQ=
github.com/vmware/go-vcloud-director/v2 v2.4.0-alpha.5/go.mod h1:+Hq7ryFfgZqsO6mXH29RQFnpIMSujCOMI57otHoXHhQ=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xlab/treeprint v0.0.0-20161029104018-1d6e34225557/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
Expand Down
8 changes: 6 additions & 2 deletions scripts/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ then
VERBOSE=1
fi

accepted="[short acceptance multiple binary binary-prepare catalog gateway vapp vm network extnetwork multinetwork short-provider lb user]"
accepted="[short acceptance sequential-acceptance multiple binary binary-prepare catalog gateway vapp vm network extnetwork multinetwork short-provider lb user]"
if [ -z "$wanted" ]
then
echo "Syntax: test TYPE"
Expand Down Expand Up @@ -90,6 +90,7 @@ function short_test {

function acceptance_test {
tags="$1"
parallel="$2"
if [ -z "$tags" ]
then
tags=functional
Expand All @@ -103,7 +104,7 @@ function acceptance_test {
if [ -z "$DRY_RUN" ]
then
check_for_config_file
TF_ACC=1 go test -tags "$tags" -v -timeout $timeout .
TF_ACC=1 go test -tags "$tags" $parallel -v -timeout $timeout .
fi
}

Expand Down Expand Up @@ -201,6 +202,9 @@ case $wanted in
acceptance)
acceptance_test functional
;;
sequential-acceptance)
acceptance_test functional "--parallel=1"
;;
multinetwork)
multiple_test TestAccVcdVappNetworkMulti
;;
Expand Down
11 changes: 11 additions & 0 deletions vcd/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,14 @@ func createTemporaryVCDConnection() *VCDClient {
}
return conn
}

// minIfLess returns:
// `min` if `value` is less than min
// `value` if `value` > `min`
func minIfLess(min, value int) int {
if value < min {
return min
}

return value
}
2 changes: 1 addition & 1 deletion vcd/resource_vcd_edgegateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestAccVcdEdgeGatewayBasic(t *testing.T) {
return
}
debugPrintf("#[DEBUG] CONFIGURATION: %s", configText)
resource.Test(t, resource.TestCase{
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVcdEdgeGatewayDestroyBasic,
Expand Down
4 changes: 1 addition & 3 deletions vcd/resource_vcd_external_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ func resourceVcdExternalNetworkDelete(d *schema.ResourceData, meta interface{})
// any cast operations or default values should be done here so that the create method is simple
func getExternalNetworkInput(d *schema.ResourceData, vcdClient *VCDClient) (*types.ExternalNetwork, error) {
params := &types.ExternalNetwork{
Name: d.Get("name").(string),
Xmlns: types.XMLNamespaceExtension,
XmlnsVCloud: types.XMLNamespaceVCloud,
Name: d.Get("name").(string),
Configuration: &types.NetworkConfiguration{
Xmlns: types.XMLNamespaceVCloud,
RetainNetInfoAcrossDeployments: d.Get("retain_net_info_across_deployments").(bool),
Expand Down
2 changes: 1 addition & 1 deletion vcd/resource_vcd_lb_app_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestAccVcdLBAppProfile(t *testing.T) {
return
}

resource.Test(t, resource.TestCase{
resource.ParallelTest(t, resource.TestCase{
Providers: testAccProviders,
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccCheckVcdLBAppProfileDestroy(params["AppProfileName"].(string)),
Expand Down
2 changes: 1 addition & 1 deletion vcd/resource_vcd_lb_app_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ acl other_page2 url_beg / other2 redirect location https://www.other2.com/ ifoth
return
}

resource.Test(t, resource.TestCase{
resource.ParallelTest(t, resource.TestCase{
Providers: testAccProviders,
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccCheckVcdLBAppRuleDestroy(params["AppRuleName"].(string)),
Expand Down
2 changes: 1 addition & 1 deletion vcd/resource_vcd_lb_server_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestAccVcdLbServerPool(t *testing.T) {
return
}

resource.Test(t, resource.TestCase{
resource.ParallelTest(t, resource.TestCase{
Providers: testAccProviders,
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccCheckVcdLbServerPoolDestroy(params["ServerPoolName"].(string)),
Expand Down
2 changes: 1 addition & 1 deletion vcd/resource_vcd_lb_service_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestAccVcdLbServiceMonitor(t *testing.T) {
t.Skip(t.Name() + "requires advanced edge gateway to work")
}

resource.Test(t, resource.TestCase{
resource.ParallelTest(t, resource.TestCase{
Providers: testAccProviders,
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccCheckVcdLbServiceMonitorDestroy(params["ServiceMonitorName"].(string)),
Expand Down
2 changes: 1 addition & 1 deletion vcd/resource_vcd_lb_virtual_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestAccVcdLbVirtualServer(t *testing.T) {
return
}

resource.Test(t, resource.TestCase{
resource.ParallelTest(t, resource.TestCase{
Providers: testAccProviders,
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccCheckVcdLbVirtualServerDestroy(params["VirtualServerName"].(string)),
Expand Down
Loading