Skip to content

Commit

Permalink
feat(plc4go/spi): added env test util option for traceExecutorWorkers
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Jun 19, 2023
1 parent ddda58b commit 9a21a7e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions plc4go/spi/testutils/TestUtils.go
Expand Up @@ -114,13 +114,20 @@ func TestContext(t *testing.T) context.Context {
return ctx
}

var highLogPrecision bool
var (
highLogPrecision bool
traceExecutorWorkers bool
)

func init() {
highLogPrecision = os.Getenv("PLC4X_TEST_HIGH_TEST_LOG_PRECISION") == "true"
if highLogPrecision {
zerolog.TimeFieldFormat = time.RFC3339Nano
}
traceExecutorWorkers = true
if traceExecutorWorkersEnv := os.Getenv("PLC4X_TEST_TRACE_EXECUTOR_WORKERS"); traceExecutorWorkersEnv != "" {
traceExecutorWorkers = traceExecutorWorkersEnv == "true"
}
}

// ProduceTestingLogger produces a logger which redirects to testing.T
Expand Down Expand Up @@ -153,15 +160,14 @@ func ProduceTestingLogger(t *testing.T) zerolog.Logger {

// EnrichOptionsWithOptionsForTesting appends options useful for testing to config.WithOption s
func EnrichOptionsWithOptionsForTesting(t *testing.T, _options ...options.WithOption) []options.WithOption {
traceWorkers := true
if extractedTraceWorkers, found := options.ExtractTracerWorkers(_options...); found {
traceWorkers = extractedTraceWorkers
traceExecutorWorkers = extractedTraceWorkers
}
// TODO: apply to other options like above
return append(_options,
options.WithCustomLogger(ProduceTestingLogger(t)),
options.WithPassLoggerToModel(true),
options.WithExecutorOptionTracerWorkers(traceWorkers),
options.WithExecutorOptionTracerWorkers(traceExecutorWorkers),
)
}

Expand Down

0 comments on commit 9a21a7e

Please sign in to comment.