Skip to content

Commit

Permalink
PMM-8019 Support partial updates of settings and other entities (#2705)
Browse files Browse the repository at this point in the history
* PMM-8019 Get rid of enable/disable flags in settings

* PMM-8019 Fixes

* PMM-8019 Fix

* PMM-8019 Cleanup

* PMM-8019 Fix tests

* PMM-8019 Fixes

* PMM-8019 Fix migrations order

* PMM-8019 Fix DB migrations

* PMM-8019 Fix tests

* PMM-8019 Update docs

* PMM-8019 Fix

* PMM-8019 Make check enabling toogle optional

* PMM-8019 Make role update params optional

* PMM-8019 Fix API tests

* PMM-8019 Use optional fields for tour flags

* PMM-8019 Use optionals instead of wrappers in API where it's possible

* PMM-8019 Comments

* PMM-8019 Fix tests

* PMM-8019 Fix linters

* PMM-8019 Fix
  • Loading branch information
artemgavrilov committed Dec 27, 2023
1 parent 5ee16cf commit 32ffd53
Show file tree
Hide file tree
Showing 87 changed files with 2,707 additions and 2,781 deletions.
5 changes: 3 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ linters:
enable-all: true
disable:
# keep the rules sorted alpahbetically
- deadcode # unmaintained, we leverage `unused`
- dupl # we can't avoid duplicating code
- execinquery # false positives only
- exhaustivestruct # too annoying
- exhaustruct # too many files to fix/nolint
- deadcode # unmaintained, we leverage `unused`
- dupl # we can't avoid duplicating code
- funlen # useless
- gochecknoglobals # mostly useless
- gochecknoinits # we use init functions
Expand All @@ -100,6 +100,7 @@ linters:
- maligned # deprecated
- nlreturn # too annoying
- nosnakecase # deprecated
- protogetter # we need direct access to proto fields
- rowserrcheck # disabled because of generics
- scopelint # too many false positives
- structcheck # replaced by unused
Expand Down
6 changes: 3 additions & 3 deletions agent/agents/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ func TestCacheErrors(t *testing.T) {
t.Parallel()
var err error
_, err = New(100, time.Second*100, 100, logrus.WithField("test", t.Name()))
assert.NotNil(t, err)
assert.Error(t, err) //nolint:testifylint

_, err = New([]float64{}, time.Second*100, 100, logrus.WithField("test", t.Name()))
assert.NotNil(t, err)
assert.Error(t, err) //nolint:testifylint

_, err = New(struct{}{}, time.Second*100, 100, logrus.WithField("test", t.Name()))
assert.NotNil(t, err)
assert.Error(t, err) //nolint:testifylint
})

t.Run("WrongTypeOnRefresh", func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions agent/utils/mongo_fix/mongo_fix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ func TestClientOptionsForDSN(t *testing.T) {
assert.Equal(t, err.Error(), tt.error)
} else {
assert.Empty(t, err)
assert.Equal(t, got.Auth.Username, tt.expectedUser)
assert.Equal(t, got.Auth.Password, tt.expectedPassword)
assert.Equal(t, tt.expectedUser, got.Auth.Username)
assert.Equal(t, tt.expectedPassword, got.Auth.Password)
}
})
}
Expand Down
3 changes: 1 addition & 2 deletions api-tests/management/alerting/alerting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ import (
)

// Note: Even though the Alerting service checks for alerting enabled or disabled before returning results
// we don't enable or disable Alerting explicit in our tests since it is enabled by default through
// DISABLE_ALERTING env var.
// we don't enable or disable Alerting explicit in our tests since it is enabled by default.
func TestRulesAPI(t *testing.T) {
t.Parallel()
client := alertingClient.Default.AlertingService
Expand Down
8 changes: 4 additions & 4 deletions api-tests/management/backup/backups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ func TestScheduleBackup(t *testing.T) {

body := backups.ChangeScheduledBackupBody{
ScheduledBackupID: backupRes.Payload.ScheduledBackupID,
Enabled: true,
CronExpression: "0 2 2 2 2",
Name: "test2",
Description: "test2",
Enabled: pointer.ToBool(true),
CronExpression: pointer.ToString("0 2 2 2 2"),
Name: pointer.ToString("test2"),
Description: pointer.ToString("test2"),
}
changeRes, err := client.ChangeScheduledBackup(&backups.ChangeScheduledBackupParams{
Body: body,
Expand Down
10 changes: 4 additions & 6 deletions api-tests/server/advisors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ func TestChangeSecurityChecks(t *testing.T) {
Body: security_checks.ChangeSecurityChecksBody{
Params: []*security_checks.ChangeSecurityChecksParamsBodyParamsItems0{
{
Name: check.Name,
Disable: !check.Disabled,
Enable: check.Disabled,
Name: check.Name,
Enable: pointer.ToBool(!check.Enabled),
},
},
},
Expand All @@ -156,7 +155,7 @@ func TestChangeSecurityChecks(t *testing.T) {

for _, c := range resp.Payload.Checks {
if c.Name == check.Name {
assert.Equal(t, !check.Disabled, c.Disabled)
assert.NotEqual(t, check.Enabled, c.Enabled)
break
}
}
Expand Down Expand Up @@ -248,8 +247,7 @@ func toggleAdvisorChecks(t *testing.T, enable bool) {

res, err := serverClient.Default.ServerService.ChangeSettings(&server_service.ChangeSettingsParams{
Body: server_service.ChangeSettingsBody{
EnableStt: enable,
DisableStt: !enable,
EnableStt: pointer.ToBool(enable),
},
Context: pmmapitests.Context,
})
Expand Down
10 changes: 6 additions & 4 deletions api-tests/server/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func restoreSettingsDefaults(t *testing.T) {

res, err := serverClient.Default.ServerService.ChangeSettings(&server.ChangeSettingsParams{
Body: server.ChangeSettingsBody{
EnableStt: true,
EnableTelemetry: true,
EnableAlerting: true,
EnableStt: pointer.ToBool(true),
EnableTelemetry: pointer.ToBool(true),
EnableAlerting: pointer.ToBool(true),
MetricsResolutions: &server.ChangeSettingsParamsBodyMetricsResolutions{
Hr: "5s",
Mr: "10s",
Expand All @@ -49,7 +49,9 @@ func restoreSettingsDefaults(t *testing.T) {
RareInterval: "280800s",
},
DataRetention: "2592000s",
AWSPartitions: []string{"aws"},
AWSPartitions: &server.ChangeSettingsParamsBodyAWSPartitions{
Values: []string{"aws"},
},
},
Context: pmmapitests.Context,
})
Expand Down
3 changes: 2 additions & 1 deletion api-tests/server/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"os"
"testing"

"github.com/AlekSi/pointer"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -56,7 +57,7 @@ func TestPlatform(t *testing.T) {
// Set the PMM address to localhost.
res, err := serverClient.ChangeSettings(&server.ChangeSettingsParams{
Body: server.ChangeSettingsBody{
PMMPublicAddress: "localhost",
PMMPublicAddress: pointer.ToString("localhost"),
},
Context: pmmapitests.Context,
})
Expand Down
Loading

0 comments on commit 32ffd53

Please sign in to comment.