Skip to content

Commit faed754

Browse files
committed
added test for streaming retry connect
1 parent a85b94c commit faed754

1 file changed

Lines changed: 35 additions & 3 deletions

File tree

spec/integrations/push_client_spec.rb

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,38 @@
8484
end
8585
end
8686

87+
it 'Retry streaming connection' do
88+
mock_splits_request(splits, -1)
89+
mock_splits_request(splits2, 1_585_948_850_109)
90+
mock_splits_request(splits3, 1_585_948_850_110)
91+
mock_segment_changes('segment3', segment3, '-1')
92+
93+
mock_server do |server|
94+
server.setup_response('/') do |_, res|
95+
send_content(res, event_split_kill_must_not_fetch, 500)
96+
end
97+
98+
stub_request(:get, auth_service_url + "?s=1.3").to_return(status: 200, body: auth_body_response)
99+
100+
streaming_service_url = server.base_uri
101+
factory = SplitIoClient::SplitFactory.new(
102+
'test_api_key',
103+
streaming_enabled: true,
104+
streaming_service_url: streaming_service_url,
105+
auth_service_url: auth_service_url
106+
)
107+
108+
client = factory.client
109+
client.block_until_ready(1)
110+
server.setup_response('/') do |_, res|
111+
send_content(res, event_split_update_must_fetch)
112+
end
113+
sleep(2)
114+
expect(client.get_treatment('admin', 'push_test')).to eq('after_fetch')
115+
client.destroy
116+
end
117+
end
118+
87119
it 'processing split update event without fetch' do
88120
mock_splits_request(splits, -1)
89121
mock_splits_request(splits2, 1_585_948_850_109)
@@ -587,14 +619,14 @@
587619
expect(client.get_treatment('admin', 'push_test')).to eq('after_fetch')
588620
client.destroy
589621
end
590-
end
622+
end
591623
end
592624

593625
private
594626

595-
def send_content(res, content)
627+
def send_content(res, content, status=200)
596628
res.content_type = 'text/event-stream'
597-
res.status = 200
629+
res.status = status
598630
res.chunked = true
599631
rd, wr = IO.pipe
600632
wr.write(content)

0 commit comments

Comments
 (0)