From cc37b947465894f9c9617e2b5d18d4203f2812e2 Mon Sep 17 00:00:00 2001 From: Zhiwei Liang Date: Mon, 22 Dec 2025 16:19:37 -0500 Subject: [PATCH 1/4] ACLP stuff --- monitor_alert_definitions.go | 36 ++++++++----------- .../monitor_alert_definitions_test.go | 16 ++++----- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/monitor_alert_definitions.go b/monitor_alert_definitions.go index eb95f0a85..a55293caa 100644 --- a/monitor_alert_definitions.go +++ b/monitor_alert_definitions.go @@ -117,24 +117,24 @@ const ( // AlertDefinitionCreateOptions are the options used to create a new alert definition. type AlertDefinitionCreateOptions struct { - Label string `json:"label"` // mandatory - Severity int `json:"severity"` // mandatory - ChannelIDs []int `json:"channel_ids"` // mandatory - RuleCriteria RuleCriteriaOptions `json:"rule_criteria"` // optional - TriggerConditions TriggerConditions `json:"trigger_conditions"` // optional - EntityIDs []string `json:"entity_ids,omitempty"` // optional - Description string `json:"description,omitempty"` // optional + Label string `json:"label"` + Severity int `json:"severity"` + ChannelIDs []int `json:"channel_ids"` + RuleCriteria *RuleCriteriaOptions `json:"rule_criteria,omitempty"` + TriggerConditions *TriggerConditions `json:"trigger_conditions,omitempty"` + EntityIDs []string `json:"entity_ids,omitempty"` + Description *string `json:"description,omitempty"` } // AlertDefinitionUpdateOptions are the options used to update an alert definition. type AlertDefinitionUpdateOptions struct { - Label string `json:"label"` // mandatory - Severity int `json:"severity"` // mandatory - ChannelIDs []int `json:"channel_ids"` // mandatory - RuleCriteria RuleCriteriaOptions `json:"rule_criteria"` // optional - TriggerConditions TriggerConditions `json:"trigger_conditions"` // optional - EntityIDs []string `json:"entity_ids,omitempty"` // optional - Description string `json:"description,omitempty"` // optional + Label string `json:"label"` + Severity int `json:"severity"` + ChannelIDs []int `json:"channel_ids"` + RuleCriteria *RuleCriteriaOptions `json:"rule_criteria,omitempty"` + TriggerConditions *TriggerConditions `json:"trigger_conditions,omitempty"` + EntityIDs []string `json:"entity_ids,omitempty"` + Description *string `json:"description,omitempty"` } // UnmarshalJSON implements the json.Unmarshaler interface @@ -166,13 +166,7 @@ func (c *Client) ListMonitorAlertDefinitions( serviceType string, opts *ListOptions, ) ([]AlertDefinition, error) { - var endpoint string - if serviceType != "" { - endpoint = formatAPIPath("monitor/services/%s/alert-definitions", serviceType) - } else { - endpoint = formatAPIPath("monitor/alert-definitions") - } - + endpoint := formatAPIPath("monitor/services/%s/alert-definitions", serviceType) return getPaginatedResults[AlertDefinition](ctx, c, endpoint, opts) } diff --git a/test/integration/monitor_alert_definitions_test.go b/test/integration/monitor_alert_definitions_test.go index e053ae66f..daab2adf1 100644 --- a/test/integration/monitor_alert_definitions_test.go +++ b/test/integration/monitor_alert_definitions_test.go @@ -15,7 +15,7 @@ const ( ) func TestMonitorAlertDefinition_smoke(t *testing.T) { - client, teardown := createTestClient(t, "fixtures/TestMonitorAlertDefinition_instance") + client, teardown := createTestClient(t, "fixtures/TestMonitorAlertDefinition") defer teardown() client.SetAPIVersion("v4beta") @@ -72,16 +72,16 @@ func TestMonitorAlertDefinition_smoke(t *testing.T) { createOpts := linodego.AlertDefinitionCreateOptions{ Label: "go-test-alert-definition-create", Severity: int(linodego.SeverityLow), - Description: "Test alert definition creation", + Description: linodego.Pointer("Test alert definition creation"), ChannelIDs: []int{channelID}, EntityIDs: nil, - TriggerConditions: linodego.TriggerConditions{ + TriggerConditions: &linodego.TriggerConditions{ CriteriaCondition: "ALL", EvaluationPeriodSeconds: 300, PollingIntervalSeconds: 300, TriggerOccurrences: 1, }, - RuleCriteria: linodego.RuleCriteriaOptions{ + RuleCriteria: &linodego.RuleCriteriaOptions{ Rules: []linodego.RuleOptions{ { AggregateFunction: "avg", @@ -151,7 +151,7 @@ func TestMonitorAlertDefinition_smoke(t *testing.T) { RuleCriteria: createOpts.RuleCriteria, TriggerConditions: createOpts.TriggerConditions, EntityIDs: createOpts.EntityIDs, - Description: createdAlert.Description, + Description: &createdAlert.Description, } // wait for 1 minute before update for create to complete time.Sleep(1 * time.Minute) @@ -243,16 +243,16 @@ func TestCreateMonitorAlertDefinitionWithIdempotency(t *testing.T) { createOpts := linodego.AlertDefinitionCreateOptions{ Label: uniqueLabel, Severity: int(linodego.SeverityLow), - Description: "Test alert definition creation with idempotency", + Description: linodego.Pointer("Test alert definition creation with idempotency"), ChannelIDs: []int{channelID}, EntityIDs: nil, - TriggerConditions: linodego.TriggerConditions{ + TriggerConditions: &linodego.TriggerConditions{ CriteriaCondition: "ALL", EvaluationPeriodSeconds: 300, PollingIntervalSeconds: 300, TriggerOccurrences: 1, }, - RuleCriteria: linodego.RuleCriteriaOptions{ + RuleCriteria: &linodego.RuleCriteriaOptions{ Rules: []linodego.RuleOptions{ { AggregateFunction: "avg", From b956080668f69fc4afcc1461f7069b2708db635a Mon Sep 17 00:00:00 2001 From: Zhiwei Liang Date: Mon, 22 Dec 2025 16:26:33 -0500 Subject: [PATCH 2/4] revert not needed changes to unit test base --- test/unit/base.go | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/test/unit/base.go b/test/unit/base.go index b393f925e..f49287aae 100644 --- a/test/unit/base.go +++ b/test/unit/base.go @@ -2,7 +2,6 @@ package unit import ( "net/http" - "strings" "testing" "github.com/jarcoal/httpmock" @@ -39,49 +38,24 @@ func (c *ClientBaseCase) TearDown(t *testing.T) { func (c *ClientBaseCase) MockGet(path string, response interface{}) { fullURL := c.BaseURL + path httpmock.RegisterResponder("GET", fullURL, httpmock.NewJsonResponderOrPanic(http.StatusOK, response)) - - // Also register beta endpoint equivalents for monitor-related endpoints - if strings.HasPrefix(path, "monitor/") { - altBase := strings.Replace(c.BaseURL, "/v4/", "/v4beta/", 1) - altURL := altBase + path - httpmock.RegisterResponder("GET", altURL, httpmock.NewJsonResponderOrPanic(http.StatusOK, response)) - } } // MockPost mocks a POST request for a given path with the provided response body func (c *ClientBaseCase) MockPost(path string, response interface{}) { fullURL := c.BaseURL + path httpmock.RegisterResponder("POST", fullURL, httpmock.NewJsonResponderOrPanic(http.StatusOK, response)) - - if strings.HasPrefix(path, "monitor/") { - altBase := strings.Replace(c.BaseURL, "/v4/", "/v4beta/", 1) - altURL := altBase + path - httpmock.RegisterResponder("POST", altURL, httpmock.NewJsonResponderOrPanic(http.StatusOK, response)) - } } // MockPut mocks a PUT request for a given path with the provided response body func (c *ClientBaseCase) MockPut(path string, response interface{}) { fullURL := c.BaseURL + path httpmock.RegisterResponder("PUT", fullURL, httpmock.NewJsonResponderOrPanic(http.StatusOK, response)) - - if strings.HasPrefix(path, "monitor/") { - altBase := strings.Replace(c.BaseURL, "/v4/", "/v4beta/", 1) - altURL := altBase + path - httpmock.RegisterResponder("PUT", altURL, httpmock.NewJsonResponderOrPanic(http.StatusOK, response)) - } } // MockDelete mocks a DELETE request for a given path with the provided response body func (c *ClientBaseCase) MockDelete(path string, response interface{}) { fullURL := c.BaseURL + path httpmock.RegisterResponder("DELETE", fullURL, httpmock.NewJsonResponderOrPanic(http.StatusOK, response)) - - if strings.HasPrefix(path, "monitor/") { - altBase := strings.Replace(c.BaseURL, "/v4/", "/v4beta/", 1) - altURL := altBase + path - httpmock.RegisterResponder("DELETE", altURL, httpmock.NewJsonResponderOrPanic(http.StatusOK, response)) - } } // MonitorClientBaseCase provides a base for unit tests From 44ad7f5c2a85677229c8c6facb3b2c204ab37014 Mon Sep 17 00:00:00 2001 From: Zhiwei Liang Date: Mon, 22 Dec 2025 16:44:44 -0500 Subject: [PATCH 3/4] test fixes --- .../TestMonitorAlertChannels_List.yaml | 113 ++++++ ...AlertDefinition_CreateWithIdempotency.yaml | 294 +++++++++++++++ .../TestMonitorAlertDefinition_Smoke.yaml | 340 ++++++++++++++++++ .../TestMonitorAlertDefinitions_List.yaml | 135 +++++++ .../monitor_alert_definitions_test.go | 28 +- 5 files changed, 892 insertions(+), 18 deletions(-) create mode 100644 test/integration/fixtures/TestMonitorAlertChannels_List.yaml create mode 100644 test/integration/fixtures/TestMonitorAlertDefinition_CreateWithIdempotency.yaml create mode 100644 test/integration/fixtures/TestMonitorAlertDefinition_Smoke.yaml create mode 100644 test/integration/fixtures/TestMonitorAlertDefinitions_List.yaml diff --git a/test/integration/fixtures/TestMonitorAlertChannels_List.yaml b/test/integration/fixtures/TestMonitorAlertChannels_List.yaml new file mode 100644 index 000000000..ece9ea602 --- /dev/null +++ b/test/integration/fixtures/TestMonitorAlertChannels_List.yaml @@ -0,0 +1,113 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/alert-channels?page=1 + method: GET + response: + body: '{"pages": 1, "page": 1, "results": 1, "data": [{"id": 10000, "label": "Read-Write + Channel", "channel_type": "email", "type": "system", "content": {"email": {"email_addresses": + ["Users-with-read-write-access-to-resources"]}}, "alerts": [{"id": 10000, "label": + "High Memory Usage Plan Dedicated", "url": "/monitor/alerts-definitions/10000", + "type": "alerts-definitions"}, {"id": 10001, "label": "High Memory Usage Plan + Shared", "url": "/monitor/alerts-definitions/10001", "type": "alerts-definitions"}, + {"id": 10002, "label": "High CPU Usage Plan Dedicated", "url": "/monitor/alerts-definitions/10002", + "type": "alerts-definitions"}, {"id": 10003, "label": "High CPU Usage Plan Shared", + "url": "/monitor/alerts-definitions/10003", "type": "alerts-definitions"}, {"id": + 10004, "label": "High Disk Usage Plan Dedicated", "url": "/monitor/alerts-definitions/10004", + "type": "alerts-definitions"}, {"id": 10005, "label": "High Disk Usage Plan + Shared", "url": "/monitor/alerts-definitions/10005", "type": "alerts-definitions"}, + {"id": 10470, "label": "jgliahjs_updated", "url": "/monitor/alerts-definitions/10470", + "type": "alerts-definitions"}, {"id": 10503, "label": "obohragp-e2e-alert-1763051867-updated", + "url": "/monitor/alerts-definitions/10503", "type": "alerts-definitions"}, {"id": + 10504, "label": "lczvmpvu-e2e-alert-1763053808", "url": "/monitor/alerts-definitions/10504", + "type": "alerts-definitions"}, {"id": 10505, "label": "ocachcjp-e2e-alert-1763055498-updated", + "url": "/monitor/alerts-definitions/10505", "type": "alerts-definitions"}, {"id": + 10506, "label": "lrbbifob-e2e-alert-1763057283", "url": "/monitor/alerts-definitions/10506", + "type": "alerts-definitions"}, {"id": 10507, "label": "cbbrhfnv-e2e-alert-1763057415", + "url": "/monitor/alerts-definitions/10507", "type": "alerts-definitions"}, {"id": + 10508, "label": "gqzzxdgh-e2e-alert-1763057687", "url": "/monitor/alerts-definitions/10508", + "type": "alerts-definitions"}, {"id": 10509, "label": "smqsmhst-e2e-alert-1763058424", + "url": "/monitor/alerts-definitions/10509", "type": "alerts-definitions"}, {"id": + 10510, "label": "vygdkmkw-e2e-alert-1763058509", "url": "/monitor/alerts-definitions/10510", + "type": "alerts-definitions"}, {"id": 10511, "label": "dvlgyyvr-e2e-alert-1763058560", + "url": "/monitor/alerts-definitions/10511", "type": "alerts-definitions"}, {"id": + 10512, "label": "pscihptu-e2e-alert-1763058653-updated", "url": "/monitor/alerts-definitions/10512", + "type": "alerts-definitions"}, {"id": 10513, "label": "emxhsdlm-e2e-alert-1763059164-updated", + "url": "/monitor/alerts-definitions/10513", "type": "alerts-definitions"}, {"id": + 10514, "label": "fxbekqdl-e2e-alert-1763059845-updated", "url": "/monitor/alerts-definitions/10514", + "type": "alerts-definitions"}, {"id": 10529, "label": "Test Database Standby + Host", "url": "/monitor/alerts-definitions/10529", "type": "alerts-definitions"}, + {"id": 10623, "label": "go-test-alert-definition-idempotency-1766438857602066000", + "url": "/monitor/alerts-definitions/10623", "type": "alerts-definitions"}, {"id": + 10624, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10624", + "type": "alerts-definitions"}, {"id": 10625, "label": "go-test-alert-definition-idempotency-1766439008803464000", + "url": "/monitor/alerts-definitions/10625", "type": "alerts-definitions"}, {"id": + 10626, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10626", + "type": "alerts-definitions"}, {"id": 10627, "label": "go-test-alert-definition-idempotency-1766439204872603000", + "url": "/monitor/alerts-definitions/10627", "type": "alerts-definitions"}, {"id": + 10628, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10628", + "type": "alerts-definitions"}, {"id": 10629, "label": "go-test-alert-definition-idempotency-1766439362488609000", + "url": "/monitor/alerts-definitions/10629", "type": "alerts-definitions"}, {"id": + 10630, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10630", + "type": "alerts-definitions"}, {"id": 10631, "label": "go-test-alert-definition-idempotency-1766439501203284000", + "url": "/monitor/alerts-definitions/10631", "type": "alerts-definitions"}, {"id": + 10632, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10632", + "type": "alerts-definitions"}], "created": "2018-01-02T03:04:05", "updated": + "2018-01-02T03:04:05", "created_by": "system", "updated_by": "system"}]}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Mon, 22 Dec 2025 21:41:17 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + - Accept-Encoding + X-Accepted-Oauth-Scopes: + - monitor:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1840" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/fixtures/TestMonitorAlertDefinition_CreateWithIdempotency.yaml b/test/integration/fixtures/TestMonitorAlertDefinition_CreateWithIdempotency.yaml new file mode 100644 index 000000000..1408104f2 --- /dev/null +++ b/test/integration/fixtures/TestMonitorAlertDefinition_CreateWithIdempotency.yaml @@ -0,0 +1,294 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/alert-channels?page=1 + method: GET + response: + body: '{"pages": 1, "page": 1, "results": 1, "data": [{"id": 10000, "label": "Read-Write + Channel", "channel_type": "email", "type": "system", "content": {"email": {"email_addresses": + ["Users-with-read-write-access-to-resources"]}}, "alerts": [{"id": 10000, "label": + "High Memory Usage Plan Dedicated", "url": "/monitor/alerts-definitions/10000", + "type": "alerts-definitions"}, {"id": 10001, "label": "High Memory Usage Plan + Shared", "url": "/monitor/alerts-definitions/10001", "type": "alerts-definitions"}, + {"id": 10002, "label": "High CPU Usage Plan Dedicated", "url": "/monitor/alerts-definitions/10002", + "type": "alerts-definitions"}, {"id": 10003, "label": "High CPU Usage Plan Shared", + "url": "/monitor/alerts-definitions/10003", "type": "alerts-definitions"}, {"id": + 10004, "label": "High Disk Usage Plan Dedicated", "url": "/monitor/alerts-definitions/10004", + "type": "alerts-definitions"}, {"id": 10005, "label": "High Disk Usage Plan + Shared", "url": "/monitor/alerts-definitions/10005", "type": "alerts-definitions"}, + {"id": 10470, "label": "jgliahjs_updated", "url": "/monitor/alerts-definitions/10470", + "type": "alerts-definitions"}, {"id": 10503, "label": "obohragp-e2e-alert-1763051867-updated", + "url": "/monitor/alerts-definitions/10503", "type": "alerts-definitions"}, {"id": + 10504, "label": "lczvmpvu-e2e-alert-1763053808", "url": "/monitor/alerts-definitions/10504", + "type": "alerts-definitions"}, {"id": 10505, "label": "ocachcjp-e2e-alert-1763055498-updated", + "url": "/monitor/alerts-definitions/10505", "type": "alerts-definitions"}, {"id": + 10506, "label": "lrbbifob-e2e-alert-1763057283", "url": "/monitor/alerts-definitions/10506", + "type": "alerts-definitions"}, {"id": 10507, "label": "cbbrhfnv-e2e-alert-1763057415", + "url": "/monitor/alerts-definitions/10507", "type": "alerts-definitions"}, {"id": + 10508, "label": "gqzzxdgh-e2e-alert-1763057687", "url": "/monitor/alerts-definitions/10508", + "type": "alerts-definitions"}, {"id": 10509, "label": "smqsmhst-e2e-alert-1763058424", + "url": "/monitor/alerts-definitions/10509", "type": "alerts-definitions"}, {"id": + 10510, "label": "vygdkmkw-e2e-alert-1763058509", "url": "/monitor/alerts-definitions/10510", + "type": "alerts-definitions"}, {"id": 10511, "label": "dvlgyyvr-e2e-alert-1763058560", + "url": "/monitor/alerts-definitions/10511", "type": "alerts-definitions"}, {"id": + 10512, "label": "pscihptu-e2e-alert-1763058653-updated", "url": "/monitor/alerts-definitions/10512", + "type": "alerts-definitions"}, {"id": 10513, "label": "emxhsdlm-e2e-alert-1763059164-updated", + "url": "/monitor/alerts-definitions/10513", "type": "alerts-definitions"}, {"id": + 10514, "label": "fxbekqdl-e2e-alert-1763059845-updated", "url": "/monitor/alerts-definitions/10514", + "type": "alerts-definitions"}, {"id": 10529, "label": "Test Database Standby + Host", "url": "/monitor/alerts-definitions/10529", "type": "alerts-definitions"}, + {"id": 10623, "label": "go-test-alert-definition-idempotency-1766438857602066000", + "url": "/monitor/alerts-definitions/10623", "type": "alerts-definitions"}, {"id": + 10624, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10624", + "type": "alerts-definitions"}, {"id": 10625, "label": "go-test-alert-definition-idempotency-1766439008803464000", + "url": "/monitor/alerts-definitions/10625", "type": "alerts-definitions"}, {"id": + 10626, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10626", + "type": "alerts-definitions"}, {"id": 10627, "label": "go-test-alert-definition-idempotency-1766439204872603000", + "url": "/monitor/alerts-definitions/10627", "type": "alerts-definitions"}, {"id": + 10628, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10628", + "type": "alerts-definitions"}, {"id": 10629, "label": "go-test-alert-definition-idempotency-1766439362488609000", + "url": "/monitor/alerts-definitions/10629", "type": "alerts-definitions"}, {"id": + 10630, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10630", + "type": "alerts-definitions"}, {"id": 10631, "label": "go-test-alert-definition-idempotency-1766439501203284000", + "url": "/monitor/alerts-definitions/10631", "type": "alerts-definitions"}, {"id": + 10632, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10632", + "type": "alerts-definitions"}], "created": "2018-01-02T03:04:05", "updated": + "2018-01-02T03:04:05", "created_by": "system", "updated_by": "system"}]}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Mon, 22 Dec 2025 21:41:18 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + - Accept-Encoding + X-Accepted-Oauth-Scopes: + - monitor:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1840" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"label":"go-test-alert-definition-idempotency-1766439678890029000","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test + alert definition creation with idempotency"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions + method: POST + response: + body: '{"id": 10633, "label": "go-test-alert-definition-idempotency-1766439678890029000", + "description": "Test alert definition creation with idempotency", "service_type": + "dbaas", "type": "user", "scope": "entity", "class": null, "regions": [], "status": + "enabled", "entity_ids": [], "has_more_resources": false, "severity": 2, "rule_criteria": + {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", + "aggregate_function": "avg", "operator": "gt", "threshold": 90, "dimension_filters": + [{"label": "Node Type", "dimension_label": "node_type", "operator": "eq", "value": + "primary"}]}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", + "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": + {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": + 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": + "2018-01-02T03:04:05", "created_by": "zliang27", "updated_by": "zliang27"}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Mon, 22 Dec 2025 21:41:19 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Accept-Encoding + X-Accepted-Oauth-Scopes: + - databases:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1840" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"label":"go-test-alert-definition-idempotency-1766439678890029000","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test + alert definition creation with idempotency"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions + method: POST + response: + body: '{"errors": [{"reason": "An alert with this label already exists", "field": + "label"}]}' + headers: + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Content-Length: + - "85" + Content-Type: + - application/json + Expires: + - Mon, 22 Dec 2025 21:41:20 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + X-Accepted-Oauth-Scopes: + - databases:read_only + X-Frame-Options: + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1840" + status: 400 Bad Request + code: 400 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/10633 + method: DELETE + response: + body: '{}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "2" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Mon, 22 Dec 2025 21:41:22 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - databases:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1840" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/fixtures/TestMonitorAlertDefinition_Smoke.yaml b/test/integration/fixtures/TestMonitorAlertDefinition_Smoke.yaml new file mode 100644 index 000000000..813b2ca7e --- /dev/null +++ b/test/integration/fixtures/TestMonitorAlertDefinition_Smoke.yaml @@ -0,0 +1,340 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/alert-definitions?page=1 + method: GET + response: + body: '{"pages": 1, "page": 1, "results": 6, "data": [{"id": 10000, "label": "High + Memory Usage Plan Dedicated", "description": "Alert triggers when dedicated + plan nodes consistently reach critical memory usage, risking application performance + degradation.", "service_type": "dbaas", "type": "system", "scope": "entity", + "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": [], + "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": + "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": + "avg", "operator": "gt", "threshold": 95, "dimension_filters": []}]}, "alert_channels": + [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", + "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": + 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": + "system", "updated_by": "system"}, {"id": 10001, "label": "High Memory Usage + Plan Shared", "description": "Alert triggers when shared plan nodes consistently + reach critical memory usage, risking application performance degradation.", + "service_type": "dbaas", "type": "system", "scope": "entity", "class": "shared", + "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": + false, "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", + "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": + "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": [{"id": + 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", + "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": + 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": + "system", "updated_by": "system"}, {"id": 10002, "label": "High CPU Usage Plan + Dedicated", "description": "Alert triggers when dedicated nodes consistently + exceed 95% CPU usage across three consecutive 5-minute intervals.", "service_type": + "dbaas", "type": "system", "scope": "entity", "class": "dedicated", "regions": + [], "status": "enabled", "entity_ids": [], "has_more_resources": false, "severity": + 2, "rule_criteria": {"rules": [{"label": "CPU Usage", "metric": "cpu_usage", + "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": + 95, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write + Channel", "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], + "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": + 300, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "system", + "updated_by": "system"}, {"id": 10003, "label": "High CPU Usage Plan Shared", + "description": "Alert triggers when shared plan nodes consistently exceed high + CPU utilization, indicating potential performance issues.", "service_type": + "dbaas", "type": "system", "scope": "entity", "class": "shared", "regions": + [], "status": "enabled", "entity_ids": [], "has_more_resources": false, "severity": + 2, "rule_criteria": {"rules": [{"label": "CPU Usage", "metric": "cpu_usage", + "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": + 90, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write + Channel", "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], + "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": + 300, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "system", + "updated_by": "system"}, {"id": 10004, "label": "High Disk Usage Plan Dedicated", + "description": "Alert triggers when dedicated plan nodes experience sustained + high disk usage, risking immediate resource exhaustion.", "service_type": "dbaas", + "type": "system", "scope": "entity", "class": "dedicated", "regions": [], "status": + "enabled", "entity_ids": [], "has_more_resources": false, "severity": 2, "rule_criteria": + {"rules": [{"label": "Disk Space Usage", "metric": "disk_usage", "unit": "percent", + "aggregate_function": "avg", "operator": "gt", "threshold": 95, "dimension_filters": + []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": + "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": + {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": + 300, "trigger_occurrences": 3}, "created": "2018-01-02T03:04:05", "updated": + "2018-01-02T03:04:05", "created_by": "system", "updated_by": "system"}, {"id": + 10005, "label": "High Disk Usage Plan Shared", "description": "Alert triggers + when shared plan nodes experience sustained high disk usage, risking immediate + resource exhaustion.", "service_type": "dbaas", "type": "system", "scope": "entity", + "class": "shared", "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": + false, "severity": 2, "rule_criteria": {"rules": [{"label": "Disk Space Usage", + "metric": "disk_usage", "unit": "percent", "aggregate_function": "avg", "operator": + "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": [{"id": + 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", + "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": + 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": + "system", "updated_by": "system"}]}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Mon, 22 Dec 2025 21:40:11 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + - Accept-Encoding + X-Accepted-Oauth-Scopes: + - monitor:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1840" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"label":"go-test-alert-definition-create","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test + alert definition creation"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions + method: POST + response: + body: '{"id": 10632, "label": "go-test-alert-definition-create", "description": + "Test alert definition creation", "service_type": "dbaas", "type": "user", "scope": + "entity", "class": null, "regions": [], "status": "enabled", "entity_ids": [], + "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": + "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": + "avg", "operator": "gt", "threshold": 90, "dimension_filters": [{"label": "Node + Type", "dimension_label": "node_type", "operator": "eq", "value": "primary"}]}]}, + "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", + "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": + 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": + "zliang27", "updated_by": "zliang27"}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Mon, 22 Dec 2025 21:40:12 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Accept-Encoding + X-Accepted-Oauth-Scopes: + - databases:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1840" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"label":"go-test-alert-definition-create-updated","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test + alert definition creation"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/10632 + method: PUT + response: + body: '{"id": 10632, "label": "go-test-alert-definition-create-updated", "description": + "Test alert definition creation", "service_type": "dbaas", "type": "user", "scope": + "entity", "class": null, "regions": [], "status": "disabled", "entity_ids": + [], "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": + "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": + "avg", "operator": "gt", "threshold": 90, "dimension_filters": [{"label": "Node + Type", "dimension_label": "node_type", "operator": "eq", "value": "primary"}]}]}, + "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", + "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": + 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": + "zliang27", "updated_by": "zliang27"}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Mon, 22 Dec 2025 21:41:14 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Accept-Encoding + X-Accepted-Oauth-Scopes: + - databases:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1840" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/10632 + method: DELETE + response: + body: '{}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "2" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Mon, 22 Dec 2025 21:41:15 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - databases:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1840" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/fixtures/TestMonitorAlertDefinitions_List.yaml b/test/integration/fixtures/TestMonitorAlertDefinitions_List.yaml new file mode 100644 index 000000000..f8986b76a --- /dev/null +++ b/test/integration/fixtures/TestMonitorAlertDefinitions_List.yaml @@ -0,0 +1,135 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/monitor/alert-definitions?page=1 + method: GET + response: + body: '{"pages": 1, "page": 1, "results": 6, "data": [{"id": 10000, "label": "High + Memory Usage Plan Dedicated", "description": "Alert triggers when dedicated + plan nodes consistently reach critical memory usage, risking application performance + degradation.", "service_type": "dbaas", "type": "system", "scope": "entity", + "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": [], + "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": + "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": + "avg", "operator": "gt", "threshold": 95, "dimension_filters": []}]}, "alert_channels": + [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", + "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": + 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": + "system", "updated_by": "system"}, {"id": 10001, "label": "High Memory Usage + Plan Shared", "description": "Alert triggers when shared plan nodes consistently + reach critical memory usage, risking application performance degradation.", + "service_type": "dbaas", "type": "system", "scope": "entity", "class": "shared", + "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": + false, "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", + "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": + "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": [{"id": + 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", + "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": + 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": + "system", "updated_by": "system"}, {"id": 10002, "label": "High CPU Usage Plan + Dedicated", "description": "Alert triggers when dedicated nodes consistently + exceed 95% CPU usage across three consecutive 5-minute intervals.", "service_type": + "dbaas", "type": "system", "scope": "entity", "class": "dedicated", "regions": + [], "status": "enabled", "entity_ids": [], "has_more_resources": false, "severity": + 2, "rule_criteria": {"rules": [{"label": "CPU Usage", "metric": "cpu_usage", + "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": + 95, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write + Channel", "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], + "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": + 300, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "system", + "updated_by": "system"}, {"id": 10003, "label": "High CPU Usage Plan Shared", + "description": "Alert triggers when shared plan nodes consistently exceed high + CPU utilization, indicating potential performance issues.", "service_type": + "dbaas", "type": "system", "scope": "entity", "class": "shared", "regions": + [], "status": "enabled", "entity_ids": [], "has_more_resources": false, "severity": + 2, "rule_criteria": {"rules": [{"label": "CPU Usage", "metric": "cpu_usage", + "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": + 90, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write + Channel", "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], + "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": + 300, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "system", + "updated_by": "system"}, {"id": 10004, "label": "High Disk Usage Plan Dedicated", + "description": "Alert triggers when dedicated plan nodes experience sustained + high disk usage, risking immediate resource exhaustion.", "service_type": "dbaas", + "type": "system", "scope": "entity", "class": "dedicated", "regions": [], "status": + "enabled", "entity_ids": [], "has_more_resources": false, "severity": 2, "rule_criteria": + {"rules": [{"label": "Disk Space Usage", "metric": "disk_usage", "unit": "percent", + "aggregate_function": "avg", "operator": "gt", "threshold": 95, "dimension_filters": + []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": + "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": + {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": + 300, "trigger_occurrences": 3}, "created": "2018-01-02T03:04:05", "updated": + "2018-01-02T03:04:05", "created_by": "system", "updated_by": "system"}, {"id": + 10005, "label": "High Disk Usage Plan Shared", "description": "Alert triggers + when shared plan nodes experience sustained high disk usage, risking immediate + resource exhaustion.", "service_type": "dbaas", "type": "system", "scope": "entity", + "class": "shared", "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": + false, "severity": 2, "rule_criteria": {"rules": [{"label": "Disk Space Usage", + "metric": "disk_usage", "unit": "percent", "aggregate_function": "avg", "operator": + "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": [{"id": + 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", + "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", + "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": + 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": + "system", "updated_by": "system"}]}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Mon, 22 Dec 2025 21:41:16 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + - Accept-Encoding + X-Accepted-Oauth-Scopes: + - monitor:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1840" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/monitor_alert_definitions_test.go b/test/integration/monitor_alert_definitions_test.go index daab2adf1..3d4d7e9f5 100644 --- a/test/integration/monitor_alert_definitions_test.go +++ b/test/integration/monitor_alert_definitions_test.go @@ -15,13 +15,11 @@ const ( ) func TestMonitorAlertDefinition_smoke(t *testing.T) { - client, teardown := createTestClient(t, "fixtures/TestMonitorAlertDefinition") + client, teardown := createTestClient(t, "fixtures/TestMonitorAlertDefinition_smoke") defer teardown() - client.SetAPIVersion("v4beta") - // Get All Alert Definitions - alerts, err := client.ListMonitorAlertDefinitions(context.Background(), "", nil) + alerts, err := client.ListAllMonitorAlertDefinitions(context.Background(), nil) // Even if there is no alert definition, it should not error out if err != nil { t.Fatalf("failed to fetch monitor alert definitions: %s", err) @@ -111,7 +109,7 @@ func TestMonitorAlertDefinition_smoke(t *testing.T) { assert.NotNil(t, createdAlert) assert.Equal(t, createOpts.Label, createdAlert.Label) assert.Equal(t, createOpts.Severity, createdAlert.Severity) - assert.Equal(t, createOpts.Description, createdAlert.Description) + assert.Equal(t, *createOpts.Description, createdAlert.Description) assert.ElementsMatch(t, createOpts.EntityIDs, createdAlert.EntityIDs) // assert.Equal(t, fetchedChannel.Label, createdAlert.AlertChannels[0].Label) @@ -189,14 +187,12 @@ func TestMonitorAlertDefinition_smoke(t *testing.T) { } } -func TestListMonitorAlertDefinitions(t *testing.T) { - client, teardown := createTestClient(t, "fixtures/TestListMonitorAlertDefinitions") +func TestMonitorAlertDefinitions_List(t *testing.T) { + client, teardown := createTestClient(t, "fixtures/TestMonitorAlertDefinitions_List") defer teardown() - client.SetAPIVersion("v4beta") - // List all alert definitions - alerts, err := client.ListMonitorAlertDefinitions(context.Background(), "", nil) + alerts, err := client.ListAllMonitorAlertDefinitions(context.Background(), nil) assert.NoError(t, err) assert.NotEmpty(t, alerts, "Expected at least one alert definition") @@ -207,12 +203,10 @@ func TestListMonitorAlertDefinitions(t *testing.T) { } } -func TestListMonitorAlertChannels(t *testing.T) { - client, teardown := createTestClient(t, "fixtures/TestListMonitorAlertChannels") +func TestMonitorAlertChannels_List(t *testing.T) { + client, teardown := createTestClient(t, "fixtures/TestMonitorAlertChannels_List") defer teardown() - client.SetAPIVersion("v4beta") - // List all alert channels channels, err := client.ListAlertChannels(context.Background(), nil) assert.NoError(t, err) @@ -225,12 +219,10 @@ func TestListMonitorAlertChannels(t *testing.T) { } } -func TestCreateMonitorAlertDefinitionWithIdempotency(t *testing.T) { - client, teardown := createTestClient(t, "fixtures/TestCreateMonitorAlertDefinitionWithIdempotency") +func TestMonitorAlertDefinition_CreateWithIdempotency(t *testing.T) { + client, teardown := createTestClient(t, "fixtures/TestMonitorAlertDefinition_CreateWithIdempotency") defer teardown() - client.SetAPIVersion("v4beta") - // Get a channel ID to use channels, err := client.ListAlertChannels(context.Background(), nil) if err != nil || len(channels) == 0 { From 231a844b9f4a650ef872a70e07e36febf31281ed Mon Sep 17 00:00:00 2001 From: Zhiwei Liang Date: Mon, 22 Dec 2025 16:56:37 -0500 Subject: [PATCH 4/4] fixtures fix --- ...e.yaml => TestMonitorAlertDefinition.yaml} | 0 .../TestMonitorAlertDefinition_instance.yaml | 432 ------------------ .../monitor_alert_definitions_test.go | 2 +- 3 files changed, 1 insertion(+), 433 deletions(-) rename test/integration/fixtures/{TestMonitorAlertDefinition_Smoke.yaml => TestMonitorAlertDefinition.yaml} (100%) delete mode 100644 test/integration/fixtures/TestMonitorAlertDefinition_instance.yaml diff --git a/test/integration/fixtures/TestMonitorAlertDefinition_Smoke.yaml b/test/integration/fixtures/TestMonitorAlertDefinition.yaml similarity index 100% rename from test/integration/fixtures/TestMonitorAlertDefinition_Smoke.yaml rename to test/integration/fixtures/TestMonitorAlertDefinition.yaml diff --git a/test/integration/fixtures/TestMonitorAlertDefinition_instance.yaml b/test/integration/fixtures/TestMonitorAlertDefinition_instance.yaml deleted file mode 100644 index 115d9b641..000000000 --- a/test/integration/fixtures/TestMonitorAlertDefinition_instance.yaml +++ /dev/null @@ -1,432 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: "" - form: {} - headers: - Accept: - - application/json - Content-Type: - - application/json - User-Agent: - - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/monitor/alert-definitions?page=1 - method: GET - response: - body: '{"pages": 1, "page": 1, "results": 14, "data": [{"id": 10000, "label": - "High Memory Usage Plan Dedicated", "description": "Alert triggers when dedicated - plan nodes consistently reach critical memory usage, risking application performance - degradation.", "service_type": "dbaas", "type": "system", "scope": "entity", - "class": "dedicated", "regions": [], "status": "enabled", "entity_ids": [], - "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": - "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": - "avg", "operator": "gt", "threshold": 95, "dimension_filters": []}]}, "alert_channels": - [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "system", "updated_by": "system"}, {"id": 10001, "label": "High Memory Usage - Plan Shared", "description": "Alert triggers when shared plan nodes consistently - reach critical memory usage, risking application performance degradation.", - "service_type": "dbaas", "type": "system", "scope": "entity", "class": "shared", - "regions": [], "status": "enabled", "entity_ids": ["389481", "395222"], "has_more_resources": - false, "severity": 2, "rule_criteria": {"rules": [{"label": "Memory Usage", - "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": - "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": [{"id": - 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "system", "updated_by": "system"}, {"id": 10002, "label": "High CPU Usage Plan - Dedicated", "description": "Alert triggers when dedicated nodes consistently - exceed 95% CPU usage across three consecutive 5-minute intervals.", "service_type": - "dbaas", "type": "system", "scope": "entity", "class": "dedicated", "regions": - [], "status": "enabled", "entity_ids": [], "has_more_resources": false, "severity": - 2, "rule_criteria": {"rules": [{"label": "CPU Usage", "metric": "cpu_usage", - "unit": "percent", "aggregate_function": "avg", "operator": "gt", "threshold": - 95, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write - Channel", "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], - "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": - 300, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": - "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "system", - "updated_by": "system"}, {"id": 10003, "label": "High CPU Usage Plan Shared", - "description": "Alert triggers when shared plan nodes consistently exceed high - CPU utilization, indicating potential performance issues.", "service_type": - "dbaas", "type": "system", "scope": "entity", "class": "shared", "regions": - [], "status": "enabled", "entity_ids": ["389481", "395222"], "has_more_resources": - false, "severity": 2, "rule_criteria": {"rules": [{"label": "CPU Usage", "metric": - "cpu_usage", "unit": "percent", "aggregate_function": "avg", "operator": "gt", - "threshold": 90, "dimension_filters": []}]}, "alert_channels": [{"id": 10000, - "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", "type": - "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", "polling_interval_seconds": - 300, "evaluation_period_seconds": 300, "trigger_occurrences": 3}, "created": - "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": "system", - "updated_by": "system"}, {"id": 10004, "label": "High Disk Usage Plan Dedicated", - "description": "Alert triggers when dedicated plan nodes experience sustained - high disk usage, risking immediate resource exhaustion.", "service_type": "dbaas", - "type": "system", "scope": "entity", "class": "dedicated", "regions": [], "status": - "enabled", "entity_ids": [], "has_more_resources": false, "severity": 2, "rule_criteria": - {"rules": [{"label": "Disk Space Usage", "metric": "disk_usage", "unit": "percent", - "aggregate_function": "avg", "operator": "gt", "threshold": 95, "dimension_filters": - []}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": - "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": - {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": - 300, "trigger_occurrences": 3}, "created": "2018-01-02T03:04:05", "updated": - "2018-01-02T03:04:05", "created_by": "system", "updated_by": "system"}, {"id": - 10005, "label": "High Disk Usage Plan Shared", "description": "Alert triggers - when shared plan nodes experience sustained high disk usage, risking immediate - resource exhaustion.", "service_type": "dbaas", "type": "system", "scope": "entity", - "class": "shared", "regions": [], "status": "enabled", "entity_ids": ["389481", - "395222"], "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": - [{"label": "Disk Space Usage", "metric": "disk_usage", "unit": "percent", "aggregate_function": - "avg", "operator": "gt", "threshold": 90, "dimension_filters": []}]}, "alert_channels": - [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 3}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "system", "updated_by": "system"}, {"id": 10550, "label": "ansible-test-220883203", - "description": "An alert definition for ansible test", "service_type": "dbaas", - "type": "user", "scope": "entity", "class": null, "regions": [], "status": "enabled", - "entity_ids": [], "has_more_resources": false, "severity": 1, "rule_criteria": - {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", - "aggregate_function": "avg", "operator": "gt", "threshold": 90.0, "dimension_filters": - [{"label": "Node Type", "dimension_label": "node_type", "operator": "eq", "value": - "primary"}]}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", - "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": - {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": - 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": - "2018-01-02T03:04:05", "created_by": "ychen123", "updated_by": "ychen123"}, - {"id": 10551, "label": "ansible-test-826575525", "description": "An alert definition - for ansible test", "service_type": "dbaas", "type": "user", "scope": "entity", - "class": null, "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": - false, "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", - "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": - "gt", "threshold": 90.0, "dimension_filters": [{"label": "Node Type", "dimension_label": - "node_type", "operator": "eq", "value": "primary"}]}]}, "alert_channels": [{"id": - 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "ychen123", "updated_by": "ychen123"}, {"id": 10552, "label": "ansible-test-375711107", - "description": "An alert definition for ansible test", "service_type": "dbaas", - "type": "user", "scope": "entity", "class": null, "regions": [], "status": "enabled", - "entity_ids": [], "has_more_resources": false, "severity": 1, "rule_criteria": - {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", - "aggregate_function": "avg", "operator": "gt", "threshold": 90.0, "dimension_filters": - [{"label": "Node Type", "dimension_label": "node_type", "operator": "eq", "value": - "primary"}]}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", - "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": - {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": - 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": - "2018-01-02T03:04:05", "created_by": "ychen123", "updated_by": "ychen123"}, - {"id": 10553, "label": "ansible-test-657347537", "description": "An alert definition - for ansible test", "service_type": "dbaas", "type": "user", "scope": "entity", - "class": null, "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": - false, "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", - "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": - "gt", "threshold": 90.0, "dimension_filters": [{"label": "Node Type", "dimension_label": - "node_type", "operator": "eq", "value": "primary"}]}]}, "alert_channels": [{"id": - 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "ychen123", "updated_by": "ychen123"}, {"id": 10554, "label": "ansible-test-534545596", - "description": "An alert definition for ansible test", "service_type": "dbaas", - "type": "user", "scope": "entity", "class": null, "regions": [], "status": "enabled", - "entity_ids": [], "has_more_resources": false, "severity": 1, "rule_criteria": - {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", - "aggregate_function": "avg", "operator": "gt", "threshold": 90.0, "dimension_filters": - [{"label": "Node Type", "dimension_label": "node_type", "operator": "eq", "value": - "primary"}]}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", - "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": - {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": - 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": - "2018-01-02T03:04:05", "created_by": "ychen123", "updated_by": "ychen123"}, - {"id": 10555, "label": "ansible-test-642881759", "description": "An alert definition - for ansible test", "service_type": "dbaas", "type": "user", "scope": "entity", - "class": null, "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": - false, "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", - "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": - "gt", "threshold": 90.0, "dimension_filters": [{"label": "Node Type", "dimension_label": - "node_type", "operator": "eq", "value": "primary"}]}]}, "alert_channels": [{"id": - 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "ychen123", "updated_by": "ychen123"}, {"id": 10556, "label": "ansible-test-656673869", - "description": "An alert definition for ansible test", "service_type": "dbaas", - "type": "user", "scope": "entity", "class": null, "regions": [], "status": "enabled", - "entity_ids": [], "has_more_resources": false, "severity": 1, "rule_criteria": - {"rules": [{"label": "Memory Usage", "metric": "memory_usage", "unit": "percent", - "aggregate_function": "avg", "operator": "gt", "threshold": 90.0, "dimension_filters": - [{"label": "Node Type", "dimension_label": "node_type", "operator": "eq", "value": - "primary"}]}]}, "alert_channels": [{"id": 10000, "label": "Read-Write Channel", - "url": "/monitor/alert-channels/10000", "type": "alert-channels"}], "trigger_conditions": - {"criteria_condition": "ALL", "polling_interval_seconds": 300, "evaluation_period_seconds": - 300, "trigger_occurrences": 1}, "created": "2018-01-02T03:04:05", "updated": - "2018-01-02T03:04:05", "created_by": "ychen123", "updated_by": "ychen123"}, - {"id": 10557, "label": "ansible-test-295829242", "description": "An alert definition - for ansible test", "service_type": "dbaas", "type": "user", "scope": "entity", - "class": null, "regions": [], "status": "enabled", "entity_ids": [], "has_more_resources": - false, "severity": 1, "rule_criteria": {"rules": [{"label": "Memory Usage", - "metric": "memory_usage", "unit": "percent", "aggregate_function": "avg", "operator": - "gt", "threshold": 90.0, "dimension_filters": [{"label": "Node Type", "dimension_label": - "node_type", "operator": "eq", "value": "primary"}]}]}, "alert_channels": [{"id": - 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "ychen123", "updated_by": "ychen123"}]}' - headers: - Access-Control-Allow-Credentials: - - "true" - Access-Control-Allow-Headers: - - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter - Access-Control-Allow-Methods: - - HEAD, GET, OPTIONS, POST, PUT, DELETE - Access-Control-Allow-Origin: - - '*' - Access-Control-Expose-Headers: - - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status - Akamai-Internal-Account: - - '*' - Cache-Control: - - max-age=0, no-cache, no-store - Connection: - - keep-alive - Content-Security-Policy: - - default-src 'none' - Content-Type: - - application/json - Expires: - - Mon, 22 Dec 2025 15:53:01 GMT - Pragma: - - no-cache - Strict-Transport-Security: - - max-age=31536000 - Vary: - - Authorization, X-Filter - - Authorization, X-Filter - - Accept-Encoding - X-Accepted-Oauth-Scopes: - - monitor:read_only - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - DENY - - DENY - X-Oauth-Scopes: - - '*' - X-Ratelimit-Limit: - - "1840" - X-Xss-Protection: - - 1; mode=block - status: 200 OK - code: 200 - duration: "" -- request: - body: '{"label":"go-test-alert-definition-create","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test - alert definition creation"}' - form: {} - headers: - Accept: - - application/json - Content-Type: - - application/json - User-Agent: - - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions - method: POST - response: - body: '{"id": 10622, "label": "go-test-alert-definition-create", "description": - "Test alert definition creation", "service_type": "dbaas", "type": "user", "scope": - "entity", "class": null, "regions": [], "status": "enabled", "entity_ids": [], - "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": - "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": - "avg", "operator": "gt", "threshold": 90, "dimension_filters": [{"label": "Node - Type", "dimension_label": "node_type", "operator": "eq", "value": "primary"}]}]}, - "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "ychen123", "updated_by": "ychen123"}' - headers: - Access-Control-Allow-Credentials: - - "true" - Access-Control-Allow-Headers: - - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter - Access-Control-Allow-Methods: - - HEAD, GET, OPTIONS, POST, PUT, DELETE - Access-Control-Allow-Origin: - - '*' - Access-Control-Expose-Headers: - - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status - Akamai-Internal-Account: - - '*' - Cache-Control: - - max-age=0, no-cache, no-store - Connection: - - keep-alive - Content-Security-Policy: - - default-src 'none' - Content-Type: - - application/json - Expires: - - Mon, 22 Dec 2025 15:53:02 GMT - Pragma: - - no-cache - Strict-Transport-Security: - - max-age=31536000 - Vary: - - Authorization, X-Filter - - Accept-Encoding - X-Accepted-Oauth-Scopes: - - databases:read_only - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - DENY - - DENY - X-Oauth-Scopes: - - '*' - X-Ratelimit-Limit: - - "1840" - X-Xss-Protection: - - 1; mode=block - status: 200 OK - code: 200 - duration: "" -- request: - body: '{"label":"go-test-alert-definition-create-updated","severity":2,"channel_ids":[10000],"rule_criteria":{"rules":[{"aggregate_function":"avg","dimension_filters":[{"dimension_label":"node_type","operator":"eq","value":"primary"}],"metric":"memory_usage","operator":"gt","threshold":90}]},"trigger_conditions":{"criteria_condition":"ALL","evaluation_period_seconds":300,"polling_interval_seconds":300,"trigger_occurrences":1},"description":"Test - alert definition creation"}' - form: {} - headers: - Accept: - - application/json - Content-Type: - - application/json - User-Agent: - - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/10622 - method: PUT - response: - body: '{"id": 10622, "label": "go-test-alert-definition-create-updated", "description": - "Test alert definition creation", "service_type": "dbaas", "type": "user", "scope": - "entity", "class": null, "regions": [], "status": "disabled", "entity_ids": - [], "has_more_resources": false, "severity": 2, "rule_criteria": {"rules": [{"label": - "Memory Usage", "metric": "memory_usage", "unit": "percent", "aggregate_function": - "avg", "operator": "gt", "threshold": 90, "dimension_filters": [{"label": "Node - Type", "dimension_label": "node_type", "operator": "eq", "value": "primary"}]}]}, - "alert_channels": [{"id": 10000, "label": "Read-Write Channel", "url": "/monitor/alert-channels/10000", - "type": "alert-channels"}], "trigger_conditions": {"criteria_condition": "ALL", - "polling_interval_seconds": 300, "evaluation_period_seconds": 300, "trigger_occurrences": - 1}, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "created_by": - "ychen123", "updated_by": "ychen123"}' - headers: - Access-Control-Allow-Credentials: - - "true" - Access-Control-Allow-Headers: - - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter - Access-Control-Allow-Methods: - - HEAD, GET, OPTIONS, POST, PUT, DELETE - Access-Control-Allow-Origin: - - '*' - Access-Control-Expose-Headers: - - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status - Akamai-Internal-Account: - - '*' - Cache-Control: - - max-age=0, no-cache, no-store - Connection: - - keep-alive - Content-Security-Policy: - - default-src 'none' - Content-Type: - - application/json - Expires: - - Mon, 22 Dec 2025 15:54:04 GMT - Pragma: - - no-cache - Strict-Transport-Security: - - max-age=31536000 - Vary: - - Authorization, X-Filter - - Accept-Encoding - X-Accepted-Oauth-Scopes: - - databases:read_only - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - DENY - - DENY - X-Oauth-Scopes: - - '*' - X-Ratelimit-Limit: - - "1840" - X-Xss-Protection: - - 1; mode=block - status: 200 OK - code: 200 - duration: "" -- request: - body: "" - form: {} - headers: - Accept: - - application/json - Content-Type: - - application/json - User-Agent: - - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/monitor/services/dbaas/alert-definitions/10622 - method: DELETE - response: - body: '{}' - headers: - Access-Control-Allow-Credentials: - - "true" - Access-Control-Allow-Headers: - - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter - Access-Control-Allow-Methods: - - HEAD, GET, OPTIONS, POST, PUT, DELETE - Access-Control-Allow-Origin: - - '*' - Access-Control-Expose-Headers: - - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status - Akamai-Internal-Account: - - '*' - Cache-Control: - - max-age=0, no-cache, no-store - Connection: - - keep-alive - Content-Length: - - "2" - Content-Security-Policy: - - default-src 'none' - Content-Type: - - application/json - Expires: - - Mon, 22 Dec 2025 15:54:05 GMT - Pragma: - - no-cache - Strict-Transport-Security: - - max-age=31536000 - Vary: - - Authorization, X-Filter - X-Accepted-Oauth-Scopes: - - databases:read_only - X-Content-Type-Options: - - nosniff - X-Frame-Options: - - DENY - - DENY - X-Oauth-Scopes: - - '*' - X-Ratelimit-Limit: - - "1840" - X-Xss-Protection: - - 1; mode=block - status: 200 OK - code: 200 - duration: "" diff --git a/test/integration/monitor_alert_definitions_test.go b/test/integration/monitor_alert_definitions_test.go index 3d4d7e9f5..90ded2122 100644 --- a/test/integration/monitor_alert_definitions_test.go +++ b/test/integration/monitor_alert_definitions_test.go @@ -15,7 +15,7 @@ const ( ) func TestMonitorAlertDefinition_smoke(t *testing.T) { - client, teardown := createTestClient(t, "fixtures/TestMonitorAlertDefinition_smoke") + client, teardown := createTestClient(t, "fixtures/TestMonitorAlertDefinition") defer teardown() // Get All Alert Definitions