diff --git a/.travis.yml b/.travis.yml
index e3c138c2..6a8046e1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ matrix:
sudo: required
go: 1.7.6
script:
- - go test -parallel 4 $(glide novendor | grep -v "\.\/tests\/\.\.\.") && cd tests && ginkgo
+ - travis_wait go test -parallel 2 $(glide novendor) --timeout 30m
# These are the latest Go versions.
- os: linux
@@ -16,7 +16,7 @@ matrix:
sudo: required
go: 1.8.3
script:
- - go test -parallel 4 $(glide novendor | grep -v "\.\/tests\/\.\.\.") && cd tests && ginkgo
+ - travis_wait go test -parallel 2 $(glide novendor) --timeout 30m
services:
- docker
@@ -26,7 +26,7 @@ install:
- go get github.com/onsi/ginkgo/ginkgo
script:
- - go test $(glide novendor)
+ - travis_wait go test -parallel 2 $(glide novendor)
notifications:
slack: maicoin:p2HicxEGvZveE900zgacSYwL
diff --git a/container/ethereum.go b/container/ethereum.go
index b50dd889..b128d8db 100644
--- a/container/ethereum.go
+++ b/container/ethereum.go
@@ -251,7 +251,7 @@ func (eth *ethereum) Start() error {
for i := 0; i < healthCheckRetryCount; i++ {
cli := eth.NewClient()
if cli == nil {
- time.Sleep(healthCheckRetryDelay)
+ <-time.After(healthCheckRetryDelay)
continue
}
_, err = cli.BlockByNumber(context.Background(), big.NewInt(0))
diff --git a/tests/block_sync_test.go b/tests/funtional/block_sync_test.go
similarity index 82%
rename from tests/block_sync_test.go
rename to tests/funtional/block_sync_test.go
index 4483b5f0..c7c7ed0d 100644
--- a/tests/block_sync_test.go
+++ b/tests/funtional/block_sync_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package tests
+package functional
import (
"context"
@@ -25,6 +25,7 @@ import (
. "github.com/onsi/gomega"
"github.com/getamis/istanbul-tools/container"
+ "github.com/getamis/istanbul-tools/tests"
)
var _ = Describe("Block synchronization testing", func() {
@@ -45,7 +46,7 @@ var _ = Describe("Block synchronization testing", func() {
blockchain.Finalize()
})
- Describe("TFS-06: block synchronization testing", func() {
+ Describe("TFS-06: Block synchronization testing", func() {
const numberOfNodes = 2
var nodes []container.Ethereum
@@ -77,17 +78,19 @@ var _ = Describe("Block synchronization testing", func() {
})
It("TFS-06-01: Node connection", func(done Done) {
- By("Connect all nodes to the validators")
- for _, n := range nodes {
- for _, v := range blockchain.Validators() {
- Expect(n.AddPeer(v.NodeAddress())).To(BeNil())
+ By("Connect all nodes to the validators", func() {
+ for _, n := range nodes {
+ for _, v := range blockchain.Validators() {
+ Expect(n.AddPeer(v.NodeAddress())).To(BeNil())
+ }
}
- }
+ })
- By("Wait for p2p connection")
- waitFor(nodes, func(node container.Ethereum, wg *sync.WaitGroup) {
- Expect(node.WaitForPeersConnected(numberOfValidators)).To(BeNil())
- wg.Done()
+ By("Wait for p2p connection", func() {
+ tests.WaitFor(nodes, func(node container.Ethereum, wg *sync.WaitGroup) {
+ Expect(node.WaitForPeersConnected(numberOfValidators)).To(BeNil())
+ wg.Done()
+ })
})
close(done)
@@ -97,7 +100,7 @@ var _ = Describe("Block synchronization testing", func() {
const targetBlockHeight = 10
By("Wait for blocks", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(targetBlockHeight)).To(BeNil())
wg.Done()
})
@@ -122,14 +125,14 @@ var _ = Describe("Block synchronization testing", func() {
})
By("Wait for p2p connection", func() {
- waitFor(nodes, func(node container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(nodes, func(node container.Ethereum, wg *sync.WaitGroup) {
Expect(node.WaitForPeersConnected(numberOfValidators)).To(BeNil())
wg.Done()
})
})
By("Wait for block synchronization between nodes and validators", func() {
- waitFor(nodes, func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(nodes, func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlockHeight(targetBlockHeight)).To(BeNil())
wg.Done()
})
diff --git a/tests/byzantine_faulty_test.go b/tests/funtional/byzantine_faulty_test.go
similarity index 85%
rename from tests/byzantine_faulty_test.go
rename to tests/funtional/byzantine_faulty_test.go
index d79832e7..395ea9e0 100644
--- a/tests/byzantine_faulty_test.go
+++ b/tests/funtional/byzantine_faulty_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package tests
+package functional
import (
"sync"
@@ -24,6 +24,7 @@ import (
. "github.com/onsi/gomega"
"github.com/getamis/istanbul-tools/container"
+ "github.com/getamis/istanbul-tools/tests"
)
var _ = Describe("TFS-05: Byzantine Faulty", func() {
@@ -49,7 +50,7 @@ var _ = Describe("TFS-05: Byzantine Faulty", func() {
It("Should generate blocks", func(done Done) {
By("Wait for p2p connection", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForPeersConnected(numberOfNormal + numberOfFaulty - 1)).To(BeNil())
wg.Done()
})
@@ -57,7 +58,7 @@ var _ = Describe("TFS-05: Byzantine Faulty", func() {
By("Wait for blocks", func() {
const targetBlockHeight = 3
- waitFor(blockchain.Validators()[:1], func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators()[:1], func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(targetBlockHeight)).To(BeNil())
wg.Done()
})
@@ -87,7 +88,7 @@ var _ = Describe("TFS-05: Byzantine Faulty", func() {
It("Should not generate blocks", func(done Done) {
By("Wait for p2p connection", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForPeersConnected(numberOfNormal + numberOfFaulty - 1)).To(BeNil())
wg.Done()
})
@@ -95,7 +96,7 @@ var _ = Describe("TFS-05: Byzantine Faulty", func() {
By("Wait for blocks", func() {
// Only check normal validators
- waitFor(blockchain.Validators()[:2], func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators()[:2], func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForNoBlocks(0, time.Second*30)).To(BeNil())
wg.Done()
})
diff --git a/tests/dynamic_test.go b/tests/funtional/dynamic_test.go
similarity index 92%
rename from tests/dynamic_test.go
rename to tests/funtional/dynamic_test.go
index a7bb6fb4..8bd61e4f 100644
--- a/tests/dynamic_test.go
+++ b/tests/funtional/dynamic_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package tests
+package functional
import (
"context"
@@ -26,6 +26,7 @@ import (
. "github.com/onsi/gomega"
"github.com/getamis/istanbul-tools/container"
+ "github.com/getamis/istanbul-tools/tests"
)
var _ = Describe("Dynamic validators addition/removal testing", func() {
@@ -64,7 +65,7 @@ var _ = Describe("Dynamic validators addition/removal testing", func() {
})
By("Wait for several blocks", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(5)).To(BeNil())
wg.Done()
})
@@ -86,7 +87,7 @@ var _ = Describe("Dynamic validators addition/removal testing", func() {
newValidators, err := blockchain.AddValidators(testValidator)
Expect(err).Should(BeNil())
- waitFor(blockchain.Validators()[numberOfValidators:], func(eth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators()[numberOfValidators:], func(eth container.Ethereum, wg *sync.WaitGroup) {
Expect(eth.WaitForProposed(newValidators[0].Address(), 100*time.Second)).Should(BeNil())
wg.Done()
})
@@ -149,7 +150,7 @@ var _ = Describe("Dynamic validators addition/removal testing", func() {
It("TFS-02-04 Reduce validator network size below 2F+1", func() {
By("Ensure that blocks are generated by validators", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(5)).To(BeNil())
wg.Done()
})
@@ -174,7 +175,7 @@ var _ = Describe("Dynamic validators addition/removal testing", func() {
})
By("Ensure that blocks are generated by validators", func() {
- waitFor(blockchain.Validators()[:numberOfValidators-1], func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators()[:numberOfValidators-1], func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(5)).To(BeNil())
wg.Done()
})
@@ -183,7 +184,7 @@ var _ = Describe("Dynamic validators addition/removal testing", func() {
It("TFS-02-05 Reduce validator network size below 2F+1", func() {
By("Ensure that blocks are generated by validators", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(5)).To(BeNil())
wg.Done()
})
diff --git a/tests/general_consensus_test.go b/tests/funtional/general_consensus_test.go
similarity index 95%
rename from tests/general_consensus_test.go
rename to tests/funtional/general_consensus_test.go
index 7e28c14a..b781c850 100644
--- a/tests/general_consensus_test.go
+++ b/tests/funtional/general_consensus_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package tests
+package functional
import (
"context"
@@ -30,6 +30,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/getamis/istanbul-tools/container"
"github.com/getamis/istanbul-tools/genesis"
+ "github.com/getamis/istanbul-tools/tests"
)
var _ = Describe("TFS-01: General consensus", func() {
@@ -113,7 +114,7 @@ var _ = Describe("TFS-01: General consensus", func() {
It("TFS-01-03: Peer connection", func(done Done) {
expectedPeerCount := len(blockchain.Validators()) - 1
- waitFor(blockchain.Validators(), func(v container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(v container.Ethereum, wg *sync.WaitGroup) {
Expect(v.WaitForPeersConnected(expectedPeerCount)).To(BeNil())
wg.Done()
})
@@ -128,7 +129,7 @@ var _ = Describe("TFS-01: General consensus", func() {
)
By("Wait for consensus progress", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlockHeight(targetBlockHeight)).To(BeNil())
wg.Done()
})
@@ -179,7 +180,7 @@ var _ = Describe("TFS-01: General consensus", func() {
)
By("Wait for consensus progress", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlockHeight(targetBlockHeight)).To(BeNil())
wg.Done()
})
diff --git a/tests/gossip_network_test.go b/tests/funtional/gossip_network_test.go
similarity index 91%
rename from tests/gossip_network_test.go
rename to tests/funtional/gossip_network_test.go
index 4b234129..500e2b3b 100644
--- a/tests/gossip_network_test.go
+++ b/tests/funtional/gossip_network_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package tests
+package functional
import (
"context"
@@ -24,6 +24,7 @@ import (
. "github.com/onsi/gomega"
"github.com/getamis/istanbul-tools/container"
+ "github.com/getamis/istanbul-tools/tests"
)
var _ = Describe("TFS-07: Gossip Network", func() {
@@ -55,7 +56,7 @@ var _ = Describe("TFS-07: Gossip Network", func() {
})
By("Checking blockchain progress", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(3)).To(BeNil())
wg.Done()
})
diff --git a/tests/integration_test.go b/tests/funtional/integration_test.go
similarity index 99%
rename from tests/integration_test.go
rename to tests/funtional/integration_test.go
index 9041c379..02003c86 100644
--- a/tests/integration_test.go
+++ b/tests/funtional/integration_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package tests
+package functional
import (
"testing"
diff --git a/tests/non_byzantine_faulty_test.go b/tests/funtional/non_byzantine_faulty_test.go
similarity index 88%
rename from tests/non_byzantine_faulty_test.go
rename to tests/funtional/non_byzantine_faulty_test.go
index 7fa7ee5d..150b6744 100644
--- a/tests/non_byzantine_faulty_test.go
+++ b/tests/funtional/non_byzantine_faulty_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package tests
+package functional
import (
"sync"
@@ -24,6 +24,7 @@ import (
. "github.com/onsi/gomega"
"github.com/getamis/istanbul-tools/container"
+ "github.com/getamis/istanbul-tools/tests"
)
var _ = Describe("TFS-04: Non-Byzantine Faulty", func() {
@@ -46,7 +47,7 @@ var _ = Describe("TFS-04: Non-Byzantine Faulty", func() {
It("TFS-04-01: Stop F validators", func(done Done) {
By("Generating blockchain progress before stopping validator", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(3)).To(BeNil())
wg.Done()
})
@@ -68,7 +69,7 @@ var _ = Describe("TFS-04: Non-Byzantine Faulty", func() {
})
By("Checking blockchain progress after stopping validator", func() {
- waitFor(blockchain.Validators()[1:], func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators()[1:], func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(3)).To(BeNil())
wg.Done()
})
diff --git a/tests/recoverability_test.go b/tests/funtional/recoverability_test.go
similarity index 79%
rename from tests/recoverability_test.go
rename to tests/funtional/recoverability_test.go
index 6b249f09..49348ab0 100644
--- a/tests/recoverability_test.go
+++ b/tests/funtional/recoverability_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package tests
+package functional
import (
"sync"
@@ -24,6 +24,7 @@ import (
. "github.com/onsi/gomega"
"github.com/getamis/istanbul-tools/container"
+ "github.com/getamis/istanbul-tools/tests"
)
var _ = Describe("TFS-03: Recoverability testing", func() {
@@ -46,7 +47,7 @@ var _ = Describe("TFS-03: Recoverability testing", func() {
It("TFS-04-01: Add validators in a network with < 2F+1 validators to > 2F+1", func(done Done) {
By("The consensus should work at the beginning", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(5)).To(BeNil())
wg.Done()
})
@@ -55,14 +56,14 @@ var _ = Describe("TFS-03: Recoverability testing", func() {
numOfValidatorsToBeStopped := 2
By("Stop several validators until there are less than 2F+1 validators", func() {
- waitFor(blockchain.Validators()[:numOfValidatorsToBeStopped], func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators()[:numOfValidatorsToBeStopped], func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.StopMining()).To(BeNil())
wg.Done()
})
})
By("The consensus should not work after resuming", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
// container.ErrNoBlock should be returned if we didn't see any block in 10 seconds
Expect(geth.WaitForBlocks(1, 10*time.Second)).To(BeEquivalentTo(container.ErrNoBlock))
wg.Done()
@@ -70,14 +71,14 @@ var _ = Describe("TFS-03: Recoverability testing", func() {
})
By("Resume the stopped validators", func() {
- waitFor(blockchain.Validators()[:numOfValidatorsToBeStopped], func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators()[:numOfValidatorsToBeStopped], func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.StartMining()).To(BeNil())
wg.Done()
})
})
By("The consensus should work after resuming", func() {
- waitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
+ tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(5)).To(BeNil())
wg.Done()
})
diff --git a/tests/utils.go b/tests/utils.go
index e61bfe39..f15c6e7c 100644
--- a/tests/utils.go
+++ b/tests/utils.go
@@ -22,7 +22,7 @@ import (
"github.com/getamis/istanbul-tools/container"
)
-func waitFor(geths []container.Ethereum, waitFn func(eth container.Ethereum, wg *sync.WaitGroup)) {
+func WaitFor(geths []container.Ethereum, waitFn func(eth container.Ethereum, wg *sync.WaitGroup)) {
wg := new(sync.WaitGroup)
for _, g := range geths {
wg.Add(1)