private void EventPayloadIdReusedOnRetry() { _ep = MakeProcessor(_config); _server.Given(EventingRequest()) .InScenario("Payload ID Retry") .WillSetStateTo("Retry") .RespondWith(Response.Create().WithStatusCode(429)); _server.Given(EventingRequest()) .InScenario("Payload ID Retry") .WhenStateIs("Retry") .RespondWith(OkResponse()); Event e = EventFactory.Default.NewIdentifyEvent(_user); _ep.SendEvent(e); _ep.Flush(); // Necessary to ensure the retry occurs before the second request for test assertion ordering ((DefaultEventProcessor)_ep).WaitUntilInactive(); _ep.SendEvent(e); _ep.Flush(); ((DefaultEventProcessor)_ep).WaitUntilInactive(); var logEntries = _server.LogEntries.ToList(); string payloadId = logEntries[0].RequestMessage.Headers["X-LaunchDarkly-Payload-ID"][0]; string retryId = logEntries[1].RequestMessage.Headers["X-LaunchDarkly-Payload-ID"][0]; Assert.Equal(payloadId, retryId); payloadId = logEntries[2].RequestMessage.Headers["X-LaunchDarkly-Payload-ID"][0]; Assert.NotEqual(payloadId, retryId); }
private RequestMessage FlushAndGetRequest(IResponseBuilder resp) { PrepareResponse(resp); _ep.Flush(); ((DefaultEventProcessor)_ep).WaitUntilInactive(); return(GetLastRequest()); }
public void SendIsRetriedOnRecoverableFailure() { _ep = MakeProcessor(_config); _server.Given(EventingRequest()) .InScenario("Send Retry") .WillSetStateTo("Retry") .RespondWith(Response.Create().WithStatusCode(429)); _server.Given(EventingRequest()) .InScenario("Send Retry") .WhenStateIs("Retry") .RespondWith(OkResponse()); Event e = EventFactory.Default.NewIdentifyEvent(_user); _ep.SendEvent(e); _ep.Flush(); ((DefaultEventProcessor)_ep).WaitUntilInactive(); var logEntries = _server.LogEntries.ToList(); Assert.Equal( logEntries[0].RequestMessage.BodyAsJson, logEntries[1].RequestMessage.BodyAsJson); }
public void FlushDoesNothingIfThereAreNoEvents() { _ep = MakeProcessor(_config); _ep.Flush(); foreach (LogEntry le in _server.LogEntries) { Assert.True(false, "Should not have sent an HTTP request"); } }
private RequestMessage FlushAndGetRequest(IResponseBuilder resp, IEventProcessor ep = null) { if (ep is null) { ep = _ep; } PrepareResponse(resp); ep.Flush(); ((DefaultEventProcessor)ep).WaitUntilInactive(); return(GetLastRequest()); }
private void VerifyUnrecoverableHttpError(int status) { _ep = MakeProcessor(_config); Event e = EventFactory.Default.NewIdentifyEvent(_user); _ep.SendEvent(e); FlushAndGetEvents(Response.Create().WithStatusCode(status)); _server.ResetLogEntries(); _ep.SendEvent(e); _ep.Flush(); ((DefaultEventProcessor)_ep).WaitUntilInactive(); foreach (LogEntry le in _server.LogEntries) { Assert.True(false, "Should not have sent an HTTP request"); } }
// Note that Flush, IsOffline, and Version are defined in ILdCommonClient, not in ILdClient. In // the next major version, the base interface will go away and they will move to ILdClient. /// <inheritdoc/> public void Flush() { _eventProcessor.Flush(); }
/// <inheritdoc/> public void Flush() { eventProcessor.Flush(); // eventProcessor will ignore this if it is offline }