Skip to content

Commit

Permalink
Add/modify test for bundle failure while discovery success.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pushpalanka committed Jul 3, 2024
1 parent fb9df05 commit 0f696aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions filters/openpolicyagent/openpolicyagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,15 @@ func (opa *OpenPolicyAgentInstance) Start(ctx context.Context, timeout time.Dura
// Register listener for "bundle" plugin
opa.manager.RegisterPluginStatusListener("bundlelistener", func(status map[string]*plugins.Status) {
if _, exists := status["bundle"]; exists {
registerBundleListenerOnce.Do(func() {
bundlePlugin := bundle.Lookup(opa.manager)
if bundlePlugin != nil {
bundlePlugin := bundle.Lookup(opa.manager)
if bundlePlugin != nil {
registerBundleListenerOnce.Do(func() {
bundlePlugin.Register("startuplistener", func(status bundle.Status) {
handleStatusErrors(status, failed, "bundle plugin")
})

}
})
})
}
}
})
defer opa.manager.UnregisterPluginStatusListener("bundlelistener")
Expand Down
4 changes: 2 additions & 2 deletions filters/openpolicyagent/openpolicyagent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func TestOpaEngineStartFailureWithTimeout(t *testing.T) {

err = engine.Start(ctx, cfg.startupTimeout)
assert.True(t, engine.stopped)
assert.Contains(t, err.Error(), "one or more open policy agent plugins failed to start in 1s")
assert.Contains(t, err.Error(), "bundle plugin failed: bundle_error")
}

func TestOpaActivationSuccessWithDiscovery(t *testing.T) {
Expand Down Expand Up @@ -339,7 +339,7 @@ func TestOpaActivationTimeOutWithDiscoveryPointingWrongBundle(t *testing.T) {

instance, err := registry.NewOpenPolicyAgentInstance("test", *cfg, "testfilter")
assert.Nil(t, instance)
assert.Contains(t, err.Error(), "one or more open policy agent plugins failed to start in 1s with error: context deadline exceeded")
assert.Contains(t, err.Error(), "bundle plugin failed: bundle_error")
assert.Equal(t, 0, len(registry.instances))
}

Expand Down

0 comments on commit 0f696aa

Please sign in to comment.