Skip to content

Commit

Permalink
use mongostat to get the current number of MongoDB connections
Browse files Browse the repository at this point in the history
  • Loading branch information
did committed Apr 1, 2024
1 parent f3d9213 commit 97f85e4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ jobs:
ports:
- 27017:27017
env:
# MONGO_INITDB_ROOT_USERNAME: test
# MONGO_INITDB_ROOT_PASSWORD: password
MONGO_INITDB_DATABASE: steam_test_1_8_x
options: >-
--health-cmd "echo 'db.runCommand("ping").ok' | mongosh --quiet"
Expand Down
6 changes: 4 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ namespace :mongodb do
`mv #{dump_path} #{db_path}`
end

`mongo steam_test_1_8_x --eval "db.dropDatabase()" #{host}`
`mongorestore -d steam_test_1_8_x #{db_path} #{host}`
# NOTE: command to drop the database
# `mongo steam_test_1_8_x --eval "db.dropDatabase()" #{host}`

`mongorestore --drop -d steam_test_1_8_x #{db_path} #{host}`

puts "Done! Update now the spec/support/helpers.rb file by setting the new id of the site returned by the mongodb_site_id method"
end
Expand Down
3 changes: 2 additions & 1 deletion spec/integration/adapters/mongodb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
end

def current_connections
`mongosh --eval "db.serverStatus().connections.current"`.split("\n").last.to_i
stats = JSON.parse(`mongostat --noheaders -n 1 --json`)
stats.dig('localhost', 'conn')&.to_i
end

end

0 comments on commit 97f85e4

Please sign in to comment.