Skip to content

Commit

Permalink
fix: validate topology processor interval (#2076)
Browse files Browse the repository at this point in the history
* validate interval

* fix test
  • Loading branch information
colelaven authored Dec 19, 2024
1 parent 0c80959 commit 669da71
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions processor/topologyprocessor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func (cfg Config) Validate() error {
return nil
}

if cfg.Interval < 10*time.Second {
return errors.New("`interval` must be at least 10 seconds")
}

if cfg.Configuration == "" {
return errors.New("`configuration` must be specified")
}
Expand Down
13 changes: 13 additions & 0 deletions processor/topologyprocessor/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package topologyprocessor

import (
"testing"
"time"

"github.com/stretchr/testify/require"
)
Expand All @@ -26,6 +27,18 @@ func TestConfigValidate(t *testing.T) {
require.NoError(t, err)
})

t.Run("interval too low", func(t *testing.T) {
cfg := Config{
Enabled: true,
Interval: 8 * time.Second,
AccountID: "myacct",
Configuration: "myConfig",
OrganizationID: "myorg",
}
err := cfg.Validate()
require.Error(t, err)
})

t.Run("Empty configuration", func(t *testing.T) {
cfg := Config{
Enabled: true,
Expand Down

0 comments on commit 669da71

Please sign in to comment.