@@ -54,17 +54,41 @@ var (
5454 "ssh_public_key" : acctest.Representation {RepType : acctest .Optional , Create : `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOuBJgh6lTmQvQJ4BA3RCJdSmxRtmiXAQEEIP68/G4gF3XuZdKEYTFeputacmRq9yO5ZnNXgO9akdUgePpf8+CfFtveQxmN5xo3HVCDKxu/70lbMgeu7+wJzrMOlzj+a4zNq2j0Ww2VWMsisJ6eV3bJTnO/9VLGCOC8M9noaOlcKcLgIYy4aDM724MxFX2lgn7o6rVADHRxkvLEXPVqYT4syvYw+8OVSnNgE4MJLxaw8/2K0qp19YlQyiriIXfQpci3ThxwLjymYRPj+kjU1xIxv6qbFQzHR7ds0pSWp1U06cIoKPfCazU9hGWW8yIe/vzfTbWrt2DK6pLwBn/G0x3 sample` },
5555 }
5656
57+ nodePoolRegionalSubnetOnlyUpdateFaultDomainsRepresentation = map [string ]interface {}{
58+ "cluster_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_containerengine_cluster.test_cluster.id}` },
59+ "compartment_id" : acctest.Representation {RepType : acctest .Required , Create : `${var.compartment_id}` },
60+ "kubernetes_version" : acctest.Representation {RepType : acctest .Required , Create : `${oci_containerengine_cluster.test_cluster.kubernetes_version}` },
61+ "name" : acctest.Representation {RepType : acctest .Required , Create : `name` , Update : `name2` },
62+ "node_image_name" : acctest.Representation {RepType : acctest .Required , Create : `Oracle-Linux-7.6` },
63+ "node_shape" : acctest.Representation {RepType : acctest .Required , Create : `VM.Standard2.1` },
64+ "node_config_details" : acctest.RepresentationGroup {RepType : acctest .Optional , Group : nodePoolNodeConfigDetailsOnlyUpdateFaultDomainsRepresentation },
65+ "initial_node_labels" : acctest.RepresentationGroup {RepType : acctest .Optional , Group : ContainerengineNodePoolInitialNodeLabelsRepresentation },
66+ "node_metadata" : acctest.Representation {RepType : acctest .Optional , Create : map [string ]string {"nodeMetadata" : "nodeMetadata" }, Update : map [string ]string {"nodeMetadata2" : "nodeMetadata2" }},
67+ "ssh_public_key" : acctest.Representation {RepType : acctest .Optional , Create : `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOuBJgh6lTmQvQJ4BA3RCJdSmxRtmiXAQEEIP68/G4gF3XuZdKEYTFeputacmRq9yO5ZnNXgO9akdUgePpf8+CfFtveQxmN5xo3HVCDKxu/70lbMgeu7+wJzrMOlzj+a4zNq2j0Ww2VWMsisJ6eV3bJTnO/9VLGCOC8M9noaOlcKcLgIYy4aDM724MxFX2lgn7o6rVADHRxkvLEXPVqYT4syvYw+8OVSnNgE4MJLxaw8/2K0qp19YlQyiriIXfQpci3ThxwLjymYRPj+kjU1xIxv6qbFQzHR7ds0pSWp1U06cIoKPfCazU9hGWW8yIe/vzfTbWrt2DK6pLwBn/G0x3 sample` },
68+ }
69+
5770 nodePoolNodeConfigDetailsRepresentation = map [string ]interface {}{
5871 "placement_configs" : acctest.RepresentationGroup {RepType : acctest .Required , Group : nodePoolNodeConfigDetailsPlacementConfigsRepresentation },
5972 "size" : acctest.Representation {RepType : acctest .Required , Create : `2` , Update : `4` },
6073 }
6174
75+ nodePoolNodeConfigDetailsOnlyUpdateFaultDomainsRepresentation = map [string ]interface {}{
76+ "placement_configs" : acctest.RepresentationGroup {RepType : acctest .Required , Group : nodePoolNodeConfigDetailsPlacementConfigsOnlyUpdateFaultDomainsRepresentation },
77+ "size" : acctest.Representation {RepType : acctest .Required , Create : `2` },
78+ }
79+
6280 nodePoolNodeConfigDetailsPlacementConfigsRepresentation = map [string ]interface {}{
6381 "availability_domain" : acctest.Representation {RepType : acctest .Required , Create : `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}` , Update : `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}` },
6482 "subnet_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_core_subnet.node_pool_regional_subnet_1.id}` , Update : `${oci_core_subnet.node_pool_regional_subnet_2.id}` },
6583 "fault_domains" : acctest.Representation {RepType : acctest .Optional , Create : []string {"FAULT-DOMAIN-1" }, Update : []string {"FAULT-DOMAIN-1" }},
6684 }
6785
86+ nodePoolNodeConfigDetailsPlacementConfigsOnlyUpdateFaultDomainsRepresentation = map [string ]interface {}{
87+ "availability_domain" : acctest.Representation {RepType : acctest .Required , Create : `${data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name}` },
88+ "subnet_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_core_subnet.node_pool_regional_subnet_1.id}` },
89+ "fault_domains" : acctest.Representation {RepType : acctest .Optional , Create : []string {"FAULT-DOMAIN-1" }, Update : []string {"FAULT-DOMAIN-2" }},
90+ }
91+
6892 nodePoolSingularDataSourceRepresentationForImageId = map [string ]interface {}{
6993 "node_pool_id" : acctest.Representation {RepType : acctest .Required , Create : `${oci_containerengine_node_pool.test_node_pool_imageId.id}` },
7094 }
@@ -338,6 +362,127 @@ func TestResourceContainerengineNodePool_regionalsubnet(t *testing.T) {
338362 })
339363}
340364
365+ // issue-routing-tag: containerengine/default
366+ func TestResourceContainerengineNodePool_OnlyUpdateFaultDomain (t * testing.T ) {
367+ httpreplay .SetScenario ("TestResourceContainerengineNodePool_OnlyUpdateFaultDomain" )
368+ defer httpreplay .SaveScenario ()
369+
370+ config := acctest .ProviderTestConfig ()
371+
372+ compartmentId := utils .GetEnvSettingWithBlankDefault ("compartment_ocid" )
373+ compartmentIdVariableStr := fmt .Sprintf ("variable \" compartment_id\" { default = \" %s\" }\n " , compartmentId )
374+
375+ resourceName := "oci_containerengine_node_pool.test_node_pool"
376+ singularDatasourceName := "data.oci_containerengine_node_pool.test_node_pool"
377+
378+ var resId , resId2 string
379+
380+ acctest .ResourceTest (t , testAccCheckContainerengineNodePoolDestroy , []resource.TestStep {
381+ // verify Create with optionals
382+ {
383+ Config : config + compartmentIdVariableStr + NodePoolReginalResourceDependencies +
384+ acctest .GenerateResourceFromRepresentationMap ("oci_containerengine_node_pool" , "test_node_pool" , acctest .Optional , acctest .Create , nodePoolRegionalSubnetOnlyUpdateFaultDomainsRepresentation ),
385+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
386+ //Asserting Resource created with Image Name
387+ resource .TestCheckResourceAttrSet (resourceName , "cluster_id" ),
388+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
389+ resource .TestCheckResourceAttr (resourceName , "initial_node_labels.#" , "1" ),
390+ resource .TestCheckResourceAttr (resourceName , "initial_node_labels.0.key" , "key" ),
391+ resource .TestCheckResourceAttr (resourceName , "initial_node_labels.0.value" , "value" ),
392+ resource .TestCheckResourceAttrSet (resourceName , "kubernetes_version" ),
393+ resource .TestCheckResourceAttr (resourceName , "name" , "name" ),
394+ resource .TestCheckResourceAttr (resourceName , "node_config_details.#" , "1" ),
395+ resource .TestCheckResourceAttr (resourceName , "node_config_details.0.placement_configs.#" , "1" ),
396+ acctest .CheckResourceSetContainsElementWithProperties (resourceName , "node_config_details.0.placement_configs" , nil , []string {"availability_domain" }),
397+ acctest .CheckResourceSetContainsElementWithProperties (resourceName , "node_config_details.0.placement_configs" , nil , []string {"subnet_id" }),
398+ resource .TestCheckResourceAttr (resourceName , "node_image_name" , "Oracle-Linux-7.6" ),
399+ resource .TestCheckResourceAttr (resourceName , "node_metadata.%" , "1" ),
400+ resource .TestCheckResourceAttr (resourceName , "node_shape" , "VM.Standard2.1" ),
401+ //resource.TestCheckResourceAttr(resourceName, "quantity_per_subnet", "2"),
402+ resource .TestCheckResourceAttr (resourceName , "ssh_public_key" , "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOuBJgh6lTmQvQJ4BA3RCJdSmxRtmiXAQEEIP68/G4gF3XuZdKEYTFeputacmRq9yO5ZnNXgO9akdUgePpf8+CfFtveQxmN5xo3HVCDKxu/70lbMgeu7+wJzrMOlzj+a4zNq2j0Ww2VWMsisJ6eV3bJTnO/9VLGCOC8M9noaOlcKcLgIYy4aDM724MxFX2lgn7o6rVADHRxkvLEXPVqYT4syvYw+8OVSnNgE4MJLxaw8/2K0qp19YlQyiriIXfQpci3ThxwLjymYRPj+kjU1xIxv6qbFQzHR7ds0pSWp1U06cIoKPfCazU9hGWW8yIe/vzfTbWrt2DK6pLwBn/G0x3 sample" ),
403+ resource .TestCheckResourceAttr (resourceName , "subnet_ids.#" , "1" ),
404+ resource .TestCheckResourceAttr (resourceName , "node_config_details.0.placement_configs.0.fault_domains.#" , "1" ),
405+ resource .TestCheckResourceAttr (resourceName , "node_config_details.0.placement_configs.0.fault_domains.0" , "FAULT-DOMAIN-1" ),
406+
407+ func (s * terraform.State ) (err error ) {
408+ resId , err = acctest .FromInstanceState (s , resourceName , "id" )
409+ if isEnableExportCompartment , _ := strconv .ParseBool (utils .GetEnvSettingWithDefault ("enable_export_compartment" , "true" )); isEnableExportCompartment {
410+ if errExport := resourcediscovery .TestExportCompartmentWithResourceName (& resId , & compartmentId , resourceName ); errExport != nil {
411+ return errExport
412+ }
413+ }
414+ return err
415+ },
416+ ),
417+ },
418+
419+ // verify updates to updatable parameters
420+ {
421+ Config : config + compartmentIdVariableStr + NodePoolReginalResourceDependencies +
422+ acctest .GenerateResourceFromRepresentationMap ("oci_containerengine_node_pool" , "test_node_pool" , acctest .Optional , acctest .Update , acctest .GetUpdatedRepresentationCopy ("node_metadata" , acctest.Representation {RepType : acctest .Optional , Update : map [string ]string {"nodeMetadata" : "nodeMetadata" }}, nodePoolRegionalSubnetOnlyUpdateFaultDomainsRepresentation )),
423+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
424+ //Asserting Resource created with Image Name
425+ resource .TestCheckResourceAttrSet (resourceName , "cluster_id" ),
426+ resource .TestCheckResourceAttr (resourceName , "compartment_id" , compartmentId ),
427+ resource .TestCheckResourceAttr (resourceName , "initial_node_labels.#" , "1" ),
428+ resource .TestCheckResourceAttr (resourceName , "initial_node_labels.0.key" , "key2" ),
429+ resource .TestCheckResourceAttr (resourceName , "initial_node_labels.0.value" , "value2" ),
430+ resource .TestCheckResourceAttrSet (resourceName , "kubernetes_version" ),
431+ resource .TestCheckResourceAttr (resourceName , "name" , "name2" ),
432+ resource .TestCheckResourceAttr (resourceName , "node_config_details.#" , "1" ),
433+ resource .TestCheckResourceAttr (resourceName , "node_config_details.0.placement_configs.#" , "1" ),
434+ acctest .CheckResourceSetContainsElementWithProperties (resourceName , "node_config_details.0.placement_configs" , nil , []string {"subnet_id" }),
435+ resource .TestCheckResourceAttr (resourceName , "node_config_details.0.size" , "2" ),
436+ resource .TestCheckResourceAttr (resourceName , "node_image_name" , "Oracle-Linux-7.6" ),
437+ resource .TestCheckResourceAttr (resourceName , "node_metadata.%" , "1" ),
438+ resource .TestCheckResourceAttr (resourceName , "node_shape" , "VM.Standard2.1" ),
439+ resource .TestCheckResourceAttr (resourceName , "ssh_public_key" , "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOuBJgh6lTmQvQJ4BA3RCJdSmxRtmiXAQEEIP68/G4gF3XuZdKEYTFeputacmRq9yO5ZnNXgO9akdUgePpf8+CfFtveQxmN5xo3HVCDKxu/70lbMgeu7+wJzrMOlzj+a4zNq2j0Ww2VWMsisJ6eV3bJTnO/9VLGCOC8M9noaOlcKcLgIYy4aDM724MxFX2lgn7o6rVADHRxkvLEXPVqYT4syvYw+8OVSnNgE4MJLxaw8/2K0qp19YlQyiriIXfQpci3ThxwLjymYRPj+kjU1xIxv6qbFQzHR7ds0pSWp1U06cIoKPfCazU9hGWW8yIe/vzfTbWrt2DK6pLwBn/G0x3 sample" ),
440+ resource .TestCheckResourceAttr (resourceName , "subnet_ids.#" , "1" ),
441+ resource .TestCheckResourceAttr (resourceName , "node_config_details.0.placement_configs.0.fault_domains.#" , "1" ),
442+ resource .TestCheckResourceAttr (resourceName , "node_config_details.0.placement_configs.0.fault_domains.0" , "FAULT-DOMAIN-2" ),
443+
444+ func (s * terraform.State ) (err error ) {
445+ resId2 , err = acctest .FromInstanceState (s , resourceName , "id" )
446+ if resId != resId2 {
447+ return fmt .Errorf ("Resource recreated when it was supposed to be updated." )
448+ }
449+ return err
450+ },
451+ ),
452+ },
453+ // verify singular datasource
454+ {
455+ Config : config +
456+ acctest .GenerateDataSourceFromRepresentationMap ("oci_containerengine_node_pool" , "test_node_pool" , acctest .Required , acctest .Create , ContainerengineContainerengineNodePoolSingularDataSourceRepresentation ) +
457+ compartmentIdVariableStr + NodePoolReginalResourceDependencies +
458+ acctest .GenerateResourceFromRepresentationMap ("oci_containerengine_node_pool" , "test_node_pool" , acctest .Optional , acctest .Update , nodePoolRegionalSubnetRepresentation ),
459+ Check : acctest .ComposeAggregateTestCheckFuncWrapper (
460+ //Asserting Singular Datasource for NodePool created with Image Name
461+ resource .TestCheckResourceAttrSet (singularDatasourceName , "cluster_id" ),
462+ resource .TestCheckResourceAttrSet (singularDatasourceName , "node_pool_id" ),
463+
464+ resource .TestCheckResourceAttr (singularDatasourceName , "compartment_id" , compartmentId ),
465+ resource .TestCheckResourceAttrSet (singularDatasourceName , "id" ),
466+ resource .TestCheckResourceAttr (singularDatasourceName , "initial_node_labels.#" , "1" ),
467+ resource .TestCheckResourceAttr (singularDatasourceName , "initial_node_labels.0.key" , "key2" ),
468+ resource .TestCheckResourceAttr (singularDatasourceName , "initial_node_labels.0.value" , "value2" ),
469+ resource .TestCheckResourceAttrSet (singularDatasourceName , "kubernetes_version" ),
470+ resource .TestCheckResourceAttr (singularDatasourceName , "name" , "name2" ),
471+ resource .TestCheckResourceAttr (singularDatasourceName , "node_config_details.#" , "1" ),
472+ resource .TestCheckResourceAttr (singularDatasourceName , "node_config_details.0.placement_configs.#" , "1" ),
473+ resource .TestCheckResourceAttrSet (singularDatasourceName , "node_image_id" ),
474+ resource .TestCheckResourceAttr (singularDatasourceName , "node_image_name" , "Oracle-Linux-7.6" ),
475+ resource .TestCheckResourceAttr (singularDatasourceName , "node_metadata.%" , "1" ),
476+ resource .TestCheckResourceAttr (singularDatasourceName , "node_shape" , "VM.Standard2.1" ),
477+ resource .TestCheckResourceAttr (singularDatasourceName , "ssh_public_key" , "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOuBJgh6lTmQvQJ4BA3RCJdSmxRtmiXAQEEIP68/G4gF3XuZdKEYTFeputacmRq9yO5ZnNXgO9akdUgePpf8+CfFtveQxmN5xo3HVCDKxu/70lbMgeu7+wJzrMOlzj+a4zNq2j0Ww2VWMsisJ6eV3bJTnO/9VLGCOC8M9noaOlcKcLgIYy4aDM724MxFX2lgn7o6rVADHRxkvLEXPVqYT4syvYw+8OVSnNgE4MJLxaw8/2K0qp19YlQyiriIXfQpci3ThxwLjymYRPj+kjU1xIxv6qbFQzHR7ds0pSWp1U06cIoKPfCazU9hGWW8yIe/vzfTbWrt2DK6pLwBn/G0x3 sample" ),
478+ resource .TestCheckResourceAttr (singularDatasourceName , "subnet_ids.#" , "1" ),
479+ // "nodes" is not set until the instances in the node_pool are "Available" so we can't assert the nodes property
480+ //resource.TestCheckResourceAttrSet(singularDatasourceName, "nodes"),
481+ ),
482+ },
483+ })
484+ }
485+
341486// issue-routing-tag: containerengine/default
342487func TestContainerengineNodePoolResource_image (t * testing.T ) {
343488 httpreplay .SetScenario ("TestContainerengineNodePoolResource_image" )
0 commit comments