From 9af4c1da67d7bd24807e3a6a176058b3c9f0b3db Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Sat, 25 Mar 2017 14:42:18 -0600 Subject: [PATCH] provider/openstack: Fix monitor_id typo in LBaaS v1 Pool (#13069) --- .../resource_openstack_lb_pool_v1.go | 2 +- .../resource_openstack_lb_pool_v1_test.go | 110 ++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) diff --git a/builtin/providers/openstack/resource_openstack_lb_pool_v1.go b/builtin/providers/openstack/resource_openstack_lb_pool_v1.go index eb0436ddf..7cf796c6f 100644 --- a/builtin/providers/openstack/resource_openstack_lb_pool_v1.go +++ b/builtin/providers/openstack/resource_openstack_lb_pool_v1.go @@ -240,7 +240,7 @@ func resourceLBPoolV1Update(d *schema.ResourceData, meta interface{}) error { } if d.HasChange("monitor_ids") { - oldMIDsRaw, newMIDsRaw := d.GetChange("security_groups") + oldMIDsRaw, newMIDsRaw := d.GetChange("monitor_ids") oldMIDsSet, newMIDsSet := oldMIDsRaw.(*schema.Set), newMIDsRaw.(*schema.Set) monitorsToAdd := newMIDsSet.Difference(oldMIDsSet) monitorsToRemove := oldMIDsSet.Difference(newMIDsSet) diff --git a/builtin/providers/openstack/resource_openstack_lb_pool_v1_test.go b/builtin/providers/openstack/resource_openstack_lb_pool_v1_test.go index c21a74b0d..72e905406 100644 --- a/builtin/providers/openstack/resource_openstack_lb_pool_v1_test.go +++ b/builtin/providers/openstack/resource_openstack_lb_pool_v1_test.go @@ -104,6 +104,42 @@ func TestAccLBV1Pool_timeout(t *testing.T) { }) } +func TestAccLBV1Pool_updateMonitor(t *testing.T) { + var monitor_1 monitors.Monitor + var monitor_2 monitors.Monitor + var network networks.Network + var pool pools.Pool + var subnet subnets.Subnet + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckLBV1PoolDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccLBV1Pool_updateMonitor_1, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network), + testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet), + testAccCheckLBV1PoolExists("openstack_lb_pool_v1.pool_1", &pool), + testAccCheckLBV1MonitorExists("openstack_lb_monitor_v1.monitor_1", &monitor_1), + testAccCheckLBV1MonitorExists("openstack_lb_monitor_v1.monitor_2", &monitor_2), + ), + }, + resource.TestStep{ + Config: testAccLBV1Pool_updateMonitor_2, + Check: resource.ComposeTestCheckFunc( + testAccCheckNetworkingV2NetworkExists("openstack_networking_network_v2.network_1", &network), + testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet), + testAccCheckLBV1PoolExists("openstack_lb_pool_v1.pool_1", &pool), + testAccCheckLBV1MonitorExists("openstack_lb_monitor_v1.monitor_1", &monitor_1), + testAccCheckLBV1MonitorExists("openstack_lb_monitor_v1.monitor_2", &monitor_2), + ), + }, + }, + }) +} + func testAccCheckLBV1PoolDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) networkingClient, err := config.networkingV2Client(OS_REGION_NAME) @@ -402,3 +438,77 @@ resource "openstack_lb_pool_v1" "pool_1" { } } ` + +const testAccLBV1Pool_updateMonitor_1 = ` +resource "openstack_networking_network_v2" "network_1" { + name = "network_1" + admin_state_up = "true" +} + +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_monitor_v1" "monitor_1" { + type = "TCP" + delay = 30 + timeout = 5 + max_retries = 3 + admin_state_up = "true" +} + +resource "openstack_lb_monitor_v1" "monitor_2" { + type = "TCP" + delay = 30 + timeout = 5 + max_retries = 3 + admin_state_up = "true" +} + +resource "openstack_lb_pool_v1" "pool_1" { + name = "pool_1" + protocol = "TCP" + lb_method = "ROUND_ROBIN" + monitor_ids = ["${openstack_lb_monitor_v1.monitor_1.id}"] + subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}" +} +` + +const testAccLBV1Pool_updateMonitor_2 = ` +resource "openstack_networking_network_v2" "network_1" { + name = "network_1" + admin_state_up = "true" +} + +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_monitor_v1" "monitor_1" { + type = "TCP" + delay = 30 + timeout = 5 + max_retries = 3 + admin_state_up = "true" +} + +resource "openstack_lb_monitor_v1" "monitor_2" { + type = "TCP" + delay = 30 + timeout = 5 + max_retries = 3 + admin_state_up = "true" +} + +resource "openstack_lb_pool_v1" "pool_1" { + name = "pool_1" + protocol = "TCP" + lb_method = "ROUND_ROBIN" + monitor_ids = ["${openstack_lb_monitor_v1.monitor_2.id}"] + subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}" +} +`