Skip to content

Commit 4bc8444

Browse files
rcohenmaalexng-canuck
authored andcommitted
adding env flag to avoid waiting for deleted state of topics in the tests
1 parent 923a8d2 commit 4bc8444

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

oci/ons_notification_topic_resource.go

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
1+
// Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
22

33
package provider
44

@@ -20,10 +20,10 @@ func OnsNotificationTopicResource() *schema.Resource {
2020
Update: &FifteenMinutes,
2121
Delete: &TwoAndHalfHours,
2222
},
23-
Create: createNotificationTopic,
24-
Read: readNotificationTopic,
25-
Update: updateNotificationTopic,
26-
Delete: deleteNotificationTopic,
23+
Create: createOnsNotificationTopic,
24+
Read: readOnsNotificationTopic,
25+
Update: updateOnsNotificationTopic,
26+
Delete: deleteOnsNotificationTopic,
2727
Schema: map[string]*schema.Schema{
2828
// Required
2929
"compartment_id": {
@@ -82,73 +82,78 @@ func OnsNotificationTopicResource() *schema.Resource {
8282
}
8383
}
8484

85-
func createNotificationTopic(d *schema.ResourceData, m interface{}) error {
86-
sync := &NotificationTopicResourceCrud{}
85+
func createOnsNotificationTopic(d *schema.ResourceData, m interface{}) error {
86+
sync := &OnsNotificationTopicResourceCrud{}
8787
sync.D = d
8888
sync.Client = m.(*OracleClients).notificationControlPlaneClient
8989

9090
return CreateResource(d, sync)
9191
}
9292

93-
func readNotificationTopic(d *schema.ResourceData, m interface{}) error {
94-
sync := &NotificationTopicResourceCrud{}
93+
func readOnsNotificationTopic(d *schema.ResourceData, m interface{}) error {
94+
sync := &OnsNotificationTopicResourceCrud{}
9595
sync.D = d
9696
sync.Client = m.(*OracleClients).notificationControlPlaneClient
9797

9898
return ReadResource(sync)
9999
}
100100

101-
func updateNotificationTopic(d *schema.ResourceData, m interface{}) error {
102-
sync := &NotificationTopicResourceCrud{}
101+
func updateOnsNotificationTopic(d *schema.ResourceData, m interface{}) error {
102+
sync := &OnsNotificationTopicResourceCrud{}
103103
sync.D = d
104104
sync.Client = m.(*OracleClients).notificationControlPlaneClient
105105

106106
return UpdateResource(d, sync)
107107
}
108108

109-
func deleteNotificationTopic(d *schema.ResourceData, m interface{}) error {
110-
sync := &NotificationTopicResourceCrud{}
109+
func deleteOnsNotificationTopic(d *schema.ResourceData, m interface{}) error {
110+
sync := &OnsNotificationTopicResourceCrud{}
111111
sync.D = d
112112
sync.Client = m.(*OracleClients).notificationControlPlaneClient
113113
sync.DisableNotFoundRetries = true
114114

115115
return DeleteResource(d, sync)
116116
}
117117

118-
type NotificationTopicResourceCrud struct {
118+
type OnsNotificationTopicResourceCrud struct {
119119
BaseCrud
120120
Client *oci_ons.NotificationControlPlaneClient
121121
Res *oci_ons.NotificationTopic
122122
DisableNotFoundRetries bool
123123
}
124124

125-
func (s *NotificationTopicResourceCrud) ID() string {
125+
func (s *OnsNotificationTopicResourceCrud) ID() string {
126126
return *s.Res.TopicId
127127
}
128128

129-
func (s *NotificationTopicResourceCrud) CreatedPending() []string {
129+
func (s *OnsNotificationTopicResourceCrud) CreatedPending() []string {
130130
return []string{
131131
string(oci_ons.NotificationTopicLifecycleStateCreating),
132132
}
133133
}
134134

135-
func (s *NotificationTopicResourceCrud) CreatedTarget() []string {
135+
func (s *OnsNotificationTopicResourceCrud) CreatedTarget() []string {
136136
return []string{
137137
string(oci_ons.NotificationTopicLifecycleStateActive),
138138
}
139139
}
140140

141-
func (s *NotificationTopicResourceCrud) DeletedPending() []string {
141+
func (s *OnsNotificationTopicResourceCrud) DeletedPending() []string {
142142
return []string{
143143
string(oci_ons.NotificationTopicLifecycleStateDeleting),
144144
}
145145
}
146146

147-
func (s *NotificationTopicResourceCrud) DeletedTarget() []string {
147+
func (s *OnsNotificationTopicResourceCrud) DeletedTarget() []string {
148+
if avoidWaitingForDeleteTarget {
149+
return []string{
150+
string(oci_ons.NotificationTopicLifecycleStateDeleting),
151+
}
152+
}
148153
return []string{}
149154
}
150155

151-
func (s *NotificationTopicResourceCrud) Create() error {
156+
func (s *OnsNotificationTopicResourceCrud) Create() error {
152157
request := oci_ons.CreateTopicRequest{}
153158

154159
if compartmentId, ok := s.D.GetOkExists("compartment_id"); ok {
@@ -189,7 +194,7 @@ func (s *NotificationTopicResourceCrud) Create() error {
189194
return nil
190195
}
191196

192-
func (s *NotificationTopicResourceCrud) Get() error {
197+
func (s *OnsNotificationTopicResourceCrud) Get() error {
193198
request := oci_ons.GetTopicRequest{}
194199

195200
if topicId, ok := s.D.GetOkExists("topic_id"); ok {
@@ -211,7 +216,7 @@ func (s *NotificationTopicResourceCrud) Get() error {
211216
return nil
212217
}
213218

214-
func (s *NotificationTopicResourceCrud) Update() error {
219+
func (s *OnsNotificationTopicResourceCrud) Update() error {
215220
request := oci_ons.UpdateTopicRequest{}
216221

217222
if definedTags, ok := s.D.GetOkExists("defined_tags"); ok {
@@ -247,7 +252,7 @@ func (s *NotificationTopicResourceCrud) Update() error {
247252
return nil
248253
}
249254

250-
func (s *NotificationTopicResourceCrud) Delete() error {
255+
func (s *OnsNotificationTopicResourceCrud) Delete() error {
251256
request := oci_ons.DeleteTopicRequest{}
252257

253258
if topicId, ok := s.D.GetOkExists("topic_id"); ok {
@@ -261,7 +266,7 @@ func (s *NotificationTopicResourceCrud) Delete() error {
261266
return err
262267
}
263268

264-
func (s *NotificationTopicResourceCrud) SetData() error {
269+
func (s *OnsNotificationTopicResourceCrud) SetData() error {
265270

266271
s.D.SetId(*s.Res.TopicId)
267272

oci/provider_clients.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ type ConfigureClient func(client *oci_common.BaseClient) error
3434

3535
var configureClient ConfigureClient
3636

37+
var avoidWaitingForDeleteTarget bool
38+
3739
func setGoSDKClients(clients *OracleClients, officialSdkConfigProvider oci_common.ConfigurationProvider, httpClient *http.Client, userAgent string) (err error) {
3840
// Official Go SDK clients:
3941

@@ -129,6 +131,8 @@ func setGoSDKClients(clients *OracleClients, officialSdkConfigProvider oci_commo
129131

130132
simulateDb, _ := strconv.ParseBool(getEnvSettingWithDefault("simulate_db", "false"))
131133

134+
avoidWaitingForDeleteTarget, _ = strconv.ParseBool(getEnvSettingWithDefault("avoid_waiting_for_delete_target", "false"))
135+
132136
requestSigner := oci_common.DefaultRequestSigner(officialSdkConfigProvider)
133137
var oboTokenProvider OboTokenProvider
134138
oboTokenProvider = emptyOboTokenProvider{}

0 commit comments

Comments
 (0)