Skip to content

Commit ccfbedd

Browse files
p-mongop
andauthored
RUBY-2947 MONGOID-5216 Update Mongoid test tooling 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]>
1 parent 80b5897 commit ccfbedd

File tree

6 files changed

+56
-53
lines changed

6 files changed

+56
-53
lines changed

.evergreen/config.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ buildvariants:
620620
topology: ['replica-set', 'sharded-cluster']
621621
display_name: "${ruby}, ${driver}, ${mongodb-version}, ${topology}"
622622
run_on:
623-
- rhel80-small
623+
- ubuntu2004-small
624624
tasks:
625625
- name: "test"
626626

@@ -632,7 +632,7 @@ buildvariants:
632632
topology: ['replica-set', 'sharded-cluster']
633633
display_name: "${ruby}, ${driver}, ${mongodb-version}, ${topology}"
634634
run_on:
635-
- rhel70-small
635+
- ubuntu1804-small
636636
tasks:
637637
- name: "test"
638638

@@ -657,7 +657,7 @@ buildvariants:
657657
rails: ['7.0']
658658
display_name: "${rails}, ${driver}, ${mongodb-version}"
659659
run_on:
660-
- rhel70-small
660+
- ubuntu2004-small
661661
tasks:
662662
- name: "test"
663663

@@ -695,7 +695,7 @@ buildvariants:
695695
rails: ['6.0', '6.1']
696696
display_name: "${rails}, ${driver}, ${mongodb-version}"
697697
run_on:
698-
- rhel80-small
698+
- ubuntu2004-small
699699
tasks:
700700
- name: "test"
701701

@@ -708,7 +708,7 @@ buildvariants:
708708
rails: ['5.1', '5.2']
709709
display_name: "${rails}, ${driver}, ${mongodb-version}"
710710
run_on:
711-
- rhel70-small
711+
- ubuntu1804-small
712712
tasks:
713713
- name: "test"
714714

@@ -721,7 +721,7 @@ buildvariants:
721721
i18n: '1.0'
722722
display_name: "i18n-1.0 ${rails}, ${driver}, ${mongodb-version}"
723723
run_on:
724-
- rhel70-small
724+
- ubuntu1804-small
725725
tasks:
726726
- name: "test"
727727

@@ -735,24 +735,23 @@ buildvariants:
735735
test-i18n-fallbacks: yes
736736
display_name: "i18n fallbacks ${rails}, ${driver}, ${mongodb-version}, ${i18n}"
737737
run_on:
738-
- rhel70-small
738+
- ubuntu1804-small
739739
tasks:
740740
- name: "test"
741741

742-
# https://jira.mongodb.org/browse/MONGOID-5216
743-
# - matrix_name: app-tests-ruby-3
744-
# matrix_spec:
745-
# ruby: ["ruby-3.0", "ruby-3.1"]
746-
# driver: ["current"]
747-
# mongodb-version: '5.0'
748-
# topology: standalone
749-
# app-tests: yes
750-
# rails: ['6.0', '6.1']
751-
# display_name: "app tests ${driver}, ${ruby}, ${rails}"
752-
# run_on:
753-
# - ubuntu2004-small
754-
# tasks:
755-
# - name: "test"
742+
- matrix_name: app-tests-ruby-3
743+
matrix_spec:
744+
ruby: ["ruby-3.0", "ruby-3.1"]
745+
driver: ["current"]
746+
mongodb-version: '5.0'
747+
topology: standalone
748+
app-tests: yes
749+
rails: ['6.0', '6.1']
750+
display_name: "app tests ${driver}, ${ruby}, ${rails}"
751+
run_on:
752+
- ubuntu2004-small
753+
tasks:
754+
- name: "test"
756755

757756
- matrix_name: app-tests-ruby-2.7
758757
matrix_spec:

.evergreen/run-tests.sh

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@ arch=`host_distro`
1717

1818
set_fcv
1919
set_env_vars
20+
set_env_python
21+
set_env_node
2022
set_env_ruby
2123

24+
if test -n "$APP_TESTS"; then
25+
# Node from toolchain
26+
export PATH=/opt/node/bin:$PATH
27+
node -v
28+
fi
29+
2230
prepare_server $arch
2331

2432
install_mlaunch_virtualenv
@@ -34,13 +42,6 @@ launch_server "$dbdir"
3442

3543
uri_options="$URI_OPTIONS"
3644

37-
# This is needed because of ruby 3.0.0.
38-
# We should remove this when moving to 3.0.1
39-
# See https://jira.mongodb.org/browse/MONGOID-5115
40-
if test "$RVM_RUBY" = "ruby-3.0"; then
41-
gem update --system
42-
fi
43-
4445
which bundle
4546
bundle --version
4647

