diff options
| author | Shulhan <ms@kilabit.info> | 2023-06-26 02:48:47 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-07-01 17:23:26 +0700 |
| commit | e3d1ce9c956dbb8c951bb8a7d52bcad482350940 (patch) | |
| tree | 8b57844efcb00705259d0c6a84a7e7dd38b62044 | |
| parent | 5e58d509b6c5ea81643c5bdf67109897f92384b2 (diff) | |
| download | pakakeh.go-e3d1ce9c956dbb8c951bb8a7d52bcad482350940.tar.xz | |
lib/websocket: move the autobahn test to package internal
Using directory testdata that contains Go code seems like not good
choices for future improvement, especially if we want to add shared code
that can be imported by server and client later.
| -rw-r--r-- | .gitignore | 22 | ||||
| -rw-r--r-- | lib/websocket/AUTOBAHN.adoc | 8 | ||||
| -rw-r--r-- | lib/websocket/internal/autobahn/Makefile (renamed from lib/websocket/testdata/Makefile) | 7 | ||||
| -rw-r--r-- | lib/websocket/internal/autobahn/client/fuzzingserver.json (renamed from lib/websocket/testdata/client/fuzzingserver.json) | 0 | ||||
| -rw-r--r-- | lib/websocket/internal/autobahn/client/main.go (renamed from lib/websocket/testdata/client/main.go) | 2 | ||||
| -rw-r--r-- | lib/websocket/internal/autobahn/client/testdata/.empty | 0 | ||||
| -rw-r--r-- | lib/websocket/internal/autobahn/server/fuzzingclient.json (renamed from lib/websocket/testdata/server/fuzzingclient.json) | 0 | ||||
| -rw-r--r-- | lib/websocket/internal/autobahn/server/main.go (renamed from lib/websocket/testdata/server/main.go) | 8 | ||||
| -rw-r--r-- | lib/websocket/internal/autobahn/server/testdata/.empty | 0 |
9 files changed, 24 insertions, 23 deletions
@@ -16,6 +16,15 @@ *.stats *.test *.zst +/_bin/bcrypt +/_bin/epoch +/_bin/gofmtcomment +/_bin/hexo +/_bin/ini +/_bin/sendemail +/_bin/smtpcli +/_bin/totp +/_bin/xtrk /_doc/*.html /cmd/smtpcli/smtpcli /gofmtcomment @@ -50,25 +59,16 @@ /lib/ssh/sftp/testdata/*.get /lib/websocket/examples/cmd/client/client /lib/websocket/examples/cmd/server/server +/lib/websocket/internal/autobahn/client/testdata +/lib/websocket/internal/autobahn/server/testdata /lib/websocket/testdata/.Python /lib/websocket/testdata/bin /lib/websocket/testdata/client/client -/lib/websocket/testdata/client/reports /lib/websocket/testdata/include /lib/websocket/testdata/lib /lib/websocket/testdata/pip-selfcheck.json -/lib/websocket/testdata/server/reports /lib/websocket/testdata/server/server _AUR/pkg/ -/_bin/bcrypt -/_bin/epoch -/_bin/gofmtcomment -/_bin/hexo -/_bin/ini -/_bin/sendemail -/_bin/smtpcli -/_bin/totp -/_bin/xtrk cover.* share-tools/ src/ diff --git a/lib/websocket/AUTOBAHN.adoc b/lib/websocket/AUTOBAHN.adoc index 6cde9222..e9039b90 100644 --- a/lib/websocket/AUTOBAHN.adoc +++ b/lib/websocket/AUTOBAHN.adoc @@ -9,12 +9,12 @@ This document track the status report from autobahn testsuite [1]. == Testing Server ---- -$ cd testdata +$ cd internal/autobahn $ make test-server ---- Wait for the test to complete. After that, we can view the reports on -"testdata/server/reports/index.html". +"internal/autobahn/server/testdata/index.html". Summary of autobahn testsuite reports for server, @@ -90,12 +90,12 @@ Success Rate = 301/301*100 = 100% == Testing Client ---- -$ cd testdata +$ cd internal/autobahn $ make test-client ---- On success, the reports will be generated at -"testdata/client/reports/index.html". +"internal/autobahn/client/testdata/index.html". Summary of autobahn testsuite reports for client, diff --git a/lib/websocket/testdata/Makefile b/lib/websocket/internal/autobahn/Makefile index ea833a56..789e3a35 100644 --- a/lib/websocket/testdata/Makefile +++ b/lib/websocket/internal/autobahn/Makefile @@ -6,7 +6,7 @@ run-autobahn-client: sleep 2 podman run -it --rm \ --volume="${PWD}/server:/config" \ - --volume="${PWD}/server/reports:/reports" \ + --volume="${PWD}/server/testdata:/reports" \ --name=fuzzingclient \ docker.io/crossbario/autobahn-testsuite \ wstest --mode fuzzingclient --spec=/config/fuzzingclient.json @@ -18,16 +18,17 @@ run-test-server: .PHONY: test-server test-server: run-test-server run-autobahn-client go run ./server shutdown + go run ./server reports ## ## Run autobahn server to test our client in the background. ## .PHONY: run-autobahn-server run-autobahn-server: - podman stop fuzzingserver + -podman stop fuzzingserver podman run -it --rm --detach \ --volume "${PWD}/client:/config" \ - --volume "${PWD}/client/reports:/reports" \ + --volume "${PWD}/client/testdata:/reports" \ --publish 9001:9001 \ --publish 8080:8080 \ --name fuzzingserver \ diff --git a/lib/websocket/testdata/client/fuzzingserver.json b/lib/websocket/internal/autobahn/client/fuzzingserver.json index 4b86b5d7..4b86b5d7 100644 --- a/lib/websocket/testdata/client/fuzzingserver.json +++ b/lib/websocket/internal/autobahn/client/fuzzingserver.json diff --git a/lib/websocket/testdata/client/main.go b/lib/websocket/internal/autobahn/client/main.go index 6df81c64..4e84ba89 100644 --- a/lib/websocket/testdata/client/main.go +++ b/lib/websocket/internal/autobahn/client/main.go @@ -66,7 +66,7 @@ func clientTestCase(testnum int) { func clientUpdateReports() { var cl = &websocket.Client{ - Endpoint: fmt.Sprintf(`ws://0.0.0.0:9001/updateReports?agent=libwebsocket`), + Endpoint: `ws://0.0.0.0:9001/updateReports?agent=libwebsocket`, } var err = cl.Connect() diff --git a/lib/websocket/internal/autobahn/client/testdata/.empty b/lib/websocket/internal/autobahn/client/testdata/.empty new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/lib/websocket/internal/autobahn/client/testdata/.empty diff --git a/lib/websocket/testdata/server/fuzzingclient.json b/lib/websocket/internal/autobahn/server/fuzzingclient.json index 8c33efda..8c33efda 100644 --- a/lib/websocket/testdata/server/fuzzingclient.json +++ b/lib/websocket/internal/autobahn/server/fuzzingclient.json diff --git a/lib/websocket/testdata/server/main.go b/lib/websocket/internal/autobahn/server/main.go index 7330c689..e09aea29 100644 --- a/lib/websocket/testdata/server/main.go +++ b/lib/websocket/internal/autobahn/server/main.go @@ -9,8 +9,8 @@ package main import ( "bytes" "flag" - "fmt" "log" + "os" "time" "github.com/shuLhan/share/lib/websocket" @@ -53,7 +53,7 @@ func main() { log.Println("handleBin: " + err.Error()) } - var elapsed = time.Now().Sub(timeStart) + var elapsed = time.Since(timeStart) if elapsed >= timeout { log.Printf(`HandleBin: %s`, elapsed) } @@ -71,7 +71,7 @@ func main() { log.Println("handleText: " + err.Error()) } - var elapsed = time.Now().Sub(timeStart) + var elapsed = time.Since(timeStart) if elapsed >= timeout { log.Printf(`HandleText: %s`, elapsed) } @@ -97,7 +97,7 @@ func doShutdown() { var ( logp = `doShutdown` cl = &websocket.Client{ - Endpoint: fmt.Sprintf(`ws://0.0.0.0:9001`), + Endpoint: `ws://0.0.0.0:9001`, } ) diff --git a/lib/websocket/internal/autobahn/server/testdata/.empty b/lib/websocket/internal/autobahn/server/testdata/.empty new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/lib/websocket/internal/autobahn/server/testdata/.empty |
