mongo 2.2.6 → 2.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df545157946c4036f58eb215212390c7ee6468c2
4
- data.tar.gz: feef5fae4e44d03d423ab47d79f6b164f90d0a36
3
+ metadata.gz: 82e2963414b68a630d0784e70921c1d44775934e
4
+ data.tar.gz: db5398568a322af951e6b7ce3dfe7a22ddb8eb42
5
5
  SHA512:
6
- metadata.gz: 765b04848c2b7d821bc1dd1c9e23c56e95b1bdad9bdff7a332bcd2d96a3dff1bbe6c0227b751b07a459688107e0511d5ff0394fd09a266297b3c487f2a4b6bf3
7
- data.tar.gz: c45d06e8676ca91af22d72435e1fdea026dab940fb9e9b6f038b7ed5b0e5c6025e8b29a7aa5bb0cf5251ea1e59c90edcf95a8a5c60c69ac4e836736f6b57b402
6
+ metadata.gz: 108c89ec2a1e2849fc76a9d71b50307fd3fa6eca10389572a675d5065a700c0a48308e594f48cde6bb901f748387e0dae845ebd281afc6d96970024563cfb7a5
7
+ data.tar.gz: 47be1ace716e50c8020cc53599a9fd82e7c9f88ace2dfdd5d157a086f65002ae51d524a424e483795c9db6e7465a4ab04b79089315f140844f44d86f74a610e7
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,11 +1,26 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  $LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
4
- require 'pry'
5
- require 'mongo'
6
4
 
5
+ require 'mongo'
7
6
  # include the mongo namespace
8
7
  include Mongo
9
8
 
10
- Pry.config.prompt_name = 'mongo'
11
- Pry.start
9
+ begin
10
+ require 'pry'
11
+ rescue LoadError
12
+ end
13
+
14
+ begin
15
+ require 'irb'
16
+ rescue LoadError
17
+ end
18
+
19
+ if defined?(Pry)
20
+ Pry.config.prompt_name = 'mongo'
21
+ Pry.start
22
+ elsif defined?(IRB)
23
+ IRB.start
24
+ else
25
+ abort 'LoadError: mongo_console requires Pry or IRB'
26
+ end
@@ -86,8 +86,8 @@ module Mongo
86
86
 
87
87
  def ensure_connected
88
88
  ensure_same_process!
89
- connect!
90
89
  begin
90
+ connect!
91
91
  result = yield socket
92
92
  success = true
93
93
  result
@@ -63,9 +63,6 @@ module Mongo
63
63
  authenticate!
64
64
  end
65
65
  true
66
- rescue Mongo::Auth::Unauthorized => e
67
- disconnect!
68
- raise e
69
66
  end
70
67
 
71
68
  # Disconnect the connection.
@@ -17,5 +17,5 @@ module Mongo
17
17
  # The current version of the driver.
18
18
  #
19
19
  # @since 2.0.0
20
- VERSION = '2.2.6'.freeze
20
+ VERSION = '2.2.7'.freeze
21
21
  end
@@ -31,5 +31,4 @@ Gem::Specification.new do |s|
31
31
  s.bindir = 'bin'
32
32
 
33
33
  s.add_dependency 'bson', '~> 4.0'
34
- s.add_dependency 'pry'
35
34
  end
@@ -145,7 +145,7 @@ describe Mongo::Auth::User::View do
145
145
  described_class.new(unauthorized_client.database)
146
146
  end
147
147
 
148
- it 'raises an OperationFailure' do
148
+ it 'raises an OperationFailure', if: auth_enabled? do
149
149
  expect{
150
150
  view.info('emily')
151
151
  }.to raise_exception(Mongo::Error::OperationFailure)
@@ -322,7 +322,7 @@ describe Mongo::Database do
322
322
  end
323
323
  end
324
324
 
325
- describe '#fs' do
325
+ describe '#fs', unless: sharded? do
326
326
 
327
327
  let(:database) do
328
328
  described_class.new(authorized_client, TEST_DB)
@@ -340,21 +340,18 @@ describe Mongo::Database do
340
340
  Mongo::Grid::File.new('Hello!', :filename => 'test.txt')
341
341
  end
342
342
 
343
- before do
344
- fs.insert_one(file)
345
- end
346
-
347
343
  after do
348
344
  fs.files_collection.delete_many
349
345
  fs.chunks_collection.delete_many
350
346
  end
351
347
 
352
348
  let(:from_db) do
353
- fs.find_one(:filename => 'test.txt')
349
+ fs.insert_one(file)
350
+ fs.find({ filename: 'test.txt' }, limit: 1).first
354
351
  end
355
352
 
356
353
  it 'returns the assembled file from the db' do
357
- expect(from_db.filename).to eq(file.info.filename)
354
+ expect(from_db['filename']).to eq(file.info.filename)
358
355
  end
359
356
  end
360
357
  end
@@ -192,4 +192,32 @@ describe Mongo::Server::ConnectionPool do
192
192
  end
193
193
  end
194
194
  end
