Skip to content

Commit

Permalink
remove v1 AM apis test
Browse files Browse the repository at this point in the history
Signed-off-by: alanprot <[email protected]>
  • Loading branch information
alanprot committed Apr 2, 2024
1 parent f5328df commit 1ef79fa
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 84 deletions.
16 changes: 1 addition & 15 deletions integration/alertmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand All @@ -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.
Expand Down
38 changes: 0 additions & 38 deletions integration/e2ecortex/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
30 changes: 0 additions & 30 deletions pkg/alertmanager/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/alertmanager/multitenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 1ef79fa

Please sign in to comment.