Skip to content

Commit

Permalink
Merge pull request #1149 from loadimpact/fix/flaky-metrics-test
Browse files Browse the repository at this point in the history
Fix(?): flaky TestSentReceivedMetrics test
  • Loading branch information
Ivan Mirić authored Sep 11, 2019
2 parents a2077dd + ae564fd commit 1f913f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
8 changes: 4 additions & 4 deletions core/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func TestSentReceivedMetrics(t *testing.T) {
{tr(`import ws from "k6/ws";
let data = "0123456789".repeat(100);
export default function() {
ws.connect("ws://HTTPBIN_IP:HTTPBIN_PORT/ws-echo", null, function (socket) {
ws.connect("WSBIN_URL/ws-echo", null, function (socket) {
socket.on('open', function open() {
socket.send(data);
});
Expand Down Expand Up @@ -618,10 +618,10 @@ func TestSentReceivedMetrics(t *testing.T) {
reuseSent, reuseReceived := runTest(t, ts, tc, false)

if noReuseSent < reuseSent {
t.Errorf("noReuseSent=%f is greater than reuseSent=%f", noReuseSent, reuseSent)
t.Errorf("reuseSent=%f is greater than noReuseSent=%f", reuseSent, noReuseSent)
}
if noReuseReceived < reuseReceived {
t.Errorf("noReuseReceived=%f is greater than reuseReceived=%f", noReuseReceived, reuseReceived)
t.Errorf("reuseReceived=%f is greater than noReuseReceived=%f", reuseReceived, noReuseReceived)
}
}
}
Expand Down Expand Up @@ -667,7 +667,7 @@ func TestRunTags(t *testing.T) {
})
group("websockets", function() {
var response = ws.connect("wss://HTTPSBIN_IP:HTTPSBIN_PORT/ws-echo", params, function (socket) {
var response = ws.connect("WSBIN_URL/ws-echo", params, function (socket) {
socket.on('open', function open() {
console.log('ws open and say hello');
socket.send("hello");
Expand Down
20 changes: 11 additions & 9 deletions lib/testutils/httpmultibin/httpmultibin.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,17 @@ func websocketEchoHandler(w http.ResponseWriter, req *http.Request) {
return
}

for {
mt, message, err := conn.ReadMessage()
if err != nil {
break
}
err = conn.WriteMessage(mt, message)
if err != nil {
break
}
mt, message, err := conn.ReadMessage()
if err != nil {
return
}
err = conn.WriteMessage(mt, message)
if err != nil {
return
}
err = conn.Close()
if err != nil {
return
}
}

Expand Down

0 comments on commit 1f913f8

Please sign in to comment.