195
+
196
+ context 'when the connection does not finish authenticating before the thread is killed' do
197
+
198
+ let(:server) do
199
+ Mongo::Server.new(address, cluster, monitoring, listeners, options)
200
+ end
201
+
202
+ let!(:pool) do
203
+ described_class.get(server)
204
+ end
205
+
206
+ let(:options) do
207
+ { user: ROOT_USER.name, password: ROOT_USER.password }.merge(TEST_OPTIONS).merge(max_pool_size: 1)
208
+ end
209
+
210
+ before do
211
+ t = Thread.new {
212
+ # Kill the thread when it's authenticating
213
+ allow(Mongo::Auth).to receive(:get) { t.kill }
214
+ pool.with_connection { |c| c.send(:ensure_connected) { |socket| socket } }
215
+ }
216
+ t.join
217
+ end
218
+
219
+ it 'disconnects the socket' do
220
+ expect(pool.checkout.send(:socket)).to be_nil
221
+ end
222
+ end
195
223
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.6
4
+ version: 2.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -32,7 +32,7 @@ cert_chain:
32
32
  EhIn2f8suSc9QAqYt7w4T+PMtjxWTVcXs+Uy2PbDtjhtEBz6ZsP6YSsOpJbrCjCV
33
33
  wZtXjpRUvWz86V5vjhHCTE8fqfEb85aeDwUCckPzpio=
34
34
  -----END CERTIFICATE-----
35
- date: 2016-07-12 00:00:00.000000000 Z
35
+ date: 2016-07-25 00:00:00.000000000 Z
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bson
@@ -48,20 +48,6 @@ dependencies:
48
48
  - - "~>"
49
49
  - !ruby/object:Gem::Version
50
50
  version: '4.0'
51
- - !ruby/object:Gem::Dependency
52
- name: pry
53
- requirement: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: '0'
58
- type: :runtime
59
- prerelease: false
60
- version_requirements: !ruby/object:Gem::Requirement
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: '0'
65
51
  description: A Ruby driver for MongoDB
66
52
  email: mongodb-dev@googlegroups.com
67
53
  executables:
@@ -74,7 +60,6 @@ files:
74
60
  - README.md
75
61
  - Rakefile
76
62
  - bin/mongo_console
77
- - bin/test.rb
78
63
  - lib/csasl/csasl.bundle
79
64
  - lib/mongo.rb
80
65
  - lib/mongo/address.rb
@@ -567,11 +552,9 @@ files:
567
552
  - spec/support/server_selection/selection/Single/read/SecondaryPreferred.yml
568
553
  - spec/support/server_selection/selection/Unknown/read/SecondaryPreferred.yml
569
554
  - spec/support/server_selection_rtt.rb
570
- - spec/support/shared/cursor.rb
571
555
  - spec/support/shared/operation.rb
572
556
  - spec/support/shared/protocol.rb
573
557
  - spec/support/shared/server_selector.rb
574
- - spec/support/shared/socket.rb
575
558
  - spec/support/travis.rb
576
559
  homepage: http://www.mongodb.org
577
560
  licenses:
@@ -593,7 +576,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
593
576
  version: '0'
594
577
  requirements: []
595
578
  rubyforge_project:
596
- rubygems_version: 2.5.1
579
+ rubygems_version: 2.4.5.1
597
580
  signing_key:
598
581
  specification_version: 4
599
582
  summary: Ruby driver for MongoDB
@@ -855,10 +838,8 @@ test_files:
855
838
  - spec/support/server_selection/selection/Unknown/read/SecondaryPreferred.yml
856
839
  - spec/support/server_selection.rb
857
840
  - spec/support/server_selection_rtt.rb
858
- - spec/support/shared/cursor.rb
859
841
  - spec/support/shared/operation.rb
860
842
  - spec/support/shared/protocol.rb
861
843
  - spec/support/shared/server_selector.rb
862
- - spec/support/shared/socket.rb
863
844
  - spec/support/travis.rb
864
845
  has_rdoc: yard
metadata.gz.sig CHANGED
Binary file
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
4
- require 'pry'
5
- require 'mongo'
6
-
7
- # include the mongo namespace
8
- include Mongo
9
-
10
- #gem 'mongo', '2.2.4' # this version raises "Cursor not found"
11
- # gem 'mongo', '2.1.2' # this version works
12
-
13
- #require 'uri'
14
- #require 'mongo'
15
-
16
- #binding.pry
17
- puts "-" * 50
18
- puts "Mongo Driver version: #{Mongo::VERSION}"
19
- puts "-" * 50
20
-
21
- uri = "mongodb://emily:qWQ6wfYfM5v7FGFf@aws-us-east-1-portal.14.dblayer.com:11118,aws-us-east-1-portal.13.dblayer.com:11141/tests?ssl=true"
22
- #uri = "mongodb://localhost:2323,localhost:2324"
23
- c = Mongo::Client.new(uri, ssl: true, ssl_verify: false, max_pool_size: 10)
24
- #c = Mongo::Client.new(uri)
25
-
26
- # c = Mongo::Client.new(["server:3000", "server:3001", "server:3002"],
27
- # :ssl => true,
28
- # :ssl_cert => "/Users/emily/ssl-certificates/client.pem",
29
- # :ssl_key => "/Users/emily/ssl-certificates/client.pem",
30
- # :ssl_ca_cert => "/Users/emily/ssl-certificates/ca.pem",
31
- # :max_pool_size => 20)
32
-
33
- binding.pry
34
-
35
- c['samplecol'].drop
36
- c['samplecol'].insert_many(50.times.map { |i| { someval: i } })
37
-
38
- 10.times.map { Thread.start { c['samplecol'].find({}).batch_size(10).to_a } }.map(&:join)
39
-
@@ -1,38 +0,0 @@
1
- shared_context 'shared cursor' do
2
-
3
- let(:client) do
4
- double('client').tap do |client|
5
- allow(client).to receive(:mongos?).and_return(false)
6
- allow(client).to receive(:execute).and_return(*get_mores)
7
- end
8
- end
9
-
10
- let(:db) { Mongo::Database.new(client, TEST_DB) }
11
- let(:collection) do
12
- db[TEST_COLL].tap do |collection|
13
- allow(collection).to receive(:full_namespace) do
14
- "#{db.name}.#{collection.name}"
15
- end
16
- allow(collection).to receive(:client) { client }
17
- end
18
- end
19
-
20
- let(:view_options) { {} }
21
- let(:view) { Mongo::View::Collection.new(collection, {}, view_options) }
22
-
23
- let(:nonzero) { 1 }
24
- let(:b) { proc { |d| d } }
25
-
26
- let(:response) { make_response(1, 3) }
27
-
28
- def make_response(cursor_id = 0, nreturned = 5)
29
- double('response').tap do |response|
30
- allow(response).to receive(:documents) { (0...nreturned).to_a }
31
- allow(response).to receive(:cursor_id) { cursor_id }
32
- end
33
- end
34
-
35
- def get_mores
36
- [ make_response ]
37
- end
38
- end
@@ -1,82 +0,0 @@
1
- shared_examples 'shared socket behavior' do
2
-
3
- describe '#read' do
4
- before { allow(socket).to receive(:read).and_return(Object.new) }
5
-
6
- context 'when an exception occurs in Socket#read' do
7
- before do
8
- allow(object).to receive(:alive?).and_return(true)
9
- object.connect
10
- end
11
-
12
- it 'raises a Mongo::SocketTimeoutError for Errno::ETIMEDOUT' do
13
- allow_any_instance_of(::Socket).to receive(:read) do
14
- raise Errno::ETIMEDOUT
15
- end
16
- expect { object.read(4096) }.to raise_error(Mongo::SocketTimeoutError)
17
- end
18
-
19
- it 'raises a Mongo::SocketError for IOError' do
20
- allow_any_instance_of(::Socket).to receive(:read) { raise IOError }
21
- expect { object.read(4096) }.to raise_error(Mongo::SocketError)
22
- end
23
-
24
- it 'raises a Mongo::SocketError for SystemCallError' do
25
- allow_any_instance_of(::Socket).to receive(:read) do
26
- raise SystemCallError, 'Oh god. Everything is ruined.'
27
- end
28
- expect { object.read(4096) }.to raise_error(Mongo::SocketError)
29
- end
30
-
31
- it 'raises a Mongo::SocketError for OpenSSL::SSL::SSLError' do
32
- allow_any_instance_of(::Socket).to receive(:read) do
33
- raise OpenSSL::SSL::SSLError
34
- end
35
- expect { object.read(4096) }.to raise_error(Mongo::SocketError)
36
- end
37
- end
38
- end
39
-
40
- describe '#write' do
41
- let(:payload) { Object.new }
42
-
43
- before { allow(socket).to receive(:write).and_return(1024) }
44
-
45
- context 'when an exception occurs in Socket#write' do
46
- before do
47
- allow(object).to receive(:alive?).and_return(true)
48
- object.connect
49
- end
50
-
51
- it 'raises a Mongo::SocketTimeoutError for Errno::ETIMEDOUT' do
52
- allow_any_instance_of(::Socket).to receive(:write) do
53
- raise Errno::ETIMEDOUT
54
- end
55
-
56
- expect do
57
- object.write(payload)
58
- end.to raise_error(Mongo::SocketTimeoutError)
59
- end
60
-
61
- it 'raises a Mongo::SocketError for IOError' do
62
- allow_any_instance_of(::Socket).to receive(:write) { raise IOError }
63
- expect { object.write(payload) }.to raise_error(Mongo::SocketError)
64
- end
65
-
66
- it 'raises a Mongo::SocketError for SystemCallError' do
67
- allow_any_instance_of(::Socket).to receive(:write) do
68
- raise SystemCallError, 'Oh god. Everything is ruined.'
69
- end
70
- expect { object.write(payload) }.to raise_error(Mongo::SocketError)
71
- end
72
-
73
- it 'raises a Mongo::SocketError for OpenSSL::SSL::SSLError' do
74
- allow_any_instance_of(::Socket).to receive(:write) do
75
- raise OpenSSL::SSL::SSLError
76
- end
77
- expect { object.write(payload) }.to raise_error(Mongo::SocketError)
78
- end
79
- end
80
- end
81
-
82
- end