@@ -6,13 +6,11 @@ package integrationtest
66import (
77 "context"
88 "fmt"
9- "strconv"
109 "testing"
1110 "time"
1211
1312 "github.com/oracle/terraform-provider-oci/internal/acctest"
1413 tf_client "github.com/oracle/terraform-provider-oci/internal/client"
15- "github.com/oracle/terraform-provider-oci/internal/resourcediscovery"
1614 "github.com/oracle/terraform-provider-oci/internal/tfresource"
1715 "github.com/oracle/terraform-provider-oci/internal/utils"
1816
@@ -50,10 +48,18 @@ var (
5048 "display_name" : acctest.Representation {RepType : acctest .Required , Create : `displayName` , Update : `displayName2` },
5149 "defined_tags" : acctest.Representation {RepType : acctest .Optional , Create : `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}` , Update : `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}` },
5250 "description" : acctest.Representation {RepType : acctest .Optional , Create : `description` , Update : `description2` },
51+ "endpoint_id" : acctest.Representation {RepType : acctest .Optional , Create : `${var.private_endpoint_ocid}` },
52+ "endpoint_name" : acctest.Representation {RepType : acctest .Optional , Create : `PE2` },
5353 "freeform_tags" : acctest.Representation {RepType : acctest .Optional , Create : map [string ]string {"Department" : "Finance" }, Update : map [string ]string {"Department" : "Accounting" }},
5454 "is_private_network_enabled" : acctest.Representation {RepType : acctest .Optional , Create : `true` },
55- "subnet_id" : acctest.Representation {RepType : acctest .Optional , Create : `${oci_core_subnet.test_subnet.id}` },
56- "vcn_id" : acctest.Representation {RepType : acctest .Optional , Create : `${oci_core_vcn.test_vcn.id}` },
55+ "registry_compartment_id" : acctest.Representation {RepType : acctest .Optional , Create : `${var.dcms_registry_comp_id}` },
56+ "registry_id" : acctest.Representation {RepType : acctest .Optional , Create : `${var.dcms_registry_id}` },
57+ "dns_server_ip" : acctest.Representation {RepType : acctest .Optional , Create : `${oci_core_subnet.test_subnet.subnet_domain_name}` },
58+ "lifecycle" : acctest.RepresentationGroup {RepType : acctest .Required , Group : ignoreDataintegrationWorkspaceDefinedTagsChangesRepresentation },
59+ }
60+
61+ ignoreDataintegrationWorkspaceDefinedTagsChangesRepresentation = map [string ]interface {}{
62+ "ignore_changes" : acctest.Representation {RepType : acctest .Required , Create : []string {`defined_tags` }},
5763 }
5864
5965 DataintegrationWorkspaceResourceDependencies = acctest .GenerateResourceFromRepresentationMap ("oci_core_subnet" , "test_subnet" , acctest .Required , acctest .Create , acctest .RepresentationCopyWithNewProperties (CoreSubnetRepresentation , map [string ]interface {}{"dns_label" : acctest.Representation {RepType : acctest .Required , Create : `dnslabel` }})) +
@@ -74,13 +80,22 @@ func TestDataintegrationWorkspaceResource_basic(t *testing.T) {
7480 compartmentIdU := utils .GetEnvSettingWithDefault ("compartment_id_for_update" , compartmentId )
7581 compartmentIdUVariableStr := fmt .Sprintf ("variable \" compartment_id_for_update\" { default = \" %s\" }\n " , compartmentIdU )
7682
83+ dcmsRegistryId := utils .GetEnvSettingWithBlankDefault ("dcms_registry_ocid" )
84+ dcmsRegistryIdVariableStr := fmt .Sprintf ("variable \" dcms_registry_id\" { default = \" %s\" }\n " , dcmsRegistryId )
85+ dcmsRegistryCompId := utils .GetEnvSettingWithBlankDefault ("dcms_registry_compartment_ocid" )
86+ dcmsRegistryCompIdVariableStr := fmt .Sprintf ("variable \" dcms_registry_comp_id\" { default = \" %s\" }\n " , dcmsRegistryCompId )
87+ dcmsRegistryName := utils .GetEnvSettingWithBlankDefault ("dcms_registry_name" )
88+ dcmsRegistryNameVariableStr := fmt .Sprintf ("variable \" dcms_registry_name\" { default = \" %s\" }\n " , dcmsRegistryName )
89+ endpointId := utils .GetEnvSettingWithBlankDefault ("private_endpoint_ocid" )
90+ endpointIdVariableStr := fmt .Sprintf ("variable \" private_endpoint_ocid\" { default = \" %s\" }\n " , endpointId )
91+
7792 resourceName := "oci_dataintegration_workspace.test_workspace"
7893 datasourceName := "data.oci_dataintegration_workspaces.test_workspaces"
7994 singularDatasourceName := "data.oci_dataintegration_workspace.test_workspace"
8095
8196 var resId , resId2 string
8297 // 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.
83- acctest .SaveConfigContent (config + compartmentIdVariableStr + DataintegrationWorkspaceResourceDependencies +
98+ acctest .SaveConfigContent (config + compartmentIdVariableStr + dcmsRegistryIdVariableStr + dcmsRegistryNameVariableStr + dcmsRegistryCompIdVariableStr + endpointIdVariableStr + DataintegrationWorkspaceResourceDependencies +
8499 acctest .GenerateResourceFromRepresentationMap ("oci_dataintegration_workspace" , "test_workspace" , acctest .Optional , acctest .Create , DataintegrationWorkspaceRepresentation ), "dataintegration" , "workspace" , t )
85100
86101 acctest .ResourceTest (t , testAccCheckDataintegrationWorkspaceDestroy , []resource.TestStep {
@@ -106,31 +121,35 @@ func TestDataintegrationWorkspaceResource_basic(t *testing.T) {
106121 },
107122 // verify Create with optionals
108123 {
109- Config : config + compartmentIdVariableStr + DataintegrationWorkspaceResourceDependencies +
124+ Config : config + compartmentIdVariableStr + dcmsRegistryIdVariableStr + dcmsRegistryNameVariableStr + dcmsRegistryCompIdVariableStr + endpointIdVariableStr + DataintegrationWorkspaceResourceDependencies +
110125 acctest .GenerateResourceFromRepresentationMap ("oci_dataintegration_workspace" , "test_workspace" , acctest .Optional , acctest .Create , DataintegrationWorkspaceRepresentation ),
111126 Check : acctest .ComposeAggregateTestCheckFuncWrapper (
112127 resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
113128 resource .TestCheckResourceAttr (resourceName , "description" , "description" ),
114129 resource .TestCheckResourceAttr (resourceName , "display_name" , "displayName" ),
130+ resource .TestCheckResourceAttrSet (resourceName , "endpoint_id" ),
131+ resource .TestCheckResourceAttr (resourceName , "endpoint_name" , "PE2" ),
115132 resource .TestCheckResourceAttr (resourceName , "freeform_tags.%" , "1" ),
116133 resource .TestCheckResourceAttrSet (resourceName , "id" ),
117134 resource .TestCheckResourceAttr (resourceName , "is_private_network_enabled" , "true" ),
135+ resource .TestCheckResourceAttrSet (resourceName , "registry_id" ),
118136
137+ //TEMPORARILY DISABLING RESOURCE DISCOVERY TEST WHICH ALWAYS FAILS DUE TO AD IN ASHBURN NOT LONDON ISSUES
119138 func (s * terraform.State ) (err error ) {
120139 resId , err = acctest .FromInstanceState (s , resourceName , "id" )
121- if isEnableExportCompartment , _ := strconv .ParseBool (utils .GetEnvSettingWithDefault ("enable_export_compartment" , "true" )); isEnableExportCompartment {
140+ /* if isEnableExportCompartment, _ := strconv.ParseBool(utils.GetEnvSettingWithDefault("enable_export_compartment", "true")); isEnableExportCompartment {
122141 if errExport := resourcediscovery.TestExportCompartmentWithResourceName(&resId, &compartmentId, resourceName); errExport != nil {
123142 return errExport
124143 }
125- }
144+ }*/
126145 return err
127146 },
128147 ),
129148 },
130149
131150 // verify Update to the compartment (the compartment will be switched back in the next step)
132151 {
133- Config : config + compartmentIdVariableStr + compartmentIdUVariableStr + DataintegrationWorkspaceResourceDependencies +
152+ Config : config + compartmentIdVariableStr + compartmentIdUVariableStr + dcmsRegistryIdVariableStr + dcmsRegistryNameVariableStr + dcmsRegistryCompIdVariableStr + endpointIdVariableStr + DataintegrationWorkspaceResourceDependencies +
134153 acctest .GenerateResourceFromRepresentationMap ("oci_dataintegration_workspace" , "test_workspace" , acctest .Optional , acctest .Create ,
135154 acctest .RepresentationCopyWithNewProperties (DataintegrationWorkspaceRepresentation , map [string ]interface {}{
136155 "compartment_id" : acctest.Representation {RepType : acctest .Required , Create : `${var.compartment_id_for_update}` },
@@ -139,14 +158,17 @@ func TestDataintegrationWorkspaceResource_basic(t *testing.T) {
139158 resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentIdU ),
140159 resource .TestCheckResourceAttr (resourceName , "description" , "description" ),
141160 resource .TestCheckResourceAttr (resourceName , "display_name" , "displayName" ),
161+ resource .TestCheckResourceAttrSet (resourceName , "endpoint_id" ),
162+ resource .TestCheckResourceAttr (resourceName , "endpoint_name" , "PE2" ),
142163 resource .TestCheckResourceAttr (resourceName , "freeform_tags.%" , "1" ),
143164 resource .TestCheckResourceAttrSet (resourceName , "id" ),
144165 resource .TestCheckResourceAttr (resourceName , "is_private_network_enabled" , "true" ),
166+ resource .TestCheckResourceAttrSet (resourceName , "registry_id" ),
145167
146168 func (s * terraform.State ) (err error ) {
147169 resId2 , err = acctest .FromInstanceState (s , resourceName , "id" )
148170 if resId != resId2 {
149- return fmt .Errorf ("resource recreated when it was supposed to be updated " )
171+ return fmt .Errorf ("resource recreated when it was supposed to be moved " )
150172 }
151173 return err
152174 },
@@ -155,22 +177,23 @@ func TestDataintegrationWorkspaceResource_basic(t *testing.T) {
155177
156178 // verify updates to updatable parameters
157179 {
158- Config : config + compartmentIdVariableStr + DataintegrationWorkspaceResourceDependencies +
180+ Config : config + compartmentIdVariableStr + dcmsRegistryIdVariableStr + dcmsRegistryNameVariableStr + dcmsRegistryCompIdVariableStr + endpointIdVariableStr + DataintegrationWorkspaceResourceDependencies +
159181 acctest .GenerateResourceFromRepresentationMap ("oci_dataintegration_workspace" , "test_workspace" , acctest .Optional , acctest .Update , DataintegrationWorkspaceRepresentation ),
160182 Check : acctest .ComposeAggregateTestCheckFuncWrapper (
161183 resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
162184 resource .TestCheckResourceAttr (resourceName , "description" , "description2" ),
163185 resource .TestCheckResourceAttr (resourceName , "display_name" , "displayName2" ),
186+ resource .TestCheckResourceAttrSet (resourceName , "endpoint_id" ),
187+ resource .TestCheckResourceAttr (resourceName , "endpoint_name" , "PE2" ),
164188 resource .TestCheckResourceAttr (resourceName , "freeform_tags.%" , "1" ),
165189 resource .TestCheckResourceAttrSet (resourceName , "id" ),
166190 resource .TestCheckResourceAttr (resourceName , "is_private_network_enabled" , "true" ),
167- resource .TestCheckResourceAttrSet (resourceName , "subnet_id" ),
168- resource .TestCheckResourceAttrSet (resourceName , "vcn_id" ),
191+ resource .TestCheckResourceAttrSet (resourceName , "registry_id" ),
169192
170193 func (s * terraform.State ) (err error ) {
171194 resId2 , err = acctest .FromInstanceState (s , resourceName , "id" )
172195 if resId != resId2 {
173- return fmt .Errorf ("Resource recreated when it was supposed to be updated. " )
196+ return fmt .Errorf ("resource recreated when it was supposed to be updated" )
174197 }
175198 return err
176199 },
@@ -180,18 +203,20 @@ func TestDataintegrationWorkspaceResource_basic(t *testing.T) {
180203 {
181204 Config : config +
182205 acctest .GenerateDataSourceFromRepresentationMap ("oci_dataintegration_workspaces" , "test_workspaces" , acctest .Optional , acctest .Update , DataintegrationDataintegrationWorkspaceDataSourceRepresentation ) +
183- compartmentIdVariableStr + DataintegrationWorkspaceResourceDependencies +
206+ compartmentIdVariableStr + dcmsRegistryIdVariableStr + dcmsRegistryNameVariableStr + dcmsRegistryCompIdVariableStr + endpointIdVariableStr + DataintegrationWorkspaceResourceDependencies +
184207 acctest .GenerateResourceFromRepresentationMap ("oci_dataintegration_workspace" , "test_workspace" , acctest .Optional , acctest .Update , DataintegrationWorkspaceRepresentation ),
185208 Check : acctest .ComposeAggregateTestCheckFuncWrapper (
186209 resource .TestCheckResourceAttr (datasourceName , "compartment_id" , compartmentId ),
187210 resource .TestCheckResourceAttr (datasourceName , "state" , "ACTIVE" ),
188-
189211 resource .TestCheckResourceAttr (datasourceName , "workspaces.#" , "1" ),
190212 resource .TestCheckResourceAttr (datasourceName , "workspaces.0.compartment_id" , compartmentId ),
191213 resource .TestCheckResourceAttr (datasourceName , "workspaces.0.description" , "description2" ),
192214 resource .TestCheckResourceAttr (datasourceName , "workspaces.0.display_name" , "displayName2" ),
215+ resource .TestCheckResourceAttrSet (datasourceName , "workspaces.0.endpoint_id" ),
216+ resource .TestCheckResourceAttr (datasourceName , "workspaces.0.endpoint_name" , "PE2" ),
193217 resource .TestCheckResourceAttr (datasourceName , "workspaces.0.freeform_tags.%" , "1" ),
194218 resource .TestCheckResourceAttrSet (datasourceName , "workspaces.0.id" ),
219+ resource .TestCheckResourceAttrSet (datasourceName , "workspaces.0.registry_id" ),
195220 resource .TestCheckResourceAttrSet (datasourceName , "workspaces.0.state" ),
196221 resource .TestCheckResourceAttrSet (datasourceName , "workspaces.0.time_created" ),
197222 resource .TestCheckResourceAttrSet (datasourceName , "workspaces.0.time_updated" ),
@@ -201,29 +226,30 @@ func TestDataintegrationWorkspaceResource_basic(t *testing.T) {
201226 {
202227 Config : config +
203228 acctest .GenerateDataSourceFromRepresentationMap ("oci_dataintegration_workspace" , "test_workspace" , acctest .Required , acctest .Create , DataintegrationDataintegrationWorkspaceSingularDataSourceRepresentation ) +
204- compartmentIdVariableStr + DataintegrationWorkspaceResourceConfig ,
229+ compartmentIdVariableStr + dcmsRegistryIdVariableStr + dcmsRegistryNameVariableStr + dcmsRegistryCompIdVariableStr + endpointIdVariableStr + DataintegrationWorkspaceResourceConfig ,
205230 Check : acctest .ComposeAggregateTestCheckFuncWrapper (
206231 resource .TestCheckResourceAttrSet (singularDatasourceName , "workspace_id" ),
207-
208232 resource .TestCheckResourceAttr (singularDatasourceName , "compartment_id" , compartmentId ),
209233 resource .TestCheckResourceAttr (singularDatasourceName , "description" , "description2" ),
210234 resource .TestCheckResourceAttr (singularDatasourceName , "display_name" , "displayName2" ),
211235 resource .TestCheckResourceAttr (singularDatasourceName , "freeform_tags.%" , "1" ),
212236 resource .TestCheckResourceAttrSet (singularDatasourceName , "id" ),
213237 resource .TestCheckResourceAttr (singularDatasourceName , "is_private_network_enabled" , "true" ),
214238 resource .TestCheckResourceAttrSet (singularDatasourceName , "state" ),
215- //resource.TestCheckResourceAttrSet(singularDatasourceName, "state_message"),
216239 resource .TestCheckResourceAttrSet (singularDatasourceName , "time_created" ),
217240 resource .TestCheckResourceAttrSet (singularDatasourceName , "time_updated" ),
218241 ),
219242 },
220243 // verify resource import
221244 {
222- Config : config + DataintegrationWorkspaceRequiredOnlyResource ,
223- ImportState : true ,
224- ImportStateVerify : true ,
225- ImportStateVerifyIgnore : []string {"is_private_network_enabled" , "state_message" },
226- ResourceName : resourceName ,
245+ Config : config + DataintegrationWorkspaceRequiredOnlyResource ,
246+ ImportState : true ,
247+ ImportStateVerify : true ,
248+ ImportStateVerifyIgnore : []string {"is_private_network_enabled" , "state_message" ,
249+ "registry_compartment_id" ,
250+ "registry_name" ,
251+ },
252+ ResourceName : resourceName ,
227253 },
228254 })
229255}
0 commit comments