mongo 2.14.0.rc1 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +1 -1
  4. data/Rakefile +39 -4
  5. data/lib/mongo/address.rb +1 -1
  6. data/lib/mongo/collection.rb +5 -0
  7. data/lib/mongo/collection/view/readable.rb +4 -0
  8. data/lib/mongo/cursor.rb +15 -3
  9. data/lib/mongo/database/view.rb +1 -1
  10. data/lib/mongo/operation/collections_info/command.rb +5 -0
  11. data/lib/mongo/operation/collections_info/result.rb +16 -1
  12. data/lib/mongo/operation/find/result.rb +10 -0
  13. data/lib/mongo/server/description.rb +8 -1
  14. data/lib/mongo/session.rb +2 -1
  15. data/lib/mongo/version.rb +1 -1
  16. data/spec/README.md +7 -0
  17. data/spec/integration/bson_symbol_spec.rb +4 -2
  18. data/spec/integration/change_stream_spec.rb +1 -1
  19. data/spec/integration/connection_pool_populator_spec.rb +1 -1
  20. data/spec/integration/cursor_reaping_spec.rb +1 -1
  21. data/spec/integration/fork_reconnect_spec.rb +56 -1
  22. data/spec/integration/query_cache_transactions_spec.rb +29 -18
  23. data/spec/integration/sdam_error_handling_spec.rb +17 -0
  24. data/spec/integration/sdam_events_spec.rb +8 -5
  25. data/spec/integration/transactions_examples_spec.rb +17 -7
  26. data/spec/lite_spec_helper.rb +5 -3
  27. data/spec/mongo/auth/user_spec.rb +1 -1
  28. data/spec/mongo/bulk_write_spec.rb +2 -2
  29. data/spec/mongo/client_construction_spec.rb +3 -3
  30. data/spec/mongo/client_encryption_spec.rb +16 -10
  31. data/spec/mongo/client_spec.rb +7 -0
  32. data/spec/mongo/cluster/topology/replica_set_spec.rb +1 -1
  33. data/spec/mongo/cluster/topology/sharded_spec.rb +1 -1
  34. data/spec/mongo/cluster/topology/single_spec.rb +1 -1
  35. data/spec/mongo/cluster/topology/unknown_spec.rb +1 -1
  36. data/spec/mongo/cluster/topology_spec.rb +1 -1
  37. data/spec/mongo/collection/view/change_stream_resume_spec.rb +1 -1
  38. data/spec/mongo/collection/view/readable_spec.rb +36 -0
  39. data/spec/mongo/collection_spec.rb +12 -0
  40. data/spec/mongo/crypt/binary_spec.rb +1 -6
  41. data/spec/mongo/crypt/binding/binary_spec.rb +1 -6
  42. data/spec/mongo/crypt/binding/context_spec.rb +2 -7
  43. data/spec/mongo/crypt/binding/helpers_spec.rb +1 -6
  44. data/spec/mongo/crypt/binding/mongocrypt_spec.rb +2 -7
  45. data/spec/mongo/crypt/binding/status_spec.rb +1 -6
  46. data/spec/mongo/crypt/binding/version_spec.rb +1 -6
  47. data/spec/mongo/crypt/data_key_context_spec.rb +1 -1
  48. data/spec/mongo/crypt/status_spec.rb +1 -6
  49. data/spec/mongo/database_spec.rb +64 -0
  50. data/spec/mongo/monitoring/event/server_closed_spec.rb +1 -1
  51. data/spec/mongo/monitoring/event/server_opening_spec.rb +1 -1
  52. data/spec/mongo/monitoring/event/topology_changed_spec.rb +1 -1
  53. data/spec/mongo/monitoring/event/topology_closed_spec.rb +1 -1
  54. data/spec/mongo/monitoring/event/topology_opening_spec.rb +1 -1
  55. data/spec/mongo/operation/delete/op_msg_spec.rb +3 -3
  56. data/spec/mongo/operation/insert/command_spec.rb +2 -2
  57. data/spec/mongo/operation/insert/op_msg_spec.rb +3 -3
  58. data/spec/mongo/operation/read_preference_op_msg_spec.rb +1 -1
  59. data/spec/mongo/operation/update/command_spec.rb +2 -2
  60. data/spec/mongo/operation/update/op_msg_spec.rb +3 -3
  61. data/spec/mongo/query_cache_spec.rb +1 -0
  62. data/spec/mongo/server/app_metadata_shared.rb +2 -2
  63. data/spec/mongo/server/connection_spec.rb +1 -1
  64. data/spec/mongo/server/description_spec.rb +18 -0
  65. data/spec/mongo/server_selector_spec.rb +2 -2
  66. data/spec/mongo/socket/ssl_spec.rb +3 -3
  67. data/spec/runners/change_streams/test.rb +1 -1
  68. data/spec/runners/crud/test_base.rb +0 -19
  69. data/spec/runners/server_selection.rb +1 -1
  70. data/spec/runners/transactions/test.rb +2 -2
  71. data/spec/shared/LICENSE +20 -0
  72. data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
  73. data/spec/shared/lib/mrss/constraints.rb +303 -0
  74. data/spec/shared/lib/mrss/lite_constraints.rb +175 -0
  75. data/spec/shared/lib/mrss/spec_organizer.rb +149 -0
  76. data/spec/spec_helper.rb +3 -1
  77. data/spec/stress/fork_reconnect_stress_spec.rb +1 -1
  78. data/spec/support/constraints.rb +0 -270
  79. data/spec/support/utils.rb +19 -0
  80. metadata +956 -952
  81. metadata.gz.sig +0 -0
  82. data/spec/support/child_process_helper.rb +0 -78
  83. data/spec/support/lite_constraints.rb +0 -165
  84. data/spec/support/spec_organizer.rb +0 -129
