Initial project import
This commit is contained in:
commit
23f2d29e32
11957 files changed
+1754577
No files matched your search
@@ -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 wss (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 certificate so you will get trust error but just accept use)
|
||||
|
||||
### Test the server
|
||||
|
||||
Todo: add information here
|
||||
@@ -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) }
|
||||
}
|
||||
@@ -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) }
|
||||
}
|
||||
@@ -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) }
|
||||
}
|
||||
@@ -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
|
||||
)
|
||||
)
|
||||
+16
@@ -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+AXPul81dwmZcs/MA0GCSqGSIb3DQEBCwUAMEUx
|
||||
CzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRl
|
||||
cm5ldCBXaWRnaXRzIFB0eSBMdGQwHhcNMjAxMTIxMDgyNjQ5WhcNMzAxMTE5MDgy
|
||||
NjQ5WjBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UE
|
||||
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-----
|
||||
@@ -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
|
||||
-----END CERTIFICATE REQUEST-----
|
||||
@@ -0,0 +1,9 @@
|
||||
# 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 update && apt install -y docker
|
||||
@@ -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) }
|
||||
}
|
||||
@@ -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