Skip to content

Commit

Permalink
Fix VN test for OpenNebula 6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Czerny authored and frousselet committed May 13, 2022
1 parent 0dad30f commit d688ed2
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions opennebula/resource_opennebula_virtual_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"
"strings"
"testing"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down Expand Up @@ -155,13 +156,27 @@ func testAccCheckVirtualNetworkDestroy(s *terraform.State) error {
for _, rs := range s.RootModule().Resources {
vnID, _ := strconv.ParseUint(rs.Primary.ID, 10, 64)
vnc := controller.VirtualNetwork(int(vnID))
// Get Virtual Network Info
// TODO: fix it after 5.10 release
// Force the "decrypt" bool to false to keep ONE 5.8 behavior
vn, _ := vnc.Info(false)
if vn != nil {
return fmt.Errorf("Expected virtual network %s to have been destroyed", rs.Primary.ID)

// Wait for Virtual Network deleted
stateConf := &resource.StateChangeConf{
Pending: []string{"anythingelse"},
Target: []string{""},
Refresh: func() (interface{}, string, error) {

vn, _ := vnc.Info(false)
if vn == nil {
return vn, "", nil
}

return vn, "EXISTS", nil
},
Timeout: 1 * time.Minute,
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
}

_, err := stateConf.WaitForState()
return err
}

return nil
Expand Down

0 comments on commit d688ed2

Please sign in to comment.