tests/load: change test spec

This commit is contained in:
Miya Chen 2017-10-11 14:39:32 +08:00
parent acea4c0aae
commit 4b0846eb1c
1 changed files with 12 additions and 5 deletions

View File

@ -17,6 +17,7 @@
package load package load
import ( import (
"fmt"
"math/big" "math/big"
"sync" "sync"
"testing" "testing"
@ -43,11 +44,11 @@ var _ = Describe("TPS-01: Large amount of transactions", func() {
runTests(numberOfValidators, gaslimit, txpoolSize) runTests(numberOfValidators, gaslimit, txpoolSize)
}, },
tests.Case("10240", 10240), tests.Case("20480", 20480),
) )
}, },
tests.Case("21000*3000", 21000*3000), tests.Case("21000*1500", 21000*1500),
) )
}, },
@ -62,8 +63,8 @@ func runTests(numberOfValidators int, gaslimit int, txpoolSize int) {
blockchain container.Blockchain blockchain container.Blockchain
sendEtherAddrs map[common.Address]common.Address sendEtherAddrs map[common.Address]common.Address
duration = 10 * time.Minute duration = 15 * time.Minute
accountsPerGeth = 30 accountsPerGeth = 20
) )
BeforeEach(func() { BeforeEach(func() {
@ -92,22 +93,28 @@ func runTests(numberOfValidators int, gaslimit int, txpoolSize int) {
var blocksCnt int = 5 var blocksCnt int = 5
metricsExport, ok := blockchain.(metrics.Exporter) metricsExport, ok := blockchain.(metrics.Exporter)
if ok { if ok {
blockSize := gaslimit / int(istcommon.DefaultGasLimit) blockSize := gaslimit / int(istcommon.DefaultGasLimit)
blocksCnt = int(metricsExport.SentTxCount()-metricsExport.ExcutedTxCount())/blockSize + 1 blocksCnt = int(int(metricsExport.SentTxCount()-metricsExport.ExcutedTxCount())/blockSize/8*10) + 5
fmt.Println("blockSize", blockSize, "sendTx", metricsExport.SentTxCount(), "excutedTx", metricsExport.ExcutedTxCount(), "waitFor", blocksCnt)
} }
tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) { tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
Expect(geth.WaitForBlocks(blocksCnt)).To(BeNil()) Expect(geth.WaitForBlocks(blocksCnt)).To(BeNil())
wg.Done() wg.Done()
}) })
fmt.Println("Begin to Stop blockchain")
Expect(blockchain.Stop(true)).To(BeNil()) Expect(blockchain.Stop(true)).To(BeNil())
fmt.Println("End to Stop blockchain")
blockchain.Finalize() blockchain.Finalize()
}) })
It("", func() { It("", func() {
By("Wait for p2p connection", func() { By("Wait for p2p connection", func() {
tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) { tests.WaitFor(blockchain.Validators(), func(geth container.Ethereum, wg *sync.WaitGroup) {
fmt.Println("Start p2p")
Expect(geth.WaitForPeersConnected(numberOfValidators - 1)).To(BeNil()) Expect(geth.WaitForPeersConnected(numberOfValidators - 1)).To(BeNil())
wg.Done() wg.Done()
fmt.Println("Done p2p")
}) })
}) })