-
Notifications
You must be signed in to change notification settings - Fork 29
Add Autobahn echo server with Dockerfile #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
djones6
wants to merge
1
commit into
master
Choose a base branch
from
autobahn-in-docker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| .build | ||
| Package.resolved | ||
| run.sh | ||
| Dockerfile | ||
| reports | ||
| config |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| .DS_Store | ||
| /.build | ||
| /Packages | ||
| /*.xcodeproj | ||
| xcuserdata/ |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| FROM swift:5.1 | ||
|
|
||
| RUN apt-get update && apt-get install -y libssl-dev libcurl4-openssl-dev libz-dev | ||
|
|
||
| COPY . /WebSocketEchoServer | ||
|
|
||
| WORKDIR /WebSocketEchoServer | ||
|
|
||
| RUN swift build | ||
|
|
||
| CMD .build/debug/WebSocketEchoServer | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // swift-tools-version:5.1 | ||
| import PackageDescription | ||
|
|
||
| let package = Package( | ||
| name: "WebSocketEchoServer", | ||
| dependencies: [ | ||
| .package(url: "https://github.com/IBM-Swift/Kitura.git", from: "2.8.0"), | ||
| .package(url: "https://github.com/IBM-Swift/HeliumLogger.git", from: "1.7.0"), | ||
| .package(url: "https://github.com/IBM-Swift/Kitura-WebSocket.git", from: "2.0.0") | ||
| ], | ||
| targets: [ | ||
| .target( | ||
| name: "WebSocketEchoServer", | ||
| dependencies: ["Kitura", "HeliumLogger", "Kitura-WebSocket"]), | ||
| ] | ||
| ) |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Autobahn | ||
|
|
||
| A description of this package. |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import Foundation | ||
|
|
||
| import KituraWebSocket | ||
| import LoggerAPI | ||
|
|
||
| class EchoService: WebSocketService { | ||
|
|
||
| public func connected(connection: WebSocketConnection) {} | ||
|
|
||
| public func disconnected(connection: WebSocketConnection, reason: WebSocketCloseReasonCode) {} | ||
|
|
||
| public func received(message: Data, from: WebSocketConnection) { | ||
| from.send(message: message) | ||
| } | ||
|
|
||
| public func received(message: String, from: WebSocketConnection) { | ||
| let msgLength = message.utf8.count | ||
| if msgLength > 100 { | ||
| Log.info("Got message of length \(msgLength)... sending it back") | ||
| } else { | ||
| Log.info("Got message '\(message)'... sending it back") | ||
| } | ||
| from.send(message: message) | ||
| } | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import Foundation | ||
| import Kitura | ||
| import KituraWebSocket | ||
| import HeliumLogger | ||
|
|
||
| // Using an implementation for a Logger | ||
| HeliumLogger.use(.info) | ||
|
|
||
| let router = Router() | ||
|
|
||
| WebSocket.register(service: EchoService(), onPath: "/") | ||
|
|
||
| let port = 9001 | ||
|
|
||
| Kitura.addHTTPServer(onPort: port, with: router) | ||
| Kitura.run() |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "outdir": "./reports/servers", | ||
| "servers": [ | ||
| { | ||
| "url": "ws://wsserver:9001" | ||
| } | ||
| ], | ||
| "cases": ["*"], | ||
| "exclude-cases": [], | ||
| "exclude-agent-cases": {} | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Convenience script to build and run a Kitura-WebSocket echo server in a Docker container, | ||
| # and then to run the autobahn test suite Docker container against it. | ||
| # | ||
| # Once complete, the autobahn report (HTML format) will be opened. | ||
| # | ||
|
|
||
| # Create network | ||
| docker network rm autobahn | ||
| docker network create --driver bridge autobahn | ||
|
|
||
| # Build server | ||
| docker build -t wsserver . | ||
|
|
||
| # Execute server | ||
| docker container rm wsserver | ||
| docker run -d --network autobahn --name wsserver wsserver | ||
|
|
||
| # Execute client | ||
| docker run -it --rm \ | ||
| -v ${PWD}/config:/config \ | ||
| -v ${PWD}/reports:/reports \ | ||
| --name fuzzingclient \ | ||
| --network autobahn \ | ||
| crossbario/autobahn-testsuite \ | ||
| wstest -m fuzzingclient -s config/fuzzingclient.json | ||
|
|
||
| # Stop server | ||
| docker container stop wsserver | ||
|
|
||
| # Check out test report! | ||
| open ./reports/servers/index.html |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Release mode? Or not...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm good question. I'd gone for debug mode since we're dealing with tests, but as this is essentially acceptance testing, perhaps it should be release mode.