From de2259d27c75fa954115420e829a954486e6de92 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Fri, 8 Nov 2019 09:58:57 +0100 Subject: [PATCH] travis: enable test suite on ARM64 (#20219) * travis: Enable ARM support * Include fixes from 20039 * Add a trace to debug the invalid lookup issue * Try increasing the timeout to see if the arm test passes * Investigate the resolver issue * Increase arm64 timeout for clique test * increase timeout in tests for arm64 * Only test the failing tests * Review feedback: don't export epsilon * Remove investigation tricks+include fjl's feeback * Revert the retry ahead of using the mock resolver * Fix rebase errors --- .travis.yml | 10 ++++ consensus/ethash/ethash_test.go | 2 +- eth/handler_test.go | 2 +- metrics/doc.go | 4 ++ metrics/ewma_test.go | 101 ++++++++++++++++---------------- metrics/sample_test.go | 3 +- miner/worker_test.go | 6 +- 7 files changed, 74 insertions(+), 54 deletions(-) create mode 100644 metrics/doc.go diff --git a/.travis.yml b/.travis.yml index 4acd00bc9..c992451c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,16 @@ jobs: # These are the latest Go versions. - stage: build os: linux + arch: amd64 + dist: xenial + go: 1.13.x + script: + - go run build/ci.go install + - go run build/ci.go test -coverage $TEST_PACKAGES + + - stage: build + os: linux + arch: arm64 dist: xenial go: 1.13.x script: diff --git a/consensus/ethash/ethash_test.go b/consensus/ethash/ethash_test.go index 90cb6470f..fdfd81320 100644 --- a/consensus/ethash/ethash_test.go +++ b/consensus/ethash/ethash_test.go @@ -49,7 +49,7 @@ func TestTestMode(t *testing.T) { if err := ethash.VerifySeal(nil, header); err != nil { t.Fatalf("unexpected verification error: %v", err) } - case <-time.NewTimer(time.Second).C: + case <-time.NewTimer(2 * time.Second).C: t.Error("sealing result timeout") } } diff --git a/eth/handler_test.go b/eth/handler_test.go index 256883d1f..05ddca3ef 100644 --- a/eth/handler_test.go +++ b/eth/handler_test.go @@ -608,7 +608,7 @@ func testBroadcastBlock(t *testing.T, totalPeers, broadcastExpected int) { } }(peer) } - timeout := time.After(300 * time.Millisecond) + timeout := time.After(time.Second) var receivedCount int outer: for { diff --git a/metrics/doc.go b/metrics/doc.go new file mode 100644 index 000000000..13f429c16 --- /dev/null +++ b/metrics/doc.go @@ -0,0 +1,4 @@ +package metrics + +const epsilon = 0.0000000000000001 +const epsilonPercentile = .00000000001 diff --git a/metrics/ewma_test.go b/metrics/ewma_test.go index 0430fbd24..5b2441916 100644 --- a/metrics/ewma_test.go +++ b/metrics/ewma_test.go @@ -1,6 +1,9 @@ package metrics -import "testing" +import ( + "math" + "testing" +) func BenchmarkEWMA(b *testing.B) { a := NewEWMA1() @@ -15,67 +18,67 @@ func TestEWMA1(t *testing.T) { a := NewEWMA1() a.Update(3) a.Tick() - if rate := a.Rate(); 0.6 != rate { + if rate := a.Rate(); math.Abs(0.6-rate) > epsilon { t.Errorf("initial a.Rate(): 0.6 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.22072766470286553 != rate { + if rate := a.Rate(); math.Abs(0.22072766470286553-rate) > epsilon { t.Errorf("1 minute a.Rate(): 0.22072766470286553 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.08120116994196772 != rate { + if rate := a.Rate(); math.Abs(0.08120116994196772-rate) > epsilon { t.Errorf("2 minute a.Rate(): 0.08120116994196772 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.029872241020718428 != rate { + if rate := a.Rate(); math.Abs(0.029872241020718428-rate) > epsilon { t.Errorf("3 minute a.Rate(): 0.029872241020718428 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.01098938333324054 != rate { + if rate := a.Rate(); math.Abs(0.01098938333324054-rate) > epsilon { t.Errorf("4 minute a.Rate(): 0.01098938333324054 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.004042768199451294 != rate { + if rate := a.Rate(); math.Abs(0.004042768199451294-rate) > epsilon { t.Errorf("5 minute a.Rate(): 0.004042768199451294 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.0014872513059998212 != rate { + if rate := a.Rate(); math.Abs(0.0014872513059998212-rate) > epsilon { t.Errorf("6 minute a.Rate(): 0.0014872513059998212 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.0005471291793327122 != rate { + if rate := a.Rate(); math.Abs(0.0005471291793327122-rate) > epsilon { t.Errorf("7 minute a.Rate(): 0.0005471291793327122 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.00020127757674150815 != rate { + if rate := a.Rate(); math.Abs(0.00020127757674150815-rate) > epsilon { t.Errorf("8 minute a.Rate(): 0.00020127757674150815 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 7.404588245200814e-05 != rate { + if rate := a.Rate(); math.Abs(7.404588245200814e-05-rate) > epsilon { t.Errorf("9 minute a.Rate(): 7.404588245200814e-05 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 2.7239957857491083e-05 != rate { + if rate := a.Rate(); math.Abs(2.7239957857491083e-05-rate) > epsilon { t.Errorf("10 minute a.Rate(): 2.7239957857491083e-05 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 1.0021020474147462e-05 != rate { + if rate := a.Rate(); math.Abs(1.0021020474147462e-05-rate) > epsilon { t.Errorf("11 minute a.Rate(): 1.0021020474147462e-05 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 3.6865274119969525e-06 != rate { + if rate := a.Rate(); math.Abs(3.6865274119969525e-06-rate) > epsilon { t.Errorf("12 minute a.Rate(): 3.6865274119969525e-06 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 1.3561976441886433e-06 != rate { + if rate := a.Rate(); math.Abs(1.3561976441886433e-06-rate) > epsilon { t.Errorf("13 minute a.Rate(): 1.3561976441886433e-06 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 4.989172314621449e-07 != rate { + if rate := a.Rate(); math.Abs(4.989172314621449e-07-rate) > epsilon { t.Errorf("14 minute a.Rate(): 4.989172314621449e-07 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 1.8354139230109722e-07 != rate { + if rate := a.Rate(); math.Abs(1.8354139230109722e-07-rate) > epsilon { t.Errorf("15 minute a.Rate(): 1.8354139230109722e-07 != %v\n", rate) } } @@ -84,67 +87,67 @@ func TestEWMA5(t *testing.T) { a := NewEWMA5() a.Update(3) a.Tick() - if rate := a.Rate(); 0.6 != rate { + if rate := a.Rate(); math.Abs(0.6-rate) > epsilon { t.Errorf("initial a.Rate(): 0.6 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.49123845184678905 != rate { + if rate := a.Rate(); math.Abs(0.49123845184678905-rate) > epsilon { t.Errorf("1 minute a.Rate(): 0.49123845184678905 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.4021920276213837 != rate { + if rate := a.Rate(); math.Abs(0.4021920276213837-rate) > epsilon { t.Errorf("2 minute a.Rate(): 0.4021920276213837 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.32928698165641596 != rate { + if rate := a.Rate(); math.Abs(0.32928698165641596-rate) > epsilon { t.Errorf("3 minute a.Rate(): 0.32928698165641596 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.269597378470333 != rate { + if rate := a.Rate(); math.Abs(0.269597378470333-rate) > epsilon { t.Errorf("4 minute a.Rate(): 0.269597378470333 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.2207276647028654 != rate { + if rate := a.Rate(); math.Abs(0.2207276647028654-rate) > epsilon { t.Errorf("5 minute a.Rate(): 0.2207276647028654 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.18071652714732128 != rate { + if rate := a.Rate(); math.Abs(0.18071652714732128-rate) > epsilon { t.Errorf("6 minute a.Rate(): 0.18071652714732128 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.14795817836496392 != rate { + if rate := a.Rate(); math.Abs(0.14795817836496392-rate) > epsilon { t.Errorf("7 minute a.Rate(): 0.14795817836496392 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.12113791079679326 != rate { + if rate := a.Rate(); math.Abs(0.12113791079679326-rate) > epsilon { t.Errorf("8 minute a.Rate(): 0.12113791079679326 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.09917933293295193 != rate { + if rate := a.Rate(); math.Abs(0.09917933293295193-rate) > epsilon { t.Errorf("9 minute a.Rate(): 0.09917933293295193 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.08120116994196763 != rate { + if rate := a.Rate(); math.Abs(0.08120116994196763-rate) > epsilon { t.Errorf("10 minute a.Rate(): 0.08120116994196763 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.06648189501740036 != rate { + if rate := a.Rate(); math.Abs(0.06648189501740036-rate) > epsilon { t.Errorf("11 minute a.Rate(): 0.06648189501740036 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.05443077197364752 != rate { + if rate := a.Rate(); math.Abs(0.05443077197364752-rate) > epsilon { t.Errorf("12 minute a.Rate(): 0.05443077197364752 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.04456414692860035 != rate { + if rate := a.Rate(); math.Abs(0.04456414692860035-rate) > epsilon { t.Errorf("13 minute a.Rate(): 0.04456414692860035 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.03648603757513079 != rate { + if rate := a.Rate(); math.Abs(0.03648603757513079-rate) > epsilon { t.Errorf("14 minute a.Rate(): 0.03648603757513079 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.0298722410207183831020718428 != rate { + if rate := a.Rate(); math.Abs(0.0298722410207183831020718428-rate) > epsilon { t.Errorf("15 minute a.Rate(): 0.0298722410207183831020718428 != %v\n", rate) } } @@ -153,67 +156,67 @@ func TestEWMA15(t *testing.T) { a := NewEWMA15() a.Update(3) a.Tick() - if rate := a.Rate(); 0.6 != rate { + if rate := a.Rate(); math.Abs(0.6-rate) > epsilon { t.Errorf("initial a.Rate(): 0.6 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.5613041910189706 != rate { + if rate := a.Rate(); math.Abs(0.5613041910189706-rate) > epsilon { t.Errorf("1 minute a.Rate(): 0.5613041910189706 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.5251039914257684 != rate { + if rate := a.Rate(); math.Abs(0.5251039914257684-rate) > epsilon { t.Errorf("2 minute a.Rate(): 0.5251039914257684 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.4912384518467888184678905 != rate { + if rate := a.Rate(); math.Abs(0.4912384518467888184678905-rate) > epsilon { t.Errorf("3 minute a.Rate(): 0.4912384518467888184678905 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.459557003018789 != rate { + if rate := a.Rate(); math.Abs(0.459557003018789-rate) > epsilon { t.Errorf("4 minute a.Rate(): 0.459557003018789 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.4299187863442732 != rate { + if rate := a.Rate(); math.Abs(0.4299187863442732-rate) > epsilon { t.Errorf("5 minute a.Rate(): 0.4299187863442732 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.4021920276213831 != rate { + if rate := a.Rate(); math.Abs(0.4021920276213831-rate) > epsilon { t.Errorf("6 minute a.Rate(): 0.4021920276213831 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.37625345116383313 != rate { + if rate := a.Rate(); math.Abs(0.37625345116383313-rate) > epsilon { t.Errorf("7 minute a.Rate(): 0.37625345116383313 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.3519877317060185 != rate { + if rate := a.Rate(); math.Abs(0.3519877317060185-rate) > epsilon { t.Errorf("8 minute a.Rate(): 0.3519877317060185 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.3292869816564153165641596 != rate { + if rate := a.Rate(); math.Abs(0.3292869816564153165641596-rate) > epsilon { t.Errorf("9 minute a.Rate(): 0.3292869816564153165641596 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.3080502714195546 != rate { + if rate := a.Rate(); math.Abs(0.3080502714195546-rate) > epsilon { t.Errorf("10 minute a.Rate(): 0.3080502714195546 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.2881831806538789 != rate { + if rate := a.Rate(); math.Abs(0.2881831806538789-rate) > epsilon { t.Errorf("11 minute a.Rate(): 0.2881831806538789 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.26959737847033216 != rate { + if rate := a.Rate(); math.Abs(0.26959737847033216-rate) > epsilon { t.Errorf("12 minute a.Rate(): 0.26959737847033216 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.2522102307052083 != rate { + if rate := a.Rate(); math.Abs(0.2522102307052083-rate) > epsilon { t.Errorf("13 minute a.Rate(): 0.2522102307052083 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.23594443252115815 != rate { + if rate := a.Rate(); math.Abs(0.23594443252115815-rate) > epsilon { t.Errorf("14 minute a.Rate(): 0.23594443252115815 != %v\n", rate) } elapseMinute(a) - if rate := a.Rate(); 0.2207276647028646247028654470286553 != rate { + if rate := a.Rate(); math.Abs(0.2207276647028646247028654470286553-rate) > epsilon { t.Errorf("15 minute a.Rate(): 0.2207276647028646247028654470286553 != %v\n", rate) } } diff --git a/metrics/sample_test.go b/metrics/sample_test.go index d60e99c5b..7bab0e3de 100644 --- a/metrics/sample_test.go +++ b/metrics/sample_test.go @@ -1,6 +1,7 @@ package metrics import ( + "math" "math/rand" "runtime" "testing" @@ -326,7 +327,7 @@ func testUniformSampleStatistics(t *testing.T, s Sample) { if 7380.5 != ps[1] { t.Errorf("75th percentile: 7380.5 != %v\n", ps[1]) } - if 9986.429999999998 != ps[2] { + if math.Abs(9986.429999999998-ps[2]) > epsilonPercentile { t.Errorf("99th percentile: 9986.429999999998 != %v\n", ps[2]) } } diff --git a/miner/worker_test.go b/miner/worker_test.go index faebee1a7..34f17e8a2 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -340,7 +340,9 @@ func testEmptyWork(t *testing.T, chainConfig *params.ChainConfig, engine consens } } w.fullTaskHook = func() { - time.Sleep(100 * time.Millisecond) + // Aarch64 unit tests are running in a VM on travis, they must + // be given more time to execute. + time.Sleep(time.Second) } // Ensure worker has finished initialization @@ -355,7 +357,7 @@ func testEmptyWork(t *testing.T, chainConfig *params.ChainConfig, engine consens for i := 0; i < 2; i += 1 { select { case <-taskCh: - case <-time.NewTimer(2 * time.Second).C: + case <-time.NewTimer(4 * time.Second).C: t.Error("new task timeout") } }