Changes and fixes before the release (docs/small tweaks) (#750)
- update README.md with new docker instructions - update docs/configuration.md - update .github/workflows to have pinned action versions - gofmt events package - fix small bugs in CI scripts - reduce config options for internal/perf/monitor and config. A ring buffer is used to keep 1hr of entries at max 5s granularity. For long term stats use prometheus monitoring on /metrics Fixes #744
This commit is contained in:
@@ -18,10 +18,8 @@ models:
|
||||
assert.NoError(t, err)
|
||||
|
||||
// When performance section is missing, defaults should be applied
|
||||
assert.True(t, config.Performance.Enable)
|
||||
assert.Equal(t, 15*time.Second, config.Performance.Every)
|
||||
assert.Equal(t, 1*time.Hour, config.Performance.MaxAge)
|
||||
assert.Equal(t, 5*time.Minute, config.Performance.GC)
|
||||
assert.False(t, config.Performance.Disabled)
|
||||
assert.Equal(t, 5*time.Second, config.Performance.Every)
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_CustomValues(t *testing.T) {
|
||||
@@ -29,8 +27,6 @@ func TestPerformanceConfig_CustomValues(t *testing.T) {
|
||||
performance:
|
||||
enable: true
|
||||
every: 30s
|
||||
maxAge: 12h
|
||||
gc: 10m
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
@@ -38,16 +34,14 @@ models:
|
||||
config, err := LoadConfigFromReader(strings.NewReader(content))
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.True(t, config.Performance.Enable)
|
||||
assert.False(t, config.Performance.Disabled)
|
||||
assert.Equal(t, 30*time.Second, config.Performance.Every)
|
||||
assert.Equal(t, 12*time.Hour, config.Performance.MaxAge)
|
||||
assert.Equal(t, 10*time.Minute, config.Performance.GC)
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_Disabled(t *testing.T) {
|
||||
content := `
|
||||
performance:
|
||||
enable: false
|
||||
disabled: true
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
@@ -55,18 +49,15 @@ models:
|
||||
config, err := LoadConfigFromReader(strings.NewReader(content))
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.False(t, config.Performance.Enable)
|
||||
assert.True(t, config.Performance.Disabled)
|
||||
// Duration defaults should still apply
|
||||
assert.Equal(t, 15*time.Second, config.Performance.Every)
|
||||
assert.Equal(t, 1*time.Hour, config.Performance.MaxAge)
|
||||
assert.Equal(t, 5*time.Minute, config.Performance.GC)
|
||||
assert.Equal(t, 5*time.Second, config.Performance.Every)
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_PartialValues(t *testing.T) {
|
||||
content := `
|
||||
performance:
|
||||
every: 10s
|
||||
maxAge: 6h
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
@@ -75,58 +66,27 @@ models:
|
||||
assert.NoError(t, err)
|
||||
|
||||
// enable should default to true
|
||||
assert.True(t, config.Performance.Enable)
|
||||
assert.False(t, config.Performance.Disabled)
|
||||
assert.Equal(t, 10*time.Second, config.Performance.Every)
|
||||
assert.Equal(t, 6*time.Hour, config.Performance.MaxAge)
|
||||
// gc should use default
|
||||
assert.Equal(t, 5*time.Minute, config.Performance.GC)
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_InvalidEvery(t *testing.T) {
|
||||
content := `
|
||||
performance:
|
||||
every: 500ms
|
||||
every: 4s
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
`
|
||||
_, err := LoadConfigFromReader(strings.NewReader(content))
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "every must be at least 1s")
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_InvalidMaxAge(t *testing.T) {
|
||||
content := `
|
||||
performance:
|
||||
maxAge: 0s
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
`
|
||||
_, err := LoadConfigFromReader(strings.NewReader(content))
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "maxAge must be greater than 0")
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_InvalidGC(t *testing.T) {
|
||||
content := `
|
||||
performance:
|
||||
gc: 0s
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
`
|
||||
_, err := LoadConfigFromReader(strings.NewReader(content))
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "gc must be greater than 0")
|
||||
assert.Contains(t, err.Error(), "every must be at least 5s")
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_ComplexDurations(t *testing.T) {
|
||||
content := `
|
||||
performance:
|
||||
every: 1m30s
|
||||
maxAge: 2h10m
|
||||
gc: 1m
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
@@ -135,6 +95,4 @@ models:
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, 90*time.Second, config.Performance.Every)
|
||||
assert.Equal(t, (2*time.Hour)+(10*time.Minute), config.Performance.MaxAge)
|
||||
assert.Equal(t, 1*time.Minute, config.Performance.GC)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user