From 749b11cfaaeb05443b35f938de74865472072f50 Mon Sep 17 00:00:00 2001 From: Kifen Date: Thu, 5 Mar 2020 17:17:32 +0000 Subject: [PATCH 1/8] rename loop to routegroup --- pkg/hypervisor/hypervisor.go | 6 +++--- pkg/router/router.go | 2 +- pkg/visor/rpc.go | 4 ++-- pkg/visor/rpc_client.go | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index eb134802fb..c07e9bd284 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -172,7 +172,7 @@ func (hv *Hypervisor) ServeHTTP(w http.ResponseWriter, req *http.Request) { r.Get("/visors/{pk}/routes/{rid}", hv.getRoute()) r.Put("/visors/{pk}/routes/{rid}", hv.putRoute()) r.Delete("/visors/{pk}/routes/{rid}", hv.deleteRoute()) - r.Get("/visors/{pk}/loops", hv.getLoops()) + r.Get("/visors/{pk}/routegroup", hv.getRouteGroup()) r.Get("/visors/{pk}/restart", hv.restart()) r.Post("/visors/{pk}/exec", hv.exec()) r.Post("/visors/{pk}/update", hv.update()) @@ -672,9 +672,9 @@ func makeLoopResp(info visor.LoopInfo) loopResp { } } -func (hv *Hypervisor) getLoops() http.HandlerFunc { +func (hv *Hypervisor) getRouteGroup() http.HandlerFunc { return hv.withCtx(hv.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { - loops, err := ctx.RPC.Loops() + loops, err := ctx.RPC.RouteGroups() if err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) return diff --git a/pkg/router/router.go b/pkg/router/router.go index 5655751ec1..6ea5c4aa8e 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -527,7 +527,7 @@ func (r *router) Close() error { return nil } - r.logger.Info("Closing all App connections and Loops") + r.logger.Info("Closing all App connections and RouteGroups") r.once.Do(func() { close(r.done) diff --git a/pkg/visor/rpc.go b/pkg/visor/rpc.go index 393004ac22..92f725ef4c 100644 --- a/pkg/visor/rpc.go +++ b/pkg/visor/rpc.go @@ -460,9 +460,9 @@ type LoopInfo struct { FwdRule routing.Rule } -// Loops retrieves loops via rules of the routing table. +// RouteGroups retrieves loops via rules of the routing table. func (r *RPC) Loops(_ *struct{}, out *[]LoopInfo) (err error) { - defer r.logReq("Loops", nil)(out, &err) + defer r.logReq("RouteGroups", nil)(out, &err) var loops []LoopInfo diff --git a/pkg/visor/rpc_client.go b/pkg/visor/rpc_client.go index 6851f0afeb..cb46a0afd0 100644 --- a/pkg/visor/rpc_client.go +++ b/pkg/visor/rpc_client.go @@ -57,7 +57,7 @@ type RPCClient interface { SaveRoutingRule(rule routing.Rule) error RemoveRoutingRule(key routing.RouteID) error - Loops() ([]LoopInfo, error) + RouteGroups() ([]LoopInfo, error) Restart() error Exec(command string) ([]byte, error) @@ -230,10 +230,10 @@ func (rc *rpcClient) RemoveRoutingRule(key routing.RouteID) error { return rc.Call("RemoveRoutingRule", &key, &struct{}{}) } -// Loops calls Loops. -func (rc *rpcClient) Loops() ([]LoopInfo, error) { +// RouteGroups calls RouteGroups. +func (rc *rpcClient) RouteGroups() ([]LoopInfo, error) { var loops []LoopInfo - err := rc.Call("Loops", &struct{}{}, &loops) + err := rc.Call("RouteGroups", &struct{}{}, &loops) return loops, err } @@ -580,8 +580,8 @@ func (mc *mockRPCClient) RemoveRoutingRule(key routing.RouteID) error { return nil } -// Loops implements RPCClient. -func (mc *mockRPCClient) Loops() ([]LoopInfo, error) { +// RouteGroups implements RPCClient. +func (mc *mockRPCClient) RouteGroups() ([]LoopInfo, error) { var loops []LoopInfo rules := mc.rt.AllRules() From 4019f78ef910519ac5823e8dfc644345a1113742 Mon Sep 17 00:00:00 2001 From: Kifen Date: Fri, 6 Mar 2020 12:23:39 +0000 Subject: [PATCH 2/8] rename functions, types and comments loops to routegroup --- pkg/hypervisor/hypervisor.go | 16 ++++++++-------- pkg/visor/rpc.go | 16 ++++++++-------- pkg/visor/rpc_client.go | 16 ++++++++-------- .../github.com/SkycoinProject/dmsg/disc/entry.go | 2 +- .../SkycoinProject/dmsg/httputil/error.go | 3 ++- vendor/modules.txt | 2 +- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index c07e9bd284..8f588ebdc4 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -656,17 +656,17 @@ func (hv *Hypervisor) deleteRoute() http.HandlerFunc { }) } -type loopResp struct { +type routeGroupResp struct { routing.RuleConsumeFields FwdRule routing.RuleForwardFields `json:"resp"` } -func makeLoopResp(info visor.LoopInfo) loopResp { +func makeRouteGroupResp(info visor.RouteGroupInfo) routeGroupResp { if len(info.FwdRule) == 0 || len(info.ConsumeRule) == 0 { - return loopResp{} + return routeGroupResp{} } - return loopResp{ + return routeGroupResp{ RuleConsumeFields: *info.ConsumeRule.Summary().ConsumeFields, FwdRule: *info.FwdRule.Summary().ForwardFields, } @@ -674,15 +674,15 @@ func makeLoopResp(info visor.LoopInfo) loopResp { func (hv *Hypervisor) getRouteGroup() http.HandlerFunc { return hv.withCtx(hv.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { - loops, err := ctx.RPC.RouteGroups() + rg, err := ctx.RPC.RouteGroups() if err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) return } - resp := make([]loopResp, len(loops)) - for i, l := range loops { - resp[i] = makeLoopResp(l) + resp := make([]routeGroupResp, len(rg)) + for i, l := range rg { + resp[i] = makeRouteGroupResp(l) } httputil.WriteJSON(w, r, http.StatusOK, resp) diff --git a/pkg/visor/rpc.go b/pkg/visor/rpc.go index 92f725ef4c..7ad0f47dd8 100644 --- a/pkg/visor/rpc.go +++ b/pkg/visor/rpc.go @@ -450,21 +450,21 @@ func (r *RPC) RemoveRoutingRule(key *routing.RouteID, _ *struct{}) (err error) { } /* - <<< LOOPS MANAGEMENT >>> + <<< ROUTEGROUPS MANAGEMENT >>> >>> TODO(evanlinjin): Implement. */ -// LoopInfo is a human-understandable representation of a loop. -type LoopInfo struct { +// RouteGroupInfo is a human-understandable representation of a RouteGroup. +type RouteGroupInfo struct { ConsumeRule routing.Rule FwdRule routing.Rule } -// RouteGroups retrieves loops via rules of the routing table. -func (r *RPC) Loops(_ *struct{}, out *[]LoopInfo) (err error) { +// RouteGroups retrieves routegroups via rules of the routing table. +func (r *RPC) RouteGroups(_ *struct{}, out *[]RouteGroupInfo) (err error) { defer r.logReq("RouteGroups", nil)(out, &err) - var loops []LoopInfo + var routegroups []RouteGroupInfo rules := r.visor.router.Rules() for _, rule := range rules { @@ -478,13 +478,13 @@ func (r *RPC) Loops(_ *struct{}, out *[]LoopInfo) (err error) { return err } - loops = append(loops, LoopInfo{ + routegroups = append(routegroups, RouteGroupInfo{ ConsumeRule: rule, FwdRule: rule, }) } - *out = loops + *out = routegroups return nil } diff --git a/pkg/visor/rpc_client.go b/pkg/visor/rpc_client.go index cb46a0afd0..e30eeae4c2 100644 --- a/pkg/visor/rpc_client.go +++ b/pkg/visor/rpc_client.go @@ -57,7 +57,7 @@ type RPCClient interface { SaveRoutingRule(rule routing.Rule) error RemoveRoutingRule(key routing.RouteID) error - RouteGroups() ([]LoopInfo, error) + RouteGroups() ([]RouteGroupInfo, error) Restart() error Exec(command string) ([]byte, error) @@ -231,10 +231,10 @@ func (rc *rpcClient) RemoveRoutingRule(key routing.RouteID) error { } // RouteGroups calls RouteGroups. -func (rc *rpcClient) RouteGroups() ([]LoopInfo, error) { - var loops []LoopInfo - err := rc.Call("RouteGroups", &struct{}{}, &loops) - return loops, err +func (rc *rpcClient) RouteGroups() ([]RouteGroupInfo, error) { + var routegroups []RouteGroupInfo + err := rc.Call("RouteGroups", &struct{}{}, &routegroups) + return routegroups, err } // Restart calls Restart. @@ -581,8 +581,8 @@ func (mc *mockRPCClient) RemoveRoutingRule(key routing.RouteID) error { } // RouteGroups implements RPCClient. -func (mc *mockRPCClient) RouteGroups() ([]LoopInfo, error) { - var loops []LoopInfo +func (mc *mockRPCClient) RouteGroups() ([]RouteGroupInfo, error) { + var loops []RouteGroupInfo rules := mc.rt.AllRules() for _, rule := range rules { @@ -595,7 +595,7 @@ func (mc *mockRPCClient) RouteGroups() ([]LoopInfo, error) { if err != nil { return nil, err } - loops = append(loops, LoopInfo{ + loops = append(loops, RouteGroupInfo{ ConsumeRule: rule, FwdRule: fwdRule, }) diff --git a/vendor/github.com/SkycoinProject/dmsg/disc/entry.go b/vendor/github.com/SkycoinProject/dmsg/disc/entry.go index b3237d959d..6555c17910 100644 --- a/vendor/github.com/SkycoinProject/dmsg/disc/entry.go +++ b/vendor/github.com/SkycoinProject/dmsg/disc/entry.go @@ -152,7 +152,7 @@ type Server struct { // Port in which the DMSG Server is listening for connections. Port string `json:"port"` - // Number of connections still available. + // Number of connections still available.180 AvailableConnections int `json:"available_connections"` } diff --git a/vendor/github.com/SkycoinProject/dmsg/httputil/error.go b/vendor/github.com/SkycoinProject/dmsg/httputil/error.go index 5b545990a2..0752c6a05e 100644 --- a/vendor/github.com/SkycoinProject/dmsg/httputil/error.go +++ b/vendor/github.com/SkycoinProject/dmsg/httputil/error.go @@ -1,6 +1,7 @@ package httputil import ( + "bytes" "fmt" "io/ioutil" "net/http" @@ -22,7 +23,7 @@ func ErrorFromResp(resp *http.Response) error { if err != nil && len(msg) == 0 { msg = []byte(fmt.Sprintf("failed to read HTTP response body: %v", err)) } - return &HTTPError{Status: status, Body: string(msg)} + return &HTTPError{Status: status, Body: string(bytes.TrimSpace(msg))} } // Error returns the error message. diff --git a/vendor/modules.txt b/vendor/modules.txt index 2ece7f09d8..22ec8c199d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/SkycoinProject/dmsg v0.0.0-20200304115237-130cc9d98ffb +# github.com/SkycoinProject/dmsg v0.0.0-20200304115237-130cc9d98ffb => ../dmsg github.com/SkycoinProject/dmsg github.com/SkycoinProject/dmsg/cipher github.com/SkycoinProject/dmsg/disc From d9c21d727d5703516efd8a2e7b1b412dac9b37c5 Mon Sep 17 00:00:00 2001 From: Kifen Date: Fri, 6 Mar 2020 13:04:31 +0000 Subject: [PATCH 3/8] rename var rg to routegroups --- pkg/hypervisor/hypervisor.go | 6 +++--- vendor/github.com/SkycoinProject/dmsg/disc/entry.go | 2 +- vendor/modules.txt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index 8f588ebdc4..a2881f60c9 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -674,14 +674,14 @@ func makeRouteGroupResp(info visor.RouteGroupInfo) routeGroupResp { func (hv *Hypervisor) getRouteGroup() http.HandlerFunc { return hv.withCtx(hv.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { - rg, err := ctx.RPC.RouteGroups() + routegroups, err := ctx.RPC.RouteGroups() if err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) return } - resp := make([]routeGroupResp, len(rg)) - for i, l := range rg { + resp := make([]routeGroupResp, len(routegroups)) + for i, l := range routegroups { resp[i] = makeRouteGroupResp(l) } diff --git a/vendor/github.com/SkycoinProject/dmsg/disc/entry.go b/vendor/github.com/SkycoinProject/dmsg/disc/entry.go index 6555c17910..b3237d959d 100644 --- a/vendor/github.com/SkycoinProject/dmsg/disc/entry.go +++ b/vendor/github.com/SkycoinProject/dmsg/disc/entry.go @@ -152,7 +152,7 @@ type Server struct { // Port in which the DMSG Server is listening for connections. Port string `json:"port"` - // Number of connections still available.180 + // Number of connections still available. AvailableConnections int `json:"available_connections"` } diff --git a/vendor/modules.txt b/vendor/modules.txt index cb559b3d1e..9e4174704b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/SkycoinProject/dmsg v0.0.0-20200305081343-7a67392d759d => ../dmsg +# github.com/SkycoinProject/dmsg v0.0.0-20200305081343-7a67392d759d github.com/SkycoinProject/dmsg github.com/SkycoinProject/dmsg/cipher github.com/SkycoinProject/dmsg/disc From c3d78d37dad5bca39ef68193242cec0f5c797f58 Mon Sep 17 00:00:00 2001 From: Kifen Date: Fri, 6 Mar 2020 13:14:50 +0000 Subject: [PATCH 4/8] rename endpoint to routegroups --- pkg/hypervisor/hypervisor.go | 4 ++-- vendor/github.com/SkycoinProject/dmsg/disc/entry.go | 2 +- vendor/modules.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index a2881f60c9..e07a85de97 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -172,7 +172,7 @@ func (hv *Hypervisor) ServeHTTP(w http.ResponseWriter, req *http.Request) { r.Get("/visors/{pk}/routes/{rid}", hv.getRoute()) r.Put("/visors/{pk}/routes/{rid}", hv.putRoute()) r.Delete("/visors/{pk}/routes/{rid}", hv.deleteRoute()) - r.Get("/visors/{pk}/routegroup", hv.getRouteGroup()) + r.Get("/visors/{pk}/routegroups", hv.getRouteGroups()) r.Get("/visors/{pk}/restart", hv.restart()) r.Post("/visors/{pk}/exec", hv.exec()) r.Post("/visors/{pk}/update", hv.update()) @@ -672,7 +672,7 @@ func makeRouteGroupResp(info visor.RouteGroupInfo) routeGroupResp { } } -func (hv *Hypervisor) getRouteGroup() http.HandlerFunc { +func (hv *Hypervisor) getRouteGroups() http.HandlerFunc { return hv.withCtx(hv.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { routegroups, err := ctx.RPC.RouteGroups() if err != nil { diff --git a/vendor/github.com/SkycoinProject/dmsg/disc/entry.go b/vendor/github.com/SkycoinProject/dmsg/disc/entry.go index b3237d959d..6555c17910 100644 --- a/vendor/github.com/SkycoinProject/dmsg/disc/entry.go +++ b/vendor/github.com/SkycoinProject/dmsg/disc/entry.go @@ -152,7 +152,7 @@ type Server struct { // Port in which the DMSG Server is listening for connections. Port string `json:"port"` - // Number of connections still available. + // Number of connections still available.180 AvailableConnections int `json:"available_connections"` } diff --git a/vendor/modules.txt b/vendor/modules.txt index 9e4174704b..cb559b3d1e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/SkycoinProject/dmsg v0.0.0-20200305081343-7a67392d759d +# github.com/SkycoinProject/dmsg v0.0.0-20200305081343-7a67392d759d => ../dmsg github.com/SkycoinProject/dmsg github.com/SkycoinProject/dmsg/cipher github.com/SkycoinProject/dmsg/disc From e8fd8cc4d7a47b62fe7c2c74d33b04827b9b29df Mon Sep 17 00:00:00 2001 From: Kifen Date: Fri, 6 Mar 2020 16:37:47 +0000 Subject: [PATCH 5/8] fix conflicts --- README.md | 6 +++--- pkg/app/appnet/skywire_networker.go | 10 +++++----- pkg/setup/node_test.go | 2 +- pkg/visor/rpc_client.go | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1398c9a28d..fc585b72b8 100644 --- a/README.md +++ b/README.md @@ -228,13 +228,13 @@ communication API over the pipe. // Setup setups app using default pair of pipes func Setup(config *Config) (*App, error) {} -// Accept awaits for incoming loop confirmation request from a Visor and -// returns net.Conn for a received loop. +// Accept awaits for incoming route group confirmation request from a Visor and +// returns net.Conn for a received route group. func (app *App) Accept() (net.Conn, error) {} // Addr implements net.Addr for App connections. &Addr{PubKey: pk, Port: 12} -// Dial sends create loop request to a Visor and returns net.Conn for created loop. +// Dial sends create route group request to a Visor and returns net.Conn for created route group. func (app *App) Dial(raddr *Addr) (net.Conn, error) {} // Close implements io.Closer for App. diff --git a/pkg/app/appnet/skywire_networker.go b/pkg/app/appnet/skywire_networker.go index 4bf78bc5f5..5f33d9b697 100644 --- a/pkg/app/appnet/skywire_networker.go +++ b/pkg/app/appnet/skywire_networker.go @@ -88,8 +88,8 @@ func (r *SkywireNetworker) ListenContext(ctx context.Context, addr Addr) (net.Li if atomic.CompareAndSwapInt32(&r.isServing, 0, 1) { go func() { - if err := r.serveLoop(ctx); err != nil && !strings.Contains(err.Error(), "use of closed network connection") { - r.log.WithError(err).Error("serveLoop stopped unexpectedly.") + if err := r.serveRouteGroup(ctx); err != nil && !strings.Contains(err.Error(), "use of closed network connection") { + r.log.WithError(err).Error("serveRouteGroup stopped unexpectedly.") } }() } @@ -97,9 +97,9 @@ func (r *SkywireNetworker) ListenContext(ctx context.Context, addr Addr) (net.Li return lis, nil } -// serveLoop accepts and serves routes. -func (r *SkywireNetworker) serveLoop(ctx context.Context) error { - log := r.log.WithField("func", "serveLoop") +// serveRouteGroup accepts and serves routes. +func (r *SkywireNetworker) serveRouteGroup(ctx context.Context) error { + log := r.log.WithField("func", "serveRouteGroup") for { log.Debug("Awaiting to accept route group...") diff --git a/pkg/setup/node_test.go b/pkg/setup/node_test.go index 5bc1813491..622bed13e2 100644 --- a/pkg/setup/node_test.go +++ b/pkg/setup/node_test.go @@ -120,7 +120,7 @@ func testDialRouteGroup(t *testing.T, keys []snettest.KeyPair, nEnv *snettest.En } func prepBidirectionalRoute(clients []clientWithDMSGAddrAndListener) routing.BidirectionalRoute { - // prepare loop creation (client_1 will use this to request loop creation with setup node). + // prepare route group creation (client_1 will use this to request a route group creation with setup node). desc := routing.NewRouteDescriptor(clients[1].Addr.PK, clients[4].Addr.PK, 1, 1) forwardHops := []routing.Hop{ diff --git a/pkg/visor/rpc_client.go b/pkg/visor/rpc_client.go index e30eeae4c2..fa0b01984a 100644 --- a/pkg/visor/rpc_client.go +++ b/pkg/visor/rpc_client.go @@ -582,7 +582,7 @@ func (mc *mockRPCClient) RemoveRoutingRule(key routing.RouteID) error { // RouteGroups implements RPCClient. func (mc *mockRPCClient) RouteGroups() ([]RouteGroupInfo, error) { - var loops []RouteGroupInfo + var routeGroups []RouteGroupInfo rules := mc.rt.AllRules() for _, rule := range rules { @@ -595,13 +595,13 @@ func (mc *mockRPCClient) RouteGroups() ([]RouteGroupInfo, error) { if err != nil { return nil, err } - loops = append(loops, RouteGroupInfo{ + routeGroups = append(routeGroups, RouteGroupInfo{ ConsumeRule: rule, FwdRule: fwdRule, }) } - return loops, nil + return routeGroups, nil } // Restart implements RPCClient. From 3078f6402f3412a1fa3723a59cc17b2f86d41b0a Mon Sep 17 00:00:00 2001 From: Kifen Date: Fri, 6 Mar 2020 16:47:02 +0000 Subject: [PATCH 6/8] rename loop to route group in router.go --- pkg/router/router.go | 2 +- pkg/router/router_test.go | 2 +- pkg/setup/node.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/router/router.go b/pkg/router/router.go index 8accb3180c..8a3eb01786 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -124,7 +124,7 @@ type Router interface { // Router implements visor.PacketRouter. It manages routing table by // communicating with setup nodes, forward packets according to local -// rules and manages loops for apps. +// rules and manages route groups for apps. type router struct { mx sync.Mutex conf *Config diff --git a/pkg/router/router_test.go b/pkg/router/router_test.go index da7bdf2adb..8e294f7d07 100644 --- a/pkg/router/router_test.go +++ b/pkg/router/router_test.go @@ -70,7 +70,7 @@ func Test_router_DialRoutes(t *testing.T) { r0.conf.RouteGroupDialer = setupclient.NewMockDialer() r1.conf.RouteGroupDialer = setupclient.NewMockDialer() - // prepare loop creation (client_1 will use this to request loop creation with setup node). + // prepare route group creation (client_1 will use this to request route group creation with setup node). desc := routing.NewRouteDescriptor(r0.conf.PubKey, r1.conf.PubKey, 1, 1) forwardHops := []routing.Hop{ diff --git a/pkg/setup/node.go b/pkg/setup/node.go index fa83950edb..9930882570 100644 --- a/pkg/setup/node.go +++ b/pkg/setup/node.go @@ -110,7 +110,7 @@ func (sn *Node) handleDialRouteGroup(ctx context.Context, route routing.Bidirect forwardRoute, reverseRoute := route.ForwardAndReverse() - // Determine the rules to send to visors using loop descriptor and reserved route IDs. + // Determine the rules to send to visors using route group descriptor and reserved route IDs. forwardRules, consumeRules, intermediaryRules, err := idr.GenerateRules(forwardRoute, reverseRoute) if err != nil { @@ -144,7 +144,7 @@ func (sn *Node) handleDialRouteGroup(ctx context.Context, route routing.Bidirect // Confirm routes with responding visor. ok, err := routerclient.AddEdgeRules(ctx, sn.logger, sn.dmsgC, route.Desc.DstPK(), respRouteRules) if err != nil || !ok { - return routing.EdgeRules{}, fmt.Errorf("failed to confirm loop with destination visor: %v", err) + return routing.EdgeRules{}, fmt.Errorf("failed to confirm route group with destination visor: %v", err) } sn.logger.Infof("Returning route rules to initiating visor: %v", initRouteRules) From 232189affb688a8e43b0dd44e1bf237a6ab923e8 Mon Sep 17 00:00:00 2001 From: Kifen Date: Fri, 6 Mar 2020 16:59:06 +0000 Subject: [PATCH 7/8] rename loop to route group in run-pkg-tests.sh --- ci_scripts/run-pkg-tests.sh | 20 ++++++++++---------- pkg/router/route_group.go | 6 +++--- pkg/router/router.go | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ci_scripts/run-pkg-tests.sh b/ci_scripts/run-pkg-tests.sh index cb70c448c8..eb33d8eb15 100755 --- a/ci_scripts/run-pkg-tests.sh +++ b/ci_scripts/run-pkg-tests.sh @@ -29,27 +29,27 @@ go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/visor -run TestRPC >> ./logs/pkg/TestRPC.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestAppManagerInit >> ./logs/pkg/TestAppManagerInit.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestAppManagerSetupLoop >> ./logs/pkg/TestAppManagerSetupLoop.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestAppManagerCloseLoop >> ./logs/pkg/TestAppManagerCloseLoop.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestAppManagerSetupRouteGroup >> ./logs/pkg/TestAppManagerSetupRouteGroup.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestAppManagerCloseRouteGRoup >> ./logs/pkg/TestAppManagerCloseRouteGroup.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestAppManagerForward >> ./logs/pkg/TestAppManagerForward.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestManagedRoutingTableCleanup >> ./logs/pkg/TestManagedRoutingTableCleanup.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestPortManager >> ./logs/pkg/TestPortManager.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouteManagerGetRule >> ./logs/pkg/TestRouteManagerGetRule.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouteManagerRemoveLoopRule >> ./logs/pkg/TestRouteManagerRemoveLoopRule.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouteManagerRemoveRouteGroupRule >> ./logs/pkg/TestRouteManagerRemoveRouteGroupRule.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouteManagerAddRemoveRule >> ./logs/pkg/TestRouteManagerAddRemoveRule.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouteManagerDeleteRules >> ./logs/pkg/TestRouteManagerDeleteRules.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouteManagerConfirmLoop >> ./logs/pkg/TestRouteManagerConfirmLoop.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouteManagerLoopClosed >> ./logs/pkg/TestRouteManagerLoopClosed.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouteManagerConfirmRouteGroup >> ./logs/pkg/TestRouteManagerConfirmRouteGroup.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouteManagerRouteGroupClosed >> ./logs/pkg/TestRouteManagerRouteGroupClosed.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterForwarding >> ./logs/pkg/TestRouterForwarding.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterAppInit >> ./logs/pkg/TestRouterAppInit.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterApp >> ./logs/pkg/TestRouterApp.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterLocalApp >> ./logs/pkg/TestRouterLocalApp.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterSetup >> ./logs/pkg/TestRouterSetup.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterSetupLoop >> ./logs/pkg/TestRouterSetupLoop.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterSetupLoopLocal >> ./logs/pkg/TestRouterSetupLoopLocal.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterCloseLoop >> ./logs/pkg/TestRouterCloseLoop.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterCloseLoopOnAppClose >> ./logs/pkg/TestRouterCloseLoopOnAppClose.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterCloseLoopOnRouterClose >> ./logs/pkg/TestRouterCloseLoopOnRouterClose.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterSetupRouteGroup >> ./logs/pkg/TestRouterSetupRouteGroup.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterSetupRouteGroupLocal >> ./logs/pkg/TestRouterSetupRouteGroupLocal.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterCloseRouteGroup >> ./logs/pkg/TestRouterCloseRouteGroup.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterCloseRouteGroupOnAppClose >> ./logs/pkg/TestRouterCloseRouteGroupOnAppClose.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterCloseRouteGroupOnRouterClose >> ./logs/pkg/TestRouterCloseRouteGroupOnRouterClose.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/router -run TestRouterRouteExpiration >> ./logs/pkg/TestRouterRouteExpiration.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/SkycoinProject/skywire-mainnet/pkg/routing -run TestBoltDBRoutingTable >> ./logs/pkg/TestBoltDBRoutingTable.log diff --git a/pkg/router/route_group.go b/pkg/router/route_group.go index b4dcdd36cc..07be4ed08a 100644 --- a/pkg/router/route_group.go +++ b/pkg/router/route_group.go @@ -424,7 +424,7 @@ func (rg *RouteGroup) close(code routing.CloseCode) error { // if this visor initiated closing, we need to wait for close packets // to come back, or to exit with a timeout if anything goes wrong in // the network - if err := rg.waitForCloseLoop(closeRoutineTimeout); err != nil { + if err := rg.waitForCloseRouteGroup(closeRoutineTimeout); err != nil { rg.logger.Errorf("Error during close loop: %v", err) } } @@ -496,7 +496,7 @@ func (rg *RouteGroup) broadcastClosePackets(code routing.CloseCode) { } } -func (rg *RouteGroup) waitForCloseLoop(waitTimeout time.Duration) error { +func (rg *RouteGroup) waitForCloseRouteGroup(waitTimeout time.Duration) error { closeCtx, closeCancel := context.WithTimeout(context.Background(), waitTimeout) defer closeCancel() @@ -509,7 +509,7 @@ func (rg *RouteGroup) waitForCloseLoop(waitTimeout time.Duration) error { select { case <-closeCtx.Done(): - return fmt.Errorf("close loop timed out: %v", closeCtx.Err()) + return fmt.Errorf("close route group timed out: %v", closeCtx.Err()) case <-closeDoneCh: } diff --git a/pkg/router/router.go b/pkg/router/router.go index 8a3eb01786..14b9a88750 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -594,7 +594,7 @@ func (r *router) forwardPacket(ctx context.Context, packet routing.Packet, rule return nil } -// RemoveRouteDescriptor removes loop rule. +// RemoveRouteDescriptor removes route group rule. func (r *router) RemoveRouteDescriptor(desc routing.RouteDescriptor) { rules := r.rt.AllRules() for _, rule := range rules { From 995df8b3ceb501ee3b525456d614e30844a0a10c Mon Sep 17 00:00:00 2001 From: Kifen Date: Fri, 6 Mar 2020 17:09:41 +0000 Subject: [PATCH 8/8] fix merge conflicts --- pkg/router/route_group.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/router/route_group.go b/pkg/router/route_group.go index 07be4ed08a..025ddb5072 100644 --- a/pkg/router/route_group.go +++ b/pkg/router/route_group.go @@ -425,7 +425,7 @@ func (rg *RouteGroup) close(code routing.CloseCode) error { // to come back, or to exit with a timeout if anything goes wrong in // the network if err := rg.waitForCloseRouteGroup(closeRoutineTimeout); err != nil { - rg.logger.Errorf("Error during close loop: %v", err) + rg.logger.Errorf("Error during close route group: %v", err) } }