Skip to content

Commit

Permalink
ws tests: replace echo.websocket.org with demos.kaazing.com/echo
Browse files Browse the repository at this point in the history
  • Loading branch information
borjacampina committed Nov 27, 2017
1 parent b65a5d0 commit 3037e28
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions js/modules/k6/ws/ws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,31 +94,31 @@ func TestSession(t *testing.T) {

t.Run("connect_ws", func(t *testing.T) {
_, err := common.RunString(rt, `
let res = ws.connect("ws://echo.websocket.org", function(socket){
let res = ws.connect("ws://demos.kaazing.com/echo", function(socket){
socket.close()
});
if (res.status != 101) { throw new Error("connection failed with status: " + res.status); }
`)
assert.NoError(t, err)
})
assertSessionMetricsEmitted(t, state.Samples, "", "ws://echo.websocket.org", 101, "")
assertSessionMetricsEmitted(t, state.Samples, "", "ws://demos.kaazing.com/echo", 101, "")

t.Run("connect_wss", func(t *testing.T) {
_, err := common.RunString(rt, `
let res = ws.connect("wss://echo.websocket.org", function(socket){
let res = ws.connect("wss://demos.kaazing.com/echo", function(socket){
socket.close()
});
if (res.status != 101) { throw new Error("TLS connection failed with status: " + res.status); }
`)
assert.NoError(t, err)
})
assertSessionMetricsEmitted(t, state.Samples, "", "wss://echo.websocket.org", 101, "")
assertSessionMetricsEmitted(t, state.Samples, "", "wss://demos.kaazing.com/echo", 101, "")

t.Run("open", func(t *testing.T) {
state.Samples = nil
_, err := common.RunString(rt, `
let opened = false;
let res = ws.connect("ws://echo.websocket.org", function(socket){
let res = ws.connect("ws://demos.kaazing.com/echo", function(socket){
socket.on("open", function() {
opened = true;
socket.close()
Expand All @@ -128,12 +128,12 @@ func TestSession(t *testing.T) {
`)
assert.NoError(t, err)
})
assertSessionMetricsEmitted(t, state.Samples, "", "ws://echo.websocket.org", 101, "")
assertSessionMetricsEmitted(t, state.Samples, "", "ws://demos.kaazing.com/echo", 101, "")

t.Run("send_receive", func(t *testing.T) {
state.Samples = nil
_, err := common.RunString(rt, `
let res = ws.connect("ws://echo.websocket.org", function(socket){
let res = ws.connect("ws://demos.kaazing.com/echo", function(socket){
socket.on("open", function() {
socket.send("test")
})
Expand All @@ -147,15 +147,15 @@ func TestSession(t *testing.T) {
`)
assert.NoError(t, err)
})
assertSessionMetricsEmitted(t, state.Samples, "", "ws://echo.websocket.org", 101, "")
assertMetricEmitted(t, metrics.WSMessagesSent, state.Samples, "ws://echo.websocket.org")
assertMetricEmitted(t, metrics.WSMessagesReceived, state.Samples, "ws://echo.websocket.org")
assertSessionMetricsEmitted(t, state.Samples, "", "ws://demos.kaazing.com/echo", 101, "")
assertMetricEmitted(t, metrics.WSMessagesSent, state.Samples, "ws://demos.kaazing.com/echo")
assertMetricEmitted(t, metrics.WSMessagesReceived, state.Samples, "ws://demos.kaazing.com/echo")

t.Run("interval", func(t *testing.T) {
state.Samples = nil
_, err := common.RunString(rt, `
let counter = 0;
let res = ws.connect("ws://echo.websocket.org", function(socket){
let res = ws.connect("ws://demos.kaazing.com/echo", function(socket){
socket.setInterval(function () {
counter += 1;
if (counter > 2) { socket.close(); }
Expand All @@ -165,14 +165,14 @@ func TestSession(t *testing.T) {
`)
assert.NoError(t, err)
})
assertSessionMetricsEmitted(t, state.Samples, "", "ws://echo.websocket.org", 101, "")
assertSessionMetricsEmitted(t, state.Samples, "", "ws://demos.kaazing.com/echo", 101, "")

t.Run("timeout", func(t *testing.T) {
state.Samples = nil
_, err := common.RunString(rt, `
let start = new Date().getTime();
let ellapsed = new Date().getTime() - start;
let res = ws.connect("ws://echo.websocket.org", function(socket){
let res = ws.connect("ws://demos.kaazing.com/echo", function(socket){
socket.setTimeout(function () {
ellapsed = new Date().getTime() - start;
socket.close();
Expand All @@ -184,13 +184,13 @@ func TestSession(t *testing.T) {
`)
assert.NoError(t, err)
})
assertSessionMetricsEmitted(t, state.Samples, "", "ws://echo.websocket.org", 101, "")
assertSessionMetricsEmitted(t, state.Samples, "", "ws://demos.kaazing.com/echo", 101, "")

t.Run("ping", func(t *testing.T) {
state.Samples = nil
_, err := common.RunString(rt, `
let pongReceived = false;
let res = ws.connect("ws://echo.websocket.org", function(socket){
let res = ws.connect("ws://demos.kaazing.com/echo", function(socket){
socket.on("open", function(data) {
socket.ping();
});
Expand All @@ -206,16 +206,16 @@ func TestSession(t *testing.T) {
`)
assert.NoError(t, err)
})
assertSessionMetricsEmitted(t, state.Samples, "", "ws://echo.websocket.org", 101, "")
assertMetricEmitted(t, metrics.WSPing, state.Samples, "ws://echo.websocket.org")
assertSessionMetricsEmitted(t, state.Samples, "", "ws://demos.kaazing.com/echo", 101, "")
assertMetricEmitted(t, metrics.WSPing, state.Samples, "ws://demos.kaazing.com/echo")

t.Run("multiple_handlers", func(t *testing.T) {
state.Samples = nil
_, err := common.RunString(rt, `
let pongReceived = false;
let otherPongReceived = false;
let res = ws.connect("ws://echo.websocket.org", function(socket){
let res = ws.connect("ws://demos.kaazing.com/echo", function(socket){
socket.on("open", function(data) {
socket.ping();
});
Expand All @@ -239,14 +239,14 @@ func TestSession(t *testing.T) {
`)
assert.NoError(t, err)
})
assertSessionMetricsEmitted(t, state.Samples, "", "ws://echo.websocket.org", 101, "")
assertMetricEmitted(t, metrics.WSPing, state.Samples, "ws://echo.websocket.org")
assertSessionMetricsEmitted(t, state.Samples, "", "ws://demos.kaazing.com/echo", 101, "")
assertMetricEmitted(t, metrics.WSPing, state.Samples, "ws://demos.kaazing.com/echo")

t.Run("close", func(t *testing.T) {
state.Samples = nil
_, err := common.RunString(rt, `
let closed = false;
let res = ws.connect("ws://echo.websocket.org", function(socket){
let res = ws.connect("ws://demos.kaazing.com/echo", function(socket){
socket.on("open", function() {
socket.close()
})
Expand All @@ -258,7 +258,7 @@ func TestSession(t *testing.T) {
`)
assert.NoError(t, err)
})
assertSessionMetricsEmitted(t, state.Samples, "", "ws://echo.websocket.org", 101, "")
assertSessionMetricsEmitted(t, state.Samples, "", "ws://demos.kaazing.com/echo", 101, "")
}

func TestErrors(t *testing.T) {
Expand Down Expand Up @@ -296,7 +296,7 @@ func TestErrors(t *testing.T) {
state.Samples = nil
_, err := common.RunString(rt, `
let hasError = false;
let res = ws.connect("ws://echo.websocket.org", function(socket){
let res = ws.connect("ws://demos.kaazing.com/echo", function(socket){
socket.on("open", function() {
socket.close();
socket.send("test");
Expand All @@ -311,6 +311,6 @@ func TestErrors(t *testing.T) {
}
`)
assert.NoError(t, err)
assertSessionMetricsEmitted(t, state.Samples, "", "ws://echo.websocket.org", 101, "")
assertSessionMetricsEmitted(t, state.Samples, "", "ws://demos.kaazing.com/echo", 101, "")
})
}

0 comments on commit 3037e28

Please sign in to comment.