Skip to content

Commit

Permalink
Enabling Debug level logs in tests (#947)
Browse files Browse the repository at this point in the history
* Now ticking the debug box in GHA will show Debug logs in GHA too.
  • Loading branch information
AnomalRoil committed Oct 3, 2022
1 parent 883cabc commit 2086f47
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Build
env:
DRAND_TEST_LOGS: "${{ runner.debug == '1' && 'DEBUG' || 'INFO' }}"
run: |
export PATH=$PATH:$(go env GOPATH)/bin
make drand
Expand All @@ -54,8 +56,12 @@ jobs:
${{ runner.os }}-go-
- run: go get -v -t -d ./...
- name: Unit tests
env:
DRAND_TEST_LOGS: "${{ runner.debug == '1' && 'DEBUG' || 'INFO' }}"
run: make test-unit
- name: Integration tests
env:
DRAND_TEST_LOGS: "${{ runner.debug == '1' && 'DEBUG' || 'INFO' }}"
run: make test-integration

test_unchained:
Expand All @@ -77,8 +83,12 @@ jobs:
${{ runner.os }}-go-
- run: go get -v -t -d ./...
- name: Unit tests
env:
DRAND_TEST_LOGS: "${{ runner.debug == '1' && 'DEBUG' || 'INFO' }}"
run: SCHEME_ID=pedersen-bls-unchained make test-unit
- name: Integration tests
env:
DRAND_TEST_LOGS: "${{ runner.debug == '1' && 'DEBUG' || 'INFO' }}"
run: SCHEME_ID=pedersen-bls-unchained make test-integration

coverage:
Expand All @@ -99,4 +109,6 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- run: make coverage
env:
DRAND_TEST_LOGS: "${{ runner.debug == '1' && 'DEBUG' || 'INFO' }}"
- run: bash <(curl -s https://codecov.io/bash)
13 changes: 11 additions & 2 deletions core/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ type DrandTestScenario struct {
// to delete at the end of the test. As well, it returns a public grpc
// client that can reach any drand node.
// Deprecated: do not use
//
//nolint:funlen
func BatchNewDrand(t *testing.T, n int, insecure bool, sch scheme.Scheme, beaconID string, opts ...ConfigOption) (
daemons []*DrandDaemon, drands []*BeaconProcess, group *key.Group, dir string, certPaths []string,
) {
Expand Down Expand Up @@ -138,6 +140,13 @@ func BatchNewDrand(t *testing.T, n int, insecure bool, sch scheme.Scheme, beacon
}
}

logLevel := log.LogInfo
debugEnv, isDebug := os.LookupEnv("DRAND_TEST_LOGS")
if isDebug && debugEnv == "DEBUG" {
t.Log("Enabling LogDebug logs")
logLevel = log.LogDebug
}

for i := 0; i < n; i++ {
s := test.NewKeyStore()

Expand All @@ -156,7 +165,7 @@ func BatchNewDrand(t *testing.T, n int, insecure bool, sch scheme.Scheme, beacon

confOptions = append(confOptions,
WithControlPort(ports[i]),
WithLogLevel(log.LogInfo, false))
WithLogLevel(logLevel, false))
// add options in last so it overwrites the default
confOptions = append(confOptions, opts...)

Expand Down Expand Up @@ -471,7 +480,7 @@ func (d *DrandTestScenario) CheckPublicBeacon(nodeAddress string, newGroup bool)
// SetupNewNodes creates new additional nodes that can participate during the resharing
func (d *DrandTestScenario) SetupNewNodes(t *testing.T, newNodes int) []*MockNode {
newDaemons, newDrands, _, newDir, newCertPaths := BatchNewDrand(d.t, newNodes, false, d.scheme, d.beaconID,
WithCallOption(grpc.WaitForReady(false)), WithLogLevel(log.LogInfo, false))
WithCallOption(grpc.WaitForReady(false)))
d.newCertPaths = newCertPaths
d.newDir = newDir
d.newNodes = make([]*MockNode, newNodes)
Expand Down

0 comments on commit 2086f47

Please sign in to comment.