Skip to content

Commit ae1dab2

Browse files
author
Emily Giurleo
authored
RUBY-2328: backport zlib compression integration test (#2025)
1 parent c709465 commit ae1dab2

File tree

6 files changed

+46
-23
lines changed

6 files changed

+46
-23
lines changed

.evergreen/config.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ functions:
8888
export WITH_ACTIVE_SUPPORT="${WITH_ACTIVE_SUPPORT}"
8989
export SINGLE_MONGOS="${SINGLE_MONGOS}"
9090
export MMAPV1="${MMAPV1}"
91+
export COMPRESSOR="${COMPRESSOR}"
9192
9293
export STRESS_SPEC=true
9394
EOT
@@ -574,7 +575,7 @@ axes:
574575
display_name: "2.6"
575576
variables:
576577
VERSION: "2.6"
577-
578+
578579
- id: fcv
579580
display_name: FCV
580581
values:
@@ -598,7 +599,7 @@ axes:
598599
display_name: Sharded
599600
variables:
600601
TOPOLOGY: "sharded_cluster"
601-
602+
602603
- id: "auth-and-ssl"
603604
display_name: Authentication and SSL
604605
values:
@@ -622,7 +623,7 @@ axes:
622623
variables:
623624
AUTH: "noauth"
624625
SSL: "nossl"
625-
626+
626627
- id: "ruby"
627628
display_name: Ruby Version
628629
# Local TLS tests run on all Ruby versions, thus no versions should be
@@ -656,7 +657,7 @@ axes:
656657
display_name: jruby-9.2
657658
variables:
658659
RVM_RUBY: "jruby-9.2"
659-
660+
660661
- id: "os"
661662
display_name: OS
662663
values:
@@ -669,47 +670,47 @@ axes:
669670
- id: rhel70
670671
display_name: "RHEL 7.0"
671672
run_on: rhel70-small
672-
673+
673674
- id: "compressor"
674675
display_name: Compressor
675676
values:
676677
- id: "zlib"
677678
display_name: Zlib
678679
variables:
679680
COMPRESSOR: "zlib"
680-
681+
681682
- id: retry-reads
682683
display_name: Retry Reads
683684
values:
684685
- id: no-retry-reads
685686
display_name: No Retry Reads
686687
variables:
687688
RETRY_READS: 'false'
688-
689+
689690
- id: retry-writes
690691
display_name: Retry Writes
691692
values:
692693
- id: no-retry-writes
693694
display_name: No Retry Writes
694695
variables:
695696
RETRY_WRITES: 'false'
696-
697+
697698
- id: lint
698699
display_name: Lint
699700
values:
700701
- id: on
701702
display_name: On
702703
variables:
703704
LINT: '1'
704-
705+
705706
- id: "as"
706707
display_name: ActiveSupport
707708
values:
708709
- id: "as"
709710
display_name: AS
710711
variables:
711712
WITH_ACTIVE_SUPPORT: true
712-
713+
713714
- id: bson
714715
display_name: BSON
715716
values:
@@ -721,15 +722,15 @@ axes:
721722
display_name: master
722723
variables:
723724
BSON: master
724-
725+
725726
- id: "single-mongos"
726727
display_name: Single Mongos
727728
values:
728729
- id: "single-mongos"
729730
display_name: Single Mongos
730731
variables:
731732
SINGLE_MONGOS: 'true'
732-
733+
733734
- id: storage-engine
734735
display_name: Storage Engine
735736
values:

.evergreen/functions.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ set_env_vars() {
7474
fi
7575

7676
export MONGODB_URI
77-
export COMPRESSOR
7877

7978
export CI=evergreen
8079

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require 'spec_helper'
2+
3+
describe 'Zlib compression' do
4+
require_compression
5+
6+
before do
7+
authorized_client['test'].drop
8+
end
9+
10+
context 'when client has zlib compressor option enabled' do
11+
it 'compresses the message to the server' do
12+
# Double check that the client has zlib compression enabled
13+
expect(authorized_client.options[:compressors]).to include('zlib')
14+
15+
expect(Mongo::Protocol::Compressed).to receive(:new).twice.and_call_original
16+
expect(Zlib::Deflate).to receive(:deflate).twice.and_call_original
17+
expect(Zlib::Inflate).to receive(:inflate).twice.and_call_original
18+
19+
authorized_client['test'].insert_one(_id: 1, text: 'hello world')
20+
document = authorized_client['test'].find(_id: 1).first
21+
22+
expect(document['text']).to eq('hello world')
23+
end
24+
end
25+
end

spec/mongo/auth/user/view_spec.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@
109109
min_server_fcv '3.6'
110110

111111
it 'does not compress the message' do
112-
# The dropUser command message will be compressed, so expect instantiation once.
113-
expect(Mongo::Protocol::Compressed).to receive(:new).once.and_call_original
112+
expect(Mongo::Protocol::Compressed).not_to receive(:new)
114113
expect(response).to be_successful
115114
end
116115
end
@@ -197,8 +196,7 @@
197196
min_server_fcv '3.6'
198197

199198
it 'does not compress the message' do
200-
# The dropUser command message will be compressed, so expect instantiation once.
201-
expect(Mongo::Protocol::Compressed).to receive(:new).once.and_call_original
199+
expect(Mongo::Protocol::Compressed).not_to receive(:new)
202200
expect(response).to be_successful
203201
end
204202
end
@@ -247,8 +245,7 @@
247245
min_server_fcv '3.6'
248246

249247
it 'does not compress the message' do
250-
# The dropUser command message will be compressed, so expect instantiation once.
251-
expect(Mongo::Protocol::Compressed).to receive(:new).once.and_call_original
248+
expect(Mongo::Protocol::Compressed).not_to receive(:new)
252249
expect(response).to be_successful
253250
end
254251
end

spec/mongo/client_construction_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@
235235
min_server_fcv '3.6'
236236

237237
it 'uses compression for messages' do
238-
expect(Mongo::Protocol::Compressed).to receive(:new).and_call_original
238+
# A Compressed object will be created for both the request and the response
239+
expect(Mongo::Protocol::Compressed).to receive(:new).twice.and_call_original
239240
client[TEST_COLL].find({}, limit: 1).first
240241
end
241242
end

spec/support/spec_config.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ def active_support?
133133

134134
# What compressor to use, if any.
135135
def compressors
136-
if ENV['COMPRESSORS']
137-
ENV['COMPRESSORS'].split(',')
138-
else
136+
if ENV['COMPRESSOR'].nil? || ENV['COMPRESSOR'].empty?
139137
nil
138+
else
139+
[ENV['COMPRESSOR']]
140140
end
141141
end
142142

0 commit comments

Comments
 (0)