Skip to content

Commit 843e6bd

Browse files
Fix yaml parsing
1 parent 63435f9 commit 843e6bd

17 files changed

+99
-38
lines changed

.evergreen/config/atlas.yml.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
buildvariants:
22
- matrix_name: "all"
33
matrix_spec:
4-
ruby: ["ruby-2.5", "ruby-2.6", "ruby-2.7", "ruby-3.0", "ruby-3.1", "jruby-9.2"]
4+
ruby: ["ruby-2.5", "ruby-2.6", "ruby-2.7", "ruby-3.0", "jruby-9.2"]
55
display_name: "Atlas tests ${ruby}"
66
run_on:
77
- ubuntu1804-small
@@ -10,7 +10,7 @@ buildvariants:
1010

1111
- matrix_name: "serverless single mongos"
1212
matrix_spec:
13-
ruby: ["ruby-2.5", "ruby-2.6", "ruby-2.7", "ruby-3.0", "ruby-3.1", "jruby-9.2"]
13+
ruby: ["ruby-2.5", "ruby-2.6", "ruby-2.7", "ruby-3.0", "jruby-9.2"]
1414
single-mongos: single-mongos
1515
display_name: "Atlas serverless ${ruby} single mongos"
1616
run_on:
@@ -20,7 +20,7 @@ buildvariants:
2020

2121
- matrix_name: "serverless multiple mongos"
2222
matrix_spec:
23-
ruby: ["ruby-2.5", "ruby-2.6", "ruby-2.7", "ruby-3.0", "ruby-3.1", "jruby-9.2"]
23+
ruby: ["ruby-2.5", "ruby-2.6", "ruby-2.7", "ruby-3.0", "jruby-9.2"]
2424
display_name: "Atlas serverless tests ${ruby}"
2525
run_on:
2626
- ubuntu1804-small

.evergreen/config/axes.yml.erb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ axes:
121121
- id: "ruby"
122122
display_name: Ruby Version
123123
values:
124-
- id: "ruby-3.1"
125-
display_name: ruby-3.1
126-
variables:
127-
RVM_RUBY: "ruby-3.1"
128124
- id: "ruby-3.0"
129125
display_name: ruby-3.0
130126
variables:

.evergreen/config/standard.yml.erb

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ buildvariants:
5959
- matrix_name: "mongo-4.4"
6060
matrix_spec:
6161
auth-and-ssl: ["auth-and-ssl", "noauth-and-nossl"]
62-
ruby: ["ruby-3.1", "ruby-3.0", "ruby-2.7"]
62+
ruby: ["ruby-3.0", "ruby-2.7"]
6363
mongodb-version: '4.4'
6464
topology: <%= tt %>
6565
os: ubuntu1604
@@ -161,7 +161,7 @@ buildvariants:
161161
- matrix_name: "fork"
162162
matrix_spec:
163163
fork: on
164-
ruby: ["ruby-3.1", "ruby-3.0", "ruby-2.7"]
164+
ruby: ["ruby-3.0", "ruby-2.7"]
165165
mongodb-version: ["4.4"]
166166
topology: <%= tt %>
167167
os: ubuntu1604
@@ -172,7 +172,7 @@ buildvariants:
172172
- matrix_name: "solo"
173173
matrix_spec:
174174
solo: on
175-
ruby: [ruby-3.1, ruby-3.0, ruby-2.7, ruby-2.6, ruby-2.5, jruby-9.2]
175+
ruby: [ruby-3.0, ruby-2.7, ruby-2.6, ruby-2.5, jruby-9.2]
176176
mongodb-version: ["4.4"]
177177
topology: <%= tt %>
178178
os: ubuntu1604
@@ -227,7 +227,19 @@ buildvariants:
227227
- matrix_name: "zlib-auth"
228228
matrix_spec:
229229
auth-and-ssl: "auth-and-ssl"
230-
ruby: ["ruby-3.1", "ruby-3.0", "ruby-2.7"]
230+
ruby: ["ruby-2.7"]
231+
mongodb-version: "4.4"
232+
topology: "replica-set"
233+
compressor: 'zlib'
234+
os: ubuntu1604
235+
display_name: "${compressor} ${mongodb-version} ${topology} ${auth-and-ssl} ${ruby}"
236+
tasks:
237+
- name: "test-mlaunch"
238+
239+
- matrix_name: "zlib-auth-3.0"
240+
matrix_spec:
241+
auth-and-ssl: "auth-and-ssl"
242+
ruby: ["ruby-3.0"]
231243
mongodb-version: "4.4"
232244
topology: "standalone"
233245
compressor: 'zlib'
@@ -251,7 +263,7 @@ buildvariants:
251263
- matrix_name: "snappy-auth"
252264
matrix_spec:
253265
auth-and-ssl: "auth-and-ssl"
254-
ruby: ["ruby-3.1", "ruby-3.0", "ruby-2.7"]
266+
ruby: ["ruby-2.7"]
255267
mongodb-version: "4.4"
256268
topology: "replica-set"
257269
compressor: 'snappy'
@@ -260,12 +272,24 @@ buildvariants:
260272
tasks:
261273
- name: "test-mlaunch"
262274

275+
- matrix_name: "snappy-auth-3.0"
276+
matrix_spec:
277+
auth-and-ssl: "auth-and-ssl"
278+
ruby: ["ruby-3.0"]
279+
mongodb-version: "4.4"
280+
topology: "standalone"
281+
compressor: 'snappy'
282+
os: ubuntu1604
283+
display_name: "${compressor} ${mongodb-version} ${topology} ${auth-and-ssl} ${ruby}"
284+
tasks:
285+
- name: "test-mlaunch"
286+
263287
- matrix_name: "snappy-noauth"
264288
matrix_spec:
265289
auth-and-ssl: "noauth-and-nossl"
266290
ruby: "ruby-2.5"
267291
mongodb-version: ["3.6"]
268-
topology: standalone
292+
topology: replica-set
269293
compressor: 'snappy'
270294
os: ubuntu1604
271295
display_name: "${compressor} ${mongodb-version} ${topology} ${auth-and-ssl} ${ruby}"
@@ -288,7 +312,7 @@ buildvariants:
288312
- matrix_name: "zstd-auth"
289313
matrix_spec:
290314
auth-and-ssl: "auth-and-ssl"
291-
ruby: ["ruby-3.1", "ruby-3.0", "ruby-2.7"]
315+
ruby: ["ruby-2.7"]
292316
mongodb-version: "4.4"
293317
topology: "replica-set"
294318
compressor: 'zstd'
@@ -297,6 +321,18 @@ buildvariants:
297321
tasks:
298322
- name: "test-mlaunch"
299323

324+
- matrix_name: "zstd-auth-3.0"
325+
matrix_spec:
326+
auth-and-ssl: "auth-and-ssl"
327+
ruby: ["ruby-3.0"]
328+
mongodb-version: "4.4"
329+
topology: "standalone"
330+
compressor: 'zstd'
331+
os: ubuntu1604
332+
display_name: "${compressor} ${mongodb-version} ${topology} ${auth-and-ssl} ${ruby}"
333+
tasks:
334+
- name: "test-mlaunch"
335+
300336
- matrix_name: "zstd-noauth"
301337
matrix_spec:
302338
auth-and-ssl: "noauth-and-nossl"
@@ -333,7 +369,7 @@ buildvariants:
333369

334370
- matrix_name: "activesupport"
335371
matrix_spec:
336-
ruby: ["ruby-3.1", "ruby-3.0", "ruby-2.7"]
372+
ruby: ["ruby-3.0", "ruby-2.7"]
337373
mongodb-version: '4.4'
338374
topology: replica-set
339375
as: as
@@ -344,7 +380,7 @@ buildvariants:
344380

345381
- matrix_name: "bson"
346382
matrix_spec:
347-
ruby: [ruby-3.1, ruby-3.0, ruby-2.7, jruby-9.2]
383+
ruby: [ruby-3.0, ruby-2.7, jruby-9.2]
348384
mongodb-version: '4.4'
349385
topology: replica-set
350386
bson: "*"
@@ -402,8 +438,8 @@ buildvariants:
402438
matrix_spec:
403439
auth-and-ssl: "noauth-and-nossl"
404440
# https://jira.mongodb.org/browse/RUBY-2832
405-
# ruby: [ruby-3.1, ruby-3.0, ruby-2.7, jruby-9.2]
406-
ruby: [ruby-3.1, ruby-3.0, ruby-2.7]
441+
# ruby: [ruby-3.0, ruby-2.7, jruby-9.2]
442+
ruby: [ruby-3.0, ruby-2.7]
407443
topology: standalone
408444
mongodb-version: ['4.4']
409445
os: ubuntu1804
@@ -459,13 +495,13 @@ buildvariants:
459495
- name: "test-aws-auth"
460496

461497
# No JRuby due to https://github.com/jruby/jruby-openssl/issues/210
462-
# TODO Add ruby-3.1, ruby-3.0: RUBY-2717
498+
# TODO Add ruby-3.0: RUBY-2717
463499
<%|= standard_debian_rubies(%w(ruby-2.5 ruby-2.6 ruby-2.7), key: 'docker-distro') do %>
464500
matrix_name: ocsp-verifier
465501
matrix_spec:
466502
ocsp-verifier: true
467503
# No JRuby due to https://github.com/jruby/jruby-openssl/issues/210
468-
ruby: [ruby-3.1, ruby-3.0, ruby-2.7, ruby-2.6, ruby-2.5]
504+
ruby: [ruby-3.0, ruby-2.7, ruby-2.6, ruby-2.5]
469505
topology: standalone
470506
mongodb-version: '4.4'
471507
os: ubuntu1604
@@ -479,7 +515,7 @@ buildvariants:
479515
ocsp-algorithm: ecdsa
480516
ocsp-must-staple: on
481517
ocsp-delegate: on
482-
ruby: [ruby-3.1, ruby-3.0, ruby-2.7]
518+
ruby: [ruby-3.0, ruby-2.7]
483519
topology: standalone
484520
mongodb-version: '4.4'
485521
os: ubuntu1604
@@ -492,7 +528,7 @@ buildvariants:
492528
matrix_spec:
493529
ocsp-algorithm: rsa
494530
ocsp-status: unknown
495-
ruby: [ruby-3.1, ruby-3.0, ruby-2.7]
531+
ruby: [ruby-3.0, ruby-2.7]
496532
topology: standalone
497533
mongodb-version: '4.4'
498534
os: ubuntu1604
@@ -522,7 +558,7 @@ buildvariants:
522558
ocsp-delegate: '*'
523559
ocsp-connectivity: <%= outcome %>
524560
extra-uri-options: "<%= extra_uri_options %>"
525-
ruby: [ruby-3.1, ruby-3.0, ruby-2.7]
561+
ruby: [ruby-3.0, ruby-2.7]
526562
topology: standalone
527563
mongodb-version: '4.4'
528564
os: ubuntu1604

spec/runners/auth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Spec
4848
attr_reader :tests
4949

5050
def initialize(test_path)
51-
@spec = YAML.load(File.read(test_path))
51+
@spec = ::Utils.load_spec_yaml_file(test_path)
5252
@description = File.basename(test_path)
5353
end
5454

spec/runners/change_streams/spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Spec
3232
#
3333
# @since 2.6.0
3434
def initialize(test_path)
35-
@spec = YAML.load(File.read(test_path))
35+
@spec = ::Utils.load_spec_yaml_file(test_path)
3636
@description = File.basename(test_path)
3737
@spec_tests = @spec['tests']
3838
@collection_name = @spec['collection_name']

spec/runners/cmap.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Spec
4040
#
4141
# @param [ String ] test_path The path to the file.
4242
def initialize(test_path)
43-
@test = YAML.load(File.read(test_path))
43+
@test = ::Utils.load_spec_yaml_file(test_path)
4444

4545
@description = @test['description']
4646
@pool_options = ::Utils.snakeize_hash(process_options(@test['poolOptions']))

spec/runners/command_monitoring.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class Spec
204204
#
205205
# @since 2.1.0
206206
def initialize(test_path)
207-
@spec = YAML.load(File.read(test_path))
207+
@spec = ::Utils.load_spec_yaml_file(test_path)
208208
@data = @spec['data']
209209
@tests = @spec['tests']
210210
end

spec/runners/connection_string.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class Spec
100100
#
101101
# @since 2.0.0
102102
def initialize(test_path)
103-
@spec = YAML.load(File.read(test_path))
103+
@spec = ::Utils.load_spec_yaml_file(test_path)
104104
@description = File.basename(test_path)
105105
end
106106

