|
74 | 74 | "ip_version": acctest.Representation{RepType: acctest.Optional, Create: `IPV4`}, |
75 | 75 | } |
76 | 76 |
|
| 77 | + NetworkLoadBalancerL3IPListenerRepresentation = map[string]interface{}{ |
| 78 | + "default_backend_set_name": acctest.Representation{RepType: acctest.Required, Create: `${oci_network_load_balancer_backend_set.test_backend_set.name}`}, |
| 79 | + "name": acctest.Representation{RepType: acctest.Required, Create: `example_listener`}, |
| 80 | + "network_load_balancer_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_network_load_balancer_network_load_balancer.test_network_load_balancer.id}`}, |
| 81 | + "port": acctest.Representation{RepType: acctest.Required, Create: `0`, Update: `0`}, |
| 82 | + "tcp_idle_timeout": acctest.Representation{RepType: acctest.Optional, Create: `180`, Update: `240`}, |
| 83 | + "udp_idle_timeout": acctest.Representation{RepType: acctest.Optional, Create: `180`, Update: `300`}, |
| 84 | + "l3ip_idle_timeout": acctest.Representation{RepType: acctest.Optional, Create: `200`, Update: `400`}, |
| 85 | + "protocol": acctest.Representation{RepType: acctest.Required, Create: `L3IP`}, |
| 86 | + "ip_version": acctest.Representation{RepType: acctest.Optional, Create: `IPV4`}, |
| 87 | + "is_ppv2enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`}, |
| 88 | + } |
| 89 | + |
77 | 90 | NetworkLoadBalancerListenerResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Required, acctest.Create, CoreSubnetRepresentation) + |
78 | 91 | acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Required, acctest.Create, CoreVcnRepresentation) + |
79 | | - acctest.GenerateResourceFromRepresentationMap("oci_network_load_balancer_backend_set", "test_backend_set", acctest.Required, acctest.Create, NetworkLoadBalancerBackendSetRepresentation) + |
| 92 | + acctest.GenerateResourceFromRepresentationMap("oci_network_load_balancer_backend_set", "test_backend_set", acctest.Required, acctest.Create, |
| 93 | + acctest.RepresentationCopyWithNewProperties(NetworkLoadBalancerBackendSetRepresentation, map[string]interface{}{ |
| 94 | + "is_preserve_source": acctest.Representation{RepType: acctest.Optional, Create: `true`}, |
| 95 | + "policy": acctest.Representation{RepType: acctest.Required, Create: `TWO_TUPLE`, Update: `THREE_TUPLE`}, |
| 96 | + })) + |
80 | 97 | acctest.GenerateResourceFromRepresentationMap("oci_network_load_balancer_network_load_balancer", "test_network_load_balancer", acctest.Required, acctest.Create, NetworkLoadBalancerNetworkLoadBalancerRepresentation) |
81 | 98 | ) |
82 | 99 |
|
@@ -199,7 +216,6 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) { |
199 | 216 | }, |
200 | 217 | ), |
201 | 218 | }, |
202 | | - |
203 | 219 | // verify updates to updatable parameters |
204 | 220 | { |
205 | 221 | Config: config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies + |
@@ -228,6 +244,62 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) { |
228 | 244 | Config: config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies, |
229 | 245 | }, |
230 | 246 |
|
| 247 | + // verify L3IP Listener create with optionals |
| 248 | + { |
| 249 | + Config: config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies + |
| 250 | + acctest.GenerateResourceFromRepresentationMap("oci_network_load_balancer_listener", "test_listener", acctest.Optional, acctest.Create, NetworkLoadBalancerL3IPListenerRepresentation), |
| 251 | + Check: acctest.ComposeAggregateTestCheckFuncWrapper( |
| 252 | + resource.TestCheckResourceAttrSet(resourceName, "default_backend_set_name"), |
| 253 | + resource.TestCheckResourceAttr(resourceName, "ip_version", "IPV4"), |
| 254 | + resource.TestCheckResourceAttr(resourceName, "is_ppv2enabled", "false"), |
| 255 | + resource.TestCheckResourceAttr(resourceName, "name", "example_listener"), |
| 256 | + resource.TestCheckResourceAttrSet(resourceName, "network_load_balancer_id"), |
| 257 | + resource.TestCheckResourceAttr(resourceName, "port", "0"), |
| 258 | + resource.TestCheckResourceAttr(resourceName, "protocol", "L3IP"), |
| 259 | + resource.TestCheckResourceAttr(resourceName, "tcp_idle_timeout", "180"), |
| 260 | + resource.TestCheckResourceAttr(resourceName, "udp_idle_timeout", "180"), |
| 261 | + resource.TestCheckResourceAttr(resourceName, "l3ip_idle_timeout", "200"), |
| 262 | + |
| 263 | + func(s *terraform.State) (err error) { |
| 264 | + resId, err = acctest.FromInstanceState(s, resourceName, "id") |
| 265 | + if isEnableExportCompartment, _ := strconv.ParseBool(utils.GetEnvSettingWithDefault("enable_export_compartment", "true")); isEnableExportCompartment { |
| 266 | + if errExport := resourcediscovery.TestExportCompartmentWithResourceName(&resId, &compartmentId, resourceName); errExport != nil { |
| 267 | + return errExport |
| 268 | + } |
| 269 | + } |
| 270 | + return err |
| 271 | + }, |
| 272 | + ), |
| 273 | + }, |
| 274 | + // verify L3IP updates to updatable parameters |
| 275 | + { |
| 276 | + Config: config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies + |
| 277 | + acctest.GenerateResourceFromRepresentationMap("oci_network_load_balancer_listener", "test_listener", acctest.Optional, acctest.Update, NetworkLoadBalancerL3IPListenerRepresentation), |
| 278 | + Check: acctest.ComposeAggregateTestCheckFuncWrapper( |
| 279 | + resource.TestCheckResourceAttrSet(resourceName, "default_backend_set_name"), |
| 280 | + resource.TestCheckResourceAttr(resourceName, "is_ppv2enabled", "true"), |
| 281 | + resource.TestCheckResourceAttr(resourceName, "ip_version", "IPV4"), |
| 282 | + resource.TestCheckResourceAttr(resourceName, "name", "example_listener"), |
| 283 | + resource.TestCheckResourceAttrSet(resourceName, "network_load_balancer_id"), |
| 284 | + resource.TestCheckResourceAttr(resourceName, "port", "0"), |
| 285 | + resource.TestCheckResourceAttr(resourceName, "protocol", "L3IP"), |
| 286 | + resource.TestCheckResourceAttr(resourceName, "tcp_idle_timeout", "240"), |
| 287 | + resource.TestCheckResourceAttr(resourceName, "udp_idle_timeout", "300"), |
| 288 | + resource.TestCheckResourceAttr(resourceName, "l3ip_idle_timeout", "400"), |
| 289 | + func(s *terraform.State) (err error) { |
| 290 | + resId2, err = acctest.FromInstanceState(s, resourceName, "id") |
| 291 | + if resId != resId2 { |
| 292 | + return fmt.Errorf("Resource recreated when it was supposed to be updated.") |
| 293 | + } |
| 294 | + return err |
| 295 | + }, |
| 296 | + ), |
| 297 | + }, |
| 298 | + // delete before next Create |
| 299 | + { |
| 300 | + Config: config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies, |
| 301 | + }, |
| 302 | + |
231 | 303 | // verify Create with optionals |
232 | 304 | { |
233 | 305 | Config: config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies + |
|
0 commit comments