Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

Commit

Permalink
Adding test_loop and a small wait to avoid probable bug in onet
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoAndreSa authored and ineiti committed Jan 16, 2020
1 parent 1125165 commit 8df1d41
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ before_install:

install:
- go get -t ./...
- go get github.com/mattn/goveralls

script:
- make test
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ test_local:
test_codecov:
./coveralls.sh

test_loop:
for i in $$( seq 100 ); \
do echo "******* Run $$i"; echo; \
go test -v -short -p=1 -run Agg -count 10 ./services/ > run.log || \
( cat run.log; exit 1 ) || exit 1; \
done

test: test_fmt test_lint test_codecov

local: test_fmt test_lint test_local
local: test_fmt test_lint test_local
2 changes: 1 addition & 1 deletion coveralls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ echo "mode: atomic" > profile.cov
for dir in ${DIR_SOURCE}; do
echo ${dir}
if ! echo ${DIR_EXCLUDE} | grep -q ${dir}; then
go test -short -p=1 -covermode=atomic -coverprofile=${dir}/profile.tmp ${dir}
go test -v -short -p=1 -covermode=atomic -coverprofile=${dir}/profile.tmp ${dir}

if [ $? -ne 0 ]; then
all_tests_passed=false
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/stretchr/testify v1.4.0
github.com/urfave/cli v1.22.2
go.dedis.ch/kyber/v3 v3.0.11
go.dedis.ch/onet/v3 v3.0.29
go.dedis.ch/onet/v3 v3.0.31
golang.org/x/crypto v0.0.0-20191202143827-86a70503ff7e // indirect
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ go.dedis.ch/onet/v3 v3.0.29 h1:7kG+gY0zQQ7mMjePewCxQQaMZwtns2020jY8uN5/Pcg=
go.dedis.ch/onet/v3 v3.0.29/go.mod h1:eRhl/hDplVZQnvW9J67Q22vSMZO1umUS4DLY8wFY+b8=
go.dedis.ch/onet/v3 v3.0.30 h1:V5m8oqhFlbxACzlRyTeXOzrRKst6QFG6Obktqwuhapw=
go.dedis.ch/onet/v3 v3.0.30/go.mod h1:eRhl/hDplVZQnvW9J67Q22vSMZO1umUS4DLY8wFY+b8=
go.dedis.ch/onet/v3 v3.0.31 h1:iVIAxP9Zy1dEsJzRbVAgVcWtbtEOC3KVWBW0yaUYX5k=
go.dedis.ch/onet/v3 v3.0.31/go.mod h1:P9R5g5BMoye1QvPVYY3LUmiq2YKodjgKfD2/nKDYosw=
go.dedis.ch/protobuf v1.0.5/go.mod h1:eIV4wicvi6JK0q/QnfIEGeSFNG0ZeB24kzut5+HaRLo=
go.dedis.ch/protobuf v1.0.7/go.mod h1:pv5ysfkDX/EawiPqcW3ikOxsL5t+BqnV6xHSmE79KI4=
go.dedis.ch/protobuf v1.0.8 h1:lmyHigYqVxoTN1V0adoGPvqSdjycAMK0XmTFjP893mA=
Expand All @@ -85,6 +87,7 @@ golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b h1:Elez2XeF2p9uyVj0yEUDqQ
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191202143827-86a70503ff7e h1:egKlR8l7Nu9vHGWbcUV8lqR4987UfUbBd7GbhqGzNYU=
golang.org/x/crypto v0.0.0-20191202143827-86a70503ff7e/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac h1:8R1esu+8QioDxo4E4mX6bFztO+dMTM49DNAaWfO5OeY=
Expand All @@ -97,6 +100,7 @@ golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191021144547-ec77196f6094/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -107,6 +111,7 @@ golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 h1:ZBzSG/7F4eNKz2L3GE9o300RX0Az1Bw5HF7PDraD+qU=
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
17 changes: 10 additions & 7 deletions services/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,7 @@ func (s *Service) HandleSurveyAggRequest(sar *SurveyAggRequest) (network.Message
surveyAgg := SurveyAgg{
SurveyID: sar.SurveyID,
Request: *sar,
//SurveyChannel: make(chan int, 100),
TR: TimeResults{MapTR: mapTR},
TR: TimeResults{MapTR: mapTR},
}
err := s.putSurveyAgg(sar.SurveyID, surveyAgg)

Expand Down Expand Up @@ -553,11 +552,16 @@ func (s *Service) NewProtocol(tn *onet.TreeNodeInstance,

case protocolsunlynx.CollectiveAggregationProtocolName:
var surveyAgg SurveyAgg
for {
maxLoop := 10 * 60
for i := 1; i <= maxLoop; i++ {
surveyAgg, err = s.getSurveyAgg(target)
if err != nil {
log.LLvl3(s.ServerIdentity(), "Waiting for data to arrive")
time.Sleep(100 * time.Millisecond)
log.Lvl3(s.ServerIdentity(), "Waiting for data to arrive for survey", target)
if i == maxLoop {
return nil, xerrors.New(
"didn't get data within 10 minutes - aborting")
}
time.Sleep(1000 * time.Millisecond)
} else {
break
}
Expand Down Expand Up @@ -640,8 +644,7 @@ func (s *Service) NewProtocol(tn *onet.TreeNodeInstance,
}

if err := tn.SetConfig(conf); err != nil {
log.Fatal(err)
return nil, err
return nil, xerrors.Errorf("couldn't set config: %+v", err)
}

return pi, nil
Expand Down
4 changes: 4 additions & 0 deletions services/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strconv"
"sync"
"testing"
"time"
)

func getParam(nbServers int) (*onet.Roster, *onet.LocalTest) {
Expand Down Expand Up @@ -212,6 +213,9 @@ func TestServiceAgg(t *testing.T) {
wg := libunlynx.StartParallelize(nbrClients)
var mutex = sync.Mutex{}
for i, client := range clients {
// Need to wait. Once dedis/onet#611 is merged,
// this time.Sleep can be removed.
time.Sleep(100 * time.Millisecond)
go func(i int, client *servicesmedco.API) {
defer wg.Done()

Expand Down
7 changes: 3 additions & 4 deletions services/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,9 @@ type SurveyShuffle struct {

// SurveyAgg is the struct that we persist in the service that contains all the data for the Aggregation request phase
type SurveyAgg struct {
SurveyID SurveyID
Request SurveyAggRequest
SurveyChannel chan int // To wait for all the aggregate results to be received by the root node
TR TimeResults
SurveyID SurveyID
Request SurveyAggRequest
TR TimeResults
}

// SurveyShuffleGenerated is used to ensure that the root server creates the survey before all the other nodes send it their results
Expand Down

0 comments on commit 8df1d41

Please sign in to comment.