provider/openstack: added acceptance test to test security group order

This commit is contained in:
Joe Topjian 2015-10-30 22:14:53 +00:00
parent a8c5c4b6fd
commit 776f15f0f3
1 changed files with 41 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import (
"github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes" "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes"
"github.com/rackspace/gophercloud/openstack/compute/v2/extensions/floatingip" "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/floatingip"
"github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups"
"github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach" "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach"
"github.com/rackspace/gophercloud/openstack/compute/v2/servers" "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
"github.com/rackspace/gophercloud/pagination" "github.com/rackspace/gophercloud/pagination"
@ -102,6 +103,46 @@ func TestAccComputeV2Instance_floatingIPAttach(t *testing.T) {
}) })
} }
func TestAccComputeV2Instance_multi_secgroups(t *testing.T) {
var instance servers.Server
var secgroup secgroups.SecurityGroup
var testAccComputeV2Instance_multi_secgroups = fmt.Sprintf(`
resource "openstack_compute_secgroup_v2" "foo" {
name = "terraform-test"
description = "a security group"
rule {
from_port = 22
to_port = 22
ip_protocol = "tcp"
cidr = "0.0.0.0/0"
}
}
resource "openstack_compute_instance_v2" "foo" {
name = "terraform-test"
security_groups = ["default", "${openstack_compute_secgroup_v2.foo.name}"]
network {
uuid = "%s"
}
}`,
os.Getenv("OS_NETWORK_ID"))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeV2InstanceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeV2Instance_multi_secgroups,
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.foo", &secgroup),
testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.foo", &instance),
),
},
},
})
}
func testAccCheckComputeV2InstanceDestroy(s *terraform.State) error { func testAccCheckComputeV2InstanceDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config) config := testAccProvider.Meta().(*Config)
computeClient, err := config.computeV2Client(OS_REGION_NAME) computeClient, err := config.computeV2Client(OS_REGION_NAME)