4545 "network_load_balancer_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_network_load_balancer_network_load_balancer.test_network_load_balancer.id}` },
4646 "port" : acctest.Representation {RepType : acctest .Required , Create : `10` , Update : `11` },
4747 "is_ppv2enabled" : acctest.Representation {RepType : acctest .Optional , Create : `false` , Update : `true` },
48- "protocol" : acctest.Representation {RepType : acctest .Required , Create : `UDP` , Update : `TCP` },
48+ "tcp_idle_timeout" : acctest.Representation {RepType : acctest .Optional , Create : `180` , Update : `300` },
49+ "udp_idle_timeout" : acctest.Representation {RepType : acctest .Optional , Create : `180` , Update : `300` },
50+ "protocol" : acctest.Representation {RepType : acctest .Required , Create : `TCP_AND_UDP` , Update : `TCP_AND_UDP` },
51+ "ip_version" : acctest.Representation {RepType : acctest .Optional , Create : `IPV4` },
52+ }
53+
54+ NetworkLoadBalancerTCPListenerRepresentation = map [string ]interface {}{
55+ "default_backend_set_name" : acctest.Representation {RepType : acctest .Required , Create : `${oci_network_load_balancer_backend_set.test_backend_set.name}` },
56+ "name" : acctest.Representation {RepType : acctest .Required , Create : `example_listener` },
57+ "network_load_balancer_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_network_load_balancer_network_load_balancer.test_network_load_balancer.id}` },
58+ "port" : acctest.Representation {RepType : acctest .Required , Create : `10` , Update : `11` },
59+ "is_ppv2enabled" : acctest.Representation {RepType : acctest .Optional , Create : `false` },
60+ "tcp_idle_timeout" : acctest.Representation {RepType : acctest .Optional , Create : `180` , Update : `180` },
61+ "udp_idle_timeout" : acctest.Representation {RepType : acctest .Optional , Update : `240` },
62+ "protocol" : acctest.Representation {RepType : acctest .Required , Create : `TCP` , Update : `TCP_AND_UDP` },
63+ "ip_version" : acctest.Representation {RepType : acctest .Optional , Create : `IPV4` },
64+ }
65+
66+ NetworkLoadBalancerUDPListenerRepresentation = map [string ]interface {}{
67+ "default_backend_set_name" : acctest.Representation {RepType : acctest .Required , Create : `${oci_network_load_balancer_backend_set.test_backend_set.name}` },
68+ "name" : acctest.Representation {RepType : acctest .Required , Create : `example_listener` },
69+ "network_load_balancer_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_network_load_balancer_network_load_balancer.test_network_load_balancer.id}` },
70+ "port" : acctest.Representation {RepType : acctest .Required , Create : `10` , Update : `11` },
71+ "is_ppv2enabled" : acctest.Representation {RepType : acctest .Optional , Create : `false` },
72+ "udp_idle_timeout" : acctest.Representation {RepType : acctest .Optional , Create : `180` , Update : `300` },
73+ "protocol" : acctest.Representation {RepType : acctest .Required , Create : `UDP` },
4974 "ip_version" : acctest.Representation {RepType : acctest .Optional , Create : `IPV4` },
5075 }
5176
@@ -84,14 +109,120 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
84109 resource .TestCheckResourceAttr (resourceName , "name" , "example_listener" ),
85110 resource .TestCheckResourceAttrSet (resourceName , "network_load_balancer_id" ),
86111 resource .TestCheckResourceAttr (resourceName , "port" , "10" ),
112+ resource .TestCheckResourceAttr (resourceName , "protocol" , "TCP_AND_UDP" ),
113+ func (s * terraform.State ) (err error ) {
114+ resId , err = acctest .FromInstanceState (s , resourceName , "id" )
115+ return err
116+ },
117+ ),
118+ },
119+ // delete before next Create
120+ {
121+ Config : config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies ,
122+ },
123+
124+ // verify TCP Listener create with optionals
125+ {
126+ Config : config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies +
127+ acctest .GenerateResourceFromRepresentationMap ("oci_network_load_balancer_listener" , "test_listener" , acctest .Optional , acctest .Create , NetworkLoadBalancerTCPListenerRepresentation ),
128+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
129+ resource .TestCheckResourceAttrSet (resourceName , "default_backend_set_name" ),
130+ resource .TestCheckResourceAttr (resourceName , "ip_version" , "IPV4" ),
131+ resource .TestCheckResourceAttr (resourceName , "is_ppv2enabled" , "false" ),
132+ resource .TestCheckResourceAttr (resourceName , "name" , "example_listener" ),
133+ resource .TestCheckResourceAttrSet (resourceName , "network_load_balancer_id" ),
134+ resource .TestCheckResourceAttr (resourceName , "port" , "10" ),
135+ resource .TestCheckResourceAttr (resourceName , "protocol" , "TCP" ),
136+ resource .TestCheckResourceAttr (resourceName , "tcp_idle_timeout" , "180" ),
137+ func (s * terraform.State ) (err error ) {
138+ resId , err = acctest .FromInstanceState (s , resourceName , "id" )
139+ if isEnableExportCompartment , _ := strconv .ParseBool (utils .GetEnvSettingWithDefault ("enable_export_compartment" , "true" )); isEnableExportCompartment {
140+ if errExport := resourcediscovery .TestExportCompartmentWithResourceName (& resId , & compartmentId , resourceName ); errExport != nil {
141+ return errExport
142+ }
143+ }
144+ return err
145+ },
146+ ),
147+ },
148+
149+ // verify updates to updatable parameters
150+ {
151+ Config : config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies +
152+ acctest .GenerateResourceFromRepresentationMap ("oci_network_load_balancer_listener" , "test_listener" , acctest .Optional , acctest .Update , NetworkLoadBalancerTCPListenerRepresentation ),
153+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
154+ resource .TestCheckResourceAttrSet (resourceName , "default_backend_set_name" ),
155+ resource .TestCheckResourceAttr (resourceName , "is_ppv2enabled" , "false" ),
156+ resource .TestCheckResourceAttr (resourceName , "ip_version" , "IPV4" ),
157+ resource .TestCheckResourceAttr (resourceName , "name" , "example_listener" ),
158+ resource .TestCheckResourceAttrSet (resourceName , "network_load_balancer_id" ),
159+ resource .TestCheckResourceAttr (resourceName , "port" , "11" ),
160+ resource .TestCheckResourceAttr (resourceName , "protocol" , "TCP_AND_UDP" ),
161+ resource .TestCheckResourceAttr (resourceName , "tcp_idle_timeout" , "180" ),
162+ resource .TestCheckResourceAttr (resourceName , "udp_idle_timeout" , "240" ),
163+
164+ func (s * terraform.State ) (err error ) {
165+ resId2 , err = acctest .FromInstanceState (s , resourceName , "id" )
166+ if resId != resId2 {
167+ return fmt .Errorf ("Resource recreated when it was supposed to be updated." )
168+ }
169+ return err
170+ },
171+ ),
172+ },
173+ // delete before next Create
174+ {
175+ Config : config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies ,
176+ },
177+
178+ // verify UDP Listener create with optionals
179+ {
180+ Config : config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies +
181+ acctest .GenerateResourceFromRepresentationMap ("oci_network_load_balancer_listener" , "test_listener" , acctest .Optional , acctest .Create , NetworkLoadBalancerUDPListenerRepresentation ),
182+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
183+ resource .TestCheckResourceAttrSet (resourceName , "default_backend_set_name" ),
184+ resource .TestCheckResourceAttr (resourceName , "ip_version" , "IPV4" ),
185+ resource .TestCheckResourceAttr (resourceName , "is_ppv2enabled" , "false" ),
186+ resource .TestCheckResourceAttr (resourceName , "name" , "example_listener" ),
187+ resource .TestCheckResourceAttrSet (resourceName , "network_load_balancer_id" ),
188+ resource .TestCheckResourceAttr (resourceName , "port" , "10" ),
87189 resource .TestCheckResourceAttr (resourceName , "protocol" , "UDP" ),
190+ resource .TestCheckResourceAttr (resourceName , "udp_idle_timeout" , "180" ),
88191 func (s * terraform.State ) (err error ) {
89192 resId , err = acctest .FromInstanceState (s , resourceName , "id" )
193+ if isEnableExportCompartment , _ := strconv .ParseBool (utils .GetEnvSettingWithDefault ("enable_export_compartment" , "true" )); isEnableExportCompartment {
194+ if errExport := resourcediscovery .TestExportCompartmentWithResourceName (& resId , & compartmentId , resourceName ); errExport != nil {
195+ return errExport
196+ }
197+ }
90198 return err
91199 },
92200 ),
93201 },
94202
203+ // verify updates to updatable parameters
204+ {
205+ Config : config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies +
206+ acctest .GenerateResourceFromRepresentationMap ("oci_network_load_balancer_listener" , "test_listener" , acctest .Optional , acctest .Update , NetworkLoadBalancerUDPListenerRepresentation ),
207+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
208+ resource .TestCheckResourceAttrSet (resourceName , "default_backend_set_name" ),
209+ resource .TestCheckResourceAttr (resourceName , "is_ppv2enabled" , "false" ),
210+ resource .TestCheckResourceAttr (resourceName , "ip_version" , "IPV4" ),
211+ resource .TestCheckResourceAttr (resourceName , "name" , "example_listener" ),
212+ resource .TestCheckResourceAttrSet (resourceName , "network_load_balancer_id" ),
213+ resource .TestCheckResourceAttr (resourceName , "port" , "11" ),
214+ resource .TestCheckResourceAttr (resourceName , "protocol" , "UDP" ),
215+ resource .TestCheckResourceAttr (resourceName , "udp_idle_timeout" , "300" ),
216+
217+ func (s * terraform.State ) (err error ) {
218+ resId2 , err = acctest .FromInstanceState (s , resourceName , "id" )
219+ if resId != resId2 {
220+ return fmt .Errorf ("Resource recreated when it was supposed to be updated." )
221+ }
222+ return err
223+ },
224+ ),
225+ },
95226 // delete before next Create
96227 {
97228 Config : config + compartmentIdVariableStr + NetworkLoadBalancerListenerResourceDependencies ,
@@ -108,7 +239,9 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
108239 resource .TestCheckResourceAttr (resourceName , "name" , "example_listener" ),
109240 resource .TestCheckResourceAttrSet (resourceName , "network_load_balancer_id" ),
110241 resource .TestCheckResourceAttr (resourceName , "port" , "10" ),
111- resource .TestCheckResourceAttr (resourceName , "protocol" , "UDP" ),
242+ resource .TestCheckResourceAttr (resourceName , "protocol" , "TCP_AND_UDP" ),
243+ resource .TestCheckResourceAttr (resourceName , "tcp_idle_timeout" , "180" ),
244+ resource .TestCheckResourceAttr (resourceName , "udp_idle_timeout" , "180" ),
112245 func (s * terraform.State ) (err error ) {
113246 resId , err = acctest .FromInstanceState (s , resourceName , "id" )
114247 if isEnableExportCompartment , _ := strconv .ParseBool (utils .GetEnvSettingWithDefault ("enable_export_compartment" , "true" )); isEnableExportCompartment {
@@ -132,7 +265,9 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
132265 resource .TestCheckResourceAttr (resourceName , "name" , "example_listener" ),
133266 resource .TestCheckResourceAttrSet (resourceName , "network_load_balancer_id" ),
134267 resource .TestCheckResourceAttr (resourceName , "port" , "11" ),
135- resource .TestCheckResourceAttr (resourceName , "protocol" , "TCP" ),
268+ resource .TestCheckResourceAttr (resourceName , "protocol" , "TCP_AND_UDP" ),
269+ resource .TestCheckResourceAttr (resourceName , "tcp_idle_timeout" , "300" ),
270+ resource .TestCheckResourceAttr (resourceName , "udp_idle_timeout" , "300" ),
136271
137272 func (s * terraform.State ) (err error ) {
138273 resId2 , err = acctest .FromInstanceState (s , resourceName , "id" )
@@ -167,7 +302,9 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
167302 resource .TestCheckResourceAttr (singularDatasourceName , "ip_version" , "IPV4" ),
168303 resource .TestCheckResourceAttr (singularDatasourceName , "name" , "example_listener" ),
169304 resource .TestCheckResourceAttr (singularDatasourceName , "port" , "11" ),
170- resource .TestCheckResourceAttr (singularDatasourceName , "protocol" , "TCP" ),
305+ resource .TestCheckResourceAttr (singularDatasourceName , "protocol" , "TCP_AND_UDP" ),
306+ resource .TestCheckResourceAttr (singularDatasourceName , "tcp_idle_timeout" , "300" ),
307+ resource .TestCheckResourceAttr (singularDatasourceName , "udp_idle_timeout" , "300" ),
171308 ),
172309 },
173310 // verify resource import
0 commit comments