From dae64707a558baa2a562d2134e1ec5fa54770fcb Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Wed, 16 May 2018 16:53:32 +0300 Subject: [PATCH] Fix tests --- common/testing/utility.go | 3 +-- driver/driver_test.go | 3 +-- driver/vm_clone_acc_test.go | 7 ++++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/common/testing/utility.go b/common/testing/utility.go index 7c72e14a9..8a13bf883 100644 --- a/common/testing/utility.go +++ b/common/testing/utility.go @@ -9,7 +9,6 @@ import ( "github.com/jetbrains-infra/packer-builder-vsphere/driver" "testing" "github.com/jetbrains-infra/packer-builder-vsphere/common" - "context" ) func NewVMName() string { @@ -35,7 +34,7 @@ func RenderConfig(config map[string]interface{}) string { func TestConn(t *testing.T) *driver.Driver { - d, err := driver.NewDriver(context.TODO(), &driver.ConnectConfig{ + d, err := driver.NewDriver(&driver.ConnectConfig{ VCenterServer: "vcenter.vsphere65.test", Username: "root", Password: "jetbrains", diff --git a/driver/driver_test.go b/driver/driver_test.go index 54590f389..e46729ad4 100644 --- a/driver/driver_test.go +++ b/driver/driver_test.go @@ -5,14 +5,13 @@ import ( "testing" "time" "math/rand" - "context" ) // Defines whether acceptance tests should be run const TestHostName = "esxi-1.vsphere65.test" func newTestDriver(t *testing.T) *Driver { - d, err := NewDriver(context.TODO(), &ConnectConfig{ + d, err := NewDriver(&ConnectConfig{ VCenterServer: "vcenter.vsphere65.test", Username: "root", Password: "jetbrains", diff --git a/driver/vm_clone_acc_test.go b/driver/vm_clone_acc_test.go index 8a023a897..fc5be60a0 100644 --- a/driver/vm_clone_acc_test.go +++ b/driver/vm_clone_acc_test.go @@ -5,6 +5,7 @@ import ( "net" "testing" "time" + "context" ) func TestVMAcc_clone(t *testing.T) { @@ -38,7 +39,7 @@ func TestVMAcc_clone(t *testing.T) { } log.Printf("[DEBUG] Clonning VM") - vm, err := template.Clone(tc.config) + vm, err := template.Clone(context.TODO(), tc.config) if err != nil { t.Fatalf("Cannot clone vm '%v': %v", templateName, err) } @@ -227,7 +228,7 @@ func startAndStopCheck(t *testing.T, vm *VirtualMachine, config *CloneConfig) { stopper := startVM(t, vm, config.Name) defer stopper() - switch ip, err := vm.WaitForIP(); { + switch ip, err := vm.WaitForIP(context.TODO()); { case err != nil: t.Errorf("Cannot obtain IP address from created vm '%v': %v", config.Name, err) case net.ParseIP(ip) == nil: @@ -236,7 +237,7 @@ func startAndStopCheck(t *testing.T, vm *VirtualMachine, config *CloneConfig) { vm.StartShutdown() log.Printf("[DEBUG] Waiting max 1m0s for shutdown to complete") - vm.WaitForShutdown(1 * time.Minute) + vm.WaitForShutdown(context.TODO(), 1 * time.Minute) } func snapshotCheck(t *testing.T, vm *VirtualMachine, config *CloneConfig) {