Skip to content

Commit

Permalink
Apply more readable comments
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Kositsyn <kositsyn.pa@phystech.edu>
  • Loading branch information
pkositsyn committed Nov 27, 2020
2 parents ee12b57 + 50a335f commit d9458ff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/agent/app/servers/tbuffered_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,18 @@ type fakeTransport struct {
wg sync.WaitGroup
}

// Read simulates three packets received, then blocks until semaphore is released at the end of the test.
// First packet is returned as normal.
// Second packet is simulated as error.
// Third packet is returned as normal, but will be dropped as overflow by the server whose queue size = 1.
func (t *fakeTransport) Read(p []byte) (n int, err error) {
packet := t.packet.Inc()
if packet == 2 {
// return some error packet, followed by valid one
return 0, io.ErrNoProgress
}
if packet > 3 {
// don't return error at this moment to avoid flaky test
// block after 3 packets until the server is shutdown and semaphore released
t.wg.Wait()
return 0, io.EOF
}
Expand Down Expand Up @@ -132,7 +136,7 @@ func TestTBufferedServer_Metrics(t *testing.T) {

// The fakeTransport will allow the server to read exactly two packets and one error in between.
// Since we use the server with queue size == 1, the first packet will be
// sent to channel, the error will be processed and the second valid packet dropped.
// sent to channel, the error will increment the metric, and the second valid packet dropped.

packetDropped := false
for i := 0; i < 5000; i++ {
Expand Down

0 comments on commit d9458ff

Please sign in to comment.