mongo 2.13.0.rc1 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.
metadata.gz.sig CHANGED
Binary file
@@ -1,98 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'BSON & command size limits' do
4
- let(:max_document_size) { 16*1024*1024 }
5
-
6
- before do
7
- authorized_collection.delete_many
8
- end
9
-
10
- # This test uses a large document that is significantly smaller than the
11
- # size limit. It is a basic sanity check.
12
- it 'allows user-provided documents to be 15MiB' do
13
- document = { key: 'a' * 15*1024*1024, _id: 'foo' }
14
-
15
- authorized_collection.insert_one(document)
16
- end
17
-
18
- # This test uses a large document that is significantly larger than the
19
- # size limit. It is a basic sanity check.
20
- it 'fails single write of oversized documents' do
21
- document = { key: 'a' * 17*1024*1024, _id: 'foo' }
22
-
23
- lambda do
24
- authorized_collection.insert_one(document)
25
- end.should raise_error(Mongo::Error::MaxBSONSize, /The document exceeds maximum allowed BSON object size after serialization/)
26
- end
27
-
28
- # This test checks our bulk write splitting when documents are not close
29
- # to the limit, but where splitting is definitely required.
30
- it 'allows split bulk write of medium sized documents' do
31
- # 8 documents of 4 MiB each = 32 MiB total data, should be split over
32
- # either 2 or 3 bulk writes depending on how well the driver splits
33
- documents = []
34
- 1.upto(8) do |index|
35
- documents << { key: 'a' * 4*1024*1024, _id: "in#{index}" }
36
- end
37
-
38
- authorized_collection.insert_many(documents)
39
- authorized_collection.count_documents({}).should == 8
40
- end
41
-
42
- # This test ensures that document which are too big definitely fail insertion.
43
- it 'fails bulk write of oversized documents' do
44
- documents = []
45
- 1.upto(3) do |index|
46
- documents << { key: 'a' * 17*1024*1024, _id: "in#{index}" }
47
- end
48
-
49
- lambda do
50
- authorized_collection.insert_many(documents)
51
- end.should raise_error(Mongo::Error::MaxBSONSize, /The document exceeds maximum allowed BSON object size after serialization/)
52
- authorized_collection.count_documents({}).should == 0
53
- end
54
-
55
- it 'allows user-provided documents to be exactly 16MiB' do
56
- # The document must contain the _id field, otherwise the server will
57
- # add it which will increase the size of the document as persisted by
58
- # the server.
59
- document = { key: 'a' * (max_document_size - 28), _id: 'foo' }
60
- expect(document.to_bson.length).to eq(max_document_size)
61
-
62
- authorized_collection.insert_one(document)
63
- end
64
-
65
- it 'fails on the server when a document larger than 16MiB is inserted' do
66
- document = { key: 'a' * (max_document_size - 27), _id: 'foo' }
67
- expect(document.to_bson.length).to eq(max_document_size+1)
68
-
69
- lambda do
70
- authorized_collection.insert_one(document)
71
- end.should raise_error(Mongo::Error::OperationFailure, /object to insert too large/)
72
- end
73
-
74
- it 'fails in the driver when a document larger than 16MiB+16KiB is inserted' do
75
- document = { key: 'a' * (max_document_size - 27 + 16*1024), _id: 'foo' }
76
- expect(document.to_bson.length).to eq(max_document_size+16*1024+1)
77
-
78
- lambda do
79
- authorized_collection.insert_one(document)
80
- end.should raise_error(Mongo::Error::MaxBSONSize, /The document exceeds maximum allowed BSON object size after serialization/)
81
- end
82
-
83
- it 'allows bulk writes of multiple documents of exactly 16 MiB each' do
84
- if SpecConfig.instance.compressors
85
- pending "RUBY-2234"
86
- end
87
-
88
- documents = []
89
- 1.upto(3) do |index|
90
- document = { key: 'a' * (max_document_size - 28), _id: "in#{index}" }
91
- expect(document.to_bson.length).to eq(max_document_size)
92
- documents << document
93
- end
94
-
95
- authorized_collection.insert_many(documents)
96
- authorized_collection.count_documents({}).should == 3
97
- end
98
- end