Merge pull request #2866 from berendt/gh_issue_2865

provider/openstack: add state 'downloading' to resource 'blockstorage_volume_v1'
This commit is contained in:
Paul Hinze 2015-09-04 18:52:56 -05:00
commit 365a7a253a
3 changed files with 20 additions and 3 deletions

View File

@ -47,8 +47,8 @@ func testAccPreCheck(t *testing.T) {
v1 := os.Getenv("OS_IMAGE_ID") v1 := os.Getenv("OS_IMAGE_ID")
v2 := os.Getenv("OS_IMAGE_NAME") v2 := os.Getenv("OS_IMAGE_NAME")
if v1 == "" && v2 == "" { if v1 == "" || v2 == "" {
t.Fatal("OS_IMAGE_ID or OS_IMAGE_NAME must be set for acceptance tests") t.Fatal("OS_IMAGE_ID and OS_IMAGE_NAME must be set for acceptance tests")
} }
v = os.Getenv("OS_POOL_NAME") v = os.Getenv("OS_POOL_NAME")

View File

@ -136,6 +136,7 @@ func resourceBlockStorageVolumeV1Create(d *schema.ResourceData, meta interface{}
v.ID) v.ID)
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
Pending: []string{"downloading"},
Target: "available", Target: "available",
Refresh: VolumeV1StateRefreshFunc(blockStorageClient, v.ID), Refresh: VolumeV1StateRefreshFunc(blockStorageClient, v.ID),
Timeout: 10 * time.Minute, Timeout: 10 * time.Minute,
@ -267,7 +268,7 @@ func resourceBlockStorageVolumeV1Delete(d *schema.ResourceData, meta interface{}
log.Printf("[DEBUG] Waiting for volume (%s) to delete", d.Id()) log.Printf("[DEBUG] Waiting for volume (%s) to delete", d.Id())
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
Pending: []string{"deleting", "available"}, Pending: []string{"deleting", "downloading", "available"},
Target: "deleted", Target: "deleted",
Refresh: VolumeV1StateRefreshFunc(blockStorageClient, d.Id()), Refresh: VolumeV1StateRefreshFunc(blockStorageClient, d.Id()),
Timeout: 10 * time.Minute, Timeout: 10 * time.Minute,

View File

@ -2,6 +2,7 @@ package openstack
import ( import (
"fmt" "fmt"
"os"
"testing" "testing"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
@ -13,6 +14,15 @@ import (
func TestAccBlockStorageV1Volume_basic(t *testing.T) { func TestAccBlockStorageV1Volume_basic(t *testing.T) {
var volume volumes.Volume var volume volumes.Volume
var testAccBlockStorageV1Volume_bootable = fmt.Sprintf(`
resource "openstack_blockstorage_volume_v1" "volume_1" {
region = "%s"
name = "tf-test-volume-bootable"
size = 5
image_id = "%s"
}`,
os.Getenv("OS_REGION_NAME"), os.Getenv("OS_IMAGE_ID"))
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
@ -33,6 +43,12 @@ func TestAccBlockStorageV1Volume_basic(t *testing.T) {
testAccCheckBlockStorageV1VolumeMetadata(&volume, "foo", "bar"), testAccCheckBlockStorageV1VolumeMetadata(&volume, "foo", "bar"),
), ),
}, },
resource.TestStep{
Config: testAccBlockStorageV1Volume_bootable,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("openstack_blockstorage_volume_v1.volume_1", "name", "tf-test-volume-bootable"),
),
},
}, },
}) })
} }