mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
x.websocket: move to net.websocket module (#10648)
This commit is contained in:
20
vlib/net/websocket/tests/autobahn/README.md
Normal file
20
vlib/net/websocket/tests/autobahn/README.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Autobahn tests
|
||||
|
||||
This is the autobahn automatic tests on build.
|
||||
The performance tests are skipped due to timeouts in Github actions.
|
||||
|
||||
## Run it locally
|
||||
|
||||
### Test the client
|
||||
|
||||
This is how to test the client:
|
||||
|
||||
1. Run the docker autobahn test suite by running the `docker-compose up`
|
||||
2. From the `local_run` folder, compile and run `autobahn_client.v` to test non ws (no TLS) and
|
||||
`autobahn_client_wss.v` to run the TLS tests
|
||||
3. Open `http://localhost:8080` and browse client test results for non TLS and `https://localhost:8081`
|
||||
if you ran the wss tests (it uses local certificat so you will get trust error but just accept use)
|
||||
|
||||
### Test the server
|
||||
|
||||
Todo: add information here
|
33
vlib/net/websocket/tests/autobahn/autobahn_client.v
Normal file
33
vlib/net/websocket/tests/autobahn/autobahn_client.v
Normal file
@ -0,0 +1,33 @@
|
||||
// use this test to test the websocket client in the autobahn test
|
||||
module main
|
||||
|
||||
import net.websocket
|
||||
|
||||
fn main() {
|
||||
for i in 1 .. 304 {
|
||||
println('\ncase: $i')
|
||||
handle_case(i) or { println('error should be ok: $err') }
|
||||
}
|
||||
// update the reports
|
||||
uri := 'ws://autobahn_server:9001/updateReports?agent=v-client'
|
||||
mut ws := websocket.new_client(uri) ?
|
||||
ws.connect() ?
|
||||
ws.listen() ?
|
||||
}
|
||||
|
||||
fn handle_case(case_nr int) ? {
|
||||
uri := 'ws://autobahn_server:9001/runCase?case=$case_nr&agent=v-client'
|
||||
mut ws := websocket.new_client(uri) ?
|
||||
ws.on_message(on_message)
|
||||
ws.connect() ?
|
||||
ws.listen() ?
|
||||
}
|
||||
|
||||
fn on_message(mut ws websocket.Client, msg &websocket.Message) ? {
|
||||
// autobahn tests expects to send same message back
|
||||
if msg.opcode == .pong {
|
||||
// We just wanna pass text and binary message back to autobahn
|
||||
return
|
||||
}
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err) }
|
||||
}
|
35
vlib/net/websocket/tests/autobahn/autobahn_client_wss.v
Normal file
35
vlib/net/websocket/tests/autobahn/autobahn_client_wss.v
Normal file
@ -0,0 +1,35 @@
|
||||
// use this test to test the websocket client in the autobahn test
|
||||
module main
|
||||
|
||||
import net.websocket
|
||||
|
||||
fn main() {
|
||||
for i in 1 .. 304 {
|
||||
println('\ncase: $i')
|
||||
handle_case(i) or { println('error should be ok: $err') }
|
||||
}
|
||||
// update the reports
|
||||
// uri := 'wss://localhost:9002/updateReports?agent=v-client'
|
||||
uri := 'wss://autobahn_server_wss:9002/updateReports?agent=v-client'
|
||||
mut ws := websocket.new_client(uri) ?
|
||||
ws.connect() ?
|
||||
ws.listen() ?
|
||||
}
|
||||
|
||||
fn handle_case(case_nr int) ? {
|
||||
uri := 'wss://autobahn_server_wss:9002/runCase?case=$case_nr&agent=v-client'
|
||||
// uri := 'wss://localhost:9002/runCase?case=$case_nr&agent=v-client'
|
||||
mut ws := websocket.new_client(uri) ?
|
||||
ws.on_message(on_message)
|
||||
ws.connect() ?
|
||||
ws.listen() ?
|
||||
}
|
||||
|
||||
fn on_message(mut ws websocket.Client, msg &websocket.Message) ? {
|
||||
// autobahn tests expects to send same message back
|
||||
if msg.opcode == .pong {
|
||||
// We just wanna pass text and binary message back to autobahn
|
||||
return
|
||||
}
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err) }
|
||||
}
|
27
vlib/net/websocket/tests/autobahn/autobahn_server.v
Normal file
27
vlib/net/websocket/tests/autobahn/autobahn_server.v
Normal file
@ -0,0 +1,27 @@
|
||||
// use this to test websocket server to the autobahn test
|
||||
module main
|
||||
|
||||
import net.websocket
|
||||
|
||||
fn main() {
|
||||
mut s := websocket.new_server(.ip6, 9002, '/')
|
||||
s.on_message(on_message)
|
||||
s.listen() or { panic(err) }
|
||||
}
|
||||
|
||||
fn handle_case(case_nr int) ? {
|
||||
uri := 'ws://localhost:9002/runCase?case=$case_nr&agent=v-client'
|
||||
mut ws := websocket.new_client(uri) ?
|
||||
ws.on_message(on_message)
|
||||
ws.connect() ?
|
||||
ws.listen() ?
|
||||
}
|
||||
|
||||
fn on_message(mut ws websocket.Client, msg &websocket.Message) ? {
|
||||
// autobahn tests expects to send same message back
|
||||
if msg.opcode == .pong {
|
||||
// We just wanna pass text and binary message back to autobahn
|
||||
return
|
||||
}
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err) }
|
||||
}
|
21
vlib/net/websocket/tests/autobahn/docker-compose.yml
Normal file
21
vlib/net/websocket/tests/autobahn/docker-compose.yml
Normal file
@ -0,0 +1,21 @@
|
||||
version: '3'
|
||||
services:
|
||||
server:
|
||||
container_name: autobahn_server
|
||||
build: fuzzing_server
|
||||
|
||||
ports:
|
||||
- "9001:9001"
|
||||
- "8080:8080"
|
||||
server_wss:
|
||||
container_name: autobahn_server_wss
|
||||
build: fuzzing_server_wss
|
||||
|
||||
ports:
|
||||
- "9002:9002"
|
||||
- "8081:8080"
|
||||
client:
|
||||
container_name: autobahn_client
|
||||
build:
|
||||
dockerfile: vlib/net/websocket/tests/autobahn/ws_test/Dockerfile
|
||||
context: ../../../../../
|
@ -0,0 +1,5 @@
|
||||
FROM crossbario/autobahn-testsuite
|
||||
COPY check_results.py /check_results.py
|
||||
RUN chmod +x /check_results.py
|
||||
|
||||
COPY config /config
|
@ -0,0 +1,46 @@
|
||||
import json
|
||||
|
||||
nr_of_client_errs = 0
|
||||
nr_of_client_tests = 0
|
||||
|
||||
nr_of_server_errs = 0
|
||||
nr_of_server_tests = 0
|
||||
|
||||
with open("/reports/clients/index.json") as f:
|
||||
data = json.load(f)
|
||||
|
||||
for i in data["v-client"]:
|
||||
# Count errors
|
||||
if (
|
||||
data["v-client"][i]["behavior"] == "FAILED"
|
||||
or data["v-client"][i]["behaviorClose"] == "FAILED"
|
||||
):
|
||||
nr_of_client_errs = nr_of_client_errs + 1
|
||||
|
||||
nr_of_client_tests = nr_of_client_tests + 1
|
||||
|
||||
with open("/reports/servers/index.json") as f:
|
||||
data = json.load(f)
|
||||
|
||||
for i in data["AutobahnServer"]:
|
||||
if (
|
||||
data["AutobahnServer"][i]["behavior"] == "FAILED"
|
||||
or data["AutobahnServer"][i]["behaviorClose"] == "FAILED"
|
||||
):
|
||||
nr_of_server_errs = nr_of_server_errs + 1
|
||||
|
||||
nr_of_server_tests = nr_of_server_tests + 1
|
||||
|
||||
if nr_of_client_errs > 0 or nr_of_server_errs > 0:
|
||||
print(
|
||||
"FAILED AUTOBAHN TESTS, CLIENT ERRORS {0}(of {1}), SERVER ERRORS {2}(of {3})".format(
|
||||
nr_of_client_errs, nr_of_client_tests, nr_of_server_errs, nr_of_server_tests
|
||||
)
|
||||
)
|
||||
exit(1)
|
||||
|
||||
print(
|
||||
"TEST SUCCESS!, CLIENT TESTS({0}), SERVER TESTS ({1})".format(
|
||||
nr_of_client_tests, nr_of_server_tests
|
||||
)
|
||||
)
|
@ -0,0 +1,22 @@
|
||||
{
|
||||
"options": {
|
||||
"failByDrop": false
|
||||
},
|
||||
"outdir": "./reports/servers",
|
||||
"servers": [
|
||||
{
|
||||
"agent": "AutobahnServer",
|
||||
"url": "ws://autobahn_client:9002"
|
||||
}
|
||||
],
|
||||
"cases": [
|
||||
"*"
|
||||
],
|
||||
"exclude-cases": [
|
||||
"9.*",
|
||||
"11.*",
|
||||
"12.*",
|
||||
"13.*"
|
||||
],
|
||||
"exclude-agent-cases": {}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"url": "ws://127.0.0.1:9001",
|
||||
"outdir": "./reports/clients",
|
||||
"cases": [
|
||||
"*"
|
||||
],
|
||||
"exclude-cases": [
|
||||
"9.*",
|
||||
"11.*",
|
||||
"12.*",
|
||||
"13.*"
|
||||
],
|
||||
"exclude-agent-cases": {}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
FROM crossbario/autobahn-testsuite
|
||||
COPY check_results.py /check_results.py
|
||||
RUN chmod +x /check_results.py
|
||||
|
||||
COPY config /config
|
||||
RUN chmod +rx /config/server.crt
|
||||
RUN chmod +rx /config/server.key
|
||||
|
||||
EXPOSE 9002 9002
|
@ -0,0 +1,35 @@
|
||||
import json
|
||||
|
||||
nr_of_client_errs = 0
|
||||
nr_of_client_tests = 0
|
||||
|
||||
nr_of_server_errs = 0
|
||||
nr_of_server_tests = 0
|
||||
|
||||
with open("/reports/clients/index.json") as f:
|
||||
data = json.load(f)
|
||||
|
||||
for i in data["v-client"]:
|
||||
# Count errors
|
||||
if (
|
||||
data["v-client"][i]["behavior"] == "FAILED"
|
||||
or data["v-client"][i]["behaviorClose"] == "FAILED"
|
||||
):
|
||||
nr_of_client_errs = nr_of_client_errs + 1
|
||||
|
||||
nr_of_client_tests = nr_of_client_tests + 1
|
||||
|
||||
|
||||
if nr_of_client_errs > 0 or nr_of_server_errs > 0:
|
||||
print(
|
||||
"FAILED AUTOBAHN TESTS, CLIENT ERRORS {0}(of {1}), SERVER ERRORS {2}(of {3})".format(
|
||||
nr_of_client_errs, nr_of_client_tests, nr_of_server_errs, nr_of_server_tests
|
||||
)
|
||||
)
|
||||
exit(1)
|
||||
|
||||
print(
|
||||
"TEST SUCCESS!, CLIENT TESTS({0}), SERVER TESTS ({1})".format(
|
||||
nr_of_client_tests, nr_of_server_tests
|
||||
)
|
||||
)
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"url": "wss://127.0.0.1:9002",
|
||||
"outdir": "./reports/clients",
|
||||
"key": "/config/server.key",
|
||||
"cert": "/config/server.crt",
|
||||
"cases": [
|
||||
"*"
|
||||
],
|
||||
"exclude-cases": [
|
||||
"9.*",
|
||||
"11.*",
|
||||
"12.*",
|
||||
"13.*"
|
||||
],
|
||||
"exclude-agent-cases": {}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDETCCAfkCFAtFKlcdB3jhD+AXP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+8lbGvOYpwReknLRMf
|
||||
pJfgSEWqWfSaetihbJl2Fmzg2SeJ
|
||||
-----END CERTIFICATE-----
|
@ -0,0 +1,16 @@
|
||||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIICijCCAXICAQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx
|
||||
ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcN
|
||||
AQEBBQADggEPADCCAQoCggEBAJ28rC33CK/fsKaCY2+a+9vI9ntO2oHnTs4fFS7h
|
||||
px6pijlDzX/CJO9O5BKAXBWO1DNgPRv9UTCMrBqfHpXkCzLTXXmHNypShwRhazjN
|
||||
4uIAnexuOJREbij9Tys0UOkXVTVF5+dV438Yx1qO5BwhFb2aMMb88S8YcG0sJhJo
|
||||
M3ENU+r4+gnaKfO7HatNBfnjgn03cvnJfkeubGyJlXX2OBENEFgFXRd1+p4y46XZ
|
||||
rXqaYIGxGhAr90d6jSFe/635SD5tXn26qe0dboL4yzyWdbtdqL7apILFm5xMs0k/
|
||||
IWxBI7Dkyf3D5B9g2i3Ye3zIH3FZqp2F3fU/oKbDRr/fA48CAwEAAaAAMA0GCSqG
|
||||
SIb3DQEBCwUAA4IBAQARfNhaiioyJPZZ8Hkf9UPbi85djYLDYCC9EqBPHpYpGh15
|
||||
WdRsTModg/X5DeGwtWwRyGSP2ROMWa1NB5RHZ9buIgCIOeszhAvXVaQMlHmpNhSD
|
||||
/hWKGGpAEq12TKHxgi9eTOE2u9MhoJf1G6iGffVsHc8r52THvGqKBp3Bi8G1Pl6L
|
||||
2J1f5qX42K1DEnCx0gGnQkydO6E4UnMbsaDSFSODQwg5LpzSYoYUfpYHstMpqAqL
|
||||
rcEt869YKjemKuTCzHODWxfqlvVr9GctNjKG2WtoqnX+10x3tw/9lsNRKUelCQxb
|
||||
E56eujAoQdMxQ4OjwSnc/gbpWa5gXKYjpgAfx2kY
|
||||
-----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KU29tZS1TdGF0ZTEhMB8GA1UE
|
||||
CgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOC
|
||||
AQ8AMIIBCgKCAQEAnbysLfcIr9+wpoJjb5r728j2e07agedOzh8VLuGnHqmKOUPN
|
||||
f8Ik707kEoBcFY7UM2A9G/1RMIysGp8eleQLMtNdeYc3KlKHBGFrOM3i4gCd7G44
|
||||
lERuKP1PKzRQ6RdVNUXn51XjfxjHWo7kHCEVvZowxvzxLxhwbSwmEmgzcQ1T6vj6
|
||||
Cdop87sdq00F+eOCfTdy+cl+R65sbImVdfY4EQ0QWAVdF3X6njLjpdmteppggbEa
|
||||
ECv3R3qNIV7/rflIPm1efbqp7R1ugvjLPJZ1u12ovtqkgsWbnEyzST8hbEEjsOTJ
|
||||
/cPkH2DaLdh7fMgfcVmqnYXd9T+gpsNGv98DjwIDAQABMA0GCSqGSIb3DQEBCwUA
|
||||
A4IBAQBG9GxUOjcrFd1ept9AOTzbxvIUvBiqIEzrL2/+3T1yPPAWQzOmBfZhIVVm
|
||||
EZeeU3xcvd7+AmX+2FPCAD+evjSHjKY048X1YksQS7mYChSgeJiknoJi3mAEAyw6
|
||||
oYGVkETksZLQfXtWTjgljbIQrwTA1s+EW0jvmvaJnWD3/8nFqmfly2/kxVsTcGEa
|
||||
wJGEUS53Cq6y6lLZ+ojjjj1iVCQ94U6L/0xPB9hgXOyL2+iQj+n38ruatnUNF77C
|
||||
UKS7N9BFF42eqVY83Xab0m25s93m8Z7J/63qu0eeA8p5t7+8lbGvOYpwReknLRMf
|
||||
pJfgSEWqWfSaetihbJl2Fmzg2SeJ
|
||||
-----END CERTIFICATE-----
|
12
vlib/net/websocket/tests/autobahn/local_run/Dockerfile
Normal file
12
vlib/net/websocket/tests/autobahn/local_run/Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
# Use this as docker builder with https://github.com/nektos/act
|
||||
# build with: docker build tests/autobahn/. -t myimage
|
||||
# use in act: act -P ubuntu-latest=myimage
|
||||
|
||||
FROM node:12.6-buster-slim
|
||||
|
||||
COPY config/fuzzingserver.json /config/fuzzingserver.json
|
||||
RUN chmod +775 /config/fuzzingserver.json
|
||||
RUN apt-get update && \
|
||||
apt-get install -y \
|
||||
docker \
|
||||
docker-compose
|
@ -0,0 +1,33 @@
|
||||
// use this test to test the websocket client in the autobahn test
|
||||
module main
|
||||
|
||||
import net.websocket
|
||||
|
||||
fn main() {
|
||||
for i in 1 .. 304 {
|
||||
println('\ncase: $i')
|
||||
handle_case(i) or { println('error should be ok: $err') }
|
||||
}
|
||||
// update the reports
|
||||
uri := 'ws://localhost:9001/updateReports?agent=v-client'
|
||||
mut ws := websocket.new_client(uri) ?
|
||||
ws.connect() ?
|
||||
ws.listen() ?
|
||||
}
|
||||
|
||||
fn handle_case(case_nr int) ? {
|
||||
uri := 'ws://localhost:9001/runCase?case=$case_nr&agent=v-client'
|
||||
mut ws := websocket.new_client(uri) ?
|
||||
ws.on_message(on_message)
|
||||
ws.connect() ?
|
||||
ws.listen() ?
|
||||
}
|
||||
|
||||
fn on_message(mut ws websocket.Client, msg &websocket.Message) ? {
|
||||
// autobahn tests expects to send same message back
|
||||
if msg.opcode == .pong {
|
||||
// We just wanna pass text and binary message back to autobahn
|
||||
return
|
||||
}
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err) }
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
// use this test to test the websocket client in the autobahn test
|
||||
module main
|
||||
|
||||
import net.websocket
|
||||
|
||||
fn main() {
|
||||
for i in 1 .. 304 {
|
||||
println('\ncase: $i')
|
||||
handle_case(i) or { println('error should be ok: $err') }
|
||||
}
|
||||
// update the reports
|
||||
// uri := 'wss://localhost:9002/updateReports?agent=v-client'
|
||||
uri := 'wss://autobahn_server_wss:9002/updateReports?agent=v-client'
|
||||
mut ws := websocket.new_client(uri) ?
|
||||
ws.connect() ?
|
||||
ws.listen() ?
|
||||
}
|
||||
|
||||
fn handle_case(case_nr int) ? {
|
||||
uri := 'wss://autobahn_server_wss:9002/runCase?case=$case_nr&agent=v-client'
|
||||
// uri := 'wss://localhost:9002/runCase?case=$case_nr&agent=v-client'
|
||||
mut ws := websocket.new_client(uri) ?
|
||||
ws.on_message(on_message)
|
||||
ws.connect() ?
|
||||
ws.listen() ?
|
||||
}
|
||||
|
||||
fn on_message(mut ws websocket.Client, msg &websocket.Message) ? {
|
||||
// autobahn tests expects to send same message back
|
||||
if msg.opcode == .pong {
|
||||
// We just wanna pass text and binary message back to autobahn
|
||||
return
|
||||
}
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err) }
|
||||
}
|
12
vlib/net/websocket/tests/autobahn/ws_test/Dockerfile
Normal file
12
vlib/net/websocket/tests/autobahn/ws_test/Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
FROM thevlang/vlang:buster-build
|
||||
|
||||
|
||||
COPY ./ /src/
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
RUN make CC=clang
|
||||
|
||||
RUN /src/v /src/vlib/net/websocket/tests/autobahn/autobahn_server.v
|
||||
RUN chmod +x /src/vlib/net/websocket/tests/autobahn/autobahn_server
|
||||
ENTRYPOINT [ "/src/vlib/net/websocket/tests/autobahn/autobahn_server" ]
|
Reference in New Issue
Block a user