@@ -104,13 +105,10 @@ if test -n "$TEST_CMD"; then
104105
elif test -n "$TEST_I18N_FALLBACKS"; then
105106
bundle exec rspec spec/integration/i18n_fallbacks_spec.rb spec/mongoid/criteria_spec.rb spec/mongoid/contextual/mongo_spec.rb
106107
elif test -n "$APP_TESTS"; then
107-
# Need recent node for rails
108-
export N_PREFIX=$HOME/.n
109-
curl -o $HOME/n --retry 3 https://raw.githubusercontent.com/tj/n/master/bin/n
110-
bash $HOME/n stable
111-
export PATH=$HOME/.n/bin:$PATH
112-
npm -g install yarn
113-
108+
if test -z "$DOCKER_PRELOAD"; then
109+
./spec/shared/bin/install-node
110+
fi
111+
114112
bundle exec rspec spec/integration/app_spec.rb
115113
else
116114
bundle exec rake ci
@@ -124,6 +122,6 @@ if test -f tmp/rspec-all.json; then
124122
mv tmp/rspec-all.json tmp/rspec.json
125123
fi
126124

127-
python2 -m mtools.mlaunch.mlaunch stop --dir "$dbdir"
125+
python3 -m mtools.mlaunch.mlaunch stop --dir "$dbdir"
128126

129127
exit ${test_status}

gemfiles/standard.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def standard_dependencies
66

77
platform :mri do
88
# Debugger for VSCode.
9-
if !ENV['CI'] && RUBY_VERSION < '3.0'
9+
if !ENV['CI'] && !ENV['DOCKER'] && RUBY_VERSION < '3.0'
1010
gem 'debase'
1111
gem 'ruby-debug-ide'
1212
end

spec/integration/app_spec.rb

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
BASE = File.join(File.dirname(__FILE__), '../..')
66
TMP_BASE = File.join(BASE, 'tmp')
77

8+
def check_call(cmd, **opts)
9+
puts "Executing #{cmd.join(' ')}"
10+
Mrss::ChildProcessHelper.check_call(cmd, **opts)
11+
end
12+
813
describe 'Mongoid application tests' do
914
before(:all) do
1015
unless SpecConfig.instance.app_tests?
@@ -87,14 +92,14 @@ def start_app(cmd, port, timeout)
8792

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

9297
Dir.chdir('mongoid-test') do
9398
adjust_app_gemfile
94-
Mrss::ChildProcessHelper.check_call(%w(bundle install), env: clean_env)
99+
check_call(%w(bundle install), env: clean_env)
95100

96-
Mrss::ChildProcessHelper.check_call(%w(rails g model post), env: clean_env)
97-
Mrss::ChildProcessHelper.check_call(%w(rails g model comment post:belongs_to), env: clean_env)
101+
check_call(%w(rails g model post), env: clean_env)
102+
check_call(%w(rails g model comment post:belongs_to), env: clean_env)
98103

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

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

114119
Dir.chdir('mongoid-test-config') do
115120
adjust_app_gemfile
116-
Mrss::ChildProcessHelper.check_call(%w(bundle install), env: clean_env)
121+
check_call(%w(bundle install), env: clean_env)
117122

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

120125
File.exist?(mongoid_config_file).should be false
121-
Mrss::ChildProcessHelper.check_call(%w(rails g mongoid:config), env: clean_env)
126+
check_call(%w(rails g mongoid:config), env: clean_env)
122127
File.exist?(mongoid_config_file).should be true
123128

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

132137
def install_rails
133-
Mrss::ChildProcessHelper.check_call(%w(gem uni rails -a))
138+
check_call(%w(gem uni rails -a))
134139
if (rails_version = SpecConfig.instance.rails_version) == 'master'
135140
else
136-
Mrss::ChildProcessHelper.check_call(%w(gem install rails --no-document -v) + [rails_version])
141+
check_call(%w(gem list))
142+
check_call(%w(gem install rails --no-document -v) + ["~> #{rails_version}.0"])
137143
end
138144
end
139145

@@ -157,7 +163,7 @@ def install_rails
157163
before do
158164
Dir.chdir(APP_PATH) do
159165
remove_bundler_req
160-
Mrss::ChildProcessHelper.check_call(%w(bundle install), env: env)
166+
check_call(%w(bundle install), env: env)
161167
write_mongoid_yml
162168
end
163169

@@ -171,7 +177,7 @@ def install_rails
171177
end
172178
index.should be nil
173179

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

177183
index = client['posts'].indexes.detect do |index|
@@ -189,11 +195,11 @@ def install_rails
189195
def clone_application(repo_url, subdir: nil)
190196
Dir.chdir(TMP_BASE) do
191197
FileUtils.rm_rf(File.basename(repo_url))
192-
Mrss::ChildProcessHelper.check_call(%w(git clone) + [repo_url])
198+
check_call(%w(git clone) + [repo_url])
193199
Dir.chdir(File.join(*[File.basename(repo_url), subdir].compact)) do
194200
adjust_app_gemfile
195201
adjust_rails_defaults
196-
Mrss::ChildProcessHelper.check_call(%w(bundle install), env: clean_env)
202+
check_call(%w(bundle install), env: clean_env)
197203
puts `git diff`
198204

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

322328
def clean_env

0 commit comments

Comments
 (0)