Skip to content

Commit

Permalink
PMM-12913 fix backup API tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Mar 15, 2024
1 parent 431cb46 commit 3d157e6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ jobs:
container_name: pmm-agent_pmm-server
environment:
- PMM_DEBUG=1
- ENABLE_TELEMETRY=0
- PERCONA_TEST_CHECKS_INTERVAL=10s
- PERCONA_TEST_PLATFORM_ADDRESS=https://check-dev.percona.com
- PERCONA_TEST_PLATFORM_PUBLIC_KEY=RWTg+ZmCCjt7O8eWeAmTLAqW+1ozUbpRSKSwNTmO+exlS5KEIPYWuYdX
Expand Down
12 changes: 6 additions & 6 deletions api-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# pmm-api-tests

API tests for PMM 2.x
API tests for PMM 3.x

# Setup Instructions

Make sure you have the latest Go version installed on your systems, execute the following steps
to set up API-tests in your local systems.

1. Run PMM Server. This can be done by running `make env-up` in the root (`pmm`) directory.
2. In the case below, `$PMM_SERVER_URL` should be replaced with a URL in format `http://USERNAME:PASSWORD@HOST`. For local development it's usually `http://admin:[email protected]`.
2. Replace `$PMM_SERVER_URL` with a URL in format `http://USERNAME:PASSWORD@HOST`. For local development it's usually `http://admin:[email protected]`.

# Usage

Expand All @@ -32,9 +32,9 @@ Run Docker container using the following command:
docker run -e PMM_SERVER_URL=**pmm-server-url** IMAGENAME
```

where `PMM_SERVER_URL` should be pointing to pmm-server.
where `PMM_SERVER_URL` should be pointing to a running PMM Server.

If pmm-server located locally:
If pmm-server is located locally:

- Use --network=host while running docker container or add both containers to the same docker network.
- Use the insecure url if you default to a self-generated certificate.
Expand All @@ -43,5 +43,5 @@ If pmm-server located locally:

All tests should follow these rules:

- Tests can work in parallel and in real system, so take into account that there might be records in database.
- Always revert changes made by test.
- Tests can work in parallel and on a real system, so take into account that there might be records in database.
- Always revert changes made by tests.
8 changes: 4 additions & 4 deletions api-tests/backup/backups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ func TestScheduleBackup(t *testing.T) {
require.NotNil(t, backup)

// Assert change
assert.Equal(t, body.Enabled, backup.Enabled)
assert.Equal(t, body.Name, backup.Name)
assert.Equal(t, body.Description, backup.Description)
assert.Equal(t, body.CronExpression, backup.CronExpression)
assert.Equal(t, pointer.GetBool(body.Enabled), backup.Enabled)
assert.Equal(t, pointer.GetString(body.Name), backup.Name)
assert.Equal(t, pointer.GetString(body.Description), backup.Description)
assert.Equal(t, pointer.GetString(body.CronExpression), backup.CronExpression)
assert.Equal(t, "backup_folder", backup.Folder)

_, err = client.RemoveScheduledBackup(&backups.RemoveScheduledBackupParams{
Expand Down
Empty file removed api-tests/pmm-api-tests-output.txt
Empty file.
8 changes: 3 additions & 5 deletions managed/services/grafana/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,10 @@ func (c *Client) CreateAlertRule(ctx context.Context, folderName, groupName stri
}

if err := c.do(ctx, "POST", fmt.Sprintf("/api/ruler/grafana/api/v1/rules/%s", folderName), "", authHeaders, body, nil); err != nil {
if err != nil {
if cErr, ok := errors.Cause(err).(*clientError); ok { //nolint:errorlint
return status.Error(codes.InvalidArgument, cErr.ErrorMessage)
}
return err
if cErr, ok := errors.Cause(err).(*clientError); ok { //nolint:errorlint
return status.Error(codes.InvalidArgument, cErr.ErrorMessage)
}
return err
}

return nil
Expand Down

0 comments on commit 3d157e6

Please sign in to comment.