Пример #1
0
        public FlowSelectSpec(ITestOutputHelper output) : base(output)
        {
            Sys.Settings.InjectTopLevelFallback(ActorMaterializer.DefaultConfig());
            _settings = ActorMaterializerSettings.Create(Sys)
                .WithInputBuffer(initialSize: 2, maxSize: 16);

            _materializer = Sys.Materializer(_settings);
        }
 public void Setup(BenchmarkContext context)
 {
     _actorSystem = ActorSystem.Create("MaterializationBenchmark",
         ConfigurationFactory.FromResource<AkkaSpec>("Akka.Streams.TestKit.Tests.reference.conf"));
     _actorSystem.Settings.InjectTopLevelFallback(ActorMaterializer.DefaultConfig());
     _materializerSettings =
         ActorMaterializerSettings.Create(_actorSystem).WithDispatcher("akka.test.stream-dispatcher");
     _materializer = _actorSystem.Materializer(_materializerSettings);
 }
Пример #3
0
        public void Setup(BenchmarkContext context)
        {
            _actorSystem = ActorSystem.Create("MergeManyBenchmark",
                ConfigurationFactory.FromResource<ScriptedTest>("Akka.Streams.TestKit.Tests.reference.conf"));
            _actorSystem.Settings.InjectTopLevelFallback(ActorMaterializer.DefaultConfig());
            _materializerSettings = ActorMaterializerSettings.Create(_actorSystem).WithDispatcher("akka.test.stream-dispatcher");
            _materializer = _actorSystem.Materializer(_materializerSettings);

            var takeSource = CreateSource(NumberOfElements);

            var singleSubSource = CreateSource(NumberOfElements);
            var singleSource = Source.Repeat(0).Take(1).MergeMany(1, _ => singleSubSource);

            var tenSubSources = CreateSource(NumberOfElements/10);
            var tenSources = Source.Repeat(0).Take(10).MergeMany(10, _ => tenSubSources);

            _takeGraph = ToSource(takeSource);
            _singleGraph = ToSource(singleSource);
            _tenGraph = ToSource(tenSources);
        }
Пример #4
0
        public FlowSelectErrorSpec()
        {
            var settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(1, 1);

            Materializer = Sys.Materializer(settings);
        }
Пример #5
0
 public FlowWhereSpec(ITestOutputHelper helper) : base(helper)
 {
     Settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 16);
     Materializer = ActorMaterializer.Create(Sys, Settings);
 }
Пример #6
0
 public FlowSelectManySpec(ITestOutputHelper output) : base(output)
 {
     settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(initialSize: 2, maxSize: 16);
     materializer = Sys.Materializer();
 }
Пример #7
0
 public FlowIdleInjectSpec(ITestOutputHelper helper) : base(helper)
 {
     Settings     = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 16);
     Materializer = ActorMaterializer.Create(Sys, Settings);
 }
