provider/openstack: Updating Compute acceptance tests (#10954)
This commit is contained in:
parent
e2f2f9c78e
commit
64051f9214
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAccComputeV2FloatingIP_importBasic(t *testing.T) {
|
||||
resourceName := "openstack_compute_floatingip_v2.foo"
|
||||
resourceName := "openstack_compute_floatingip_v2.fip_1"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAccComputeV2SecGroup_importBasic(t *testing.T) {
|
||||
resourceName := "openstack_compute_secgroup_v2.foo"
|
||||
resourceName := "openstack_compute_secgroup_v2.sg_1"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAccComputeV2ServerGroup_importBasic(t *testing.T) {
|
||||
resourceName := "openstack_compute_servergroup_v2.mysg"
|
||||
resourceName := "openstack_compute_servergroup_v2.sg_1"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
|
|
@ -2,7 +2,6 @@ package openstack
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
|
@ -13,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAccComputeV2FloatingIP_basic(t *testing.T) {
|
||||
var floatingIP floatingips.FloatingIP
|
||||
var fip floatingips.FloatingIP
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -23,7 +22,7 @@ func TestAccComputeV2FloatingIP_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccComputeV2FloatingIP_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2FloatingIPExists(t, "openstack_compute_floatingip_v2.foo", &floatingIP),
|
||||
testAccCheckComputeV2FloatingIPExists("openstack_compute_floatingip_v2.fip_1", &fip),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -33,21 +32,6 @@ func TestAccComputeV2FloatingIP_basic(t *testing.T) {
|
|||
func TestAccComputeV2FloatingIP_attach(t *testing.T) {
|
||||
var instance servers.Server
|
||||
var fip floatingips.FloatingIP
|
||||
var testAccComputeV2FloatingIP_attach = fmt.Sprintf(`
|
||||
resource "openstack_compute_floatingip_v2" "myip" {
|
||||
}
|
||||
|
||||
resource "openstack_compute_instance_v2" "foo" {
|
||||
name = "terraform-test"
|
||||
security_groups = ["default"]
|
||||
floating_ip = "${openstack_compute_floatingip_v2.myip.address}"
|
||||
|
||||
network {
|
||||
uuid = "%s"
|
||||
}
|
||||
}`,
|
||||
os.Getenv("OS_NETWORK_ID"))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
@ -56,8 +40,8 @@ func TestAccComputeV2FloatingIP_attach(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccComputeV2FloatingIP_attach,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2FloatingIPExists(t, "openstack_compute_floatingip_v2.myip", &fip),
|
||||
testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.foo", &instance),
|
||||
testAccCheckComputeV2FloatingIPExists("openstack_compute_floatingip_v2.fip_1", &fip),
|
||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_1", &instance),
|
||||
testAccCheckComputeV2InstanceFloatingIPAttach(&instance, &fip),
|
||||
),
|
||||
},
|
||||
|
@ -69,7 +53,7 @@ func testAccCheckComputeV2FloatingIPDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
computeClient, err := config.computeV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckComputeV2FloatingIPDestroy) Error creating OpenStack compute client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -86,7 +70,7 @@ func testAccCheckComputeV2FloatingIPDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckComputeV2FloatingIPExists(t *testing.T, n string, kp *floatingips.FloatingIP) resource.TestCheckFunc {
|
||||
func testAccCheckComputeV2FloatingIPExists(n string, kp *floatingips.FloatingIP) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -100,7 +84,7 @@ func testAccCheckComputeV2FloatingIPExists(t *testing.T, n string, kp *floatingi
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
computeClient, err := config.computeV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckComputeV2FloatingIPExists) Error creating OpenStack compute client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
||||
found, err := floatingips.Get(computeClient, rs.Primary.ID).Extract()
|
||||
|
@ -118,6 +102,22 @@ func testAccCheckComputeV2FloatingIPExists(t *testing.T, n string, kp *floatingi
|
|||
}
|
||||
}
|
||||
|
||||
var testAccComputeV2FloatingIP_basic = `
|
||||
resource "openstack_compute_floatingip_v2" "foo" {
|
||||
}`
|
||||
const testAccComputeV2FloatingIP_basic = `
|
||||
resource "openstack_compute_floatingip_v2" "fip_1" {
|
||||
}
|
||||
`
|
||||
|
||||
var testAccComputeV2FloatingIP_attach = fmt.Sprintf(`
|
||||
resource "openstack_compute_floatingip_v2" "fip_1" {
|
||||
}
|
||||
|
||||
resource "openstack_compute_instance_v2" "instance_1" {
|
||||
name = "instance_1"
|
||||
security_groups = ["default"]
|
||||
floating_ip = "${openstack_compute_floatingip_v2.fip_1.address}"
|
||||
|
||||
network {
|
||||
uuid = "%s"
|
||||
}
|
||||
}
|
||||
`, OS_NETWORK_ID)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -21,7 +21,7 @@ func TestAccComputeV2Keypair_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccComputeV2Keypair_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2KeypairExists(t, "openstack_compute_keypair_v2.foo", &keypair),
|
||||
testAccCheckComputeV2KeypairExists("openstack_compute_keypair_v2.kp_1", &keypair),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -32,7 +32,7 @@ func testAccCheckComputeV2KeypairDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
computeClient, err := config.computeV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckComputeV2KeypairDestroy) Error creating OpenStack compute client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -49,7 +49,7 @@ func testAccCheckComputeV2KeypairDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckComputeV2KeypairExists(t *testing.T, n string, kp *keypairs.KeyPair) resource.TestCheckFunc {
|
||||
func testAccCheckComputeV2KeypairExists(n string, kp *keypairs.KeyPair) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -63,7 +63,7 @@ func testAccCheckComputeV2KeypairExists(t *testing.T, n string, kp *keypairs.Key
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
computeClient, err := config.computeV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckComputeV2KeypairExists) Error creating OpenStack compute client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
||||
found, err := keypairs.Get(computeClient, rs.Primary.ID).Extract()
|
||||
|
@ -81,8 +81,9 @@ func testAccCheckComputeV2KeypairExists(t *testing.T, n string, kp *keypairs.Key
|
|||
}
|
||||
}
|
||||
|
||||
var testAccComputeV2Keypair_basic = fmt.Sprintf(`
|
||||
resource "openstack_compute_keypair_v2" "foo" {
|
||||
name = "test-keypair-tf"
|
||||
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAjpC1hwiOCCmKEWxJ4qzTTsJbKzndLo1BCz5PcwtUnflmU+gHJtWMZKpuEGVi29h0A/+ydKek1O18k10Ff+4tyFjiHDQAT9+OfgWf7+b1yK+qDip3X1C0UPMbwHlTfSGWLGZquwhvEFx9k3h/M+VtMvwR1lJ9LUyTAImnNjWG7TAIPmui30HvM2UiFEmqkr4ijq45MyX2+fLIePLRIFuu1p4whjHAQYufqyno3BS48icQb4p6iVEZPo4AE2o9oIyQvj2mx4dk5Y8CgSETOZTYDOR3rU2fZTRDRgPJDH9FWvQjF5tA0p3d9CoWWd2s6GKKbfoUIi8R/Db1BSPJwkqB jrp-hp-pc"
|
||||
}`)
|
||||
const testAccComputeV2Keypair_basic = `
|
||||
resource "openstack_compute_keypair_v2" "kp_1" {
|
||||
name = "kp_1"
|
||||
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAjpC1hwiOCCmKEWxJ4qzTTsJbKzndLo1BCz5PcwtUnflmU+gHJtWMZKpuEGVi29h0A/+ydKek1O18k10Ff+4tyFjiHDQAT9+OfgWf7+b1yK+qDip3X1C0UPMbwHlTfSGWLGZquwhvEFx9k3h/M+VtMvwR1lJ9LUyTAImnNjWG7TAIPmui30HvM2UiFEmqkr4ijq45MyX2+fLIePLRIFuu1p4whjHAQYufqyno3BS48icQb4p6iVEZPo4AE2o9oIyQvj2mx4dk5Y8CgSETOZTYDOR3rU2fZTRDRgPJDH9FWvQjF5tA0p3d9CoWWd2s6GKKbfoUIi8R/Db1BSPJwkqB jrp-hp-pc"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestAccComputeV2SecGroup_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccComputeV2SecGroup_basic_orig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.foo", &secgroup),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.sg_1", &secgroup),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -39,14 +39,14 @@ func TestAccComputeV2SecGroup_update(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccComputeV2SecGroup_basic_orig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.foo", &secgroup),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.sg_1", &secgroup),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccComputeV2SecGroup_basic_update,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.foo", &secgroup),
|
||||
testAccCheckComputeV2SecGroupRuleCount(t, &secgroup, 2),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.sg_1", &secgroup),
|
||||
testAccCheckComputeV2SecGroupRuleCount(&secgroup, 2),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -64,19 +64,19 @@ func TestAccComputeV2SecGroup_groupID(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccComputeV2SecGroup_groupID_orig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.test_group_1", &secgroup1),
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.test_group_2", &secgroup2),
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.test_group_3", &secgroup3),
|
||||
testAccCheckComputeV2SecGroupGroupIDMatch(t, &secgroup1, &secgroup3),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.sg_1", &secgroup1),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.sg_2", &secgroup2),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.sg_3", &secgroup3),
|
||||
testAccCheckComputeV2SecGroupGroupIDMatch(&secgroup1, &secgroup3),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccComputeV2SecGroup_groupID_update,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.test_group_1", &secgroup1),
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.test_group_2", &secgroup2),
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.test_group_3", &secgroup3),
|
||||
testAccCheckComputeV2SecGroupGroupIDMatch(t, &secgroup2, &secgroup3),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.sg_1", &secgroup1),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.sg_2", &secgroup2),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.sg_3", &secgroup3),
|
||||
testAccCheckComputeV2SecGroupGroupIDMatch(&secgroup2, &secgroup3),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -94,12 +94,12 @@ func TestAccComputeV2SecGroup_self(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccComputeV2SecGroup_self,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.test_group_1", &secgroup),
|
||||
testAccCheckComputeV2SecGroupGroupIDMatch(t, &secgroup, &secgroup),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.sg_1", &secgroup),
|
||||
testAccCheckComputeV2SecGroupGroupIDMatch(&secgroup, &secgroup),
|
||||
resource.TestCheckResourceAttr(
|
||||
"openstack_compute_secgroup_v2.test_group_1", "rule.3170486100.self", "true"),
|
||||
"openstack_compute_secgroup_v2.sg_1", "rule.3170486100.self", "true"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"openstack_compute_secgroup_v2.test_group_1", "rule.3170486100.from_group_id", ""),
|
||||
"openstack_compute_secgroup_v2.sg_1", "rule.3170486100.from_group_id", ""),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -117,7 +117,7 @@ func TestAccComputeV2SecGroup_icmpZero(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccComputeV2SecGroup_icmpZero,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.test_group_1", &secgroup),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.sg_1", &secgroup),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -135,9 +135,9 @@ func TestAccComputeV2SecGroup_lowerCaseCIDR(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccComputeV2SecGroup_lowerCaseCIDR,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.test_group_1", &secgroup),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.sg_1", &secgroup),
|
||||
resource.TestCheckResourceAttr(
|
||||
"openstack_compute_secgroup_v2.test_group_1", "rule.3862435458.cidr", "2001:558:fc00::/39"),
|
||||
"openstack_compute_secgroup_v2.sg_1", "rule.3862435458.cidr", "2001:558:fc00::/39"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -148,7 +148,7 @@ func testAccCheckComputeV2SecGroupDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
computeClient, err := config.computeV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckComputeV2SecGroupDestroy) Error creating OpenStack compute client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -165,7 +165,7 @@ func testAccCheckComputeV2SecGroupDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckComputeV2SecGroupExists(t *testing.T, n string, secgroup *secgroups.SecurityGroup) resource.TestCheckFunc {
|
||||
func testAccCheckComputeV2SecGroupExists(n string, secgroup *secgroups.SecurityGroup) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -179,7 +179,7 @@ func testAccCheckComputeV2SecGroupExists(t *testing.T, n string, secgroup *secgr
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
computeClient, err := config.computeV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckComputeV2SecGroupExists) Error creating OpenStack compute client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
||||
found, err := secgroups.Get(computeClient, rs.Primary.ID).Extract()
|
||||
|
@ -197,7 +197,7 @@ func testAccCheckComputeV2SecGroupExists(t *testing.T, n string, secgroup *secgr
|
|||
}
|
||||
}
|
||||
|
||||
func testAccCheckComputeV2SecGroupRuleCount(t *testing.T, secgroup *secgroups.SecurityGroup, count int) resource.TestCheckFunc {
|
||||
func testAccCheckComputeV2SecGroupRuleCount(secgroup *secgroups.SecurityGroup, count int) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
if len(secgroup.Rules) != count {
|
||||
return fmt.Errorf("Security group rule count does not match. Expected %d, got %d", count, len(secgroup.Rules))
|
||||
|
@ -207,7 +207,7 @@ func testAccCheckComputeV2SecGroupRuleCount(t *testing.T, secgroup *secgroups.Se
|
|||
}
|
||||
}
|
||||
|
||||
func testAccCheckComputeV2SecGroupGroupIDMatch(t *testing.T, sg1, sg2 *secgroups.SecurityGroup) resource.TestCheckFunc {
|
||||
func testAccCheckComputeV2SecGroupGroupIDMatch(sg1, sg2 *secgroups.SecurityGroup) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
if len(sg2.Rules) == 1 {
|
||||
if sg1.Name != sg2.Rules[0].Group.Name || sg1.TenantID != sg2.Rules[0].Group.TenantID {
|
||||
|
@ -221,148 +221,155 @@ func testAccCheckComputeV2SecGroupGroupIDMatch(t *testing.T, sg1, sg2 *secgroups
|
|||
}
|
||||
}
|
||||
|
||||
var testAccComputeV2SecGroup_basic_orig = fmt.Sprintf(`
|
||||
resource "openstack_compute_secgroup_v2" "foo" {
|
||||
name = "test_group_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
ip_protocol = "tcp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
rule {
|
||||
from_port = 1
|
||||
to_port = 65535
|
||||
ip_protocol = "udp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
rule {
|
||||
from_port = -1
|
||||
to_port = -1
|
||||
ip_protocol = "icmp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}`)
|
||||
const testAccComputeV2SecGroup_basic_orig = `
|
||||
resource "openstack_compute_secgroup_v2" "sg_1" {
|
||||
name = "sg_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
ip_protocol = "tcp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
rule {
|
||||
from_port = 1
|
||||
to_port = 65535
|
||||
ip_protocol = "udp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
rule {
|
||||
from_port = -1
|
||||
to_port = -1
|
||||
ip_protocol = "icmp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
var testAccComputeV2SecGroup_basic_update = fmt.Sprintf(`
|
||||
resource "openstack_compute_secgroup_v2" "foo" {
|
||||
name = "test_group_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 2200
|
||||
to_port = 2200
|
||||
ip_protocol = "tcp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
rule {
|
||||
from_port = -1
|
||||
to_port = -1
|
||||
ip_protocol = "icmp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}`)
|
||||
const testAccComputeV2SecGroup_basic_update = `
|
||||
resource "openstack_compute_secgroup_v2" "sg_1" {
|
||||
name = "sg_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 2200
|
||||
to_port = 2200
|
||||
ip_protocol = "tcp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
rule {
|
||||
from_port = -1
|
||||
to_port = -1
|
||||
ip_protocol = "icmp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
var testAccComputeV2SecGroup_groupID_orig = fmt.Sprintf(`
|
||||
resource "openstack_compute_secgroup_v2" "test_group_1" {
|
||||
name = "test_group_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
ip_protocol = "tcp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
const testAccComputeV2SecGroup_groupID_orig = `
|
||||
resource "openstack_compute_secgroup_v2" "sg_1" {
|
||||
name = "sg_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
ip_protocol = "tcp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_compute_secgroup_v2" "test_group_2" {
|
||||
name = "test_group_2"
|
||||
description = "second test security group"
|
||||
rule {
|
||||
from_port = -1
|
||||
to_port = -1
|
||||
ip_protocol = "icmp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
resource "openstack_compute_secgroup_v2" "sg_2" {
|
||||
name = "sg_2"
|
||||
description = "second test security group"
|
||||
rule {
|
||||
from_port = -1
|
||||
to_port = -1
|
||||
ip_protocol = "icmp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_compute_secgroup_v2" "test_group_3" {
|
||||
name = "test_group_3"
|
||||
description = "third test security group"
|
||||
rule {
|
||||
from_port = 80
|
||||
to_port = 80
|
||||
ip_protocol = "tcp"
|
||||
from_group_id = "${openstack_compute_secgroup_v2.test_group_1.id}"
|
||||
}
|
||||
}`)
|
||||
resource "openstack_compute_secgroup_v2" "sg_3" {
|
||||
name = "sg_3"
|
||||
description = "third test security group"
|
||||
rule {
|
||||
from_port = 80
|
||||
to_port = 80
|
||||
ip_protocol = "tcp"
|
||||
from_group_id = "${openstack_compute_secgroup_v2.sg_1.id}"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
var testAccComputeV2SecGroup_groupID_update = fmt.Sprintf(`
|
||||
resource "openstack_compute_secgroup_v2" "test_group_1" {
|
||||
name = "test_group_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
ip_protocol = "tcp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
const testAccComputeV2SecGroup_groupID_update = `
|
||||
resource "openstack_compute_secgroup_v2" "sg_1" {
|
||||
name = "sg_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
ip_protocol = "tcp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_compute_secgroup_v2" "test_group_2" {
|
||||
name = "test_group_2"
|
||||
description = "second test security group"
|
||||
rule {
|
||||
from_port = -1
|
||||
to_port = -1
|
||||
ip_protocol = "icmp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
resource "openstack_compute_secgroup_v2" "sg_2" {
|
||||
name = "sg_2"
|
||||
description = "second test security group"
|
||||
rule {
|
||||
from_port = -1
|
||||
to_port = -1
|
||||
ip_protocol = "icmp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_compute_secgroup_v2" "test_group_3" {
|
||||
name = "test_group_3"
|
||||
description = "third test security group"
|
||||
rule {
|
||||
from_port = 80
|
||||
to_port = 80
|
||||
ip_protocol = "tcp"
|
||||
from_group_id = "${openstack_compute_secgroup_v2.test_group_2.id}"
|
||||
}
|
||||
}`)
|
||||
resource "openstack_compute_secgroup_v2" "sg_3" {
|
||||
name = "sg_3"
|
||||
description = "third test security group"
|
||||
rule {
|
||||
from_port = 80
|
||||
to_port = 80
|
||||
ip_protocol = "tcp"
|
||||
from_group_id = "${openstack_compute_secgroup_v2.sg_2.id}"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
var testAccComputeV2SecGroup_self = fmt.Sprintf(`
|
||||
resource "openstack_compute_secgroup_v2" "test_group_1" {
|
||||
name = "test_group_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
ip_protocol = "tcp"
|
||||
self = true
|
||||
}
|
||||
}`)
|
||||
const testAccComputeV2SecGroup_self = `
|
||||
resource "openstack_compute_secgroup_v2" "sg_1" {
|
||||
name = "sg_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
ip_protocol = "tcp"
|
||||
self = true
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
var testAccComputeV2SecGroup_icmpZero = fmt.Sprintf(`
|
||||
resource "openstack_compute_secgroup_v2" "test_group_1" {
|
||||
name = "test_group_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
ip_protocol = "icmp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}`)
|
||||
const testAccComputeV2SecGroup_icmpZero = `
|
||||
resource "openstack_compute_secgroup_v2" "sg_1" {
|
||||
name = "sg_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
ip_protocol = "icmp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
var testAccComputeV2SecGroup_lowerCaseCIDR = fmt.Sprintf(`
|
||||
resource "openstack_compute_secgroup_v2" "test_group_1" {
|
||||
name = "test_group_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
ip_protocol = "icmp"
|
||||
cidr = "2001:558:FC00::/39"
|
||||
}
|
||||
}`)
|
||||
const testAccComputeV2SecGroup_lowerCaseCIDR = `
|
||||
resource "openstack_compute_secgroup_v2" "sg_1" {
|
||||
name = "sg_1"
|
||||
description = "first test security group"
|
||||
rule {
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
ip_protocol = "icmp"
|
||||
cidr = "2001:558:FC00::/39"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAccComputeV2ServerGroup_basic(t *testing.T) {
|
||||
var serverGroup servergroups.ServerGroup
|
||||
var sg servergroups.ServerGroup
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -22,7 +22,7 @@ func TestAccComputeV2ServerGroup_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccComputeV2ServerGroup_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2ServerGroupExists(t, "openstack_compute_servergroup_v2.mysg", &serverGroup),
|
||||
testAccCheckComputeV2ServerGroupExists("openstack_compute_servergroup_v2.sg_1", &sg),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -41,8 +41,8 @@ func TestAccComputeV2ServerGroup_affinity(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccComputeV2ServerGroup_affinity,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2ServerGroupExists(t, "openstack_compute_servergroup_v2.mysg", &sg),
|
||||
testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.myinstance", &instance),
|
||||
testAccCheckComputeV2ServerGroupExists("openstack_compute_servergroup_v2.sg_1", &sg),
|
||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_1", &instance),
|
||||
testAccCheckComputeV2InstanceInServerGroup(&instance, &sg),
|
||||
),
|
||||
},
|
||||
|
@ -54,7 +54,7 @@ func testAccCheckComputeV2ServerGroupDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
computeClient, err := config.computeV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckComputeV2ServerGroupDestroy) Error creating OpenStack compute client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -71,7 +71,7 @@ func testAccCheckComputeV2ServerGroupDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckComputeV2ServerGroupExists(t *testing.T, n string, kp *servergroups.ServerGroup) resource.TestCheckFunc {
|
||||
func testAccCheckComputeV2ServerGroupExists(n string, kp *servergroups.ServerGroup) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -85,7 +85,7 @@ func testAccCheckComputeV2ServerGroupExists(t *testing.T, n string, kp *servergr
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
computeClient, err := config.computeV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckComputeV2ServerGroupExists) Error creating OpenStack compute client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
||||
found, err := servergroups.Get(computeClient, rs.Primary.ID).Extract()
|
||||
|
@ -117,22 +117,24 @@ func testAccCheckComputeV2InstanceInServerGroup(instance *servers.Server, sg *se
|
|||
}
|
||||
}
|
||||
|
||||
var testAccComputeV2ServerGroup_basic = `
|
||||
resource "openstack_compute_servergroup_v2" "mysg" {
|
||||
name = "mysg"
|
||||
policies = ["affinity"]
|
||||
}`
|
||||
const testAccComputeV2ServerGroup_basic = `
|
||||
resource "openstack_compute_servergroup_v2" "sg_1" {
|
||||
name = "sg_1"
|
||||
policies = ["affinity"]
|
||||
}
|
||||
`
|
||||
|
||||
var testAccComputeV2ServerGroup_affinity = `
|
||||
resource "openstack_compute_servergroup_v2" "mysg" {
|
||||
name = "mysg"
|
||||
policies = ["affinity"]
|
||||
}
|
||||
const testAccComputeV2ServerGroup_affinity = `
|
||||
resource "openstack_compute_servergroup_v2" "sg_1" {
|
||||
name = "sg_1"
|
||||
policies = ["affinity"]
|
||||
}
|
||||
|
||||
resource "openstack_compute_instance_v2" "myinstance" {
|
||||
name = "myinstance"
|
||||
security_groups = ["default"]
|
||||
scheduler_hints {
|
||||
group = "${openstack_compute_servergroup_v2.mysg.id}"
|
||||
}
|
||||
}`
|
||||
resource "openstack_compute_instance_v2" "instance_1" {
|
||||
name = "instance_1"
|
||||
security_groups = ["default"]
|
||||
scheduler_hints {
|
||||
group = "${openstack_compute_servergroup_v2.sg_1.id}"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestAccComputeV2VolumeAttach_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccComputeV2VolumeAttach_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckComputeV2VolumeAttachExists(t, "openstack_compute_volume_attach_v2.va_1", &va),
|
||||
testAccCheckComputeV2VolumeAttachExists("openstack_compute_volume_attach_v2.va_1", &va),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -54,7 +54,7 @@ func testAccCheckComputeV2VolumeAttachDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckComputeV2VolumeAttachExists(t *testing.T, n string, va *volumeattach.VolumeAttachment) resource.TestCheckFunc {
|
||||
func testAccCheckComputeV2VolumeAttachExists(n string, va *volumeattach.VolumeAttachment) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -68,7 +68,7 @@ func testAccCheckComputeV2VolumeAttachExists(t *testing.T, n string, va *volumea
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
computeClient, err := config.computeV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckComputeV2VolumeAttachExists) Error creating OpenStack compute client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
||||
instanceId, volumeId, err := parseComputeVolumeAttachmentId(rs.Primary.ID)
|
||||
|
@ -91,19 +91,19 @@ func testAccCheckComputeV2VolumeAttachExists(t *testing.T, n string, va *volumea
|
|||
}
|
||||
}
|
||||
|
||||
var testAccComputeV2VolumeAttach_basic = `
|
||||
resource "openstack_blockstorage_volume_v2" "volume_1" {
|
||||
name = "volume_1"
|
||||
size = 1
|
||||
}
|
||||
const testAccComputeV2VolumeAttach_basic = `
|
||||
resource "openstack_blockstorage_volume_v2" "volume_1" {
|
||||
name = "volume_1"
|
||||
size = 1
|
||||
}
|
||||
|
||||
resource "openstack_compute_instance_v2" "instance_1" {
|
||||
name = "instance_1"
|
||||
security_groups = ["default"]
|
||||
}
|
||||
resource "openstack_compute_instance_v2" "instance_1" {
|
||||
name = "instance_1"
|
||||
security_groups = ["default"]
|
||||
}
|
||||
|
||||
resource "openstack_compute_volume_attach_v2" "va_1" {
|
||||
instance_id = "${openstack_compute_instance_v2.instance_1.id}"
|
||||
volume_id = "${openstack_blockstorage_volume_v2.volume_1.id}"
|
||||
}
|
||||
resource "openstack_compute_volume_attach_v2" "va_1" {
|
||||
instance_id = "${openstack_compute_instance_v2.instance_1.id}"
|
||||
volume_id = "${openstack_blockstorage_volume_v2.volume_1.id}"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -60,9 +60,9 @@ func TestAccLBV1Pool_fullstack(t *testing.T) {
|
|||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.network_1", &network),
|
||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.secgroup_1", &secgroup),
|
||||
testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.instance_1", &instance1),
|
||||
testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.instance_2", &instance2),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.secgroup_1", &secgroup),
|
||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_1", &instance1),
|
||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_2", &instance2),
|
||||
testAccCheckLBV1PoolExists(t, "openstack_lb_pool_v1.pool_1", &pool),
|
||||
testAccCheckLBV1MonitorExists(t, "openstack_lb_monitor_v1.monitor_1", &monitor),
|
||||
testAccCheckLBV1VIPExists(t, "openstack_lb_vip_v1.vip_1", &vip),
|
||||
|
@ -73,9 +73,9 @@ func TestAccLBV1Pool_fullstack(t *testing.T) {
|
|||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.network_1", &network),
|
||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.subnet_1", &subnet),
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.secgroup_1", &secgroup),
|
||||
testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.instance_1", &instance1),
|
||||
testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.instance_2", &instance2),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.secgroup_1", &secgroup),
|
||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_1", &instance1),
|
||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.instance_2", &instance2),
|
||||
testAccCheckLBV1PoolExists(t, "openstack_lb_pool_v1.pool_1", &pool),
|
||||
testAccCheckLBV1MonitorExists(t, "openstack_lb_monitor_v1.monitor_1", &monitor),
|
||||
testAccCheckLBV1VIPExists(t, "openstack_lb_vip_v1.vip_1", &vip),
|
||||
|
|
|
@ -57,7 +57,7 @@ func TestAccNetworkingV2FloatingIP_attach(t *testing.T) {
|
|||
Config: testAccNetworkV2FloatingIP_attach,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckNetworkingV2FloatingIPExists(t, "openstack_networking_floatingip_v2.myip", &fip),
|
||||
testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.foo", &instance),
|
||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.foo", &instance),
|
||||
testAccCheckNetworkingV2InstanceFloatingIPAttach(&instance, &fip),
|
||||
),
|
||||
},
|
||||
|
|
|
@ -145,9 +145,9 @@ func TestAccNetworkingV2Network_fullstack(t *testing.T) {
|
|||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckNetworkingV2NetworkExists(t, "openstack_networking_network_v2.foo", &network),
|
||||
testAccCheckNetworkingV2SubnetExists(t, "openstack_networking_subnet_v2.foo", &subnet),
|
||||
testAccCheckComputeV2SecGroupExists(t, "openstack_compute_secgroup_v2.foo", &secgroup),
|
||||
testAccCheckComputeV2SecGroupExists("openstack_compute_secgroup_v2.foo", &secgroup),
|
||||
testAccCheckNetworkingV2PortExists(t, "openstack_networking_port_v2.foo", &port),
|
||||
testAccCheckComputeV2InstanceExists(t, "openstack_compute_instance_v2.foo", &instance),
|
||||
testAccCheckComputeV2InstanceExists("openstack_compute_instance_v2.foo", &instance),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue