Commit 09354d66 authored by Yann KAISER's avatar Yann KAISER

Fixed service existence check in acceptance tests

parent c40e96a0
......@@ -2,7 +2,6 @@ package one
import (
"fmt"
"strconv"
"testing"
"gitlab.ippon.fr/ims/opennebula-api/vm"
......@@ -94,7 +93,6 @@ func testAccServiceConfig() string {
cooldown = "%s"
}
}
}
resource "one_service" "test" {
......@@ -122,51 +120,38 @@ func testAccServiceExists(n string, vm *vm.VMData) resource.TestCheckFunc {
continue
}
session := provider.Meta().(*Client).VMSession
id, err := strconv.Atoi(rs.Primary.ID)
if err != nil {
return err
}
vm, err = session.GetVMState(id)
session := provider.Meta().(*Client).ServiceSession
service, err := session.GetService(rs.Primary.ID)
if err != nil {
return err
}
if vm != nil {
if service != nil {
return nil
}
}
return fmt.Errorf("VM instance not found")
return fmt.Errorf("Service instance not found")
}
}
func testAccCheckServiceDestroy(s *terraform.State) error {
session := testAccProvider.Meta().(*Client).VMSession
session := testAccProvider.Meta().(*Client).ServiceSession
for _, rs := range s.RootModule().Resources {
if rs.Type != "one_vm" {
if rs.Type != "one_service" {
continue
}
instanceID, err := strconv.Atoi(rs.Primary.ID)
if err != nil {
return err
}
vmData, err := session.GetVMState(instanceID)
service, err := session.GetService(rs.Primary.ID)
if err != nil {
return err
}
if vmData == nil {
if service == nil {
return nil
}
if vmData.State != vm.StateDone {
return fmt.Errorf("found unterminated vm instance with id: %d", instanceID)
}
}
return nil
......
......@@ -13,7 +13,6 @@ import (
)
func TestAccVMTemplate(t *testing.T) {
//t.Skip()
var v vm.VMTemplateItem
var cpu = testContext.ResourceVMTemplate["cpu"].(string)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment