mongo 2.19.2 → 2.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/mongo/collection.rb +23 -1
  4. data/lib/mongo/operation/create_search_indexes/op_msg.rb +31 -0
  5. data/lib/mongo/operation/create_search_indexes.rb +15 -0
  6. data/lib/mongo/operation/drop_search_index/op_msg.rb +33 -0
  7. data/lib/mongo/operation/drop_search_index.rb +15 -0
  8. data/lib/mongo/operation/shared/specifiable.rb +7 -0
  9. data/lib/mongo/operation/update_search_index/op_msg.rb +34 -0
  10. data/lib/mongo/operation/update_search_index.rb +15 -0
  11. data/lib/mongo/operation.rb +3 -0
  12. data/lib/mongo/search_index/view.rb +232 -0
  13. data/lib/mongo/version.rb +1 -1
  14. data/lib/mongo.rb +1 -0
  15. data/spec/atlas/atlas_connectivity_spec.rb +1 -5
  16. data/spec/atlas/operations_spec.rb +1 -5
  17. data/spec/integration/search_indexes_prose_spec.rb +168 -0
  18. data/spec/lite_spec_helper.rb +32 -10
  19. data/spec/runners/unified/search_index_operations.rb +63 -0
  20. data/spec/runners/unified/test.rb +3 -1
  21. data/spec/spec_helper.rb +1 -1
  22. data/spec/spec_tests/data/index_management/createSearchIndex.yml +62 -0
  23. data/spec/spec_tests/data/index_management/createSearchIndexes.yml +83 -0
  24. data/spec/spec_tests/data/index_management/dropSearchIndex.yml +42 -0
  25. data/spec/spec_tests/data/index_management/listSearchIndexes.yml +85 -0
  26. data/spec/spec_tests/data/index_management/updateSearchIndex.yml +45 -0
  27. data/spec/spec_tests/index_management_unified_spec.rb +13 -0
  28. data/spec/support/faas/app/aws_lambda/mongodb/Gemfile.lock +19 -0
  29. data/spec/support/spec_config.rb +5 -0
  30. data.tar.gz.sig +0 -0
  31. metadata +1276 -1251
  32. metadata.gz.sig +0 -0
@@ -106,6 +106,31 @@ Mrss.patch_mongo_for_session_registry
106
106
 
107
107
  class ExampleTimeout < StandardError; end
108
108
 
109
+ STANDARD_TIMEOUTS = {
110
+ stress: 210,
111
+ jruby: 90,
112
+ default: 45,
113
+ }.freeze
114
+
115
+ def timeout_type
116
+ if ENV['EXAMPLE_TIMEOUT'].to_i > 0
117
+ :custom
118
+ elsif %w(1 true yes).include?(ENV['STRESS']&.downcase)
119
+ :stress
120
+ elsif BSON::Environment.jruby?
121
+ :jruby
122
+ else
123
+ :default
124
+ end
125
+ end
126
+
127
+ def example_timeout_seconds
128
+ STANDARD_TIMEOUTS.fetch(
129
+ timeout_type,
130
+ (ENV['EXAMPLE_TIMEOUT'] || STANDARD_TIMEOUTS[:default]).to_i
131
+ )
132
+ end
133
+
109
134
  RSpec.configure do |config|
110
135
  config.extend(CommonShortcuts::ClassMethods)
111
136
  config.include(CommonShortcuts::InstanceMethods)
@@ -123,6 +148,12 @@ RSpec.configure do |config|
123
148
  end
124
149
  end
125
150
 
151
+ def require_atlas
152
+ before do
153
+ skip 'Set ATLAS_URI in environment to run atlas tests' if ENV['ATLAS_URI'].nil?
154
+ end
155
+ end
156
+
126
157
  if SpecConfig.instance.ci?
127
158
  SdamFormatterIntegration.subscribe
128
159
  config.add_formatter(JsonExtFormatter, File.join(File.dirname(__FILE__), '../tmp/rspec.json'))
@@ -141,16 +172,7 @@ RSpec.configure do |config|
141
172
  # Tests should take under 10 seconds ideally but it seems
142
173
  # we have some that run for more than 10 seconds in CI.
143
174
  config.around(:each) do |example|
144
- timeout = if %w(1 true yes).include?(ENV['STRESS']&.downcase)
145
- 210
146
- else
147
- if BSON::Environment.jruby?
148
- 90
149
- else
150
- 45
151
- end
152
- end
153
- TimeoutInterrupt.timeout(timeout, ExampleTimeout) do
175
+ TimeoutInterrupt.timeout(example_timeout_seconds, ExampleTimeout) do
154
176
  example.run
155
177
  end
156
178
  end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unified
4
+ # The definitions of available search index operations, as used by the
5
+ # unified tests.
6
+ module SearchIndexOperations
7
+ def create_search_index(op)
8
+ collection = entities.get(:collection, op.use!('object'))
9
+
10
+ use_arguments(op) do |args|
11
+ model = args.use('model')
12
+ name = model.use('name')
13
+ definition = model.use('definition')
14
+ collection.search_indexes.create_one(definition, name: name)
15
+ end
16
+ end
17
+
18
+ def create_search_indexes(op)
19
+ collection = entities.get(:collection, op.use!('object'))
20
+
21
+ use_arguments(op) do |args|
22
+ models = args.use('models')
23
+ collection.search_indexes.create_many(models)
24
+ end
25
+ end
26
+
27
+ def drop_search_index(op)
28
+ collection = entities.get(:collection, op.use!('object'))
29
+
30
+ use_arguments(op) do |args|
31
+ collection.search_indexes.drop_one(
32
+ id: args.use('id'),
33
+ name: args.use('name')
34
+ )
35
+ end
36
+ end
37
+
38
+ def list_search_indexes(op)
39
+ collection = entities.get(:collection, op.use!('object'))
40
+
41
+ use_arguments(op) do |args|
42
+ agg_opts = args.use('aggregationOptions') || {}
43
+ collection.search_indexes(
44
+ id: args.use('id'),
45
+ name: args.use('name'),
46
+ aggregate: ::Utils.underscore_hash(agg_opts)
47
+ ).to_a
48
+ end
49
+ end
50
+
51
+ def update_search_index(op)
52
+ collection = entities.get(:collection, op.use!('object'))
53
+
54
+ use_arguments(op) do |args|
55
+ collection.search_indexes.update_one(
56
+ args.use('definition'),
57
+ id: args.use('id'),
58
+ name: args.use('name')
59
+ )
60
+ end
61
+ end
62
+ end
63
+ end
@@ -9,6 +9,7 @@ require 'runners/unified/ddl_operations'
9
9
  require 'runners/unified/change_stream_operations'
10
10
  require 'runners/unified/support_operations'
11
11
  require 'runners/unified/thread_operations'
12
+ require 'runners/unified/search_index_operations'
12
13
  require 'runners/unified/assertions'
13
14
  require 'support/utils'
14
15
  require 'support/crypt'
@@ -23,6 +24,7 @@ module Unified
23
24
  include ChangeStreamOperations
24
25
  include SupportOperations
25
26
  include ThreadOperations
27
+ include SearchIndexOperations
26
28
  include Assertions
27
29
  include RSpec::Core::Pending
28
30
 
@@ -120,7 +122,7 @@ module Unified
120
122
  # the other set members, in standalone deployments because
121
123
  # there is only one server, but changes behavior in
122
124
  # sharded clusters compared to how the test suite is configured.
123
- opts[:single_address] = true
125
+ options[:single_address] = true
124
126
  end
125
127
 
126
128
  if store_events = spec.use('storeEventsAsEntities')
data/spec/spec_helper.rb CHANGED
@@ -20,7 +20,7 @@ RSpec.configure do |config|
20
20
  config.extend(Constraints)
21
21
 
22
22
  config.before(:all) do
23
- if ClusterConfig.instance.fcv_ish >= '3.6' && !SpecConfig.instance.serverless? # Serverless instances do not support killAllSessions command.
23
+ if SpecConfig.instance.kill_all_server_sessions?
24
24
  kill_all_server_sessions
25
25
  end
26
26
  end
@@ -0,0 +1,62 @@
1
+ description: "createSearchIndex"
2
+ schemaVersion: "1.4"
3
+ createEntities:
4
+ - client:
5
+ id: &client0 client0
6
+ useMultipleMongoses: false
7
+ observeEvents:
8
+ - commandStartedEvent
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: *database0
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: *collection0
17
+
18
+ runOnRequirements:
19
+ - minServerVersion: "7.0.0"
20
+ topologies: [ replicaset, load-balanced, sharded ]
21
+ serverless: forbid
22
+
23
+ tests:
24
+ - description: "no name provided for an index definition"
25
+ operations:
26
+ - name: createSearchIndex
27
+ object: *collection0
28
+ arguments:
29
+ model: { definition: &definition { mappings: { dynamic: true } } }
30
+ expectError:
31
+ # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
32
+ # that the driver constructs and sends the correct command.
33
+ isError: true
34
+ errorContains: Search index commands are only supported with Atlas
35
+ expectEvents:
36
+ - client: *client0
37
+ events:
38
+ - commandStartedEvent:
39
+ command:
40
+ createSearchIndexes: *collection0
41
+ indexes: [ { definition: *definition } ]
42
+ $db: *database0
43
+
44
+ - description: "name provided for an index definition"
45
+ operations:
46
+ - name: createSearchIndex
47
+ object: *collection0
48
+ arguments:
49
+ model: { definition: &definition { mappings: { dynamic: true } } , name: 'test index' }
50
+ expectError:
51
+ # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
52
+ # that the driver constructs and sends the correct command.
53
+ isError: true
54
+ errorContains: Search index commands are only supported with Atlas
55
+ expectEvents:
56
+ - client: *client0
57
+ events:
58
+ - commandStartedEvent:
59
+ command:
60
+ createSearchIndexes: *collection0
61
+ indexes: [ { definition: *definition, name: 'test index' } ]
62
+ $db: *database0
@@ -0,0 +1,83 @@
1
+ description: "createSearchIndexes"
2
+ schemaVersion: "1.4"
3
+ createEntities:
4
+ - client:
5
+ id: &client0 client0
6
+ useMultipleMongoses: false
7
+ observeEvents:
8
+ - commandStartedEvent
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: *database0
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: *collection0
17
+
18
+ runOnRequirements:
19
+ - minServerVersion: "7.0.0"
20
+ topologies: [ replicaset, load-balanced, sharded ]
21
+ serverless: forbid
22
+
23
+ tests:
24
+ - description: "empty index definition array"
25
+ operations:
26
+ - name: createSearchIndexes
27
+ object: *collection0
28
+ arguments:
29
+ models: []
30
+ expectError:
31
+ # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
32
+ # that the driver constructs and sends the correct command.
33
+ isError: true
34
+ errorContains: Search index commands are only supported with Atlas
35
+ expectEvents:
36
+ - client: *client0
37
+ events:
38
+ - commandStartedEvent:
39
+ command:
40
+ createSearchIndexes: *collection0
41
+ indexes: []
42
+ $db: *database0
43
+
44
+
45
+ - description: "no name provided for an index definition"
46
+ operations:
47
+ - name: createSearchIndexes
48
+ object: *collection0
49
+ arguments:
50
+ models: [ { definition: &definition { mappings: { dynamic: true } } } ]
51
+ expectError:
52
+ # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
53
+ # that the driver constructs and sends the correct command.
54
+ isError: true
55
+ errorContains: Search index commands are only supported with Atlas
56
+ expectEvents:
57
+ - client: *client0
58
+ events:
59
+ - commandStartedEvent:
60
+ command:
61
+ createSearchIndexes: *collection0
62
+ indexes: [ { definition: *definition } ]
63
+ $db: *database0
64
+
65
+ - description: "name provided for an index definition"
66
+ operations:
67
+ - name: createSearchIndexes
68
+ object: *collection0
69
+ arguments:
70
+ models: [ { definition: &definition { mappings: { dynamic: true } } , name: 'test index' } ]
71
+ expectError:
72
+ # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
73
+ # that the driver constructs and sends the correct command.
74
+ isError: true
75
+ errorContains: Search index commands are only supported with Atlas
76
+ expectEvents:
77
+ - client: *client0
78
+ events:
79
+ - commandStartedEvent:
80
+ command:
81
+ createSearchIndexes: *collection0
82
+ indexes: [ { definition: *definition, name: 'test index' } ]
83
+ $db: *database0
@@ -0,0 +1,42 @@
1
+ description: "dropSearchIndex"
2
+ schemaVersion: "1.4"
3
+ createEntities:
4
+ - client:
5
+ id: &client0 client0
6
+ useMultipleMongoses: false
7
+ observeEvents:
8
+ - commandStartedEvent
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: *database0
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: *collection0
17
+
18
+ runOnRequirements:
19
+ - minServerVersion: "7.0.0"
20
+ topologies: [ replicaset, load-balanced, sharded ]
21
+ serverless: forbid
22
+
23
+ tests:
24
+ - description: "sends the correct command"
25
+ operations:
26
+ - name: dropSearchIndex
27
+ object: *collection0
28
+ arguments:
29
+ name: &indexName 'test index'
30
+ expectError:
31
+ # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
32
+ # that the driver constructs and sends the correct command.
33
+ isError: true
34
+ errorContains: Search index commands are only supported with Atlas
35
+ expectEvents:
36
+ - client: *client0
37
+ events:
38
+ - commandStartedEvent:
39
+ command:
40
+ dropSearchIndex: *collection0
41
+ name: *indexName
42
+ $db: *database0
@@ -0,0 +1,85 @@
1
+ description: "listSearchIndexes"
2
+ schemaVersion: "1.4"
3
+ createEntities:
4
+ - client:
5
+ id: &client0 client0
6
+ useMultipleMongoses: false
7
+ observeEvents:
8
+ - commandStartedEvent
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: *database0
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: *collection0
17
+
18
+ runOnRequirements:
19
+ - minServerVersion: "7.0.0"
20
+ topologies: [ replicaset, load-balanced, sharded ]
21
+ serverless: forbid
22
+
23
+ tests:
24
+ - description: "when no name is provided, it does not populate the filter"
25
+ operations:
26
+ - name: listSearchIndexes
27
+ object: *collection0
28
+ expectError:
29
+ # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
30
+ # that the driver constructs and sends the correct command.
31
+ isError: true
32
+ errorContains: Search index commands are only supported with Atlas
33
+ expectEvents:
34
+ - client: *client0
35
+ events:
36
+ - commandStartedEvent:
37
+ command:
38
+ aggregate: *collection0
39
+ pipeline:
40
+ - $listSearchIndexes: {}
41
+
42
+ - description: "when a name is provided, it is present in the filter"
43
+ operations:
44
+ - name: listSearchIndexes
45
+ object: *collection0
46
+ arguments:
47
+ name: &indexName "test index"
48
+ expectError:
49
+ # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
50
+ # that the driver constructs and sends the correct command.
51
+ isError: true
52
+ errorContains: Search index commands are only supported with Atlas
53
+ expectEvents:
54
+ - client: *client0
55
+ events:
56
+ - commandStartedEvent:
57
+ command:
58
+ aggregate: *collection0
59
+ pipeline:
60
+ - $listSearchIndexes: { name: *indexName }
61
+ $db: *database0
62
+
63
+ - description: aggregation cursor options are supported
64
+ operations:
65
+ - name: listSearchIndexes
66
+ object: *collection0
67
+ arguments:
68
+ name: &indexName "test index"
69
+ aggregationOptions:
70
+ batchSize: 10
71
+ expectError:
72
+ # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
73
+ # that the driver constructs and sends the correct command.
74
+ isError: true
75
+ errorContains: Search index commands are only supported with Atlas
76
+ expectEvents:
77
+ - client: *client0
78
+ events:
79
+ - commandStartedEvent:
80
+ command:
81
+ aggregate: *collection0
82
+ cursor: { batchSize: 10 }
83
+ pipeline:
84
+ - $listSearchIndexes: { name: *indexName }
85
+ $db: *database0
@@ -0,0 +1,45 @@
1
+ description: "updateSearchIndex"
2
+ schemaVersion: "1.4"
3
+ createEntities:
4
+ - client:
5
+ id: &client0 client0
6
+ useMultipleMongoses: false
7
+ observeEvents:
8
+ - commandStartedEvent
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: *database0
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: *collection0
17
+
18
+ runOnRequirements:
19
+ - minServerVersion: "7.0.0"
20
+ topologies: [ replicaset, load-balanced, sharded ]
21
+ serverless: forbid
22
+
23
+ tests:
24
+ - description: "sends the correct command"
25
+ operations:
26
+ - name: updateSearchIndex
27
+ object: *collection0
28
+ arguments:
29
+ name: &indexName 'test index'
30
+ definition: &definition {}
31
+ expectError:
32
+ # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
33
+ # that the driver constructs and sends the correct command.
34
+ isError: true
35
+ errorContains: Search index commands are only supported with Atlas
36
+ expectEvents:
37
+ - client: *client0
38
+ events:
39
+ - commandStartedEvent:
40
+ command:
41
+ updateSearchIndex: *collection0
42
+ name: *indexName
43
+ definition: *definition
44
+ $db: *database0
45
+
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'runners/unified'
5
+
6
+ base = "#{CURRENT_PATH}/spec_tests/data/index_management"
7
+ INDEX_MANAGEMENT_UNIFIED_TESTS = Dir.glob("#{base}/**/*.yml").sort
8
+
9
+ # rubocop:disable RSpec/EmptyExampleGroup
10
+ describe 'index management unified spec tests' do
11
+ define_unified_spec_tests(base, INDEX_MANAGEMENT_UNIFIED_TESTS)
12
+ end
13
+ # rubocop:enable RSpec/EmptyExampleGroup
@@ -0,0 +1,19 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ bson (4.15.0)
5
+ mongo (2.19.1)
6
+ bson (>= 4.14.1, < 5.0.0)
7
+
8
+ PLATFORMS
9
+ arm64-darwin-22
10
+ x86_64-linux
11
+
12
+ DEPENDENCIES
13
+ mongo
14
+
15
+ RUBY VERSION
16
+ ruby 3.2.2p53
17
+
18
+ BUNDLED WITH
19
+ 2.4.12
@@ -172,6 +172,11 @@ class SpecConfig
172
172
  !!ENV['SERVERLESS']
173
173
  end
174
174
 
175
+ def kill_all_server_sessions?
176
+ !serverless? && # Serverless instances do not support killAllSessions command.
177
+ ClusterConfig.instance.fcv_ish >= '3.6'
178
+ end
179
+
175
180
  # Test suite configuration
176
181
 
177
182
  def client_debug?
data.tar.gz.sig CHANGED
Binary file