spec/runners/crud/spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ class Spec
1212
#
1313
# @since 2.0.0
1414
def initialize(test_path)
15-
contents = File.read(test_path)
16-
17-
@spec = YAML.load(contents)
15+
@spec = ::Utils.load_spec_yaml_file(test_path)
1816
@description = File.basename(test_path)
1917
@data = BSON::ExtJSON.parse_obj(@spec['data'])
2018
@tests = @spec['tests']

spec/runners/gridfs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class Spec
100100
#
101101
# @since 2.1.0
102102
def initialize(test_path)
103-
@spec = YAML.load(File.read(test_path))
103+
@spec = ::Utils.load_spec_yaml_file(test_path)
104104
@description = File.basename(test_path)
105105
@data = @spec['data']
106106
end

spec/runners/read_write_concern_document.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Spec
1313
#
1414
# @since 2.0.0
1515
def initialize(test_path)
16-
@spec = YAML.load(File.read(test_path))
16+
@spec = ::Utils.load_spec_yaml_file(test_path)
1717
@description = File.basename(test_path)
1818
end
1919

spec/runners/sdam.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Spec
7777
#
7878
# @since 2.0.0
7979
def initialize(test_path)
80-
@test = YAML.load(File.read(test_path))
80+
@test = ::Utils.load_spec_yaml_file(test_path)
8181
@description = @test['description']
8282
@uri_string = @test['uri']
8383
@uri = URI.new(uri_string)

spec/runners/server_selection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Spec
6464
#
6565
# @since 2.0.0
6666
def initialize(test_path)
67-
@test = YAML.load(File.read(test_path))
67+
@test = ::Utils.load_spec_yaml_file(test_path)
6868
@description = "#{@test['topology_description']['type']}: #{File.basename(test_path)}"
6969
@heartbeat_frequency = @test['heartbeatFrequencyMS'] / 1000 if @test['heartbeatFrequencyMS']
7070
@read_preference = @test['read_preference']

spec/runners/server_selection_rtt.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Spec
2828
#
2929
# @since 2.0.0
3030
def initialize(test_path)
31-
@test = YAML.load(File.read(test_path))
31+
@test = ::Utils.load_spec_yaml_file(test_path)
3232
@description = "#{File.basename(test_path)}: avg_rtt_ms: #{@test['avg_rtt_ms']}, new_rtt_ms: #{@test['new_rtt_ms']}," +
3333
" new_avg_rtt: #{@test['new_avg_rtt']}"
3434
@average_rtt = @test['avg_rtt_ms'] == 'NULL' ? nil : @test['avg_rtt_ms'].to_f / 1000

spec/runners/unified/test_group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Unified
66
class TestGroup
77
def initialize(path, **opts)
88
if String === path
9-
data = YAML.load(File.read(path))
9+
data = ::Utils.load_spec_yaml_file(path)
1010
else
1111
data = path
1212
end

spec/spec_tests/seed_list_discovery_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
SEED_LIST_DISCOVERY_TESTS.each do |test_path|
1717

18-
spec = YAML.load(File.read(test_path))
18+
spec = ::Utils.load_spec_yaml_file(test_path)
1919

2020
test = Mongo::ConnectionString::Test.new(spec)
2121

spec/support/utils.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,4 +613,35 @@ def match_with_type?(expected, actual)
613613
end
614614
end
615615
end
616+
617+
module_function def load_spec_yaml_file(path)
618+
permitted_classes = [
619+
BigDecimal,
620+
Date,
621+
Time,
622+
Range,
623+
Regexp,
624+
Symbol,
625+
BSON::Binary,
626+
BSON::Code,
627+
BSON::CodeWithScope,
628+
BSON::DbPointer,
629+
BSON::Decimal128,
630+
BSON::Int32,
631+
BSON::Int64,
632+
BSON::MaxKey,
633+
BSON::MinKey,
634+
BSON::ObjectId,
635+
BSON::Regexp::Raw,
636+
BSON::Symbol::Raw,
637+
BSON::Timestamp,
638+
BSON::Undefined,
639+
]
640+
if RUBY_VERSION.start_with?("2.5")
641+
YAML.safe_load(File.read(path), permitted_classes, [], true)
642+
else
643+
# Here we have Ruby 2.6+ that supports the new syntax of `safe_load``.
644+
YAML.safe_load(File.read(path), permitted_classes: permitted_classes, aliases: true)
645+
end
646+
end
616647
end

0 commit comments

Comments
 (0)