Skip to content

Commit

Permalink
RUBY-2947 MONGOID-5216 partial cherry-pick: Update Mongoid test tooli…
Browse files Browse the repository at this point in the history
…ng for driver/MRSS 5.2/6.0 changes + partial work on app tests fixes (#5132)

* MONGOID-5216 reinstate app tests

* retry node installs

* update test-apps to remove bootsnap

* debug

* remove debug

* speed up tests

* use newer node in evergreen

* update mrss

* use python3

* do not load ruby-debug-ide in docker, same is driver

* update mrss

* use python3

* Make app tests default to ubuntu2004, make them work on this distro

* use ubuntu instead of rhel

* python env setup from driver

* test 4.x server on ubuntu1804

* use node 12 in evergreen

* update mrss

* update

* update mrss

Co-authored-by: Oleg Pudeyev <[email protected]>
  • Loading branch information
p-mongo and p committed Jul 20, 2022
1 parent c0e1350 commit d4b9469
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
14 changes: 7 additions & 7 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ buildvariants:
topology: ['replica-set', 'sharded-cluster']
display_name: "${ruby}, ${driver}, ${mongodb-version}, ${topology}"
run_on:
- rhel80-small
- ubuntu2004-small
tasks:
- name: "test"

Expand All @@ -656,7 +656,7 @@ buildvariants:
topology: ['replica-set', 'sharded-cluster']
display_name: "${ruby}, ${driver}, ${mongodb-version}, ${topology}"
run_on:
- rhel70-small
- ubuntu1804-small
tasks:
- name: "test"

Expand All @@ -681,7 +681,7 @@ buildvariants:
rails: ['7.0']
display_name: "${rails}, ${driver}, ${mongodb-version}"
run_on:
- rhel70-small
- ubuntu2004-small
tasks:
- name: "test"

Expand All @@ -694,7 +694,7 @@ buildvariants:
rails: ['6.0', '6.1']
display_name: "${rails}, ${driver}, ${mongodb-version}"
run_on:
- rhel80-small
- ubuntu2004-small
tasks:
- name: "test"

Expand All @@ -707,7 +707,7 @@ buildvariants:
rails: ['5.1', '5.2']
display_name: "${rails}, ${driver}, ${mongodb-version}"
run_on:
- rhel70-small
- ubuntu1804-small
tasks:
- name: "test"

Expand All @@ -720,7 +720,7 @@ buildvariants:
i18n: '1.0'
display_name: "i18n-1.0 ${rails}, ${driver}, ${mongodb-version}"
run_on:
- rhel70-small
- ubuntu1804-small
tasks:
- name: "test"

Expand All @@ -734,7 +734,7 @@ buildvariants:
test-i18n-fallbacks: yes
display_name: "i18n fallbacks ${rails}, ${driver}, ${mongodb-version}, ${i18n}"
run_on:
- rhel70-small
- ubuntu1804-small
tasks:
- name: "test"

Expand Down
17 changes: 9 additions & 8 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ arch=`host_distro`

set_fcv
set_env_vars
set_env_python
set_env_node
set_env_ruby

if test -n "$APP_TESTS"; then
# Node from toolchain
export PATH=/opt/node/bin:$PATH
node -v
fi

prepare_server $arch

install_mlaunch_virtualenv
Expand All @@ -34,13 +42,6 @@ launch_server "$dbdir"

uri_options="$URI_OPTIONS"

# This is needed because of ruby 3.0.0.
# We should remove this when moving to 3.0.1
# See https://jira.mongodb.org/browse/MONGOID-5115
if test "$RVM_RUBY" = "ruby-3.0"; then
gem update --system
fi

which bundle
bundle --version

Expand Down Expand Up @@ -118,6 +119,6 @@ if test -f tmp/rspec-all.json; then
mv tmp/rspec-all.json tmp/rspec.json
fi

python2 -m mtools.mlaunch.mlaunch stop --dir "$dbdir"
python3 -m mtools.mlaunch.mlaunch stop --dir "$dbdir"

exit ${test_status}
2 changes: 1 addition & 1 deletion gemfiles/standard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def standard_dependencies

platform :mri do
# Debugger for VSCode.
if !ENV['CI'] && RUBY_VERSION < '3.0'
if !ENV['CI'] && !ENV['DOCKER'] && RUBY_VERSION < '3.0'
gem 'debase'
gem 'ruby-debug-ide'
end
Expand Down
34 changes: 20 additions & 14 deletions spec/integration/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
BASE = File.join(File.dirname(__FILE__), '../..')
TMP_BASE = File.join(BASE, 'tmp')

def check_call(cmd, **opts)
puts "Executing #{cmd.join(' ')}"
Mrss::ChildProcessHelper.check_call(cmd, **opts)
end

describe 'Mongoid application tests' do
before(:all) do
unless SpecConfig.instance.app_tests?
Expand Down Expand Up @@ -87,14 +92,14 @@ def start_app(cmd, port, timeout)

Dir.chdir(TMP_BASE) do
FileUtils.rm_rf('mongoid-test')
Mrss::ChildProcessHelper.check_call(%w(rails new mongoid-test --skip-spring --skip-active-record), env: clean_env)
check_call(%w(rails new mongoid-test --skip-spring --skip-active-record), env: clean_env)

Dir.chdir('mongoid-test') do
adjust_app_gemfile
Mrss::ChildProcessHelper.check_call(%w(bundle install), env: clean_env)
check_call(%w(bundle install), env: clean_env)

Mrss::ChildProcessHelper.check_call(%w(rails g model post), env: clean_env)
Mrss::ChildProcessHelper.check_call(%w(rails g model comment post:belongs_to), env: clean_env)
check_call(%w(rails g model post), env: clean_env)
check_call(%w(rails g model comment post:belongs_to), env: clean_env)

# https://jira.mongodb.org/browse/MONGOID-4885
comment_text = File.read('app/models/comment.rb')
Expand All @@ -109,16 +114,16 @@ def start_app(cmd, port, timeout)

Dir.chdir(TMP_BASE) do
FileUtils.rm_rf('mongoid-test-config')
Mrss::ChildProcessHelper.check_call(%w(rails new mongoid-test-config --skip-spring --skip-active-record), env: clean_env)
check_call(%w(rails new mongoid-test-config --skip-spring --skip-active-record), env: clean_env)

Dir.chdir('mongoid-test-config') do
adjust_app_gemfile
Mrss::ChildProcessHelper.check_call(%w(bundle install), env: clean_env)
check_call(%w(bundle install), env: clean_env)

mongoid_config_file = File.join(TMP_BASE,'mongoid-test-config/config/mongoid.yml')

File.exist?(mongoid_config_file).should be false
Mrss::ChildProcessHelper.check_call(%w(rails g mongoid:config), env: clean_env)
check_call(%w(rails g mongoid:config), env: clean_env)
File.exist?(mongoid_config_file).should be true

config_text = File.read(mongoid_config_file)
Expand All @@ -130,10 +135,11 @@ def start_app(cmd, port, timeout)
end

def install_rails
Mrss::ChildProcessHelper.check_call(%w(gem uni rails -a))
check_call(%w(gem uni rails -a))
if (rails_version = SpecConfig.instance.rails_version) == 'master'
else
Mrss::ChildProcessHelper.check_call(%w(gem install rails --no-document -v) + [rails_version])
check_call(%w(gem list))
check_call(%w(gem install rails --no-document -v) + ["~> #{rails_version}.0"])
end
end

Expand All @@ -157,7 +163,7 @@ def install_rails
before do
Dir.chdir(APP_PATH) do
remove_bundler_req
Mrss::ChildProcessHelper.check_call(%w(bundle install), env: env)
check_call(%w(bundle install), env: env)
write_mongoid_yml
end

Expand All @@ -171,7 +177,7 @@ def install_rails
end
index.should be nil

Mrss::ChildProcessHelper.check_call(%w(bundle exec rake db:mongoid:create_indexes),
check_call(%w(bundle exec rake db:mongoid:create_indexes -t),
cwd: APP_PATH, env: env)

index = client['posts'].indexes.detect do |index|
Expand All @@ -189,11 +195,11 @@ def install_rails
def clone_application(repo_url, subdir: nil)
Dir.chdir(TMP_BASE) do
FileUtils.rm_rf(File.basename(repo_url))
Mrss::ChildProcessHelper.check_call(%w(git clone) + [repo_url])
check_call(%w(git clone) + [repo_url])
Dir.chdir(File.join(*[File.basename(repo_url), subdir].compact)) do
adjust_app_gemfile
adjust_rails_defaults
Mrss::ChildProcessHelper.check_call(%w(bundle install), env: clean_env)
check_call(%w(bundle install), env: clean_env)
puts `git diff`

write_mongoid_yml
Expand Down Expand Up @@ -316,7 +322,7 @@ def remove_spring
# in `initialize': too long unix socket path (126bytes given but 108bytes max) (ArgumentError)
# Is it trying to create unix sockets in current directory?
# https://stackoverflow.com/questions/30302021/rails-runner-without-spring
Mrss::ChildProcessHelper.check_call(%w(bin/spring binstub --remove --all), env: clean_env)
check_call(%w(bin/spring binstub --remove --all), env: clean_env)
end

def clean_env
Expand Down

0 comments on commit d4b9469

Please sign in to comment.