Created
October 4, 2017 13:19
-
-
Save ppcano/c20cf4b4b6daa2230af74237944ebeae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ws from "k6/ws"; | |
import {check} from "k6"; | |
export let options = { | |
vus: 1, | |
duration: "5s" | |
} | |
export default function () { | |
var url = "ws://echo.websocket.org"; | |
var response = ws.connect(url, {}, function (socket) { | |
socket.ping(); | |
socket.on('pong', function (e) { | |
console.log('received pong'); | |
}); | |
socket.on('error', function (e) { | |
if (e) { | |
console.log('k6 error ' + e.error()); | |
} | |
}); | |
}); | |
check(response, { "status is 101": (r) => r && r.status === 101 }); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment