Skip to content

Commit

Permalink
Fix refresh after heal request; Add refresh after heal testing
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Belov <artem.belov@xored.com>
  • Loading branch information
Artem Belov committed Mar 22, 2021
1 parent c724d15 commit 6e1807c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
29 changes: 28 additions & 1 deletion pkg/networkservice/chains/nsmgr/server_heal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ func testNSMGRHealEndpoint(t *testing.T, restored bool) {

// Wait NSE expired and reconnecting to the new NSE
require.Eventually(t, checkSecondRequestsReceived(counter.UniqueRequests), timeout, tick)
require.Equal(t, 2, counter.UniqueRequests())

// Check refresh
request.Connection = conn
_, err = nsc.Request(ctx, request.Clone())
require.NoError(t, err)

// Close.
e, err := nsc.Close(ctx, conn)
Expand Down Expand Up @@ -244,6 +250,16 @@ func testNSMGRHealForwarder(t *testing.T, nodeNum int, restored bool, customConf
} else {
require.Eventually(t, checkSecondRequestsReceived(counter.UniqueRequests), timeout, tick)
}
if restored {
require.Equal(t, int32(2), atomic.LoadInt32(&counter.Requests))
} else {
require.Equal(t, 2, counter.UniqueRequests())
}

// Check refresh
request.Connection = conn
_, err = nsc.Request(ctx, request.Clone())
require.NoError(t, err)

// Close.
closes := atomic.LoadInt32(&counter.Closes)
Expand All @@ -252,7 +268,7 @@ func testNSMGRHealForwarder(t *testing.T, nodeNum int, restored bool, customConf
require.NotNil(t, e)

if restored {
require.Equal(t, int32(2), atomic.LoadInt32(&counter.Requests))
require.Equal(t, int32(3), atomic.LoadInt32(&counter.Requests))
require.Equal(t, closes+1, atomic.LoadInt32(&counter.Closes))
} else {
require.Equal(t, 2, counter.UniqueRequests())
Expand Down Expand Up @@ -345,6 +361,11 @@ func testNSMGRHealNSMgr(t *testing.T, nodeNum int, customConfig []*sandbox.NodeC
return int(atomic.LoadInt32(&counter.Requests))
}), timeout, tick)

// Check refresh
request.Connection = conn
_, err = nsc.Request(ctx, request.Clone())
require.NoError(t, err)

// Close.
closes := atomic.LoadInt32(&counter.Closes)
e, err := nsc.Close(ctx, conn)
Expand Down Expand Up @@ -419,6 +440,12 @@ func TestNSMGR_HealRemoteNSMgr(t *testing.T) {

// Wait Cross NSE expired and reconnecting through the new Cross NSE
require.Eventually(t, checkSecondRequestsReceived(counter.UniqueRequests), timeout, tick)
require.Equal(t, 2, counter.UniqueRequests())

// Check refresh
request.Connection = conn
_, err = nsc.Request(ctx, request.Clone())
require.NoError(t, err)

// Close.
e, err := nsc.Close(ctx, conn)
Expand Down
1 change: 1 addition & 0 deletions pkg/networkservice/common/heal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ func (f *healServer) replaceConnectionPath(conn *networkservice.Connection) {
if storedConn, ok := f.conns.Load(conn.GetId()); ok {
path.PathSegments = path.PathSegments[:path.Index+1]
path.PathSegments = append(path.PathSegments, storedConn.Path.PathSegments[path.Index+1:]...)
conn.NetworkServiceEndpointName = storedConn.NetworkServiceEndpointName
}
}
}
Expand Down

0 comments on commit 6e1807c

Please sign in to comment.