Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: generate Go boilerplate to disable logging in tests. #1889

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

i4ki
Copy link
Contributor

@i4ki i4ki commented Sep 26, 2024

What this PR does / why we need it:

By default we disable logging by calling zerolog.SetGlobalLevel(zerolog.Disabled) in the init() function of a test file. There's no consistency and sometimes it's done inside an specific test file and sometimes this is done in a separate loglevel_test.go file.

This PR generates this boilerplate file using Terramate, with the additional feature that you can easily re-enable the logging in a specific package by just setting a global.enable_test_logging = true in a specific directory.

Which issue(s) this PR fixes:

none

Special notes for your reviewer:

Does this PR introduce a user-facing change?

no

@i4ki i4ki requested review from a team as code owners September 26, 2024 00:49
Copy link

github-actions bot commented Sep 26, 2024

2024/10/24 13:39:28 Terraform detected version: 1.9.7
toolsetPath: /tmp/cmd-terramate-test-4045129969
=== RUN   TestInteropCloudSyncPreview
=== RUN   TestInteropCloudSyncPreview/preview:_basic-drift
    interoperability_test.go:46: using GITHUB_EVENT_FILE=/home/runner/work/_temp/_github_workflow/event.json
=== RUN   TestInteropCloudSyncPreview/preview:_basic-drift-uppercase-id
    interoperability_test.go:46: using GITHUB_EVENT_FILE=/home/runner/work/_temp/_github_workflow/event.json
--- PASS: TestInteropCloudSyncPreview (12.84s)
    --- PASS: TestInteropCloudSyncPreview/preview:_basic-drift (6.65s)
    --- PASS: TestInteropCloudSyncPreview/preview:_basic-drift-uppercase-id (6.18s)
=== RUN   TestInteropSyncDeployment
=== RUN   TestInteropSyncDeployment/deployment:_empty
=== RUN   TestInteropSyncDeployment/deployment:_empty-uppercase-id
--- PASS: TestInteropSyncDeployment (37.41s)
    --- PASS: TestInteropSyncDeployment/deployment:_empty (18.91s)
    --- PASS: TestInteropSyncDeployment/deployment:_empty-uppercase-id (18.50s)
=== RUN   TestInteropDrift
=== RUN   TestInteropDrift/drift:_basic-drift
=== RUN   TestInteropDrift/drift:_basic-drift-uppercase-id
--- PASS: TestInteropDrift (61.09s)
    --- PASS: TestInteropDrift/drift:_basic-drift (30.61s)
    --- PASS: TestInteropDrift/drift:_basic-drift-uppercase-id (30.48s)
PASS
ok  	github.com/terramate-io/terramate/e2etests/cloud/interop	172.516s

@i4ki i4ki force-pushed the i4k-generate-log-disabling branch 2 times, most recently from 25e6f9d to 0751458 Compare September 26, 2024 01:03
Copy link

github-actions bot commented Sep 26, 2024

Preview of ubuntu-focal/go1.21 tests in 454eee3

🔍 View Details on Terramate Cloud

.
benchmarks/changed
cloud
cloud/deployment
cloud/drift
cloud/preview
cloud/stack
cloud/testserver
cloud/testserver/cloudstore
cmd/terramate/cli/cliconfig
cmd/terramate/cli/github
cmd/terramate/cli/gitlab
cmd/terramate/cli/out
config
config/filter
errors
event
fs
generate
generate/genfile
generate/genhcl
git
globals
hcl
hcl/ast
hcl/eval
hcl/fmt
hcl/info
ls
modvendor/download
printer
project
run
run/dag
scheduler
stack
stack/trigger
stdlib
test
test/hclwrite
test/ls
test/sandbox
tf
tg
versions
e2etests/cloud
e2etests/core

Copy link

github-actions bot commented Sep 26, 2024

