diff --git a/integration/alertmanager_test.go b/integration/alertmanager_test.go index dfd60c8897..2ab05bbdca 100644 --- a/integration/alertmanager_test.go +++ b/integration/alertmanager_test.go @@ -70,7 +70,7 @@ func TestAlertmanager(t *testing.T) { assertServiceMetricsPrefixes(t, AlertManager, alertmanager) // Test compression by inspecting the response Headers - req, err := http.NewRequest("GET", fmt.Sprintf("http://%s/api/v1/alerts", alertmanager.HTTPEndpoint()), nil) + req, err := http.NewRequest("GET", fmt.Sprintf("http://%s/api/v2/alerts", alertmanager.HTTPEndpoint()), nil) require.NoError(t, err) req.Header.Set("X-Scope-OrgID", "user-1") @@ -487,18 +487,6 @@ func TestAlertmanagerSharding(t *testing.T) { e2e.SkipMissingMetrics)) } - // Endpoint: GET /v1/alerts - { - // Reads will query at least two replicas and merge the results. - // Therefore, the alerts we posted should always be visible. - - for _, c := range clients { - list, err := c.GetAlertsV1(context.Background()) - require.NoError(t, err) - assert.ElementsMatch(t, []string{"alert_1", "alert_2", "alert_3"}, alertNames(list)) - } - } - // Endpoint: GET /v2/alerts { for _, c := range clients { @@ -525,8 +513,6 @@ func TestAlertmanagerSharding(t *testing.T) { require.Contains(t, groups, "group_2") assert.ElementsMatch(t, []string{"alert_3"}, alertNames(groups["group_2"])) } - - // Note: /v1/alerts/groups does not exist. } // Check the alerts were eventually written to every replica. diff --git a/integration/e2ecortex/client.go b/integration/e2ecortex/client.go index 62c7e0d436..b926073f8f 100644 --- a/integration/e2ecortex/client.go +++ b/integration/e2ecortex/client.go @@ -729,44 +729,6 @@ func (c *Client) SendAlertToAlermanager(ctx context.Context, alert *model.Alert) return nil } -func (c *Client) GetAlertsV1(ctx context.Context) ([]model.Alert, error) { - u := c.alertmanagerClient.URL("api/prom/api/v1/alerts", nil) - - req, err := http.NewRequest(http.MethodGet, u.String(), nil) - if err != nil { - return nil, fmt.Errorf("error creating request: %v", err) - } - - resp, body, err := c.alertmanagerClient.Do(ctx, req) - if err != nil { - return nil, err - } - - if resp.StatusCode == http.StatusNotFound { - return nil, ErrNotFound - } - - if resp.StatusCode/100 != 2 { - return nil, fmt.Errorf("getting alerts failed with status %d and error %v", resp.StatusCode, string(body)) - } - - type response struct { - Status string `json:"status"` - Data []model.Alert `json:"data"` - } - - decoded := &response{} - if err := json.Unmarshal(body, decoded); err != nil { - return nil, err - } - - if decoded.Status != "success" { - return nil, fmt.Errorf("unexpected response status '%s'", decoded.Status) - } - - return decoded.Data, nil -} - func (c *Client) GetAlertsV2(ctx context.Context) ([]model.Alert, error) { u := c.alertmanagerClient.URL("api/prom/api/v2/alerts", nil) diff --git a/pkg/alertmanager/distributor_test.go b/pkg/alertmanager/distributor_test.go index ddda42749f..beb2277e74 100644 --- a/pkg/alertmanager/distributor_test.go +++ b/pkg/alertmanager/distributor_test.go @@ -85,16 +85,6 @@ func TestDistributor_DistributeRequest(t *testing.T) { expStatusCode: http.StatusInternalServerError, expectedTotalCalls: 3, route: "/alerts", - }, { - name: "Read /v1/alerts is sent to 3 AMs", - numAM: 5, - numHappyAM: 5, - replicationFactor: 3, - isRead: true, - expStatusCode: http.StatusOK, - expectedTotalCalls: 3, - route: "/v1/alerts", - responseBody: []byte(`{"status":"success","data":[]}`), }, { name: "Read /v2/alerts is sent to 3 AMs", numAM: 5, @@ -133,16 +123,6 @@ func TestDistributor_DistributeRequest(t *testing.T) { expectedTotalCalls: 0, headersNotPreserved: true, route: "/alerts/groups", - }, { - name: "Read /v1/silences is sent to 3 AMs", - numAM: 5, - numHappyAM: 5, - replicationFactor: 3, - isRead: true, - expStatusCode: http.StatusOK, - expectedTotalCalls: 3, - route: "/v1/silences", - responseBody: []byte(`{"status":"success","data":[]}`), }, { name: "Read /v2/silences is sent to 3 AMs", numAM: 5, @@ -161,16 +141,6 @@ func TestDistributor_DistributeRequest(t *testing.T) { expStatusCode: http.StatusOK, expectedTotalCalls: 1, route: "/silences", - }, { - name: "Read /v1/silence/id is sent to 3 AMs", - numAM: 5, - numHappyAM: 5, - replicationFactor: 3, - isRead: true, - expStatusCode: http.StatusOK, - expectedTotalCalls: 3, - route: "/v1/silence/id", - responseBody: []byte(`{"status":"success","data":{"id":"aaa","updatedAt":"2020-01-01T00:00:00Z"}}`), }, { name: "Read /v2/silence/id is sent to 3 AMs", numAM: 5, diff --git a/pkg/alertmanager/multitenant_test.go b/pkg/alertmanager/multitenant_test.go index a50113afbe..5fa5635350 100644 --- a/pkg/alertmanager/multitenant_test.go +++ b/pkg/alertmanager/multitenant_test.go @@ -529,7 +529,7 @@ receivers: require.NoError(t, err) // Push an alert. - req := httptest.NewRequest(http.MethodPost, cfg.ExternalURL.String()+"/api/v1/alerts", bytes.NewReader(alertsPayload)) + req := httptest.NewRequest(http.MethodPost, cfg.ExternalURL.String()+"/api/v2/alerts", bytes.NewReader(alertsPayload)) req.Header.Set("content-type", "application/json") reqCtx := user.InjectOrgID(req.Context(), userID) {