mirror of https://github.com/status-im/consul.git
Fixup test
This commit is contained in:
parent
4f4112662e
commit
bf72df7b0e
|
@ -351,11 +351,15 @@ func (s *Server) realHandleStream(streamReq HandleStreamRequest) error {
|
||||||
err := streamReq.Stream.Send(msg)
|
err := streamReq.Stream.Send(msg)
|
||||||
sendMutex.Unlock()
|
sendMutex.Unlock()
|
||||||
|
|
||||||
|
// We only track send successes and errors for response types because this is meant to track
|
||||||
|
// resources, not request/ack messages.
|
||||||
|
if msg.GetResponse() != nil {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
status.TrackSendError(err.Error())
|
status.TrackSendError(err.Error())
|
||||||
} else {
|
} else {
|
||||||
status.TrackSendSuccess()
|
status.TrackSendSuccess()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -572,9 +572,15 @@ func TestStreamResources_Server_StreamTracker(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
var lastSendAck time.Time
|
var lastSendAck time.Time
|
||||||
|
var lastSendSuccess time.Time
|
||||||
|
|
||||||
client.DrainStream(t)
|
client.DrainStream(t)
|
||||||
|
|
||||||
|
// Manually grab the last success time from sending the trust bundle or exported services list.
|
||||||
|
status, ok := srv.StreamStatus(testPeerID)
|
||||||
|
require.True(t, ok)
|
||||||
|
lastSendSuccess = status.LastSendSuccess
|
||||||
|
|
||||||
testutil.RunStep(t, "ack tracked as success", func(t *testing.T) {
|
testutil.RunStep(t, "ack tracked as success", func(t *testing.T) {
|
||||||
ack := &pbpeerstream.ReplicationMessage{
|
ack := &pbpeerstream.ReplicationMessage{
|
||||||
Payload: &pbpeerstream.ReplicationMessage_Request_{
|
Payload: &pbpeerstream.ReplicationMessage_Request_{
|
||||||
|
@ -589,11 +595,13 @@ func TestStreamResources_Server_StreamTracker(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
lastSendAck = it.FutureNow(1)
|
lastSendAck = it.FutureNow(1)
|
||||||
|
|
||||||
err := client.Send(ack)
|
err := client.Send(ack)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
expect := Status{
|
expect := Status{
|
||||||
Connected: true,
|
Connected: true,
|
||||||
|
LastSendSuccess: lastSendSuccess,
|
||||||
LastAck: lastSendAck,
|
LastAck: lastSendAck,
|
||||||
ExportedServices: []string{},
|
ExportedServices: []string{},
|
||||||
}
|
}
|
||||||
|
@ -631,6 +639,7 @@ func TestStreamResources_Server_StreamTracker(t *testing.T) {
|
||||||
|
|
||||||
expect := Status{
|
expect := Status{
|
||||||
Connected: true,
|
Connected: true,
|
||||||
|
LastSendSuccess: lastSendSuccess,
|
||||||
LastAck: lastSendAck,
|
LastAck: lastSendAck,
|
||||||
LastNack: lastNack,
|
LastNack: lastNack,
|
||||||
LastNackMessage: lastNackMsg,
|
LastNackMessage: lastNackMsg,
|
||||||
|
@ -682,6 +691,7 @@ func TestStreamResources_Server_StreamTracker(t *testing.T) {
|
||||||
|
|
||||||
expect := Status{
|
expect := Status{
|
||||||
Connected: true,
|
Connected: true,
|
||||||
|
LastSendSuccess: lastSendSuccess,
|
||||||
LastAck: lastSendAck,
|
LastAck: lastSendAck,
|
||||||
LastNack: lastNack,
|
LastNack: lastNack,
|
||||||
LastNackMessage: lastNackMsg,
|
LastNackMessage: lastNackMsg,
|
||||||
|
@ -737,6 +747,7 @@ func TestStreamResources_Server_StreamTracker(t *testing.T) {
|
||||||
|
|
||||||
expect := Status{
|
expect := Status{
|
||||||
Connected: true,
|
Connected: true,
|
||||||
|
LastSendSuccess: lastSendSuccess,
|
||||||
LastAck: lastSendAck,
|
LastAck: lastSendAck,
|
||||||
LastNack: lastNack,
|
LastNack: lastNack,
|
||||||
LastNackMessage: lastNackMsg,
|
LastNackMessage: lastNackMsg,
|
||||||
|
@ -766,6 +777,7 @@ func TestStreamResources_Server_StreamTracker(t *testing.T) {
|
||||||
|
|
||||||
expect := Status{
|
expect := Status{
|
||||||
Connected: true,
|
Connected: true,
|
||||||
|
LastSendSuccess: lastSendSuccess,
|
||||||
LastAck: lastSendAck,
|
LastAck: lastSendAck,
|
||||||
LastNack: lastNack,
|
LastNack: lastNack,
|
||||||
LastNackMessage: lastNackMsg,
|
LastNackMessage: lastNackMsg,
|
||||||
|
@ -793,6 +805,7 @@ func TestStreamResources_Server_StreamTracker(t *testing.T) {
|
||||||
expect := Status{
|
expect := Status{
|
||||||
Connected: false,
|
Connected: false,
|
||||||
DisconnectErrorMessage: lastRecvErrorMsg,
|
DisconnectErrorMessage: lastRecvErrorMsg,
|
||||||
|
LastSendSuccess: lastSendSuccess,
|
||||||
LastAck: lastSendAck,
|
LastAck: lastSendAck,
|
||||||
LastNack: lastNack,
|
LastNack: lastNack,
|
||||||
LastNackMessage: lastNackMsg,
|
LastNackMessage: lastNackMsg,
|
||||||
|
|
Loading…
Reference in New Issue