Пример #8
0
        public BidiFlowSpec()
        {
            var settings = ActorMaterializerSettings.Create(Sys);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
        public SinkForeachParallelSpec(ITestOutputHelper helper) : base(helper)
        {
            var settings = ActorMaterializerSettings.Create(Sys);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
        public SubstreamSubscriptionTimeoutSpec(ITestOutputHelper helper) : base(Config, helper)
        {
            var settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 2);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
Пример #11
0
 public ChasingEventsSpec(ITestOutputHelper output = null) : base(output)
 {
     Materializer = Sys.Materializer(ActorMaterializerSettings.Create(Sys).WithFuzzingMode(false));
 }
Пример #12
0
 protected AkkaSubscriberWhiteboxVerification(TestEnvironment environment) : base(environment)
 {
     System = ActorSystem.Create(GetType().Name, AkkaSpec.AkkaSpecConfig);
     System.EventStream.Publish(new Mute(new ErrorFilter(typeof(Exception), new ContainsString("Test exception"))));
     Materializer = ActorMaterializer.Create(System, ActorMaterializerSettings.Create(System));
 }
Пример #13
0
 public static IBuffer <T> Create <T>(int size, ActorMaterializerSettings settings)
 => Create <T>(size, settings.MaxFixedBufferSize);
Пример #14
0
        public void GroupBy_must_work_with_random_demand()
        {
            this.AssertAllStagesStopped(() =>
            {
                var settings     = ActorMaterializerSettings.Create(Sys).WithInputBuffer(1, 1);
                var materializer = Sys.Materializer(settings);

                var props = new RandomDemandProperties
                {
                    Kit = this
                };
                Enumerable.Range(0, 100)
                .ToList()
                .ForEach(_ => props.Probes.Add(new TaskCompletionSource <TestSubscriber.Probe <ByteString> >()));

                var map = new Dictionary <int, SubFlowState>();

                var publisherProbe = this.CreateManualPublisherProbe <ByteString>();
                var probeShape     = new SinkShape <ByteString>(new Inlet <ByteString>("ProbeSink.in"));
                var probeSink      = new ProbeSink(probeShape, props, Attributes.None);
                Source.FromPublisher(publisherProbe)
                .GroupBy(100, element => Math.Abs(element[0] % 100))
                .To(new Sink <ByteString, TestSubscriber.Probe <ByteString> >(probeSink))
                .Run(materializer);

                var upstreamSubscription = publisherProbe.ExpectSubscription();

                for (var i = 1; i <= 400; i++)
                {
                    var byteString = RandomByteString(10);
                    var index      = Math.Abs(byteString[0] % 100);

                    upstreamSubscription.ExpectRequest();
                    upstreamSubscription.SendNext(byteString);

                    if (map.TryGetValue(index, out var state))
                    {
                        if (state.FirstElement != null) //first element in subFlow
                        {
                            if (!state.HasDemand)
                            {
                                props.BlockingNextElement = byteString;
                            }
                            RandomDemand(map, props);
                        }
                        else if (state.HasDemand)
                        {
                            if (props.BlockingNextElement == null)
                            {
                                state.Probe.ExpectNext().ShouldBeEquivalentTo(byteString);
                                map[index] = new SubFlowState(state.Probe, false, null);
                                RandomDemand(map, props);
                            }
                            else
                            {
                                true.ShouldBeFalse("INVALID CASE");
                            }
                        }
                        else
                        {
                            props.BlockingNextElement = byteString;
                            RandomDemand(map, props);
                        }
                    }
                    else
                    {
                        var probe = props.Probes[props.ProbesReaderTop].Task.AwaitResult();
                        props.ProbesReaderTop++;
                        map[index] = new SubFlowState(probe, false, byteString);
                        //stream automatically requests next element
                    }
                }
                upstreamSubscription.SendComplete();
            }, Materializer);
        }
Пример #15
0
        public FlowStatefulSelectManySpec()
        {
            var settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 16);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
        public FlowWatchTerminationSpec(ITestOutputHelper helper) : base(helper)
        {
            var settings = ActorMaterializerSettings.Create(Sys);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
Пример #17
0
        public FlowLimitWeightedSpec(ITestOutputHelper helper) : base(helper)
        {
            var settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 16);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
Пример #18
0
        public FlowSkipWhileSpec(ITestOutputHelper helper) : base(helper)
        {
            var settings = ActorMaterializerSettings.Create(Sys);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
Пример #19
0
        public FlowSlidingSpec()
        {
            var settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 16);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
Пример #20
0
 public FlowSelectManySpec(ITestOutputHelper output) : base(output)
 {
     Settings     = ActorMaterializerSettings.Create(Sys).WithInputBuffer(initialSize: 2, maxSize: 16);
     Materializer = Sys.Materializer();
 }
Пример #21
0
 public FlowGroupedSpec(ITestOutputHelper output = null) : base(output)
 {
     Settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 16);
 }
Пример #22
0
        public void Setup(BenchmarkContext context)
        {
            _system = ActorSystem.Create("Test");
            var settings =
                ActorMaterializerSettings.Create(_system)
                .WithFuzzingMode(false)
                .WithSyncProcessingLimit(int.MaxValue)
                .WithAutoFusing(false);     // We fuse manually in this test in the setup

            _materializer = _system.Materializer(settings);
            _testElements = Enumerable.Repeat(0, ElementCount).Select(i => new MutableElement(i)).ToArray();
            var testSource    = Source.FromGraph(new TestSource(_testElements));
            var testSink      = Sink.FromGraph(new CompletionLatch());
            var identityStage = new IdentityStage();

            _singleIdentity    = Fuse(testSource.Via(identityStage).ToMaterialized(testSink, Keep.Right));
            _chainOfIdentities =
                Fuse(
                    testSource.Via(identityStage)
                    .Via(identityStage)
                    .Via(identityStage)
                    .Via(identityStage)
                    .Via(identityStage)
                    .Via(identityStage)
                    .Via(identityStage)
                    .Via(identityStage)
                    .Via(identityStage)
                    .Via(identityStage)
                    .ToMaterialized(testSink, Keep.Right));

            _singleSelect = Fuse(testSource.Select(Add).ToMaterialized(testSink, Keep.Right));

            _chainOfSelects = Fuse(
                testSource.Select(Add)
                .Select(Add)
                .Select(Add)
                .Select(Add)
                .Select(Add)
                .Select(Add)
                .Select(Add)
                .Select(Add)
                .Select(Add)
                .Select(Add)
                .ToMaterialized(testSink, Keep.Right));

            _repeatTakeSelectAndAggregate =
                Fuse(Source.Repeat(new MutableElement(0))
                     .Take(ElementCount)
                     .Select(Add)
                     .Select(Add)
                     .Aggregate(new MutableElement(0), (acc, x) =>
            {
                acc.Value += x.Value;
                return(acc);
            }).ToMaterialized(testSink, Keep.Right));

            _singleBuffer =
                Fuse(testSource.Buffer(10, OverflowStrategy.Backpressure).ToMaterialized(testSink, Keep.Right));

            _chainOfBuffers =
                Fuse(
                    testSource.Buffer(10, OverflowStrategy.Backpressure)
                    .Buffer(10, OverflowStrategy.Backpressure)
                    .Buffer(10, OverflowStrategy.Backpressure)
                    .Buffer(10, OverflowStrategy.Backpressure)
                    .Buffer(10, OverflowStrategy.Backpressure)
                    .Buffer(10, OverflowStrategy.Backpressure)
                    .Buffer(10, OverflowStrategy.Backpressure)
                    .Buffer(10, OverflowStrategy.Backpressure)
                    .Buffer(10, OverflowStrategy.Backpressure)
                    .Buffer(10, OverflowStrategy.Backpressure)
                    .ToMaterialized(testSink, Keep.Right));

            var broadcastZipFLow = Flow.FromGraph(GraphDsl.Create(b =>
            {
                var bcast = b.Add(new Broadcast <MutableElement>(2));
                var zip   = b.Add(new Zip <MutableElement, MutableElement>());

                b.From(bcast).To(zip.In0);
                b.From(bcast).To(zip.In1);
                var outlet =
                    b.From(zip.Out).Via(Flow.Create <(MutableElement, MutableElement)>().Select(t => t.Item1));
                return(new FlowShape <MutableElement, MutableElement>(bcast.In, outlet.Out));
            }));

            var balanceMergeFlow = Flow.FromGraph(GraphDsl.Create(b =>
            {
                var balance = b.Add(new Balance <MutableElement>(2));
                var merge   = b.Add(new Merge <MutableElement>(2));

                b.From(balance).To(merge);
                b.From(balance).To(merge);

                return(new FlowShape <MutableElement, MutableElement>(balance.In, merge.Out));
            }));

            _broadcastZip = Fuse(testSource.Via(broadcastZipFLow).ToMaterialized(testSink, Keep.Right));

            _balanceMerge = Fuse(testSource.Via(balanceMergeFlow).ToMaterialized(testSink, Keep.Right));

            _broadcastZipBalanceMerge = Fuse(testSource.Via(broadcastZipFLow).Via(balanceMergeFlow).ToMaterialized(testSink, Keep.Right));
        }
Пример #23
0
        public FlowRecoverWithSpec(ITestOutputHelper helper) : base(helper)
        {
            var settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(1, 1);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
Пример #24
0
        public ReverseArrowSpec()
        {
            var settings = ActorMaterializerSettings.Create(Sys);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
Пример #25
0
        public GraphUnzipSpec(ITestOutputHelper helper) : base(helper)
        {
            var settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 16);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
Пример #26
0
        public FlowGroupBySpec(ITestOutputHelper helper) : base(helper)
        {
            var settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 2);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
Пример #27
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <typeparam name="T">TBD</typeparam>
 /// <param name="settings">TBD</param>
 /// <returns>TBD</returns>
 public static Props Props <T>(ActorMaterializerSettings settings)
 => Actor.Props.Create(() => new Unzip <T>(settings, 2)).WithDeploy(Deploy.Local);
Пример #28
0
        private IMaterializer CreateMaterializer(bool autoFusing)
        {
            var settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 16).WithAutoFusing(autoFusing);

            return(Sys.Materializer(settings));
        }
Пример #29
0
 public FlowSpec(ITestOutputHelper helper) : base(Config.WithFallback(ConfigurationFactory.FromResource <ScriptedTest>("Akka.Streams.TestKit.Tests.reference.conf")), helper)
 {
     Settings     = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 2);
     Materializer = ActorMaterializer.Create(Sys, Settings);
 }
Пример #30
0
 public FlowGroupedWithinSpec(ITestOutputHelper helper) : base(helper)
 {
     Settings     = ActorMaterializerSettings.Create(Sys);
     Materializer = ActorMaterializer.Create(Sys, Settings);
 }
Пример #31
0
        protected AbstractFlowIteratorSpec(ITestOutputHelper helper) : base(helper)
        {
            var settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 2);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
Пример #32
0
        public GraphDslCompileSpec(ITestOutputHelper helper) : base(helper)
        {
            var settings = ActorMaterializerSettings.Create(Sys);

            Materializer = ActorMaterializer.Create(Sys, settings);
        }
Пример #33
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="settings">TBD</param>
 /// <param name="haveShutdown">TBD</param>
 /// <returns>TBD</returns>
 public static Props Props(ActorMaterializerSettings settings, AtomicBoolean haveShutdown)
 => Actor.Props.Create(() => new StreamSupervisor(settings, haveShutdown)).WithDeploy(Deploy.Local);
Пример #34
0
 public FlowDispatcherSpec(ITestOutputHelper helper) : base("my-dispatcher = akka.test.stream-dispatcher", helper)
 {
     _defaultSettings = ActorMaterializerSettings.Create(Sys);
 }
Пример #35
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="settings">TBD</param>
 /// <param name="haveShutdown">TBD</param>
 public StreamSupervisor(ActorMaterializerSettings settings, AtomicBoolean haveShutdown)
 {
     Settings     = settings;
     HaveShutdown = haveShutdown;
 }
Пример #36
0
 public StreamLayoutSpec(ITestOutputHelper output) : base(output: output)
 {
     Sys.Settings.InjectTopLevelFallback(ActorMaterializer.DefaultConfig());
     _materializer = ActorMaterializer.Create(Sys, ActorMaterializerSettings.Create(Sys).WithAutoFusing(false));
 }
Пример #37
0
 public FlowGroupedSpec(ITestOutputHelper output = null) : base(output)
 {
     Settings = ActorMaterializerSettings.Create(Sys).WithInputBuffer(2, 16);
 }