Skip to content

Commit 74ffe3a

Browse files
authored
Merge pull request #6541 from Algo-devops-service/relbeta4.5.1
2 parents 9b0fe61 + 129ea62 commit 74ffe3a

File tree

28 files changed

+164
-85
lines changed

28 files changed

+164
-85
lines changed

.codecov.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
codecov:
22
require_ci_to_pass: yes
33

4+
flags:
5+
full_coverage:
6+
joined: false
7+
48
ignore:
59
- "**/*_gen.go"
610
- "**/*_gen_test.go"
711
- "**/generated"
12+
- "**/*_string.go" # ignore stringer-generated code
813

914
coverage:
1015
status:

.github/workflows/ci-nightly.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ jobs:
103103
run: |
104104
./scripts/configure_dev.sh
105105
PACKAGES="$(go list ./... | grep -v /go-algorand/test/)"
106-
export PACKAGE_NAMES=$(echo $PACKAGES | tr -d '\n')
106+
export PACKAGE_NAMES=$(echo $PACKAGES | tr -d '\n')
107+
COVERPACKAGES="$(go list ./... | grep -E -v '/go-algorand/(test|debug|cmd|config/defaultsGenerator|tools)' | grep -E -v '(test|testing|mock|mocks)$' | paste -sd ',' -)"
107108
mkdir -p test_results/${{ matrix.platform }}_test_nightly/${PARTITION_ID}
108109
go tool -modfile=tool.mod gotestsum --format standard-quiet \
109110
--junitfile ~/test_results/${{ matrix.platform }}_test_nightly/${PARTITION_ID}/results.xml \
110111
--jsonfile ~/test_results/${{ matrix.platform }}_test_nightly/${PARTITION_ID}/testresults.json \
111112
-- --tags "sqlite_unlock_notify sqlite_omit_load_extension" \
112113
-race -timeout 1h -coverprofile=coverage.txt -covermode=atomic -p 1 \
114+
-coverpkg=$COVERPACKAGES \
113115
$PACKAGE_NAMES
114116
- name: Notify Slack on failure
115117
if: failure()
@@ -142,6 +144,7 @@ jobs:
142144
with:
143145
token: ${{ env.CODECOV_TOKEN }}
144146
file: ./coverage.txt
147+
flags: full_coverage
145148
fail_ci_if_error: false
146149
- name: Upload test results to Codecov
147150
if: ${{ !cancelled() }}

.github/workflows/ci-pr.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ on:
44
branches:
55
- master
66
- 'rel/**'
7+
workflow_dispatch:
8+
inputs:
9+
full_coverage:
10+
description: 'Run with -coverpkg to measure cross-package coverage (slower)'
11+
required: false
12+
type: boolean
13+
default: false
714

815
env:
916
CODECOV_TOKEN: "8b4a1f91-f154-4c26-b84c-c9aaa90159c6" # Same public token from CircleCI config
@@ -49,13 +56,19 @@ jobs:
4956
- name: Run tests
5057
run: |
5158
PACKAGES="$(go list ./... | grep -v /go-algorand/test/)"
52-
export PACKAGE_NAMES=$(echo $PACKAGES | tr -d '\n')
59+
export PACKAGE_NAMES=$(echo $PACKAGES | tr -d '\n')
60+
COVERPKG_FLAG=""
61+
if [[ "${{ inputs.full_coverage }}" == "true" ]]; then
62+
COVERPACKAGES="$(go list ./... | grep -E -v '/go-algorand/(test|debug|cmd|config/defaultsGenerator|tools)' | grep -E -v '(test|testing|mock|mocks)$' | paste -sd ',' -)"
63+
COVERPKG_FLAG="-coverpkg=$COVERPACKAGES"
64+
fi
5365
mkdir -p test_results/${{ matrix.platform }}_test/${PARTITION_ID}
5466
go tool -modfile=tool.mod gotestsum --format standard-quiet \
5567
--junitfile ~/test_results/${{ matrix.platform }}_test/${PARTITION_ID}/results.xml \
5668
--jsonfile ~/test_results/${{ matrix.platform }}_test/${PARTITION_ID}/testresults.json \
5769
-- --tags "sqlite_unlock_notify sqlite_omit_load_extension" $SHORTTEST \
5870
-race -timeout 1h -coverprofile=coverage.txt -covermode=atomic -p 4 \
71+
$COVERPKG_FLAG \
5972
$PACKAGE_NAMES
6073
- name: Notify Slack on failure
6174
if: failure()
@@ -89,6 +102,7 @@ jobs:
89102
with:
90103
token: ${{ env.CODECOV_TOKEN }}
91104
file: ./coverage.txt
105+
flags: ${{ inputs.full_coverage && 'full_coverage' || '' }}
92106
fail_ci_if_error: false
93107
- name: Upload test results to Codecov
94108
if: ${{ !cancelled() }}

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ GOLDFLAGS := $(GOLDFLAGS_BASE) \
8484
-X github.com/algorand/go-algorand/config.Channel=$(CHANNEL)
8585

8686
UNIT_TEST_SOURCES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && go list ./... | grep -v /go-algorand/test/ ))
87+
COVERPKG_PACKAGES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && go list ./... | egrep -v '/go-algorand/(test|debug|cmd|config/defaultsGenerator|tools)' | egrep -v '(test|testing|mocks|mock)$$' ))
8788
ALGOD_API_PACKAGES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && cd daemon/algod/api; go list ./... ))
8889

8990
GOMOD_DIRS := ./tools/block-generator ./tools/x-repo-types
@@ -132,8 +133,19 @@ check_shell:
132133

133134
sanity: fix lint fmt tidy modernize
134135

