Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve reliability and logging of setup node. #381

Merged
merged 6 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: go
go:
# - "1.13.x" At minimum the code should run make check on the latest two go versions in the default linux environment provided by Travis.
# - "1.14.x" At minimum the code should run make check on the latest two go versions in the default linux environment provided by Travis.
- "1.14.x"
evanlinjin marked this conversation as resolved.
Show resolved Hide resolved

dist: xenial
Expand Down
15 changes: 15 additions & 0 deletions pkg/routing/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ func (br *BidirectionalRoute) Check() error {
return nil
}

// String implements fmt.Stringer
func (br *BidirectionalRoute) String() string {
m := map[string]interface{}{
"descriptor": br.Desc.String(),
"keep_alive": br.KeepAlive.String(),
"fwd_hops": br.Forward,
"rev_hops": br.Reverse,
}
evanlinjin marked this conversation as resolved.
Show resolved Hide resolved
j, err := json.MarshalIndent(m, "", "\t")
if err != nil {
panic(err) // should never happen
}
return string(j)
}

// EdgeRules represents edge forward and reverse rules. Edge rules are forward and consume rules.
type EdgeRules struct {
Desc RouteDescriptor
Expand Down
60 changes: 30 additions & 30 deletions pkg/setup/id_reserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ func TestIdReserver_ReserveIDs(t *testing.T) {
timeout := time.Second

type testCase struct {
testName string // test name
routers map[cipher.PubKey]*mockGatewayForDialer // arrange: map of mock router gateways
paths [][]routing.Hop // arrange: idReserver input
expErr error // assert: expected error
testName string // test name
routers map[cipher.PubKey]interface{} // arrange: map of mock router gateways
nkryuchkov marked this conversation as resolved.
Show resolved Hide resolved
paths [][]routing.Hop // arrange: idReserver input
expErr error // assert: expected error
}

makeRun := func(tc testCase) func(t *testing.T) {
Expand Down Expand Up @@ -116,29 +116,29 @@ func TestIdReserver_ReserveIDs(t *testing.T) {
testCases := []testCase{
{
testName: "fwd1_rev1",
routers: map[cipher.PubKey]*mockGatewayForDialer{
pkA: {},
pkC: {},
routers: map[cipher.PubKey]interface{}{
pkA: &mockGatewayForDialer{},
pkC: &mockGatewayForDialer{},
},
paths: [][]routing.Hop{makeHops(pkA, pkC), makeHops(pkC, pkA)},
expErr: nil,
},
{
testName: "fwd2_rev2",
routers: map[cipher.PubKey]*mockGatewayForDialer{
pkA: {},
pkB: {},
pkC: {},
routers: map[cipher.PubKey]interface{}{
pkA: &mockGatewayForDialer{},
pkB: &mockGatewayForDialer{},
pkC: &mockGatewayForDialer{},
},
paths: [][]routing.Hop{makeHops(pkA, pkB, pkC), makeHops(pkC, pkB, pkA)},
expErr: nil,
},
{
testName: "fwd1_rev2",
routers: map[cipher.PubKey]*mockGatewayForDialer{
pkA: {},
pkB: {},
pkC: {},
routers: map[cipher.PubKey]interface{}{
pkA: &mockGatewayForDialer{},
pkB: &mockGatewayForDialer{},
pkC: &mockGatewayForDialer{},
},
paths: [][]routing.Hop{makeHops(pkA, pkC), makeHops(pkC, pkB, pkA)},
expErr: nil,
Expand All @@ -158,39 +158,39 @@ func TestIdReserver_ReserveIDs(t *testing.T) {
testCases := []testCase{
{
testName: "all_routers_hang",
routers: map[cipher.PubKey]*mockGatewayForDialer{
pkA: {hangDuration: time.Second * 5},
pkC: {hangDuration: time.Second * 5},
routers: map[cipher.PubKey]interface{}{
pkA: &mockGatewayForDialer{hangDuration: time.Second * 5},
pkC: &mockGatewayForDialer{hangDuration: time.Second * 5},
},
paths: [][]routing.Hop{makeHops(pkA, pkC), makeHops(pkC, pkA)},
expErr: context.DeadlineExceeded,
},
{
testName: "intermediary_router_hangs",
routers: map[cipher.PubKey]*mockGatewayForDialer{
pkA: {},
pkB: {hangDuration: time.Second * 5},
pkC: {},
routers: map[cipher.PubKey]interface{}{
pkA: &mockGatewayForDialer{},
pkB: &mockGatewayForDialer{hangDuration: time.Second * 5},
pkC: &mockGatewayForDialer{},
},
paths: [][]routing.Hop{makeHops(pkA, pkB, pkC), makeHops(pkC, pkB, pkA)},
expErr: context.DeadlineExceeded,
},
{
testName: "initiating_router_hangs",
routers: map[cipher.PubKey]*mockGatewayForDialer{
pkA: {hangDuration: time.Second * 5},
pkB: {},
pkC: {},
routers: map[cipher.PubKey]interface{}{
pkA: &mockGatewayForDialer{hangDuration: time.Second * 5},
pkB: &mockGatewayForDialer{},
pkC: &mockGatewayForDialer{},
},
paths: [][]routing.Hop{makeHops(pkA, pkC), makeHops(pkC, pkB, pkA)},
expErr: context.DeadlineExceeded,
},
{
testName: "responding_router_hangs",
routers: map[cipher.PubKey]*mockGatewayForDialer{
pkA: {},
pkB: {},
pkC: {hangDuration: time.Second * 5},
routers: map[cipher.PubKey]interface{}{
pkA: &mockGatewayForDialer{},
pkB: &mockGatewayForDialer{},
pkC: &mockGatewayForDialer{hangDuration: time.Second * 5},
},
paths: [][]routing.Hop{makeHops(pkA, pkB, pkC), makeHops(pkC, pkB, pkA)},
expErr: context.DeadlineExceeded,
Expand Down
248 changes: 0 additions & 248 deletions pkg/setup/node_old_test.go

This file was deleted.

Loading