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

provider/vsphere: deduplicate code in createVirtualMachine and deployVirtualMachine #6659

Merged
merged 1 commit into from
May 17, 2016
Merged

provider/vsphere: deduplicate code in createVirtualMachine and deployVirtualMachine #6659

merged 1 commit into from
May 17, 2016

Conversation

thetuxkeeper
Copy link
Contributor

In preparation for easier implementation of #6520 I try to remove as much duplicate code as possible in createVirtualMachine and deployVirtualMachine.
I try to get to a point where:

  • it's possible to merge the two function in one
  • or make it easier to see what's shared code and what's different

Overall goal is to make it easier to keep the two functions in sync.

Sharing it as WIP PR to avoid duplicate work

cc @chrislovecnm

@chrislovecnm
Copy link
Contributor

@thetuxkeeper make test vet failed ...

@thetuxkeeper
Copy link
Contributor Author

Yes, I'm not done yet. just wanted to share it as early as possible, so nobody starts something like that and we do the same work.

@chrislovecnm
Copy link
Contributor

@thetuxkeeper I understand ... lol

@thetuxkeeper
Copy link
Contributor Author

Acceptance test results with a time.Sleep(40 * time.Second) at line 758 to wait for the network (have to check the path format for createWithExistingVmdk):

=== RUN   TestProvider
--- PASS: TestProvider (0.00s)
=== RUN   TestProvider_impl
--- PASS: TestProvider_impl (0.00s)
=== RUN   TestAccVSphereFile_basic
Expected error received: cannot stat '[DS1] tf_file_test.vmdk': No such file
--- PASS: TestAccVSphereFile_basic (3.97s)
=== RUN   TestAccVSphereFile_renamePostCreation
Expected error received: cannot stat '[DS1] tf_test_file_moved.vmdk': No such file
Expected error received: cannot stat '[DS1] tf_test_file.vmdk': No such file
--- PASS: TestAccVSphereFile_renamePostCreation (6.49s)
=== RUN   TestAccVSphereFolder_basic
--- PASS: TestAccVSphereFolder_basic (3.05s)
=== RUN   TestAccVSphereFolder_nested
--- PASS: TestAccVSphereFolder_nested (3.01s)
=== RUN   TestAccVSphereFolder_dontDeleteExisting
--- PASS: TestAccVSphereFolder_dontDeleteExisting (3.78s)
=== RUN   TestAccVSphereVirtualMachine_basic
--- PASS: TestAccVSphereVirtualMachine_basic (190.61s)
=== RUN   TestAccVSphereVirtualMachine_diskInitType
--- PASS: TestAccVSphereVirtualMachine_diskInitType (190.06s)
=== RUN   TestAccVSphereVirtualMachine_dhcp
--- PASS: TestAccVSphereVirtualMachine_dhcp (228.16s)
=== RUN   TestAccVSphereVirtualMachine_custom_configs
--- PASS: TestAccVSphereVirtualMachine_custom_configs (221.31s)
=== RUN   TestAccVSphereVirtualMachine_createInExistingFolder
--- PASS: TestAccVSphereVirtualMachine_createInExistingFolder (230.42s)
=== RUN   TestAccVSphereVirtualMachine_createWithFolder
--- PASS: TestAccVSphereVirtualMachine_createWithFolder (229.12s)
=== RUN   TestAccVSphereVirtualMachine_createWithCdrom
--- PASS: TestAccVSphereVirtualMachine_createWithCdrom (229.13s)
=== RUN   TestAccVSphereVirtualMachine_createWithExistingVmdk
--- FAIL: TestAccVSphereVirtualMachine_createWithExistingVmdk (4.87s)
        testing.go:234: Step 0 error: Error applying: 1 error(s) occurred:

                * vsphere_virtual_machine.with_existing_vmdk: Ungültiger Datenspeicherpfad 'terraform-unit-test/centos-terraform.vmdk'.
=== RUN   TestAccVSphereVirtualMachine_updateMemory
--- PASS: TestAccVSphereVirtualMachine_updateMemory (394.27s)
=== RUN   TestAccVSphereVirtualMachine_updateVcpu
--- PASS: TestAccVSphereVirtualMachine_updateVcpu (383.06s)
=== RUN   TestAccVSphereVirtualMachine_ipv4Andipv6
--- PASS: TestAccVSphereVirtualMachine_ipv4Andipv6 (188.69s)

@thetuxkeeper
Copy link
Contributor Author

Rebased to master and fixed conflicts. ipv4Andipv6 fails sometimes but I saw that before this change too, so it is unrelated to the change (I think the network wait is not waiting long enough => separate issue).

I hope that's better to understand and easier to refactor since some duplicate code was removed. I tried not to change too much that it's easier to review and I don't have the golang knowledge/experience to refactor it from zero :)