metric: time/op
ChangeDetection-4: old 3.96ms ± 4%: new 4.06ms ± 5%: delta: 2.65%
ChangeDetectionTFAndTG-4: old 12.6ms ± 2%: new 12.9ms ± 4%: delta: 2.69%
CloudReadLines-4: old 1.02ms ± 4%: new 1.01ms ± 5%: delta: 0.00%
CloudReadLine-4: old 7.20ms ± 2%: new 7.25ms ± 2%: delta: 0.75%
ListFiles-4: old 80.5µs ± 1%: new 80.1µs ± 1%: delta: -0.46%
Generate-4: old 1.55s ± 2%: new 1.56s ± 3%: delta: 0.00%
GenerateRegex-4: old 1.06s ± 4%: new 1.05s ± 3%: delta: 0.00%
TokensForExpressionComplex-4: old 1.25ms ± 1%: new 1.25ms ± 0%: delta: 0.00%
TokensForExpressionPlainStringNoNewline-4: old 789ns ± 1%: new 788ns ± 1%: delta: 0.00%
TokensForExpressionStringWith100Newlines-4: old 23.7µs ± 1%: new 23.7µs ± 1%: delta: 0.00%
TokensForExpressionObjectWith100KeysWithNumberValues-4: old 1.45ms ± 1%: new 1.45ms ± 1%: delta: 0.00%
TokensForExpression-4: old 1.26ms ± 0%: new 1.26ms ± 2%: delta: 0.00%
PartialEvalComplex-4: old 541µs ± 1%: new 537µs ± 1%: delta: -0.89%
PartialEvalSmallString-4: old 3.91µs ± 0%: new 3.87µs ± 0%: delta: -0.82%
PartialEvalHugeString-4: old 1.91ms ± 1%: new 1.90ms ± 1%: delta: -0.46%
PartialEvalHugeInterpolatedString-4: old 4.94ms ± 1%: new 4.89ms ± 1%: delta: -0.97%
PartialEvalObject-4: old 27.3µs ± 2%: new 26.6µs ± 1%: delta: -2.57%
TmAllTrueLiteralList-4: old 619µs ± 0%: new 616µs ± 1%: delta: -0.42%
TmAllTrueFuncall-4: old 20.3µs ± 1%: new 20.3µs ± 1%: delta: -0.42%
TmAnyTrueLiteralList-4: old 4.88ms ± 1%: new 4.86ms ± 0%: delta: -0.35%
TmAnyTrueFuncall-4: old 20.7µs ± 0%: new 20.8µs ± 2%: delta: 0.79%
TmTernary-4: old 2.51µs ± 0%: new 2.52µs ± 1%: delta: 0.65%
TmTryUnknownFunc-4: old 2.28µs ± 0%: new 2.26µs ± 0%: delta: -0.71%
TmTryUnknownVariable-4: old 2.18µs ± 1%: new 2.19µs ± 1%: delta: 0.55%
TmTryUnknownObjectKey-4: old 2.49µs ± 1%: new 2.51µs ± 2%: delta: 0.75%
metric: alloc/op
ChangeDetection-4: old 357kB ± 0%: new 357kB ± 0%: delta: 0.00%
ChangeDetectionTFAndTG-4: old 4.80MB ± 0%: new 4.80MB ± 0%: delta: 0.00%
CloudReadLines-4: old 3.12MB ± 0%: new 3.12MB ± 0%: delta: 0.00%
CloudReadLine-4: old 3.37MB ± 0%: new 3.37MB ± 0%: delta: 0.00%
ListFiles-4: old 27.6kB ± 0%: new 27.6kB ± 0%: delta: 0.00%
Generate-4: old 2.24GB ± 0%: new 2.24GB ± 0%: delta: 0.00%
GenerateRegex-4: old 926MB ± 0%: new 926MB ± 0%: delta: 0.00%
TokensForExpressionComplex-4: old 394kB ± 0%: new 394kB ± 0%: delta: 0.00%
TokensForExpressionPlainStringNoNewline-4: old 512B ± 0%: new 512B ± 0%: delta: 0.00%
TokensForExpressionStringWith100Newlines-4: old 12.5kB ± 0%: new 12.5kB ± 0%: delta: 0.00%
TokensForExpressionObjectWith100KeysWithNumberValues-4: old 395kB ± 0%: new 395kB ± 0%: delta: 0.00%
TokensForExpression-4: old 394kB ± 0%: new 394kB ± 0%: delta: 0.00%
PartialEvalComplex-4: old 361kB ± 0%: new 361kB ± 0%: delta: 0.00%
PartialEvalSmallString-4: old 1.95kB ± 0%: new 1.95kB ± 0%: delta: 0.00%
PartialEvalHugeString-4: old 196kB ± 0%: new 196kB ± 0%: delta: 0.00%
PartialEvalHugeInterpolatedString-4: old 4.31MB ± 0%: new 4.31MB ± 0%: delta: 0.00%
PartialEvalObject-4: old 19.4kB ± 0%: new 19.4kB ± 0%: delta: 0.00%
TmAllTrueLiteralList-4: old 321kB ± 0%: new 321kB ± 0%: delta: 0.00%
TmAllTrueFuncall-4: old 10.6kB ± 0%: new 10.6kB ± 0%: delta: 0.00%
TmAnyTrueLiteralList-4: old 2.09MB ± 0%: new 2.09MB ± 0%: delta: -0.00%
TmAnyTrueFuncall-4: old 10.7kB ± 0%: new 10.7kB ± 0%: delta: 0.00%
TmTernary-4: old 1.18kB ± 0%: new 1.18kB ± 0%: delta: 0.00%
TmTryUnknownFunc-4: old 784B ± 0%: new 784B ± 0%: delta: 0.00%
TmTryUnknownVariable-4: old 768B ± 0%: new 768B ± 0%: delta: 0.00%
TmTryUnknownObjectKey-4: old 952B ± 0%: new 952B ± 0%: delta: 0.00%
metric: allocs/op
ChangeDetection-4: old 2.43k ± 0%: new 2.43k ± 0%: delta: 0.01%
ChangeDetectionTFAndTG-4: old 33.6k ± 0%: new 33.6k ± 0%: delta: 0.00%
CloudReadLines-4: old 5.54k ± 0%: new 5.54k ± 0%: delta: 0.00%
CloudReadLine-4: old 60.0k ± 0%: new 60.0k ± 0%: delta: 0.00%
ListFiles-4: old 335 ± 0%: new 335 ± 0%: delta: 0.00%
Generate-4: old 25.7M ± 0%: new 25.7M ± 0%: delta: 0.00%
GenerateRegex-4: old 18.4M ± 0%: new 18.4M ± 0%: delta: 0.00%
TokensForExpressionComplex-4: old 4.83k ± 0%: new 4.83k ± 0%: delta: 0.00%
TokensForExpressionPlainStringNoNewline-4: old 20.0 ± 0%: new 20.0 ± 0%: delta: 0.00%
TokensForExpressionStringWith100Newlines-4: old 227 ± 0%: new 227 ± 0%: delta: 0.00%
TokensForExpressionObjectWith100KeysWithNumberValues-4: old 3.19k ± 0%: new 3.19k ± 0%: delta: -0.01%
TokensForExpression-4: old 4.83k ± 0%: new 4.83k ± 0%: delta: 0.00%
PartialEvalComplex-4: old 3.78k ± 0%: new 3.78k ± 0%: delta: 0.00%
PartialEvalSmallString-4: old 26.0 ± 0%: new 26.0 ± 0%: delta: 0.00%
PartialEvalHugeString-4: old 38.0 ± 0%: new 38.0 ± 0%: delta: 0.00%
PartialEvalHugeInterpolatedString-4: old 26.1k ± 0%: new 26.1k ± 0%: delta: 0.00%
PartialEvalObject-4: old 183 ± 0%: new 183 ± 0%: delta: 0.00%
TmAllTrueLiteralList-4: old 5.94k ± 0%: new 5.94k ± 0%: delta: 0.00%
TmAllTrueFuncall-4: old 275 ± 0%: new 275 ± 0%: delta: 0.00%
TmAnyTrueLiteralList-4: old 59.6k ± 0%: new 59.6k ± 0%: delta: 0.00%
TmAnyTrueFuncall-4: old 277 ± 0%: new 277 ± 0%: delta: 0.00%
TmTernary-4: old 27.0 ± 0%: new 27.0 ± 0%: delta: 0.00%
TmTryUnknownFunc-4: old 21.0 ± 0%: new 21.0 ± 0%: delta: 0.00%
TmTryUnknownVariable-4: old 20.0 ± 0%: new 20.0 ± 0%: delta: 0.00%
TmTryUnknownObjectKey-4: old 23.0 ± 0%: new 23.0 ± 0%: delta: 0.00%

Copy link

github-actions bot commented Sep 26, 2024

Preview of macos-ventura/go1.21 tests in 454eee3

🔍 View Details on Terramate Cloud

.
benchmarks/changed
cloud
cloud/deployment
cloud/drift
cloud/preview
cloud/stack
cloud/testserver
cloud/testserver/cloudstore
cmd/terramate/cli/cliconfig
cmd/terramate/cli/github
cmd/terramate/cli/gitlab
cmd/terramate/cli/out
config
config/filter
errors
event
fs
generate
generate/genfile
generate/genhcl
git
globals
hcl
hcl/ast
hcl/eval
hcl/fmt
hcl/info
ls
modvendor/download
printer
project
run
run/dag
scheduler
stack
stack/trigger
stdlib
test
test/hclwrite
test/ls
test/sandbox
tf
tg
versions
e2etests/cloud
e2etests/core

@i4ki i4ki force-pushed the i4k-generate-log-disabling branch from 0751458 to 2753c6a Compare September 26, 2024 15:23
@i4ki i4ki force-pushed the i4k-generate-log-disabling branch from 2753c6a to bae9481 Compare September 27, 2024 08:23
@i4ki i4ki marked this pull request as draft September 27, 2024 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant