vmware / go-vcloud-director

Golang SDK for VMware Cloud Director
Other
80 stars 76 forks source link

Fix quirks in Test_CreateOrgVdcWithFlex and Test_VMPowerOnPowerOff #538

Closed adambarreiro closed 1 year ago

adambarreiro commented 1 year ago

This PR amends two tests:

Test_CreateOrgVdcWithFlex

It failed randomly with the following error:

START: adminvdc_test.go:24: TestVCD.Test_CreateOrgVdcWithFlex
adminvdc_test.go:150:
    check.Assert(*vdcStorageProfileDetails.Enabled, Equals, false)
... obtained bool = true
... expected bool = false

FAIL: adminvdc_test.go:24: TestVCD.Test_CreateOrgVdcWithFlex

I could reproduce this issue several times, then it started to pass without any change. Given that the variable vdcStorageProfileDetails was being retrieved from a fixed index from an array, my assumption is that it failed due to the array being unordered.

I could not demonstrate this hypothesis but I changed the test implementation to use a loop to avoid the situation if that's the case. It should make the test more robust anyway.

Test_VMPowerOnPowerOff

Thanks to @Didainius for fixing this one.

This one failed randomly with the following error:

START: vm_test.go:666: TestVCD.Test_VMPowerOnPowerOff
vm_test.go:683:
    check.Assert(err, IsNil)
... value *errors.errorString = &errors.errorString{s:"error powering off VM: API Error: 400: [ 714a562e-1f6b-4e06-8ba5-621564803be1 ] The requested operation could not be executed since VM \"My-vm\" is not powered on."} ("error powering off VM: API Error: 400: [ 714a562e-1f6b-4e06-8ba5-621564803be1 ] The requested operation could not be executed since VM \"My-vm\" is not powered on.")

FAIL: vm_test.go:666: TestVCD.Test_VMPowerOnPowerOff

Due to the underlying VCD not being as fast as expected in powering off the VM, it could be in state "Powering off".

Tests done

Just a simple

  for i in {1..$2}
  do
    echo "####### Iteration $i"
    go test -tags functional -check.vv -check.f $1 -timeout=120m .
  done 

Where $1 is Test_CreateOrgVdcWithFlex (add GOVCD_SKIP_VAPP_CREATION=1) and Test_VMPowerOnPowerOff and $2 is 25.