Skip to content

Commit

Permalink
store test results for easier ci viewing (#333)
Browse files Browse the repository at this point in the history
store test results for easier ci viewing
different job for coverage
relaxed timing

Co-authored-by: nikkolasg <nikkolasg@gmail.com>
Co-authored-by: Nicolas Gailly <nikkolasg@users.noreply.github.com>
  • Loading branch information
3 people committed May 15, 2020
1 parent 07c732b commit 2283204
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
25 changes: 22 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,29 @@ jobs:
steps:
- checkout
- run: go get -v -t -d ./...
- run: make test-unit
- run: make test-unit-cover
- run: go get github.com/jstemmer/go-junit-report
- run:
name: Unit tests
command: |
mkdir /tmp/test-results
trap "go-junit-report </tmp/test-results/go-test.out > /tmp/test-results/go-test-report.xml" EXIT
make test-unit | tee /tmp/test-results/go-test.out
- run: make test-integration
- store_test_results:
path: /tmp/test-results
coverage:
working_directory: /go/src/github.com/drand/drand
docker:
# specify the version
- image: circleci/golang:latest
environment:
# special env for tests to wait a bit longer between phases
CIRCLE_CI: on
steps:
- checkout
- run: go get -v -t -d ./...
- run: make test-unit-cover
- run: bash <(curl -s https://codecov.io/bash)

deploy:
docker:
- image: circleci/golang:latest
Expand Down Expand Up @@ -55,6 +73,7 @@ workflows:
build-deploy:
jobs:
- build
- coverage
- deploy:
requires:
- build
Expand Down
6 changes: 4 additions & 2 deletions beacon/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func checkWait(counter *sync.WaitGroup) {
case <-doneCh:
break

case <-time.After(3 * time.Second):
case <-time.After(20 * time.Second):
fmt.Println(" _------------- OUTDATED ----------------")
panic("outdated beacon time")
}
Expand Down Expand Up @@ -392,7 +392,9 @@ func TestBeaconSync(t *testing.T) {

// move clock to genesis time
fmt.Printf("\n\n --- BEFORE GENESIS --- \n\n")
doRound(n, genesisOffset)
now := bt.time.Now().Unix()
toMove := genesisTime - now
doRound(n, time.Duration(toMove)*time.Second)
fmt.Printf("\n\n --- AFTER GENESIS --- \n\n")
// do some rounds
for i := 0; i < 2; i++ {
Expand Down
26 changes: 12 additions & 14 deletions core/drand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/stretchr/testify/require"
)

var testBeaconOffset = int((5 * time.Second).Seconds())
var testDkgTimeout = 1 * time.Second
var testBeaconOffset = int((7 * time.Second).Seconds())
var testDkgTimeout = 2 * time.Second

func TestDrandDKGFresh(t *testing.T) {
n := 4
Expand Down Expand Up @@ -382,19 +382,17 @@ func (d *DrandTest2) TestBeaconLength(length int, newGroup bool, ids ...string)
if node.addr != id {
continue
}
drand := node.drand
drand.state.Lock()
defer drand.state.Unlock()
fmt.Printf("\n\tTest %s (beacon %p)\n", id, drand.beacon)
howMany := 0
drand.beacon.Store().Cursor(func(c beacon.Cursor) {
for b := c.First(); b != nil; b = c.Next() {
howMany++
fmt.Printf("\t %d - %s: beacon %s\n", drand.index, drand.priv.Public.Address(), b)
var found bool
for i := 0; i < 3; i++ {
drand := node.drand
if length != drand.beacon.Store().Len() {
time.Sleep(getSleepDuration())
continue
}
})
require.Equal(d.t, length, drand.beacon.Store().Len(), "id %s - howMany is %d vs Len() %d", id, howMany, drand.beacon.Store().Len())

found = true
break
}
require.True(d.t, found, "node %d not have enough beacon", id)
}
}
}
Expand Down

0 comments on commit 2283204

Please sign in to comment.