provider/openstack: Updating LBaaSV1 acceptance tests (#10979)
This commit is contained in:
parent
af5baf7b13
commit
414b566d2e
|
@ -20,7 +20,7 @@ func TestAccLBV1Member_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccLBV1Member_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckLBV1MemberExists(t, "openstack_lb_member_v1.member_1", &member),
|
||||
testAccCheckLBV1MemberExists("openstack_lb_member_v1.member_1", &member),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
|
@ -37,7 +37,7 @@ func testAccCheckLBV1MemberDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV1MemberDestroy) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -54,7 +54,7 @@ func testAccCheckLBV1MemberDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckLBV1MemberExists(t *testing.T, n string, member *members.Member) resource.TestCheckFunc {
|
||||
func testAccCheckLBV1MemberExists(n string, member *members.Member) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -68,7 +68,7 @@ func testAccCheckLBV1MemberExists(t *testing.T, n string, member *members.Member
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV1MemberExists) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
found, err := members.Get(networkingClient, rs.Primary.ID).Extract()
|
||||
|
@ -86,54 +86,56 @@ func testAccCheckLBV1MemberExists(t *testing.T, n string, member *members.Member
|
|||
}
|
||||
}
|
||||
|
||||
var testAccLBV1Member_basic = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
const testAccLBV1Member_basic = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
}
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
name = "tf_test_lb_pool"
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "HTTP"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
}
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_member_v1" "member_1" {
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
resource "openstack_lb_member_v1" "member_1" {
|
||||
address = "192.168.199.10"
|
||||
port = 80
|
||||
admin_state_up = true
|
||||
}`)
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
}
|
||||
`
|
||||
|
||||
var testAccLBV1Member_update = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
const testAccLBV1Member_update = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
}
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
name = "tf_test_lb_pool"
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "HTTP"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
}
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_member_v1" "member_1" {
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
resource "openstack_lb_member_v1" "member_1" {
|
||||
address = "192.168.199.10"
|
||||
port = 80
|
||||
admin_state_up = false
|
||||
}`)
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestAccLBV1Monitor_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccLBV1Monitor_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckLBV1MonitorExists(t, "openstack_lb_monitor_v1.monitor_1", &monitor),
|
||||
testAccCheckLBV1MonitorExists("openstack_lb_monitor_v1.monitor_1", &monitor),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
|
@ -38,7 +38,7 @@ func testAccCheckLBV1MonitorDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV1MonitorDestroy) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -55,7 +55,7 @@ func testAccCheckLBV1MonitorDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckLBV1MonitorExists(t *testing.T, n string, monitor *monitors.Monitor) resource.TestCheckFunc {
|
||||
func testAccCheckLBV1MonitorExists(n string, monitor *monitors.Monitor) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -69,7 +69,7 @@ func testAccCheckLBV1MonitorExists(t *testing.T, n string, monitor *monitors.Mon
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV1MonitorExists) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
found, err := monitors.Get(networkingClient, rs.Primary.ID).Extract()
|
||||
|
@ -87,24 +87,24 @@ func testAccCheckLBV1MonitorExists(t *testing.T, n string, monitor *monitors.Mon
|
|||
}
|
||||
}
|
||||
|
||||
var testAccLBV1Monitor_basic = fmt.Sprintf(`
|
||||
resource "openstack_lb_monitor_v1" "monitor_1" {
|
||||
const testAccLBV1Monitor_basic = `
|
||||
resource "openstack_lb_monitor_v1" "monitor_1" {
|
||||
region = "%s"
|
||||
type = "PING"
|
||||
delay = 30
|
||||
timeout = 5
|
||||
max_retries = 3
|
||||
admin_state_up = "true"
|
||||
}`,
|
||||
OS_REGION_NAME)
|
||||
}
|
||||
`
|
||||
|
||||
var testAccLBV1Monitor_update = fmt.Sprintf(`
|
||||
resource "openstack_lb_monitor_v1" "monitor_1" {
|
||||
const testAccLBV1Monitor_update = `
|
||||
resource "openstack_lb_monitor_v1" "monitor_1" {
|
||||
region = "%s"
|
||||
type = "PING"
|
||||
delay = 20
|
||||
timeout = 5
|
||||
max_retries = 3
|
||||
admin_state_up = "true"
|
||||
}`,
|
||||
OS_REGION_NAME)
|
||||
}
|
||||
`
|
||||
|
|
|
@ -27,14 +27,14 @@ func TestAccLBV1Pool_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccLBV1Pool_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckLBV1PoolExists(t, "openstack_lb_pool_v1.pool_1", &pool),
|
||||
testAccCheckLBV1PoolExists("openstack_lb_pool_v1.pool_1", &pool),
|
||||
resource.TestCheckResourceAttr("openstack_lb_pool_v1.pool_1", "lb_provider", "haproxy"),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccLBV1Pool_update,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr("openstack_lb_pool_v1.pool_1", "name", "tf_test_lb_pool_updated"),
|
||||
resource.TestCheckResourceAttr("openstack_lb_pool_v1.pool_1", "name", "pool_1"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -63,9 +63,9 @@ func TestAccLBV1Pool_fullstack(t *testing.T) {
|
|||
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),
|
||||
testAccCheckLBV1PoolExists("openstack_lb_pool_v1.pool_1", &pool),
|
||||
testAccCheckLBV1MonitorExists("openstack_lb_monitor_v1.monitor_1", &monitor),
|
||||
testAccCheckLBV1VIPExists("openstack_lb_vip_v1.vip_1", &vip),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
|
@ -76,9 +76,9 @@ func TestAccLBV1Pool_fullstack(t *testing.T) {
|
|||
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),
|
||||
testAccCheckLBV1PoolExists("openstack_lb_pool_v1.pool_1", &pool),
|
||||
testAccCheckLBV1MonitorExists("openstack_lb_monitor_v1.monitor_1", &monitor),
|
||||
testAccCheckLBV1VIPExists("openstack_lb_vip_v1.vip_1", &vip),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -89,7 +89,7 @@ func testAccCheckLBV1PoolDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV1PoolDestroy) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -106,7 +106,7 @@ func testAccCheckLBV1PoolDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckLBV1PoolExists(t *testing.T, n string, pool *pools.Pool) resource.TestCheckFunc {
|
||||
func testAccCheckLBV1PoolExists(n string, pool *pools.Pool) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -120,7 +120,7 @@ func testAccCheckLBV1PoolExists(t *testing.T, n string, pool *pools.Pool) resour
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV1PoolExists) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
found, err := pools.Get(networkingClient, rs.Primary.ID).Extract()
|
||||
|
@ -138,66 +138,60 @@ func testAccCheckLBV1PoolExists(t *testing.T, n string, pool *pools.Pool) resour
|
|||
}
|
||||
}
|
||||
|
||||
var testAccLBV1Pool_basic = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
region = "%s"
|
||||
const testAccLBV1Pool_basic = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
region = "%s"
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
}
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
region = "%s"
|
||||
name = "tf_test_lb_pool"
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "HTTP"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
lb_provider = "haproxy"
|
||||
}`,
|
||||
OS_REGION_NAME, OS_REGION_NAME, OS_REGION_NAME)
|
||||
|
||||
var testAccLBV1Pool_update = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
region = "%s"
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
region = "%s"
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
region = "%s"
|
||||
name = "tf_test_lb_pool_updated"
|
||||
protocol = "HTTP"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
}`,
|
||||
OS_REGION_NAME, OS_REGION_NAME, OS_REGION_NAME)
|
||||
}
|
||||
`
|
||||
|
||||
var testAccLBV1Pool_fullstack_1 = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
const testAccLBV1Pool_update = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
}
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_compute_secgroup_v2" "secgroup_1" {
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "HTTP"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
`
|
||||
|
||||
const testAccLBV1Pool_fullstack_1 = `
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_compute_secgroup_v2" "secgroup_1" {
|
||||
name = "secgroup_1"
|
||||
description = "Rules for secgroup_1"
|
||||
|
||||
|
@ -214,76 +208,79 @@ var testAccLBV1Pool_fullstack_1 = fmt.Sprintf(`
|
|||
ip_protocol = "tcp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_compute_instance_v2" "instance_1" {
|
||||
resource "openstack_compute_instance_v2" "instance_1" {
|
||||
name = "instance_1"
|
||||
security_groups = ["default", "${openstack_compute_secgroup_v2.secgroup_1.name}"]
|
||||
|
||||
network {
|
||||
uuid = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_compute_instance_v2" "instance_2" {
|
||||
resource "openstack_compute_instance_v2" "instance_2" {
|
||||
name = "instance_2"
|
||||
security_groups = ["default", "${openstack_compute_secgroup_v2.secgroup_1.name}"]
|
||||
|
||||
network {
|
||||
uuid = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_lb_monitor_v1" "monitor_1" {
|
||||
resource "openstack_lb_monitor_v1" "monitor_1" {
|
||||
type = "TCP"
|
||||
delay = 30
|
||||
timeout = 5
|
||||
max_retries = 3
|
||||
admin_state_up = "true"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "TCP"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
monitor_ids = ["${openstack_lb_monitor_v1.monitor_1.id}"]
|
||||
}
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_member_v1" "member_1" {
|
||||
resource "openstack_lb_member_v1" "member_1" {
|
||||
port = 80
|
||||
admin_state_up = true
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
address = "${openstack_compute_instance_v2.instance_1.access_ip_v4}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_member_v1" "member_2" {
|
||||
port = 80
|
||||
admin_state_up = true
|
||||
}
|
||||
|
||||
resource "openstack_lb_member_v1" "member_2" {
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
address = "${openstack_compute_instance_v2.instance_2.access_ip_v4}"
|
||||
port = 80
|
||||
admin_state_up = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_lb_vip_v1" "vip_1" {
|
||||
resource "openstack_lb_vip_v1" "vip_1" {
|
||||
name = "vip_1"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
protocol = "TCP"
|
||||
port = 80
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
admin_state_up = true
|
||||
}`)
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
}
|
||||
`
|
||||
|
||||
var testAccLBV1Pool_fullstack_2 = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
const testAccLBV1Pool_fullstack_2 = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
}
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_compute_secgroup_v2" "secgroup_1" {
|
||||
resource "openstack_compute_secgroup_v2" "secgroup_1" {
|
||||
name = "secgroup_1"
|
||||
description = "Rules for secgroup_1"
|
||||
|
||||
|
@ -300,60 +297,63 @@ var testAccLBV1Pool_fullstack_2 = fmt.Sprintf(`
|
|||
ip_protocol = "tcp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_compute_instance_v2" "instance_1" {
|
||||
resource "openstack_compute_instance_v2" "instance_1" {
|
||||
name = "instance_1"
|
||||
security_groups = ["default", "${openstack_compute_secgroup_v2.secgroup_1.name}"]
|
||||
|
||||
network {
|
||||
uuid = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_compute_instance_v2" "instance_2" {
|
||||
resource "openstack_compute_instance_v2" "instance_2" {
|
||||
name = "instance_2"
|
||||
security_groups = ["default", "${openstack_compute_secgroup_v2.secgroup_1.name}"]
|
||||
user_data = "#cloud-config\ndisable_root: false"
|
||||
|
||||
network {
|
||||
uuid = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_lb_monitor_v1" "monitor_1" {
|
||||
resource "openstack_lb_monitor_v1" "monitor_1" {
|
||||
type = "TCP"
|
||||
delay = 30
|
||||
timeout = 5
|
||||
max_retries = 3
|
||||
admin_state_up = "true"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "TCP"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
monitor_ids = ["${openstack_lb_monitor_v1.monitor_1.id}"]
|
||||
}
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_member_v1" "member_1" {
|
||||
resource "openstack_lb_member_v1" "member_1" {
|
||||
port = 80
|
||||
admin_state_up = true
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
address = "${openstack_compute_instance_v2.instance_1.access_ip_v4}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_member_v1" "member_2" {
|
||||
port = 80
|
||||
admin_state_up = true
|
||||
}
|
||||
|
||||
resource "openstack_lb_member_v1" "member_2" {
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
address = "${openstack_compute_instance_v2.instance_2.access_ip_v4}"
|
||||
port = 80
|
||||
admin_state_up = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_lb_vip_v1" "vip_1" {
|
||||
resource "openstack_lb_vip_v1" "vip_1" {
|
||||
name = "vip_1"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
protocol = "TCP"
|
||||
port = 80
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
admin_state_up = true
|
||||
}`)
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -21,13 +21,13 @@ func TestAccLBV1VIP_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccLBV1VIP_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckLBV1VIPExists(t, "openstack_lb_vip_v1.vip_1", &vip),
|
||||
testAccCheckLBV1VIPExists("openstack_lb_vip_v1.vip_1", &vip),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccLBV1VIP_update,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr("openstack_lb_vip_v1.vip_1", "name", "tf_test_lb_vip_updated"),
|
||||
resource.TestCheckResourceAttr("openstack_lb_vip_v1.vip_1", "name", "vip_1_updated"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -38,7 +38,7 @@ func testAccCheckLBV1VIPDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV1VIPDestroy) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -55,7 +55,7 @@ func testAccCheckLBV1VIPDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckLBV1VIPExists(t *testing.T, n string, vip *vips.VirtualIP) resource.TestCheckFunc {
|
||||
func testAccCheckLBV1VIPExists(n string, vip *vips.VirtualIP) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -69,7 +69,7 @@ func testAccCheckLBV1VIPExists(t *testing.T, n string, vip *vips.VirtualIP) reso
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV1VIPExists) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
found, err := vips.Get(networkingClient, rs.Primary.ID).Extract()
|
||||
|
@ -87,74 +87,68 @@ func testAccCheckLBV1VIPExists(t *testing.T, n string, vip *vips.VirtualIP) reso
|
|||
}
|
||||
}
|
||||
|
||||
var testAccLBV1VIP_basic = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
region = "%s"
|
||||
const testAccLBV1VIP_basic = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
region = "%s"
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
}
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
region = "%s"
|
||||
name = "tf_test_lb_pool"
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "HTTP"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
}
|
||||
|
||||
resource "openstack_lb_vip_v1" "vip_1" {
|
||||
region = "RegionOne"
|
||||
name = "tf_test_lb_vip"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_vip_v1" "vip_1" {
|
||||
name = "vip_1"
|
||||
protocol = "HTTP"
|
||||
port = 80
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
admin_state_up = true
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
|
||||
persistence {
|
||||
type = "SOURCE_IP"
|
||||
}
|
||||
}`,
|
||||
OS_REGION_NAME, OS_REGION_NAME, OS_REGION_NAME)
|
||||
}
|
||||
`
|
||||
|
||||
var testAccLBV1VIP_update = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
region = "%s"
|
||||
const testAccLBV1VIP_update = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
region = "%s"
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
}
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
region = "%s"
|
||||
name = "tf_test_lb_pool"
|
||||
resource "openstack_lb_pool_v1" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "HTTP"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
}
|
||||
|
||||
resource "openstack_lb_vip_v1" "vip_1" {
|
||||
region = "RegionOne"
|
||||
name = "tf_test_lb_vip_updated"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_vip_v1" "vip_1" {
|
||||
name = "vip_1_updated"
|
||||
protocol = "HTTP"
|
||||
port = 80
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
admin_state_up = true
|
||||
pool_id = "${openstack_lb_pool_v1.pool_1.id}"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
|
||||
persistence {
|
||||
type = "SOURCE_IP"
|
||||
}
|
||||
}`,
|
||||
OS_REGION_NAME, OS_REGION_NAME, OS_REGION_NAME)
|
||||
}
|
||||
`
|
||||
|
|
Loading…
Reference in New Issue