136+
# "make cover" runs all tests, and collects full coverage across all go-algorand packages by setting -coverpkg.
137+
# Without setting -coverpkg, coverage reports only measure lines of code exercised within the same package as the tests.
138+
#
139+
# "make cover PACKAGE=X" runs all tests in package github.com/algorand/go-algorand/X/... and collects full coverage
140+
# across all packages that are dependencies of that package.
135141
cover:
136-
go test $(GOTAGS) -coverprofile=cover.out $(UNIT_TEST_SOURCES)
142+
ifeq ($(PACKAGE),)
143+
$(GOTESTCOMMAND) $(GOTAGS) -coverprofile=cover.out $(UNIT_TEST_SOURCES) -covermode=atomic -coverpkg=$(shell echo $(COVERPKG_PACKAGES) | sed 's/ /,/g')
144+
else
145+
cd $(PACKAGE); \
146+
$(GOTESTCOMMAND) $(GOTAGS) -coverprofile=cover.out ./... -covermode=atomic -coverpkg=$$( (go list -f '{{ join .Deps "\n" }}' ./...; go list -f '{{ join .TestImports "\n" }}' ./...) | grep 'github.com/algorand/go-algorand' | egrep -v '/go-algorand/(test|debug|cmd|config/defaultsGenerator|tools)' | egrep -v '(test|testing|mocks|mock)$$' | sort | uniq | paste -sd ',' -); \
147+
go tool cover -html cover.out
148+
endif
137149

138150
prof:
139151
cd node && go test $(GOTAGS) -cpuprofile=cpu.out -memprofile=mem.out -mutexprofile=mutex.out

buildnumber.dat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0
1+
1

data/txHandler.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"errors"
2323
"fmt"
2424
"io"
25-
"reflect"
2625
"sync"
2726
"time"
2827

@@ -145,10 +144,6 @@ func MakeTxHandler(opts TxHandlerOpts) (*TxHandler, error) {
145144
if opts.TxPool == nil {
146145
return nil, ErrInvalidTxPool
147146
}
148-
txPoolValue := reflect.ValueOf(opts.TxPool)
149-
if txPoolValue.Kind() == reflect.Ptr && txPoolValue.IsNil() {
150-
return nil, ErrInvalidTxPool
151-
}
152147

153148
if opts.Ledger == nil {
154149
return nil, ErrInvalidLedger

data/txHandler_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,11 +3247,12 @@ func TestTxHandlerNilTxPool(t *testing.T) {
32473247
})
32483248
require.ErrorIs(t, err, ErrInvalidTxPool)
32493249

3250-
var nilPoll2 *mockTxPool
3251-
_, err = MakeTxHandler(TxHandlerOpts{
3252-
TxPool: nilPoll2,
3253-
})
3254-
require.ErrorIs(t, err, ErrInvalidTxPool)
3250+
// This case not handled in MakeTxHandler
3251+
// var nilPoll2 *mockTxPool
3252+
// _, err = MakeTxHandler(TxHandlerOpts{
3253+
// TxPool: nilPoll2,
3254+
// })
3255+
// require.ErrorIs(t, err, ErrInvalidTxPool)
32553256

32563257
_, err = MakeTxHandler(TxHandlerOpts{
32573258
TxPool: &mockTxPool{},

installer/rpm/algorand-devtools/algorand-devtools.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mkdir -p %{buildroot}/usr/bin
2727
# NOTE: keep in sync with scripts/build_deb.sh bin_files
2828
# NOTE: keep in sync with %files section below
2929
for f in carpenter msgpacktool tealdbg; do
30-
install -m 755 ${ALGO_BIN}/${f} %{buildroot}/usr/bin/${f}
30+
install -m 755 ${ALGO_TOOLS}/${f} %{buildroot}/usr/bin/${f}
3131
done
3232

3333
mkdir -p %{buildroot}/etc/pki/rpm-gpg

ledger/boxtxn_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,10 @@ assert
513513
for i := 0; i < 330; i++ {
514514
dl.fullBlock()
515515
}
516-
time.Sleep(5 * time.Second) // balancesFlushInterval, so commit happens
517516
dl.fullBlock(call.Args("check", "x", string(make([]byte, 16))))
518-
time.Sleep(100 * time.Millisecond) // give commit time to run, and prune au caches
517+
// commit au deltas so the box app is executed on of data from ledger, not trackers
518+
commitRoundLookback(0, dl.generator)
519+
commitRoundLookback(0, dl.validator)
519520
dl.fullBlock(call.Args("check", "x", string(make([]byte, 16))))
520521

521522
// Still the same after caches are flushed

ledger/ledger_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,10 +1514,6 @@ func benchLedgerCache(b *testing.B, startRound basics.Round) {
15141514

15151515
// triggerTrackerFlush is based in the commit flow but executed it in a single (this) goroutine.
15161516
func triggerTrackerFlush(t *testing.T, l *Ledger) {
1517-
l.trackers.mu.Lock()
1518-
dbRound := l.trackers.dbRound
1519-
l.trackers.mu.Unlock()
1520-
15211517
rnd := l.Latest()
15221518
minBlock := rnd
15231519
maxLookback := basics.Round(0)
@@ -1538,6 +1534,7 @@ func triggerTrackerFlush(t *testing.T, l *Ledger) {
15381534
}
15391535

15401536
l.trackers.mu.RLock()
1537+
dbRound := l.trackers.dbRound
15411538
cdr := l.trackers.produceCommittingTask(rnd, dbRound, &dcc.deferredCommitRange)
15421539
if cdr != nil {
15431540
dcc.deferredCommitRange = *cdr

0 commit comments

Comments
 (0)