|
221 | 221 | end |
222 | 222 | end |
223 | 223 |
|
| 224 | + it 'client timeout and reconnect' do |
| 225 | + stub_request(:get, 'https://sdk.split.io/api/splitChanges?s=1.3&since=-1&rbSince=-1') |
| 226 | + .with(headers: { 'Authorization' => 'Bearer client-spec-key' }) |
| 227 | + .to_return(status: 200, body: '{"ff":{"d":[],"s":-1,"t":5564531221}, "rbs":{"d":[],"s":-1,"t":-1}}') |
| 228 | + stub_request(:get, 'https://sdk.split.io/api/splitChanges?s=1.3&since=5564531221&rbSince=-1') |
| 229 | + .with(headers: { 'Authorization' => 'Bearer client-spec-key' }) |
| 230 | + .to_return(status: 200, body: '{"ff":{"d":[],"s":5564531221,"t":5564531221}, "rbs":{"d":[],"s":-1,"t":-1}}') |
| 231 | + |
| 232 | + mock_server do |server| |
| 233 | + start_workers |
| 234 | + server.setup_response('/') do |_, res| |
| 235 | + send_stream_content(res, event_split_update) |
| 236 | + end |
| 237 | + |
| 238 | + sse_client = subject.new(config, api_token, telemetry_runtime_producer, event_parser, notification_manager_keeper, notification_processor, push_status_queue, read_timeout: 0.1) |
| 239 | + connected = sse_client.start(server.base_uri) |
| 240 | + sleep 1 |
| 241 | + expect(connected).to eq(true) |
| 242 | + expect(sse_client.connected?).to eq(true) |
| 243 | + expect(push_status_queue.pop(true)).to eq(SplitIoClient::Constants::PUSH_CONNECTED) |
| 244 | + sleep 3 |
| 245 | + expect(log.string).to include 'SSE read operation timed out, no data available' |
| 246 | + expect(sse_client.connected?).to eq(true) |
| 247 | + sse_client.close |
| 248 | + expect(sse_client.connected?).to eq(false) |
| 249 | + |
| 250 | + stop_workers |
| 251 | + end |
| 252 | + end |
| 253 | + |
224 | 254 | it 'first event - when server return 400' do |
225 | 255 | mock_server do |server| |
226 | 256 | server.setup_response('/') do |_, res| |
|
0 commit comments