3737 "network_load_balancer_id" : Representation {RepType : Required , Create : `${oci_network_load_balancer_network_load_balancer.test_network_load_balancer.id}` },
3838 "port" : Representation {RepType : Required , Create : `10` , Update : `11` },
3939 "protocol" : Representation {RepType : Required , Create : `UDP` , Update : `TCP` },
40+ "ip_version" : Representation {RepType : Optional , Create : `IPV4` },
4041 }
4142
4243 NlbListenerResourceDependencies = GenerateResourceFromRepresentationMap ("oci_core_subnet" , "test_subnet" , Required , Create , subnetRepresentation ) +
@@ -60,6 +61,9 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
6061 singularDatasourceName := "data.oci_network_load_balancer_listener.test_listener"
6162
6263 var resId , resId2 string
64+ // Save TF content to Create resource with optional properties. This has to be exactly the same as the config part in the "create with optionals" step in the test.
65+ SaveConfigContent (config + compartmentIdVariableStr + ListenerResourceDependencies +
66+ GenerateResourceFromRepresentationMap ("oci_network_load_balancer_listener" , "test_listener" , Optional , Create , nlbListenerRepresentation ), "networkloadbalancer" , "listener" , t )
6367
6468 ResourceTest (t , testAccCheckNetworkLoadBalancerListenerDestroy , []resource.TestStep {
6569 // verify Create
@@ -73,6 +77,30 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
7377 resource .TestCheckResourceAttr (resourceName , "port" , "10" ),
7478 resource .TestCheckResourceAttr (resourceName , "protocol" , "UDP" ),
7579
80+ func (s * terraform.State ) (err error ) {
81+ resId , err = FromInstanceState (s , resourceName , "id" )
82+ return err
83+ },
84+ ),
85+ },
86+
87+ // delete before next Create
88+ {
89+ Config : config + compartmentIdVariableStr + NlbListenerResourceDependencies ,
90+ },
91+
92+ // verify Create with optionals
93+ {
94+ Config : config + compartmentIdVariableStr + NlbListenerResourceDependencies +
95+ GenerateResourceFromRepresentationMap ("oci_network_load_balancer_listener" , "test_listener" , Optional , Create , nlbListenerRepresentation ),
96+ Check : ComposeAggregateTestCheckFuncWrapper (
97+ resource .TestCheckResourceAttrSet (resourceName , "default_backend_set_name" ),
98+ resource .TestCheckResourceAttr (resourceName , "ip_version" , "IPV4" ),
99+ resource .TestCheckResourceAttr (resourceName , "name" , "example_listener" ),
100+ resource .TestCheckResourceAttrSet (resourceName , "network_load_balancer_id" ),
101+ resource .TestCheckResourceAttr (resourceName , "port" , "10" ),
102+ resource .TestCheckResourceAttr (resourceName , "protocol" , "UDP" ),
103+
76104 func (s * terraform.State ) (err error ) {
77105 resId , err = FromInstanceState (s , resourceName , "id" )
78106 if isEnableExportCompartment , _ := strconv .ParseBool (getEnvSettingWithDefault ("enable_export_compartment" , "true" )); isEnableExportCompartment {
@@ -91,6 +119,7 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
91119 GenerateResourceFromRepresentationMap ("oci_network_load_balancer_listener" , "test_listener" , Optional , Update , nlbListenerRepresentation ),
92120 Check : ComposeAggregateTestCheckFuncWrapper (
93121 resource .TestCheckResourceAttrSet (resourceName , "default_backend_set_name" ),
122+ resource .TestCheckResourceAttr (resourceName , "ip_version" , "IPV4" ),
94123 resource .TestCheckResourceAttr (resourceName , "name" , "example_listener" ),
95124 resource .TestCheckResourceAttrSet (resourceName , "network_load_balancer_id" ),
96125 resource .TestCheckResourceAttr (resourceName , "port" , "11" ),
@@ -126,6 +155,7 @@ func TestNetworkLoadBalancerListenerResource_basic(t *testing.T) {
126155 resource .TestCheckResourceAttrSet (singularDatasourceName , "listener_name" ),
127156 resource .TestCheckResourceAttrSet (singularDatasourceName , "network_load_balancer_id" ),
128157
158+ resource .TestCheckResourceAttr (singularDatasourceName , "ip_version" , "IPV4" ),
129159 resource .TestCheckResourceAttr (singularDatasourceName , "name" , "example_listener" ),
130160 resource .TestCheckResourceAttr (singularDatasourceName , "port" , "11" ),
131161 resource .TestCheckResourceAttr (singularDatasourceName , "protocol" , "TCP" ),
0 commit comments