metadata.gz.sig CHANGED
Binary file
@@ -1,78 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- autoload :ChildProcess, 'childprocess'
5
- autoload :Tempfile, 'tempfile'
6
-
7
- module ChildProcessHelper
8
- class SpawnError < StandardError; end
9
-
10
- module_function def call(cmd, env: nil, cwd: nil)
11
- process = ChildProcess.new(*cmd)
12
- process.io.inherit!
13
- if cwd
14
- process.cwd = cwd
15
- end
16
- if env
17
- env.each do |k, v|
18
- process.environment[k.to_s] = v
19
- end
20
- end
21
- process.start
22
- process.wait
23
- process
24
- end
25
-
26
- module_function def check_call(cmd, env: nil, cwd: nil)
27
- process = call(cmd, env: env, cwd: cwd)
28
- unless process.exit_code == 0
29
- raise SpawnError, "Failed to execute: #{cmd}"
30
- end
31
- end
32
-
33
- module_function def get_output(cmd, env: nil, cwd: nil)
34
- process = ChildProcess.new(*cmd)
35
- process.io.inherit!
36
- if cwd
37
- process.cwd = cwd
38
- end
39
- if env
40
- env.each do |k, v|
41
- process.environment[k.to_s] = v
42
- end
43
- end
44
-
45
- output = ''
46
- r, w = IO.pipe
47
-
48
- begin
49
- process.io.stdout = w
50
- process.start
51
- w.close
52
-
53
- thread = Thread.new do
54
- begin
55
- loop do
56
- output << r.readpartial(16384)
57
- end
58
- rescue EOFError
59
- end
60
- end
61
-
62
- process.wait
63
- thread.join
64
- ensure
65
- r.close
66
- end
67
-
68
- [process, output]
69
- end
70
-
71
- module_function def check_output(*args)
72
- process, output = get_output(*args)
73
- unless process.exit_code == 0
74
- raise SpawnError,"Failed to execute: #{args}"
75
- end
76
- output
77
- end
78
- end
@@ -1,165 +0,0 @@
1
- module LiteConstraints
2
- # Constrain tests that use TimeoutInterrupt to MRI (and Unix)
3
- def only_mri
4
- before(:all) do
5
- unless SpecConfig.instance.mri?
6
- skip "MRI required, we have #{SpecConfig.instance.platform}"
7
- end
8
- end
9
- end
10
-
11
- def require_jruby
12
- before(:all) do
13
- unless BSON::Environment.jruby?
14
- skip "JRuby required, we have #{SpecConfig.instance.platform}"
15
- end
16
- end
17
- end
18
-
19
- # This is for marking tests that fail on jruby that should
20
- # in principle work (as opposed to being fundamentally incompatible
21
- # with jruby).
22
- # Often times these failures happen only in Evergreen.
23
- def fails_on_jruby(version=nil)
24
- before(:all) do
25
- if BSON::Environment.jruby?
26
- if version
27
- min_parts = version.split('.').map(&:to_i)
28
- actual_parts = JRUBY_VERSION.split('.').map(&:to_i)[0...min_parts.length]
29
- actual = actual_parts.join('.')
30
- if actual <= version
31
- skip "Fails on jruby through #{version}"
32
- end
33
- else
34
- skip "Fails on jruby"
35
- end
36
- end
37
- end
38
- end
39
-
40
- def require_external_connectivity
41
- before(:all) do
42
- if ENV['EXTERNAL_DISABLED']
43
- skip "Test requires external connectivity"
44
- end
45
- end
46
- end
47
-
48
- def require_mongo_kerberos
49
- before(:all) do
50
- unless %w(1 yes true).include?(ENV['MONGO_RUBY_DRIVER_KERBEROS']&.downcase)
51
- skip 'Set MONGO_RUBY_DRIVER_KERBEROS=1 in environment to run Kerberos unit tests'
52
- end
53
- require 'mongo_kerberos'
54
- end
55
- end
56
-
57
- def require_linting
58
- before do
59
- unless Mongo::Lint.enabled?
60
- skip "Linting is not enabled"
61
- end
62
- end
63
- end
64
-
65
- def require_libmongocrypt
66
- before(:all) do
67
- unless ENV['LIBMONGOCRYPT_PATH']
68
- skip 'Test requires path to libmongocrypt to be specified in LIBMONGOCRYPT_PATH env variable'
69
- end
70
- end
71
- end
72
-
73
- def require_no_libmongocrypt
74
- before(:all) do
75
- if ENV['LIBMONGOCRYPT_PATH']
76
- skip 'Test requires libmongocrypt to not be configured'
77
- end
78
- end
79
- end
80
-
81
- # Some tests will fail if linting is enabled:
82
- # 1. Tests that pass invalid options to client, etc. which the linter
83
- # rejects.
84
- # 2. Tests that set expectations on topologies, server descriptions, etc.
85
- # (since setting expectations requires mutating said objects, and when
86
- # linting is on those objects are frozen).
87
- def skip_if_linting
88
- before do
89
- if Mongo::Lint.enabled?
90
- skip "Linting is enabled"
91
- end
92
- end
93
- end
94
-
95
- def require_aws_auth
96
- before(:all) do
97
- unless (ENV['AUTH'] || '') =~ /^aws/
98
- skip 'This test requires AUTH=aws* and an appropriately configured runtime environment'
99
- end
100
- end
101
- end
102
-
103
- def require_ec2_host
104
- before(:all) do
105
- if $have_aws.nil?
106
- $have_aws = begin
107
- require 'open-uri'
108
- begin
109
- Timeout.timeout(3.81) do
110
- URI.parse('http://169.254.169.254/latest/meta-data/profile').open.read
111
- end
112
- true
113
- # When trying to use the EC2 metadata endpoint on ECS:
114
- # Errno::EINVAL: Failed to open TCP connection to 169.254.169.254:80 (Invalid argument - connect(2) for "169.254.169.254" port 80)
115
- rescue Timeout::Error, Errno::ETIMEDOUT, Errno::EINVAL, OpenURI::HTTPError => $aws_error
116
- false
117
- end
118
- end
119
- end
120
- unless $have_aws
121
- skip "EC2 instance metadata is not available - assuming not running on an EC2 instance: #{$aws_error.class}: #{$aws_error}"
122
- end
123
- end
124
- end
125
-
126
- def require_stress
127
- before(:all) do
128
- if !SpecConfig.instance.stress?
129
- skip 'Set STRESS=1 in environment to run stress tests'
130
- end
131
- end
132
- end
133
-
134
- def require_fork
135
- before(:all) do
136
- if !SpecConfig.instance.fork?
137
- skip 'Set FORK=1 in environment to run fork tests'
138
- end
139
- end
140
- end
141
-
142
- def require_ocsp
143
- before(:all) do
144
- if !SpecConfig.instance.ocsp?
145
- skip 'Set OCSP=1 in environment to run OCSP tests'
146
- end
147
- end
148
- end
149
-
150
- def require_ocsp_verifier
151
- before(:all) do
152
- if !SpecConfig.instance.ocsp_verifier?
153
- skip 'Set OCSP_VERIFIER=1 in environment to run OCSP verifier tests'
154
- end
155
- end
156
- end
157
-
158
- def require_ocsp_connectivity
159
- before(:all) do
160
- if !SpecConfig.instance.ocsp_connectivity?
161
- skip 'Set OCSP_CONNECTIVITY=pass or OCSP_CONNECTIVITY=fail in environment to run OCSP connectivity tests'
162
- end
163
- end
164
- end
165
- end
@@ -1,129 +0,0 @@
1
- autoload :FileUtils, 'fileutils'
2
- autoload :Find, 'find'
3
- autoload :ChildProcessHelper, 'support/child_process_helper'
4
-
5
- # Organizes and runs all of the tests in the test suite in batches.
6
- #
7
- # Organizing the tests in batches serves two purposes:
8
- #
9
- # 1. This allows running unit tests before integration tests, therefore
10
- # in theory revealing failures quicker on average.
11
- # 2. This allows running some tests that have high intermittent failure rate
12
- # in their own test process.
13
- #
14
- # This class aggregates RSpec results after the test runs.
15
- class SpecOrganizer
16
- CLASSIFIERS = [
17
- [%r,^mongo,, :unit],
18
- [%r,^kerberos,, :unit],
19
- [%r,^integration/sdam_error_handling,, :sdam_integration],
20
- [%r,^integration/cursor_reaping,, :cursor_reaping],
21
- [%r,^(atlas|integration),, :integration],
22
- [%r,^spec_tests,, :spec],
23
- [%r,^spec_tests/sdam_integration,, :spec_sdam_integration],
24
- ]
25
-
26
- RUN_PRIORITY = %i(unit
27
- integration sdam_integration cursor_reaping
28
- spec spec_sdam_integration
29
- )
30
-
31
- SPEC_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
32
- ROOT = File.expand_path(File.join(SPEC_ROOT, '..'))
33
- RSPEC_JSON_PATH = File.join(ROOT, 'tmp/rspec.json')
34
- RSPEC_ALL_JSON_PATH = File.join(ROOT, 'tmp/rspec-all.json')
35
-
36
- def run
37
- FileUtils.rm_f(RSPEC_ALL_JSON_PATH)
38
-
39
- buckets = {}
40
- Find.find(SPEC_ROOT) do |path|
41
- next unless File.file?(path)
42
- next unless path =~ /_spec\.rb\z/
43
- rel_path = path[(SPEC_ROOT.length + 1)..path.length]
44
-
45
- found = false
46
- CLASSIFIERS.each do |(regexp, category)|
47
- if regexp =~ rel_path
48
- buckets[category] ||= []
49
- buckets[category] << rel_path
50
- found = true
51
- break
52
- end
53
- end
54
-
55
- unless found
56
- buckets[nil] ||= []
57
- buckets[nil] << rel_path
58
- end
59
- end
60
-
61
- failed = []
62
-
63
- RUN_PRIORITY.each do |category|
64
- if files = buckets.delete(category)
65
- unless run_files(category, files)
66
- failed << category
67
- end
68
- end
69
- end
70
- if files = buckets.delete(nil)
71
- unless run_files('remaining', files)
72
- failed << 'remaining'
73
- end
74
- end
75
-
76
- unless buckets.empty?
77
- raise "Some buckets were not executed: #{buckets.keys.map(&:to_s).join(', ')}"
78
- end
79
-
80
- if failed.any?
81
- raise "The following buckets failed: #{failed.map(&:to_s).join(', ')}"
82
- end
83
- end
84
-
85
- def run_files(category, paths)
86
- paths = paths.map do |path|
87
- File.join('spec', path)
88
- end
89
-
90
- puts "Running #{category.to_s.gsub('_', ' ')} tests"
91
- FileUtils.rm_f(RSPEC_JSON_PATH)
92
- cmd = %w(rspec) + paths
93
-
94
- begin
95
- ChildProcessHelper.check_call(cmd)
96
- ensure
97
- if File.exist?(RSPEC_JSON_PATH)
98
- if File.exist?(RSPEC_ALL_JSON_PATH)
99
- merge_rspec_results
100
- else
101
- FileUtils.cp(RSPEC_JSON_PATH, RSPEC_ALL_JSON_PATH)
102
- end
103
- end
104
- end
105
-
106
- true
107
- rescue ChildProcessHelper::SpawnError
108
- false
109
- end
110
-
111
- def merge_rspec_results
112
- all = JSON.parse(File.read(RSPEC_ALL_JSON_PATH))
113
- new = JSON.parse(File.read(RSPEC_JSON_PATH))
114
- all['examples'] += new.delete('examples')
115
- new.delete('summary').each do |k, v|
116
- all['summary'][k] += v
117
- end
118
- new.delete('version')
119
- new.delete('summary_line')
120
- unless new.empty?
121
- raise "Unhandled rspec results keys: #{new.keys.join(', ')}"
122
- end
123
- # We do not merge summary lines, delete them from aggregated results
124
- all.delete('summary_line')
125
- File.open(RSPEC_ALL_JSON_PATH, 'w') do |f|
126
- f << JSON.dump(all)
127
- end
128
- end
129
- end