@@ -129,35 +129,6 @@ func TestAccCockpitAlertManager_UpdateSingleContact(t *testing.T) {
129129 })
130130}
131131
132- func TestAccCockpitAlertManager_EnableDisable (t * testing.T ) {
133- t .Skip ("TestAccCockpit_WithSourceEndpoints skipped: encountered repeated HTTP 500 errors from the Scaleway Cockpit API." )
134-
135- tt := acctest .NewTestTools (t )
136- defer tt .Cleanup ()
137-
138- resource .ParallelTest (t , resource.TestCase {
139- ProtoV6ProviderFactories : tt .ProviderFactories ,
140- CheckDestroy : testAccCockpitAlertManagerAndContactsDestroy (tt ),
141- Steps : []resource.TestStep {
142- {
143- Config : testAccCockpitAlertManagerEnableConfig (true ),
144- Check : resource .ComposeTestCheckFunc (
145- resource .TestCheckResourceAttrSet ("scaleway_cockpit_alert_manager.alert_manager" , "region" ),
146- resource .TestCheckResourceAttrSet ("scaleway_cockpit_alert_manager.alert_manager" , "alert_manager_url" ),
147- testAccCheckAlertManagerEnabled (tt , "scaleway_cockpit_alert_manager.alert_manager" , true ),
148- ),
149- },
150- {
151- Config : testAccCockpitAlertManagerEnableConfig (false ),
152- Check : resource .ComposeTestCheckFunc (
153- resource .TestCheckResourceAttr ("scaleway_cockpit_alert_manager.alert_manager" , "enable_managed_alerts" , "false" ),
154- testAccCheckAlertManagerEnabled (tt , "scaleway_cockpit_alert_manager.alert_manager" , false ),
155- ),
156- },
157- },
158- })
159- }
160-
161132func TestAccCockpitAlertManager_IDHandling (t * testing.T ) {
162133 tt := acctest .NewTestTools (t )
163134 defer tt .Cleanup ()
@@ -168,13 +139,7 @@ func TestAccCockpitAlertManager_IDHandling(t *testing.T) {
168139 Steps : []resource.TestStep {
169140 {
170141 Config : `
171- resource "scaleway_account_project" "project" {
172- name = "tf_test_cockpit_alert_manager_id_parsing"
173- }
174-
175142 resource "scaleway_cockpit_alert_manager" "main" {
176- project_id = scaleway_account_project.project.id
177-
178143 contact_points {
179144 email = "test@example.com"
180145 }
@@ -191,13 +156,7 @@ func TestAccCockpitAlertManager_IDHandling(t *testing.T) {
191156 },
192157 {
193158 Config : `
194- resource "scaleway_account_project" "project" {
195- name = "tf_test_cockpit_alert_manager_id_parsing"
196- }
197-
198159 resource "scaleway_cockpit_alert_manager" "main" {
199- project_id = scaleway_account_project.project.id
200-
201160 contact_points {
202161 email = "updated@example.com"
203162 }
@@ -225,55 +184,12 @@ func testAccCockpitAlertManagerConfigWithContacts(contactPoints []map[string]str
225184 }
226185
227186 return fmt .Sprintf (`
228- resource "scaleway_account_project" "project" {
229- name = "tf_test_project"
230- }
231-
232187 resource "scaleway_cockpit_alert_manager" "alert_manager" {
233- project_id = scaleway_account_project.project.id
234188 %s
235189 }
236190 ` , contactsConfig )
237191}
238192
239- func testAccCockpitAlertManagerEnableConfig (enable bool ) string {
240- return fmt .Sprintf (`
241- resource "scaleway_account_project" "project" {
242- name = "tf_test_project"
243- }
244-
245- resource "scaleway_cockpit_alert_manager" "alert_manager" {
246- project_id = scaleway_account_project.project.id
247- enable_managed_alerts = %t
248- }
249- ` , enable )
250- }
251-
252- func testAccCheckAlertManagerEnabled (tt * acctest.TestTools , resourceName string , expectedEnabled bool ) resource.TestCheckFunc {
253- return func (s * terraform.State ) error {
254- rs , ok := s .RootModule ().Resources [resourceName ]
255- if ! ok {
256- return errors .New ("alert manager not found: " + resourceName )
257- }
258-
259- api := cockpit .NewRegionalAPI (meta .ExtractScwClient (tt .Meta ))
260- projectID := rs .Primary .Attributes ["project_id" ]
261-
262- alertManager , err := api .GetAlertManager (& cockpit.RegionalAPIGetAlertManagerRequest {
263- ProjectID : projectID ,
264- })
265- if err != nil {
266- return err
267- }
268-
269- if alertManager .ManagedAlertsEnabled != expectedEnabled {
270- return fmt .Errorf ("alert manager enabled state %t does not match expected state %t" , alertManager .AlertManagerEnabled , expectedEnabled )
271- }
272-
273- return nil
274- }
275- }
276-
277193func testAccCheckCockpitContactPointExists (tt * acctest.TestTools , resourceName string ) resource.TestCheckFunc {
278194 return func (s * terraform.State ) error {
279195 rs , ok := s .RootModule ().Resources [resourceName ]
@@ -390,13 +306,7 @@ func TestAccCockpitAlertManager_WithPreconfiguredAlerts(t *testing.T) {
390306 Steps : []resource.TestStep {
391307 {
392308 Config : `
393- resource "scaleway_account_project" "project" {
394- name = "tf_tests_cockpit_alert_preconfigured"
395- }
396-
397309 resource "scaleway_cockpit_alert_manager" "main" {
398- project_id = scaleway_account_project.project.id
399-
400310 # Enable 2 specific preconfigured alerts (stable IDs)
401311 preconfigured_alert_ids = [
402312 "6c6843af-1815-46df-9e52-6feafcf31fd7", # PostgreSQL Too Many Connections
@@ -434,13 +344,7 @@ func TestAccCockpitAlertManager_UpdatePreconfiguredAlerts(t *testing.T) {
434344 Steps : []resource.TestStep {
435345 {
436346 Config : `
437- resource "scaleway_account_project" "project" {
438- name = "tf_tests_cockpit_alert_update"
439- }
440-
441347 resource "scaleway_cockpit_alert_manager" "main" {
442- project_id = scaleway_account_project.project.id
443-
444348 # Enable a specific PostgreSQL alert (stable ID)
445349 preconfigured_alert_ids = [
446350 "6c6843af-1815-46df-9e52-6feafcf31fd7" # PostgreSQL Too Many Connections
@@ -462,13 +366,7 @@ func TestAccCockpitAlertManager_UpdatePreconfiguredAlerts(t *testing.T) {
462366 },
463367 {
464368 Config : `
465- resource "scaleway_account_project" "project" {
466- name = "tf_tests_cockpit_alert_update"
467- }
468-
469369 resource "scaleway_cockpit_alert_manager" "main" {
470- project_id = scaleway_account_project.project.id
471-
472370 # Enable 2 specific alerts (stable IDs)
473371 preconfigured_alert_ids = [
474372 "6c6843af-1815-46df-9e52-6feafcf31fd7", # PostgreSQL Too Many Connections
@@ -491,13 +389,7 @@ func TestAccCockpitAlertManager_UpdatePreconfiguredAlerts(t *testing.T) {
491389 },
492390 {
493391 Config : `
494- resource "scaleway_account_project" "project" {
495- name = "tf_tests_cockpit_alert_update"
496- }
497-
498392 resource "scaleway_cockpit_alert_manager" "main" {
499- project_id = scaleway_account_project.project.id
500-
501393 # Disable all
502394 preconfigured_alert_ids = []
503395
0 commit comments