/// <summary> /// Have to hide other method otherwise we get an NRE due to base class /// constructor being called first. /// </summary> protected new void AtStartup() { MuteSystem(Sys); _remoteSystem.EventStream.Publish(EventFilter.Error(start: "AssociationError").Mute()); // OversizedPayloadException inherits from EndpointException, so have to mute it for now //_remoteSystem.EventStream.Publish(EventFilter.Exception<EndpointException>().Mute()); }
public void GivenProcessDoesNotExist_WhenDomainEvent_ShouldLogError() { var evnt = Substitute.For <DomainEvent>(processId); EventFilter.Error($"Could not delagate event to process with Id: {processId}.") .ExpectOne(() => manager.Tell(evnt)); }
public void GivenProcessExists_WhenStartProcessCommand_ShouldLogError() { manager.Tell(new StartProcessCommand(processId)); EventFilter.Error($"Process exists with Id: {processId}.") .ExpectOne(() => manager.Tell(new StartProcessCommand(processId))); }
public void LoggingActor_should_log_no_errors_on_valid_operation() { // we expect zero error messages EventFilter.Error().Expect(0, () => { _logger.Tell(new ValidData()); }); }
protected void MuteMarkingAsUnreachable(ActorSystem system = null) { var sys = system ?? Sys; if (!sys.Log.IsDebugEnabled) { EventFilter.Error(new Regex(".*Marking.* as UNREACHABLE.*")).Mute(); } }
public void LoggingActor_should_log_error_on_invalid_operation() { // we expect one error message, but we're not specifying // the content of the error message we expect (just that one happens) EventFilter.Error("Could not complete operation! Data is invalid.").ExpectOne(() => { _logger.Tell(new InvalidData()); }); }
public void OrderProcessorActor_logs_warning_about_bad_charge() { var message = new PlaceOrder(12345, 10, 25, -5000); var orderProcessorActor = ActorOfAsTestActorRef( () => new OrderProcessorActor(), TestActor); EventFilter.Error("Error! Account not charged!") .ExpectOne(() => orderProcessorActor.Tell(message)); }
public void Expect_0_events_Should_work() { this.Invoking(_ => { EventFilter.Error().Expect(0, () => { Log.Error("something"); }); }).Should().Throw <Exception>("Expected 0 events"); }
public void Should_not_crash_if_ReadinessSubscriber_dies() { var tempActor = Sys.ActorOf(act => act.ReceiveAny((_, ctx) => TestActor.Forward(_))); Watch(tempActor); ReadinessProbe.Tell(new SubscribeToReadiness(tempActor)); ExpectMsg <ReadinessStatus>().IsReady.Should().BeTrue(); EventFilter.Error().Expect(0, () => { Sys.Stop(tempActor); ExpectTerminated(tempActor); }); }
public void GraphInterpreter_should_handle_failure_in_PostStop() { lastEvents().Should().Equal(new PreStart(stage.Value)); upstream.Complete(); downstream.Cancel(); failOnPostStop(); EventFilter.Error("Error during PostStop in [stage]").ExpectOne(() => { stepAll(); lastEvents().Should().BeEmpty(); }); }
public void FSMActor_must_log_termination() { var actorRef = Sys.ActorOf(Props.Create(() => new ActorLogTermination())); var name = actorRef.Path.ToStringWithUid(); EventFilter.Error("Next state 2 does not exist").ExpectOne(() => { Sys.EventStream.Subscribe(TestActor, typeof(Error)); actorRef.Tell("go"); var error = ExpectMsg <Error>(1.Seconds()); error.LogSource.Should().Contain(name); error.Message.Should().Be("Next state 2 does not exist"); Sys.EventStream.Unsubscribe(TestActor); }); }
public void ReplayFilter_in_Fail_mode_should_fail_when_message_with_same_SequenceNo_from_old_overlapping_writer() { var filter = Sys.ActorOf(ReplayFilter.Props(TestActor, ReplayFilterMode.Fail, 100, 10, false)); EventFilter.Error(start: "Invalid replayed event").ExpectOne(() => { filter.Tell(_m1); filter.Tell(_m2); filter.Tell(_m3); var m3B = new ReplayedMessage(WithWriter(_m3.Persistent, WriterB)); filter.Tell(m3B); // same as SequenceNo as m3, but from WriterB filter.Tell(_successMsg); ExpectMsg <ReplayMessagesFailure>(m => m.Cause is IllegalStateException); }); }
public void MergeHub_must_keep_working_even_if_one_of_the_producers_fail() { this.AssertAllStagesStopped(() => { var t = MergeHub.Source <int>(16).Take(10).ToMaterialized(Sink.Seq <int>(), Keep.Both).Run(Materializer); var sink = t.Item1; var result = t.Item2; EventFilter.Error(contains: "Upstream producer failed with exception").ExpectOne(() => { Source.Failed <int>(new TestException("failing")).RunWith(sink, Materializer); Source.From(Enumerable.Range(1, 10)).RunWith(sink, Materializer); }); result.AwaitResult().ShouldAllBeEquivalentTo(Enumerable.Range(1, 10)); }, Materializer); }
public async Task ExpectAsync_0_events_Should_work() { Exception ex = null; try { await EventFilter.Error().ExpectAsync(0, async() => { await Task.Delay(100); // bug only happens when error is not logged instantly Log.Error("something"); }); } catch (Exception e) { ex = e; } ex.Should().NotBeNull("Expected 0 errors logged, but there are error logs"); }
public void When_sending_Close_to_TcpManager_Should_log_detailed_error_message() { new TestSetup(this).Run(x => { // Setup multiple clients var actors = x.EstablishNewClientConnection(); // Error message should contain invalid message type EventFilter.Error(contains: nameof(Tcp.Close)).ExpectOne(() => { // Sending `Tcp.Close` to TcpManager instead of outgoing connection Sys.Tcp().Tell(Tcp.Close.Instance, actors.ClientHandler); }); // Should also contain ref to documentation EventFilter.Error(contains: "https://getakka.net/articles/networking/io.html").ExpectOne(() => { // Sending `Tcp.Close` to TcpManager instead of outgoing connection Sys.Tcp().Tell(Tcp.Close.Instance, actors.ClientHandler); }); }); }
public void MemorySnapshotStore_is_threadsafe() { EventFilter.Error().Expect(0, () => { // get a few persistent actors going in parallel var sa1 = Sys.ActorOf(Props.Create(() => new SnapshotActor("sa1", TestActor))); var sa2 = Sys.ActorOf(Props.Create(() => new SnapshotActor("sa2", TestActor))); var sa3 = Sys.ActorOf(Props.Create(() => new SnapshotActor("sa3", TestActor))); Watch(sa1); Watch(sa2); Watch(sa3); var writeCount = 3000; var sas = new List <IActorRef> { sa1, sa2, sa3 }; // hammer with write requests Parallel.ForEach(Enumerable.Range(0, writeCount), i => { sas[ThreadLocalRandom.Current.Next(0, 3)].Tell(i); }); // spawn more persistence actors while writes are still going(?) var sa4 = Sys.ActorOf(Props.Create(() => new SnapshotActor("sa4", TestActor))); var sa5 = Sys.ActorOf(Props.Create(() => new SnapshotActor("sa5", TestActor))); var sa6 = Sys.ActorOf(Props.Create(() => new SnapshotActor("sa6", TestActor))); ReceiveN(writeCount).All(x => x is SaveSnapshotSuccess).Should().BeTrue("Expected all snapshot store saves to be successful, but some were not"); // kill the existing snapshot stores, then re-create them to force recovery while the new snapshot actors // are still being written to. sa1.Tell(PoisonPill.Instance); ExpectTerminated(sa1); sa2.Tell(PoisonPill.Instance); ExpectTerminated(sa2); sa3.Tell(PoisonPill.Instance); ExpectTerminated(sa3); var sas2 = new List <IActorRef> { sa4, sa5, sa6 }; // hammer with write requests Parallel.ForEach(Enumerable.Range(0, writeCount), i => { sas2[ThreadLocalRandom.Current.Next(0, 3)].Tell(i); }); // recreate the previous entities var sa12 = Sys.ActorOf(Props.Create(() => new SnapshotActor("sa1", TestActor))); var sa22 = Sys.ActorOf(Props.Create(() => new SnapshotActor("sa2", TestActor))); var sa32 = Sys.ActorOf(Props.Create(() => new SnapshotActor("sa3", TestActor))); var sas12 = new List <IActorRef> { sa12, sa22, sa32 }; // hammer other entities Parallel.ForEach(Enumerable.Range(0, writeCount), i => { sas12[ThreadLocalRandom.Current.Next(0, 3)].Tell(i); }); ReceiveN(writeCount * 2).All(x => x is SaveSnapshotSuccess).Should().BeTrue("Expected all snapshot store saves to be successful, but some were not"); }); }
private void MuteSystem(ActorSystem system) { system.EventStream.Publish(EventFilter.Error(start: "AssociationError").Mute()); system.EventStream.Publish(EventFilter.Warning(start: "AssociationError").Mute()); system.EventStream.Publish(EventFilter.Warning(contains: "dead letter").Mute()); }