Skip to content

Commit

Permalink
Add wsdirector integration test to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
palkan committed Jan 27, 2023
1 parent 2de4049 commit 0f9a0b6
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/system_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
options: --add-host=host.docker.internal:host-gateway
env:
ANYCABLE_HOST: "0.0.0.0"
ANYCABLE_REDIS_URL: redis://redis:6379/0
ANYCABLE_REDIS_URL: redis://host.docker.internal:6379/0
ANYCABLE_RPC_HOST: host.docker.internal:50051
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -71,3 +71,10 @@ jobs:
bundle exec rails db:test:prepare
export CABLE_URL="ws://$(hostname):8080/cable"
bundle exec rspec --tag type:system --force-color
- name: Run WebSocket Director scenarios
run: |
bundle exec rails db:seed
mkdir -p tmp/pids
bundle exec anycabled start
gem install wsdirector-cli
wsdirector etc/wsdirector/chat.yml localhost:8080/cable -c -vv
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ gem 'puma', '~> 6.0'
gem 'redis', '~> 5.0'
gem 'grpc', '~> 1.37'
gem 'anycable-rails', '~> 1.3.0'
gem 'daemons', '~> 1.3', require: false

gem 'bootsnap', '>= 1.4.2', require: false
gem 'ruby-next', '>= 0.15.0', require: false
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ GEM
cuprite (0.14.3)
capybara (~> 3.0)
ferrum (~> 0.13.0)
daemons (1.4.1)
date (3.3.3)
debug (1.7.0)
irb (>= 1.5.0)
Expand Down Expand Up @@ -268,6 +269,7 @@ DEPENDENCIES
capybara
cssbundling-rails
cuprite
daemons (~> 1.3)
debug (= 1.7.0)
grpc (~> 1.37)
jsbundling-rails
Expand Down
81 changes: 81 additions & 0 deletions etc/wsdirector/chat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
- client:
x-channel: &channel
channel: ChatChannel
params:
id: "demo"
protocol: action_cable
name: write
multiplier: ":scale"
connection_options:
cookies:
uid: "<%= ENV.fetch('NAME', 'ghost_writer') %>/<%= rand(100) %>"
actions:
- subscribe:
<<: *channel
- wait_all
- sleep:
time: 3
shift: 2
- perform:
<<: *channel
action: speak
data:
message: "hello"
- sleep:
time: 4
shift: 2
- perform:
<<: *channel
action: speak
data:
message: "hello 2"
- sleep:
time: 4
shift: 2
- perform:
<<: *channel
action: speak
data:
message: "hello 3"
- sleep:
time: 4
shift: 2

- client:
protocol: action_cable
name: read
multiplier: ":scale * 2"
connection_options:
cookies:
uid: "<%= ENV.fetch('NAME', 'reader') %>/<%= rand(100) %>"
actions:
- subscribe:
<<: *channel
- wait_all
- sleep:
time: 3
shift: 2
- receive:
<<: *channel
multiplier: ":scale"
data>:
action: "newMessage"
- sleep:
time: 4
shift: 2
- receive:
<<: *channel
multiplier: ":scale"
data>:
action: "newMessage"
- sleep:
time: 4
shift: 2
- receive:
<<: *channel
multiplier: ":scale"
data>:
action: "newMessage"
- sleep:
time: 4
shift: 2

0 comments on commit 0f9a0b6

Please sign in to comment.