discourse/spec
Alan Guo Xiang Tan 4dd053a69c
DEV: Call `MessageBus.stop()` after each system test (#21848)
## What is the problem?

MessageBus by default uses long polling which keeps a connection
open for 25 seconds by default. The problem here is that Capybara does not know about these
connections being kept opened by MessageBus and hence does not know how
to stop these connections at the end of each test. As a result, the long polling MessageBus connections are kept opened by the browser and we hit chrome's limit of 6 concurrent requests per host, new request made in the browser is marked as "pending" until a request is freed up. Since we keep a MessageBus long polling connection opened for 25 seconds, our finders in Capybara end up hitting Capybara's wait time out causing the tests to fail.  

## What is the fix?

Since we can't rely on Capybara to close all the existing Capybara
connections, we manually execute a script to stop all MessageBus
connections after each system test.

```
for i in {1..10}; do
  echo "Running iteration $i"
  PARALLEL_TEST_PROCESSORS=8 CAPYBARA_DEFAULT_MAX_WAIT_TIME=10 bin/turbo_rspec --seed=34908 --profile --verbose --format documentation spec/system
  if [ $? -ne 0 ]; then
    echo "Error encountered on iteration $i"
    exit 1
  fi
done
echo "All 10 iterations completed successfully"
```

Without the fix, the script fails consistently in the first few iterations. Running in non-headless mode with the "network" tab opened will reveal the requests that are marked as pending.
2023-05-31 21:00:35 +08:00
..
fabricators FIX: Fix for Default to subcategory when parent category does not allow posting (#21537) 2023-05-19 07:37:23 -05:00
fixtures FIX: improve mailman email parsing (#21627) 2023-05-19 10:33:48 +02:00
helpers DEV: Replace #pluck_first freedom patch with AR #pick in core (#19893) 2023-02-13 12:39:45 +08:00
import_export DEV: Apply syntax_tree formatting to `spec/*` 2023-01-09 11:49:28 +00:00
initializers FEATURE: Create legal topics for set company name (#21620) 2023-05-24 23:05:36 +03:00
integration FIX: Handle all UTF-8 characters (#21344) 2023-05-15 12:45:04 +03:00
integrity DEV: Remove `renderTemplate` from the styleguide (#21660) 2023-05-25 11:22:36 +02:00
jobs FIX: consider users.created_at for inactive cleanup (#21688) 2023-05-23 13:41:23 +05:30
lib FEATURE: Create legal topics for set company name (#21620) 2023-05-24 23:05:36 +03:00
mailers FIX: Likes received count in digest email (#21458) 2023-05-09 19:19:26 +02:00
models DEV: Added modifier hooks to allow plugins to tweak how categories and groups are fetched (#21837) 2023-05-30 18:41:50 -03:00
multisite DEV: Add plugin hook for transforming site setting defaults (#20941) 2023-04-05 12:28:16 +01:00
requests DEV: Remove deprecated posts/:username/flagged (#21846) 2023-05-31 13:00:35 +02:00
script/import_scripts DEV: Correct syntax_tree violations 2023-02-02 13:03:11 +00:00
serializers DEV: Remove legacy user menu (#21308) 2023-05-17 09:16:42 -07:00
services DEV: Allow plugins to hook into user preferences update process on the server (#21737) 2023-05-26 03:26:38 +03:00
support DEV: Disable splash screen in system tests (#21840) 2023-05-31 06:16:22 +08:00
system DEV: Call `MessageBus.stop()` after each system test (#21848) 2023-05-31 21:00:35 +08:00
tasks DEV: Capture output in hashtags spec (#20773) 2023-03-23 11:47:14 +10:00
views FEATURE: add category name in articleSection meta tag for schema. (#21004) 2023-04-06 23:30:19 +05:30
rails_helper.rb DEV: Call `MessageBus.stop()` after each system test (#21848) 2023-05-31 21:00:35 +08:00
regenerate_swagger_docs DEV: Add API docs for uploads and API doc watcher (#15387) 2021-12-23 08:40:15 +10:00
swagger_helper.rb DEV: Apply syntax_tree formatting to `spec/*` 2023-01-09 11:49:28 +00:00