Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(?): flaky TestSentReceivedMetrics test #1149

Merged
merged 3 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now correct, right? 😄

The error message noReuseReceived=28325.000000 is greater than reuseReceived=28329.000000 seemed wrong to me :)

}
}
}
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should've been WSSBIN_URL although ... apperantly it doesn't matter :(

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