From 3b39d6dab7a41bff81a1eae2ad0e4ef56925b95f Mon Sep 17 00:00:00 2001 From: mikatong Date: Tue, 10 Sep 2024 16:47:56 +0800 Subject: [PATCH 1/3] udp listener support enable health_check --- .../resource_tc_gaap_layer4_listener_test.go | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener_test.go b/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener_test.go index b37273ede4..24c4314852 100644 --- a/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener_test.go +++ b/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener_test.go @@ -302,6 +302,59 @@ func TestAccTencentCloudGaapLayer4Listener_udpHealthCheck(t *testing.T) { }) } +func TestAccTencentCloudGaapLayer4Listener_udpHealthCheck(t *testing.T) { + t.Parallel() + id := new(string) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { tcacctest.AccPreCheckCommon(t, tcacctest.ACCOUNT_TYPE_PREPAY) }, + Providers: tcacctest.AccProviders, + CheckDestroy: testAccCheckGaapLayer4ListenerDestroy(id, "UDP"), + Steps: []resource.TestStep{ + { + Config: testAccGaapLayer4ListenerUdpHealthCheckUpdatePing, + Check: resource.ComposeTestCheckFunc( + testAccCheckGaapLayer4ListenerExists("tencentcloud_gaap_layer4_listener.foo", id, "UDP"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "protocol", "UDP"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "name", "layer4-udp-listener-hc"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "port", "9093"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "scheduler", "rr"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_type", "IP"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "health_check", "true"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_bind_set.#", "2"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "status"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "create_time"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "check_type", "PING"), + ), + }, + { + Config: testAccGaapLayer4ListenerUdpHealthCheckUpdatePort, + Check: resource.ComposeTestCheckFunc( + testAccCheckGaapLayer4ListenerExists("tencentcloud_gaap_layer4_listener.foo", id, "UDP"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "protocol", "UDP"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "name", "layer4-udp-listener-hc"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "port", "9093"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "scheduler", "rr"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_type", "IP"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "health_check", "true"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_bind_set.#", "2"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "status"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "create_time"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "check_type", "PORT"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "check_port", "6666"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "context_type", "TEXT"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "send_context", "111"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "recv_context", "222"), + ), + }, + }, + }) +} + func TestAccTencentCloudGaapLayer4Listener_udpDomain(t *testing.T) { t.Parallel() id := new(string) From cdca1118a23d3334088c2254659adfe27c846d05 Mon Sep 17 00:00:00 2001 From: mikatong Date: Tue, 10 Sep 2024 17:16:32 +0800 Subject: [PATCH 2/3] update --- .../resource_tc_gaap_layer4_listener_test.go | 53 ------------------- 1 file changed, 53 deletions(-) diff --git a/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener_test.go b/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener_test.go index 24c4314852..b37273ede4 100644 --- a/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener_test.go +++ b/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener_test.go @@ -302,59 +302,6 @@ func TestAccTencentCloudGaapLayer4Listener_udpHealthCheck(t *testing.T) { }) } -func TestAccTencentCloudGaapLayer4Listener_udpHealthCheck(t *testing.T) { - t.Parallel() - id := new(string) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { tcacctest.AccPreCheckCommon(t, tcacctest.ACCOUNT_TYPE_PREPAY) }, - Providers: tcacctest.AccProviders, - CheckDestroy: testAccCheckGaapLayer4ListenerDestroy(id, "UDP"), - Steps: []resource.TestStep{ - { - Config: testAccGaapLayer4ListenerUdpHealthCheckUpdatePing, - Check: resource.ComposeTestCheckFunc( - testAccCheckGaapLayer4ListenerExists("tencentcloud_gaap_layer4_listener.foo", id, "UDP"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "protocol", "UDP"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "name", "layer4-udp-listener-hc"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "port", "9093"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "scheduler", "rr"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_type", "IP"), - resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "health_check", "true"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_bind_set.#", "2"), - resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "status"), - resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "create_time"), - resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "check_type", "PING"), - ), - }, - { - Config: testAccGaapLayer4ListenerUdpHealthCheckUpdatePort, - Check: resource.ComposeTestCheckFunc( - testAccCheckGaapLayer4ListenerExists("tencentcloud_gaap_layer4_listener.foo", id, "UDP"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "protocol", "UDP"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "name", "layer4-udp-listener-hc"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "port", "9093"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "scheduler", "rr"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_type", "IP"), - resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "health_check", "true"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_bind_set.#", "2"), - resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "status"), - resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "create_time"), - resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "check_type", "PORT"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "check_port", "6666"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "context_type", "TEXT"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "send_context", "111"), - resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "recv_context", "222"), - ), - }, - }, - }) -} - func TestAccTencentCloudGaapLayer4Listener_udpDomain(t *testing.T) { t.Parallel() id := new(string) From 966bc0497b8ea18f8ea3486e53ffd31bd8928ee3 Mon Sep 17 00:00:00 2001 From: mikatong Date: Wed, 11 Sep 2024 16:06:57 +0800 Subject: [PATCH 3/3] connect_timeout support tcp and udp --- .../services/gaap/resource_tc_gaap_layer4_listener.go | 5 ++--- website/docs/r/gaap_layer4_listener.html.markdown | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener.go b/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener.go index 3fa33bda8c..a2da938bd1 100644 --- a/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener.go +++ b/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener.go @@ -81,7 +81,7 @@ func ResourceTencentCloudGaapLayer4Listener() *schema.Resource { Optional: true, Default: 2, ValidateFunc: tccommon.ValidateIntegerInRange(2, 60), - Description: "Timeout of the health check response, should less than interval, default value is 2s. NOTES: Only supports listeners of `TCP` protocol and require less than `interval`.", + Description: "Timeout of the health check response, should less than interval, default value is 2s. NOTES: Require less than `interval`.", }, "healthy_threshold": { Type: schema.TypeInt, @@ -215,8 +215,7 @@ func resourceTencentCloudGaapLayer4ListenerCreate(d *schema.ResourceData, m inte healthyThreshold := d.Get("healthy_threshold").(int) unhealthyThreshold := d.Get("unhealthy_threshold").(int) - // only check for TCP listener - if protocol == "TCP" && connectTimeout >= interval { + if connectTimeout >= interval { return errors.New("connect_timeout must be less than interval") } clientIPMethod := d.Get("client_ip_method").(int) diff --git a/website/docs/r/gaap_layer4_listener.html.markdown b/website/docs/r/gaap_layer4_listener.html.markdown index ebd04a2239..59267f2ad4 100644 --- a/website/docs/r/gaap_layer4_listener.html.markdown +++ b/website/docs/r/gaap_layer4_listener.html.markdown @@ -66,7 +66,7 @@ The following arguments are supported: * `check_port` - (Optional, Int) UDP origin station health check probe port. * `check_type` - (Optional, String) UDP origin server health type. PORT means check port, and PING means PING. * `client_ip_method` - (Optional, Int, ForceNew) The way the listener gets the client IP, 0 for TOA, 1 for Proxy Protocol, default value is 0. NOTES: Only supports listeners of `TCP` protocol. -* `connect_timeout` - (Optional, Int) Timeout of the health check response, should less than interval, default value is 2s. NOTES: Only supports listeners of `TCP` protocol and require less than `interval`. +* `connect_timeout` - (Optional, Int) Timeout of the health check response, should less than interval, default value is 2s. NOTES: Require less than `interval`. * `context_type` - (Optional, String) UDP source station health check port probe message type: TEXT represents text. Only used when the health check type is PORT. * `health_check` - (Optional, Bool) Indicates whether health check is enable, default value is `false`. * `healthy_threshold` - (Optional, Int) Health threshold, which indicates how many consecutive inspections are successful, the source station is determined to be healthy. Range from 1 to 10. Default value is 1.