feat(event): Remove BOUNDARY_DEVELOPER_ENABLE_EVENTS env var
This commit is contained in:
1 parent
1af803780c
commit
4599e64cab
12 files changed
-79
No files matched your search
@@ -1,8 +1 @@
|
||||
package globals
|
||||
|
||||
const (
|
||||
// BOUNDARY_DEVELOPER_ENABLE_EVENTS defines an envvar that enables events.
|
||||
// Once this feature is generally available, then this envvar will be
|
||||
// deprecated and removed.
|
||||
BOUNDARY_DEVELOPER_ENABLE_EVENTS = "BOUNDARY_DEVELOPER_ENABLE_EVENTS"
|
||||
)
|
||||
@@ -916,9 +916,6 @@ func TestDb_LookupWhere(t *testing.T) {
|
||||
// TestDb_LookupNotFoundEvent validates that not found error events are suppressed when
|
||||
// LookupById and LookupWhere are called.
|
||||
func TestDb_LookupNotFoundEvent(t *testing.T) {
|
||||
// this test and its subtests cannot be run in parallel because of it's
|
||||
// dependency on the sysEventer
|
||||
event.TestEnableEventing(t, true)
|
||||
conn, _ := TestSetup(t, "postgres")
|
||||
TestCreateTables(t, conn)
|
||||
|
||||
|
||||
@@ -3,12 +3,9 @@ package event
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
@@ -170,11 +167,6 @@ func WriteError(ctx context.Context, caller Op, e error, opt ...Option) {
|
||||
// WithRequest, WithResponse, WithAuth, WithId, WithFlush and WithRequestInfo.
|
||||
// All other options are ignored.
|
||||
func WriteAudit(ctx context.Context, caller Op, opt ...Option) error {
|
||||
// TODO (jimlambrt) 6/2021: remove this feature flag envvar when events are
|
||||
// generally available.
|
||||
if !strings.EqualFold(os.Getenv(globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS), "true") {
|
||||
return nil
|
||||
}
|
||||
const op = "event.WriteAudit"
|
||||
if ctx == nil {
|
||||
return fmt.Errorf("%s: missing context: %w", op, ErrInvalidParameter)
|
||||
|
||||
@@ -261,8 +261,6 @@ func Test_EventerFromContext(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_WriteObservation(t *testing.T) {
|
||||
event.TestEnableEventing(t, true)
|
||||
|
||||
// this test and its subtests cannot be run in parallel because of it's
|
||||
// dependency on the sysEventer
|
||||
|
||||
@@ -505,7 +503,6 @@ func Test_WriteObservation(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Filtering(t *testing.T) {
|
||||
event.TestEnableEventing(t, true)
|
||||
testLock := &sync.Mutex{}
|
||||
testLogger := hclog.New(&hclog.LoggerOptions{
|
||||
Mutex: testLock,
|
||||
@@ -631,8 +628,6 @@ func testObservationJsonFromCtx(t *testing.T, ctx context.Context, caller event.
|
||||
}
|
||||
|
||||
func Test_WriteAudit(t *testing.T) {
|
||||
event.TestEnableEventing(t, true)
|
||||
|
||||
// this test and its subtests cannot be run in parallel because of it's
|
||||
// dependency on the sysEventer
|
||||
now := time.Now()
|
||||
@@ -970,8 +965,6 @@ func Test_WriteAudit(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_WriteError(t *testing.T) {
|
||||
event.TestEnableEventing(t, true)
|
||||
|
||||
// this test and its subtests cannot be run in parallel because of it's
|
||||
// dependency on the sysEventer
|
||||
now := time.Now()
|
||||
|
||||
@@ -4,12 +4,10 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-secure-stdlib/strutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -20,9 +18,6 @@ func TestEventer_Gating(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
// FIXME: Remove this when no longer needed:
|
||||
os.Setenv(globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS, "true")
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
eventerConfig := EventerConfig{
|
||||
AuditEnabled: true,
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/groups"
|
||||
"github.com/hashicorp/eventlogger"
|
||||
@@ -15,20 +14,6 @@ import (
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
|
||||
// TestEnableEventing will enable eventing via it's envvar
|
||||
// globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS
|
||||
func TestEnableEventing(t *testing.T, enable bool) {
|
||||
t.Helper()
|
||||
if enable {
|
||||
os.Setenv(globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS, "true")
|
||||
t.Cleanup(func() {
|
||||
defer os.Unsetenv(globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS)
|
||||
})
|
||||
} else {
|
||||
os.Unsetenv(globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS)
|
||||
}
|
||||
}
|
||||
|
||||
// TestGetEventerConfig is a test accessor for the eventer's config
|
||||
func TestGetEventerConfig(t *testing.T, e *Eventer) EventerConfig {
|
||||
t.Helper()
|
||||
|
||||
@@ -25,7 +25,6 @@ func TestSchedulerWorkflow(t *testing.T) {
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
wrapper := db.TestWrapper(t)
|
||||
iam.TestRepo(t, conn, wrapper)
|
||||
event.TestEnableEventing(t, true)
|
||||
testConfig := event.DefaultEventerConfig()
|
||||
testLock := &sync.Mutex{}
|
||||
testLogger := hclog.New(&hclog.LoggerOptions{
|
||||
@@ -108,7 +107,6 @@ func TestSchedulerCancelCtx(t *testing.T) {
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
wrapper := db.TestWrapper(t)
|
||||
iam.TestRepo(t, conn, wrapper)
|
||||
event.TestEnableEventing(t, true)
|
||||
testConfig := event.DefaultEventerConfig()
|
||||
testLock := &sync.Mutex{}
|
||||
testLogger := hclog.New(&hclog.LoggerOptions{
|
||||
@@ -158,7 +156,6 @@ func TestSchedulerInterruptedCancelCtx(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
kmsCache := kms.TestKms(t, conn, wrapper)
|
||||
iam.TestRepo(t, conn, wrapper)
|
||||
event.TestEnableEventing(t, true)
|
||||
testConfig := event.DefaultEventerConfig()
|
||||
testLock := &sync.Mutex{}
|
||||
testLogger := hclog.New(&hclog.LoggerOptions{
|
||||
@@ -260,7 +257,6 @@ func TestSchedulerJobProgress(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
kmsCache := kms.TestKms(t, conn, wrapper)
|
||||
iam.TestRepo(t, conn, wrapper)
|
||||
event.TestEnableEventing(t, true)
|
||||
testConfig := event.DefaultEventerConfig()
|
||||
testLock := &sync.Mutex{}
|
||||
testLogger := hclog.New(&hclog.LoggerOptions{
|
||||
@@ -369,7 +365,6 @@ func TestSchedulerMonitorLoop(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
kmsCache := kms.TestKms(t, conn, wrapper)
|
||||
iam.TestRepo(t, conn, wrapper)
|
||||
event.TestEnableEventing(t, true)
|
||||
testConfig := event.DefaultEventerConfig()
|
||||
testLock := &sync.Mutex{}
|
||||
testLogger := hclog.New(&hclog.LoggerOptions{
|
||||
@@ -435,7 +430,6 @@ func TestSchedulerFinalStatusUpdate(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
kmsCache := kms.TestKms(t, conn, wrapper)
|
||||
iam.TestRepo(t, conn, wrapper)
|
||||
event.TestEnableEventing(t, true)
|
||||
testConfig := event.DefaultEventerConfig()
|
||||
testLock := &sync.Mutex{}
|
||||
testLogger := hclog.New(&hclog.LoggerOptions{
|
||||
@@ -526,7 +520,6 @@ func TestSchedulerRunNow(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
kmsCache := kms.TestKms(t, conn, wrapper)
|
||||
iam.TestRepo(t, conn, wrapper)
|
||||
event.TestEnableEventing(t, true)
|
||||
testConfig := event.DefaultEventerConfig()
|
||||
testLock := &sync.Mutex{}
|
||||
testLogger := hclog.New(&hclog.LoggerOptions{
|
||||
|
||||
@@ -166,10 +166,6 @@ func Test_WrapWithOptionals(t *testing.T) {
|
||||
|
||||
func Test_WrapWithEventsHandler(t *testing.T) {
|
||||
// This cannot run in parallel because it relies on a pkg var common.privateNets
|
||||
|
||||
// this cannot run in parallel because it relies on envvar
|
||||
// globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS
|
||||
event.TestEnableEventing(t, true)
|
||||
wrapper := db.TestWrapper(t)
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
testKms := kms.TestKms(t, conn, wrapper)
|
||||
@@ -353,9 +349,6 @@ func Test_WrapWithEventsHandler(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_startGatedEvents(t *testing.T) {
|
||||
// this cannot run in parallel because it relies on envvar
|
||||
// globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS
|
||||
event.TestEnableEventing(t, true)
|
||||
testStartTime := time.Now()
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -412,9 +405,6 @@ func Test_startGatedEvents(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_flushGatedEvents(t *testing.T) {
|
||||
// this cannot run in parallel because it relies on envvar
|
||||
// globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS
|
||||
event.TestEnableEventing(t, true)
|
||||
testStartTime := time.Now()
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@@ -140,9 +140,6 @@ func TestAuthTokenAuthenticator(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestVerify_AuditEvent(t *testing.T) {
|
||||
// this cannot run in parallel because it relies on envvar
|
||||
// globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS
|
||||
event.TestEnableEventing(t, true)
|
||||
eventConfig := event.TestEventerConfig(t, "Test_Verify", event.TestWithAuditSink(t))
|
||||
testLock := &sync.Mutex{}
|
||||
testLogger := hclog.New(&hclog.LoggerOptions{
|
||||
|
||||
@@ -14,8 +14,6 @@ import (
|
||||
)
|
||||
|
||||
func TestWorkerWaitForNextSuccessfulStatusUpdate(t *testing.T) {
|
||||
// do not run using t.Parallel() since it relies on the sys eventer
|
||||
event.TestEnableEventing(t, true)
|
||||
testConfig := event.DefaultEventerConfig()
|
||||
testLock := &sync.Mutex{}
|
||||
testLogger := hclog.New(&hclog.LoggerOptions{
|
||||
|
||||
@@ -22,10 +22,6 @@ import (
|
||||
|
||||
// TestAuthenticate tests the api calls and the audit events it should produce
|
||||
func TestAuthenticate(t *testing.T) {
|
||||
// this cannot run in parallel because it relies on envvar
|
||||
// globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS
|
||||
event.TestEnableEventing(t, true)
|
||||
|
||||
assert, require := assert.New(t), require.New(t)
|
||||
eventConfig := event.TestEventerConfig(t, "TestAuthenticateAuditEntry", event.TestWithAuditSink(t))
|
||||
testLock := &sync.Mutex{}
|
||||
|
||||
@@ -24,10 +24,6 @@ import (
|
||||
const global = "global"
|
||||
|
||||
func TestCrud(t *testing.T) {
|
||||
// this cannot run in parallel because it relies on envvar
|
||||
// globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS
|
||||
event.TestEnableEventing(t, true)
|
||||
|
||||
assert, require := assert.New(t), require.New(t)
|
||||
eventConfig := event.TestEventerConfig(t, "TestCrud", event.TestWithAuditSink(t))
|
||||
testLock := &sync.Mutex{}
|
||||
@@ -253,10 +249,6 @@ func TestList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCustomMethods(t *testing.T) {
|
||||
// this cannot run in parallel because it relies on envvar
|
||||
// globals.BOUNDARY_DEVELOPER_ENABLE_EVENTS
|
||||
event.TestEnableEventing(t, true)
|
||||
|
||||
assert, require := assert.New(t), require.New(t)
|
||||
eventConfig := event.TestEventerConfig(t, "TestCrud", event.TestWithAuditSink(t))
|
||||
testLock := &sync.Mutex{}
|
||||
|
||||
Reference in new issue
Block a user