swarm/pss: Shorten TextProxNetwork shortrunning test timeout

This commit is contained in:
lash 2019-03-19 12:00:42 +01:00
parent 6220dd5b16
commit c6b56e6928

View file

@ -89,7 +89,7 @@ func (d *testData) setDone() {
d.handlerDone = true
}
func getCmdParams(t *testing.T) (int, int) {
func getCmdParams(t *testing.T) (int, int, time.Duration) {
args := strings.Split(t.Name(), "/")
msgCount, err := strconv.ParseInt(args[2], 10, 16)
if err != nil {
@ -99,7 +99,12 @@ func getCmdParams(t *testing.T) (int, int) {
if err != nil {
t.Fatal(err)
}
return int(msgCount), int(nodeCount)
timeoutStr := fmt.Sprintf("%ss", args[3])
timeoutDur, err := time.ParseDuration(timeoutStr)
if err != nil {
t.Fatal(err)
}
return int(msgCount), int(nodeCount), timeoutDur
}
func newTestData() *testData {
@ -200,7 +205,7 @@ func (d *testData) init(msgCount int) error {
// nodes Y and Z will be considered required recipients of the msg,
// whereas nodes X, Y and Z will be allowed recipients.
func TestProxNetwork(t *testing.T) {
t.Run("16/16", testProxNetwork)
t.Run("16/16/10", testProxNetwork)
}
// params in run name: nodes/msgs
@ -208,22 +213,26 @@ func TestProxNetworkLong(t *testing.T) {
if !*longrunning {
t.Skip("run with --longrunning flag to run extensive network tests")
}
t.Run("8/100", testProxNetwork)
t.Run("16/100", testProxNetwork)
t.Run("32/100", testProxNetwork)
t.Run("64/100", testProxNetwork)
t.Run("128/100", testProxNetwork)
t.Run("8/100/30", testProxNetwork)
t.Run("16/100/30", testProxNetwork)
t.Run("32/100/60", testProxNetwork)
t.Run("64/100/60", testProxNetwork)
t.Run("128/100/120", testProxNetwork)
}
func testProxNetwork(t *testing.T) {
tstdata := newTestData()
msgCount, nodeCount := getCmdParams(t)
msgCount, nodeCount, timeout := getCmdParams(t)
handlerContextFuncs := make(map[Topic]handlerContextFunc)
handlerContextFuncs[topic] = nodeMsgHandler
services := newProxServices(tstdata, true, handlerContextFuncs, tstdata.kademlias)
tstdata.sim = simulation.New(services)
defer tstdata.sim.Close()
ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second)
err := tstdata.sim.UploadSnapshot(fmt.Sprintf("testdata/snapshot_%d.json", nodeCount))
if err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
filename := fmt.Sprintf("testdata/snapshot_%d.json", nodeCount)
err := tstdata.sim.UploadSnapshot(ctx, filename)