mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
plugins/logs: Add test to check upload size limit on reconfig
This change adds a test to check the upload limit is updated when the log plugin is reconfigured. Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
This commit is contained in:
@@ -1007,6 +1007,49 @@ func TestPluginReconfigure(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPluginReconfigureUploadSizeLimit(t *testing.T) {
|
||||
|
||||
ctx := context.Background()
|
||||
limit := int64(300)
|
||||
|
||||
fixture := newTestFixture(t, func(c *Config) {
|
||||
c.Reporting.UploadSizeLimitBytes = &limit
|
||||
})
|
||||
|
||||
defer fixture.server.stop()
|
||||
|
||||
if err := fixture.plugin.Start(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ensurePluginState(t, fixture.plugin, plugins.StateOK)
|
||||
|
||||
if fixture.plugin.enc.limit != limit {
|
||||
t.Fatalf("Expected upload size limit %v but got %v", limit, fixture.plugin.enc.limit)
|
||||
}
|
||||
|
||||
newLimit := int64(600)
|
||||
|
||||
pluginConfig := []byte(fmt.Sprintf(`{
|
||||
"service": "example",
|
||||
"reporting": {
|
||||
"upload_size_limit_bytes": %v,
|
||||
}
|
||||
}`, newLimit))
|
||||
|
||||
config, _ := ParseConfig(pluginConfig, fixture.manager.Services(), nil)
|
||||
|
||||
fixture.plugin.Reconfigure(ctx, config)
|
||||
ensurePluginState(t, fixture.plugin, plugins.StateOK)
|
||||
|
||||
fixture.plugin.Stop(ctx)
|
||||
ensurePluginState(t, fixture.plugin, plugins.StateNotReady)
|
||||
|
||||
if fixture.plugin.enc.limit != newLimit {
|
||||
t.Fatalf("Expected upload size limit %v but got %v", newLimit, fixture.plugin.enc.limit)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPluginMasking(t *testing.T) {
|
||||
tests := []struct {
|
||||
note string
|
||||
|
||||
Reference in New Issue
Block a user