==> Checking that code complies with gofmt requirements...
/home/tux/go/bin/stringer
go generate $(go list ./... | grep -v /vendor/)
2016/05/17 21:55:58 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/vsphere -v  -timeout 120m
=== RUN   TestProvider
--- PASS: TestProvider (0.00s)
=== RUN   TestProvider_impl
--- PASS: TestProvider_impl (0.00s)
=== RUN   TestAccVSphereFile_basic
Expected error received: cannot stat '[DS1] tf_file_test.vmdk': No such file
--- PASS: TestAccVSphereFile_basic (8.29s)
=== RUN   TestAccVSphereFile_renamePostCreation
Expected error received: cannot stat '[DS1] tf_test_file_moved.vmdk': No such file
Expected error received: cannot stat '[DS1] tf_test_file.vmdk': No such file
--- PASS: TestAccVSphereFile_renamePostCreation (13.35s)
=== RUN   TestAccVSphereFolder_basic
--- PASS: TestAccVSphereFolder_basic (5.92s)
=== RUN   TestAccVSphereFolder_nested
--- PASS: TestAccVSphereFolder_nested (6.04s)
=== RUN   TestAccVSphereFolder_dontDeleteExisting
--- PASS: TestAccVSphereFolder_dontDeleteExisting (7.15s)
=== RUN   TestAccVSphereVirtualMachine_basic
--- PASS: TestAccVSphereVirtualMachine_basic (102.79s)
=== RUN   TestAccVSphereVirtualMachine_diskInitType
--- PASS: TestAccVSphereVirtualMachine_diskInitType (99.64s)
=== RUN   TestAccVSphereVirtualMachine_dhcp
--- PASS: TestAccVSphereVirtualMachine_dhcp (101.01s)
=== RUN   TestAccVSphereVirtualMachine_custom_configs
--- PASS: TestAccVSphereVirtualMachine_custom_configs (101.74s)
=== RUN   TestAccVSphereVirtualMachine_createInExistingFolder
--- PASS: TestAccVSphereVirtualMachine_createInExistingFolder (99.18s)
=== RUN   TestAccVSphereVirtualMachine_createWithFolder
--- PASS: TestAccVSphereVirtualMachine_createWithFolder (103.16s)
=== RUN   TestAccVSphereVirtualMachine_createWithCdrom
--- PASS: TestAccVSphereVirtualMachine_createWithCdrom (95.35s)
=== RUN   TestAccVSphereVirtualMachine_createWithExistingVmdk
--- PASS: TestAccVSphereVirtualMachine_createWithExistingVmdk (70.42s)
=== RUN   TestAccVSphereVirtualMachine_updateMemory
--- PASS: TestAccVSphereVirtualMachine_updateMemory (161.83s)
=== RUN   TestAccVSphereVirtualMachine_updateVcpu
--- PASS: TestAccVSphereVirtualMachine_updateVcpu (148.14s)
=== RUN   TestAccVSphereVirtualMachine_ipv4Andipv6
--- FAIL: TestAccVSphereVirtualMachine_ipv4Andipv6 (107.96s)
        testing.go:234: Step 0 error: Check failed: Check 11/12 error: vsphere_virtual_machine.ipv4ipv6: Attribute 'network_interface.0.ipv6_address' expected "fc00::2", got "fe80::250:56ff:fe8e:2794"
FAIL
exit status 1
FAIL    github.com/hashicorp/terraform/builtin/providers/vsphere        1232.033s
2016/05/17 22:30:33 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/vsphere -v -run=TestAccVSphereVirtualMachine_ipv4Andipv6 -timeout 120m
=== RUN   TestAccVSphereVirtualMachine_ipv4Andipv6
--- PASS: TestAccVSphereVirtualMachine_ipv4Andipv6 (112.99s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/vsphere        113.005s

@thetuxkeeper thetuxkeeper changed the title [WIP] provider/vsphere: deduplicate code in createVirtualMachine and deployVirtualMachine provider/vsphere: deduplicate code in createVirtualMachine and deployVirtualMachine May 17, 2016
@chrislovecnm
Copy link
Contributor

@phinze @stack72 @jen20 might we get a merge??

@stack72 stack72 merged commit 6263962 into hashicorp:master May 17, 2016
@chrislovecnm
Copy link
Contributor

@stack72 bro I owe u multiple pints ;)

terraformbot pushed a commit that referenced this pull request May 18, 2016
[origin/master] merged createVirtualMachine and deployVirtualMachine to setupVirtualMachine (#6659)
6263962
terraformbot pushed a commit that referenced this pull request May 18, 2016
[origin/master] merged createVirtualMachine and deployVirtualMachine to setupVirtualMachine (#6659)
6263962
terraformbot pushed a commit that referenced this pull request May 18, 2016
[origin/master] merged createVirtualMachine and deployVirtualMachine to setupVirtualMachine (#6659)
6263962
terraformbot pushed a commit that referenced this pull request May 18, 2016
[origin/master] merged createVirtualMachine and deployVirtualMachine to setupVirtualMachine (#6659)
6263962
ojongerius added a commit to atlassian/terraform that referenced this pull request May 18, 2016
…equire_full_window_and_locked

* upstream/master: (665 commits)
  merged createVirtualMachine and deployVirtualMachine to setupVirtualMachine (hashicorp#6659)
  Update CHANGELOG.md
  provider/fastly: add support for custom VCL configuration (supersedes hashicorp#6587) (hashicorp#6662)
  Remove CHANGELOG entry for backported 0.6.17 feature
  Update CHANGELOG.md
  provider/vsphere: wait for network enhanced (hashicorp#6377)
  Update CHANGELOG.md
  Update CHANGELOG.md
  Update CHANGELOG.md
  docs: clarify an internal-plugins header
  Fixes an vet error.
  Update CHANGELOG.md
  provider/aws: Support for Redshift Cluster encryption using a KMS key (hashicorp#6712)
  provider/aws: Randomize key names in KMS alias test
  Include the list of allowed values for AWS auto scaling group termination policies (hashicorp#6710)
  website: docs for azurerm custom images
  Update CHANGELOG.md
  Godeps: rm dup github.com/ryanuber/columnize
  Add note about paid training
  provider/aws: Fix crash in ElastiCache param group
  ...
cristicalin pushed a commit to cristicalin/terraform that referenced this pull request May 24, 2016
@ghost
Copy link

ghost commented Apr 25, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants