Skip to content

Commit 4eeabf4

Browse files
xiyayanravinitp
authored andcommitted
Added provider support for Resource Scheduler enhancement feature
1 parent e44120a commit 4eeabf4

10 files changed

+441
-58
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ vendor/github.com/oracle/oci-go-sdk/target
2828
internal/record
2929
.terraform.lock.hcl
3030
dist/
31-
examples/opsi/description.md
31+
internal/integrationtest/output

examples/resourcescheduler/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ variable "schedule_state" {
7373
}
7474

7575
variable "schedule_time_ends" {
76-
default = "2024-12-20T00:00:00Z"
76+
default = "2025-12-31T00:00:00Z"
7777
}
7878

7979
variable "schedule_time_starts" {
80-
default = "2024-12-01T00:00:00Z"
80+
default = "2025-05-01T00:00:00Z"
8181
}
8282

8383

@@ -124,7 +124,7 @@ resource "oci_resource_scheduler_schedule" "test_schedule" {
124124
}
125125

126126
#Optional
127-
defined_tags = map(oci_identity_tag_namespace.tag-namespace1.name.oci_identity_tag.tag1.name, var.schedule_defined_tags_value)
127+
# defined_tags = map(oci_identity_tag_namespace.tag-namespace1.name.oci_identity_tag.tag1.name, var.schedule_defined_tags_value)
128128
description = var.schedule_description
129129
display_name = var.schedule_display_name
130130
freeform_tags = var.schedule_freeform_tags

internal/integrationtest/resource_scheduler_schedule_sync_update_test.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
)
1616

1717
var (
18-
computeInstanceUpdateSyncOcid = utils.GetEnvSettingWithBlankDefault("computeInstance_ocid")
1918
ResourceScheduleUpdateSyncRequiredOnlyResource = ResourceSchedulerScheduleResourceDependencies +
2019
acctest.GenerateResourceFromRepresentationMap("oci_resource_scheduler_schedule", "test_schedule", acctest.Required, acctest.Create, ResourceScheduleUpdateSyncRepresentation)
2120

@@ -39,15 +38,15 @@ var (
3938
// Optionals
4039
"description": acctest.Representation{RepType: acctest.Optional, Create: `provider description1`, Update: `provider description2`},
4140
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `provider displayName1`, Update: `provider displayName2`},
42-
"time_ends": acctest.Representation{RepType: acctest.Optional, Create: `2024-11-20T00:00:00Z`, Update: `2024-11-20T00:00:00Z`},
43-
"time_starts": acctest.Representation{RepType: acctest.Optional, Create: `2024-11-15T00:00:00Z`, Update: `2024-11-15T00:00:00Z`},
41+
"time_ends": acctest.Representation{RepType: acctest.Optional, Create: `2025-12-31T00:00:00Z`, Update: `2025-12-25T00:00:00Z`},
42+
"time_starts": acctest.Representation{RepType: acctest.Optional, Create: `2025-05-01T00:00:00Z`, Update: `2025-05-11T00:00:00Z`},
4443
"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")}`},
4544
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Finance"}},
4645
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Optional, Group: ignoreChangesDefinedTagsResourceSchedulerRepresentation},
4746
}
4847

4948
ResourceSchedulerScheduleResourcesUpdateSyncRepresentation = map[string]interface{}{
50-
"id": acctest.Representation{RepType: acctest.Required, Create: computeInstanceUpdateSyncOcid, Update: computeInstanceUpdateSyncOcid},
49+
"id": acctest.Representation{RepType: acctest.Required, Create: `${var.compute_ocid}`, Update: `${var.compute_ocid}`},
5150
// mimic customer's behavior
5251
"metadata": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"metadata": "metadata"}, Update: map[string]string{"metadata": "metadata"}},
5352
}
@@ -62,6 +61,9 @@ func TestResourceScheduleUpdateSync(t *testing.T) {
6261
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
6362
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
6463

64+
computeOcid := utils.GetEnvSettingWithBlankDefault("compute_ocid")
65+
computeOcidVariableStr := fmt.Sprintf("variable \"compute_ocid\" { default = \"%s\" }\n", computeOcid)
66+
6567
resourceName := "oci_resource_scheduler_schedule.test_schedule"
6668
singularDatasourceName := "data.oci_resource_scheduler_schedule.test_schedule"
6769
datasourceName := "data.oci_resource_scheduler_schedules.test_schedules"
@@ -74,7 +76,7 @@ func TestResourceScheduleUpdateSync(t *testing.T) {
7476
acctest.ResourceTest(t, testAccCheckResourceSchedulerScheduleDestroy, []resource.TestStep{
7577
//verify Create with Required - resource ocids
7678
{
77-
Config: config + compartmentIdVariableStr + ResourceSchedulerScheduleResourceDependencies +
79+
Config: config + compartmentIdVariableStr + computeOcidVariableStr + ResourceSchedulerScheduleResourceDependencies +
7880
acctest.GenerateResourceFromRepresentationMap("oci_resource_scheduler_schedule", "test_schedule", acctest.Required, acctest.Create, ResourceScheduleUpdateSyncRepresentation),
7981

8082
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
@@ -100,7 +102,7 @@ func TestResourceScheduleUpdateSync(t *testing.T) {
100102

101103
// verify create with optionals - resourceOCID
102104
{
103-
Config: config + compartmentIdVariableStr + ResourceSchedulerScheduleResourceDependencies +
105+
Config: config + compartmentIdVariableStr + computeOcidVariableStr + ResourceSchedulerScheduleResourceDependencies +
104106
acctest.GenerateResourceFromRepresentationMap("oci_resource_scheduler_schedule", "test_schedule", acctest.Optional, acctest.Create, ResourceScheduleUpdateSyncRepresentation),
105107

106108
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
@@ -111,11 +113,11 @@ func TestResourceScheduleUpdateSync(t *testing.T) {
111113
resource.TestCheckResourceAttr(resourceName, "recurrence_type", "ICAL"),
112114
resource.TestCheckResourceAttr(resourceName, "description", "provider description1"),
113115
resource.TestCheckResourceAttr(resourceName, "display_name", "provider displayName1"),
114-
resource.TestCheckResourceAttr(resourceName, "time_ends", "2024-11-20T00:00:00Z"),
115-
resource.TestCheckResourceAttr(resourceName, "time_starts", "2024-11-15T00:00:00Z"),
116+
resource.TestCheckResourceAttr(resourceName, "time_ends", "2025-12-31T00:00:00Z"),
117+
resource.TestCheckResourceAttr(resourceName, "time_starts", "2025-05-01T00:00:00Z"),
116118
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
117119
resource.TestCheckResourceAttr(resourceName, "resources.#", "1"),
118-
resource.TestCheckResourceAttr(resourceName, "resources.0.id", computeInstanceUpdateSyncOcid),
120+
resource.TestCheckResourceAttr(resourceName, "resources.0.id", computeOcid),
119121
resource.TestCheckResourceAttr(resourceName, "resources.0.metadata.%", "1"),
120122

121123
func(s *terraform.State) (err error) {
@@ -127,7 +129,7 @@ func TestResourceScheduleUpdateSync(t *testing.T) {
127129

128130
//verify updates to updatable parameters
129131
{
130-
Config: config + compartmentIdVariableStr + ResourceSchedulerScheduleResourceDependencies +
132+
Config: config + compartmentIdVariableStr + computeOcidVariableStr + ResourceSchedulerScheduleResourceDependencies +
131133
acctest.GenerateResourceFromRepresentationMap("oci_resource_scheduler_schedule", "test_schedule", acctest.Optional, acctest.Update, ResourceScheduleUpdateSyncRepresentation),
132134
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
133135
resource.TestCheckResourceAttrSet(resourceName, "id"),
@@ -138,16 +140,15 @@ func TestResourceScheduleUpdateSync(t *testing.T) {
138140
resource.TestCheckResourceAttr(resourceName, "recurrence_type", "ICAL"),
139141
resource.TestCheckResourceAttr(resourceName, "description", "provider description2"),
140142
resource.TestCheckResourceAttr(resourceName, "display_name", "provider displayName2"),
141-
resource.TestCheckResourceAttr(resourceName, "time_ends", "2024-11-20T00:00:00Z"),
142-
resource.TestCheckResourceAttr(resourceName, "time_starts", "2024-11-15T00:00:00Z"),
143+
resource.TestCheckResourceAttr(resourceName, "time_ends", "2025-12-25T00:00:00Z"),
144+
resource.TestCheckResourceAttr(resourceName, "time_starts", "2025-05-11T00:00:00Z"),
143145
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
144146
resource.TestCheckResourceAttr(resourceName, "resources.#", "1"),
145-
resource.TestCheckResourceAttr(resourceName, "resources.0.id", computeInstanceOcid),
147+
resource.TestCheckResourceAttr(resourceName, "resources.0.id", computeOcid),
146148
resource.TestCheckResourceAttr(resourceName, "resources.0.metadata.%", "1"),
147149

148150
func(s *terraform.State) (err error) {
149151
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
150-
fmt.Printf("xiaotong printing resId and resId2, %s, %s", resId, resId2)
151152
if resId != resId2 {
152153
return fmt.Errorf("Resource recreated when it was supposed to be updated.")
153154
}
@@ -160,7 +161,7 @@ func TestResourceScheduleUpdateSync(t *testing.T) {
160161
{
161162
Config: config +
162163
acctest.GenerateDataSourceFromRepresentationMap("oci_resource_scheduler_schedule", "test_schedule", acctest.Required, acctest.Create, ResourceScheduleUpdateSyncSingularDataSourceRepresentation) +
163-
compartmentIdVariableStr + ResourceScheduleUpdateSyncRequiredOnlyResource,
164+
compartmentIdVariableStr + computeOcidVariableStr + ResourceScheduleUpdateSyncRequiredOnlyResource,
164165

165166
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
166167
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),
@@ -177,7 +178,7 @@ func TestResourceScheduleUpdateSync(t *testing.T) {
177178

178179
// verify datasources
179180
{
180-
Config: config + compartmentIdVariableStr + ResourceSchedulerScheduleResourceDependencies +
181+
Config: config + compartmentIdVariableStr + computeOcidVariableStr + ResourceSchedulerScheduleResourceDependencies +
181182
acctest.GenerateResourceFromRepresentationMap("oci_resource_scheduler_schedule", "test_schedule", acctest.Required, acctest.Create, ResourceScheduleUpdateSyncRepresentation) +
182183
acctest.GenerateDataSourceFromRepresentationMap("oci_resource_scheduler_schedules", "test_schedules", acctest.Required, acctest.Create, ResourceScheduleUpdateSyncDataSourceRepresentation),
183184

0 commit comments

Comments
 (0)