From f311544090934cf235f8f3b6eaecf2cc623efae0 Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Fri, 27 Jan 2023 15:54:28 -0500 Subject: [PATCH] Add wsdirector integration test to CI --- .github/workflows/system_test.yml | 16 +++--- Gemfile | 1 + Gemfile.lock | 2 + etc/wsdirector/chat.yml | 81 +++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 etc/wsdirector/chat.yml diff --git a/.github/workflows/system_test.yml b/.github/workflows/system_test.yml index 8f9e9a3..5f1ebb4 100644 --- a/.github/workflows/system_test.yml +++ b/.github/workflows/system_test.yml @@ -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 @@ -50,13 +50,10 @@ jobs: with: ruby-version: 3.2.0 bundler-cache: true - - uses: actions/setup-node@v1 - with: - node-version: '16.x' - name: Get yarn cache directory path id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v2 + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + - uses: actions/cache@v3 id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} @@ -71,3 +68,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 diff --git a/Gemfile b/Gemfile index 4ba3f99..6af9109 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 2041ca4..b99fe35 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -268,6 +269,7 @@ DEPENDENCIES capybara cssbundling-rails cuprite + daemons (~> 1.3) debug (= 1.7.0) grpc (~> 1.37) jsbundling-rails diff --git a/etc/wsdirector/chat.yml b/etc/wsdirector/chat.yml new file mode 100644 index 0000000..27b0ef7 --- /dev/null +++ b/etc/wsdirector/chat.yml @@ -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