Example #1
0
 public TestSubscription(MiniClusterNode node, int expectedEvents, string streamId, CountdownEvent subscriptionsConfirmed)
 {
     Node = node;
     SubscriptionsConfirmed = subscriptionsConfirmed;
     EventAppeared          = new CountdownEvent(expectedEvents);
     StreamId = streamId;
 }
        private MiniClusterNode <TLogFormat, TStreamId> CreateNode(int index, Endpoints endpoints, EndPoint[] gossipSeeds)
        {
            _projections[index] = new ProjectionsSubsystem(new ProjectionSubsystemOptions(1, ProjectionType.All, false, TimeSpan.FromMinutes(Opts.ProjectionsQueryExpiryDefault), Opts.FaultOutOfOrderProjectionsDefault, 500, 250));
            var node = new MiniClusterNode <TLogFormat, TStreamId>(
                PathName, index, endpoints.InternalTcp,
                endpoints.ExternalTcp, endpoints.HttpEndPoint,
                subsystems: new ISubsystem[] { _projections[index] }, gossipSeeds: gossipSeeds);

            return(node);
        }
Example #3
0
 private MiniClusterNode CreateNode(int index, Endpoints endpoints, IPEndPoint[] gossipSeeds)
 {
     _projections = new ProjectionsSubsystem(1, runProjections: ProjectionType.All, startStandardProjections: false);
     var node = new MiniClusterNode(
         PathName, index, endpoints.InternalTcp, endpoints.InternalTcpSec, endpoints.InternalHttp, endpoints.ExternalTcp,
         endpoints.ExternalTcpSec, endpoints.ExternalHttp, skipInitializeStandardUsersCheck: false,
         subsystems: new ISubsystem[] { _projections }, gossipSeeds: gossipSeeds);
     WaitIdle();
     return node;
 }
        protected virtual MiniClusterNode CreateNode(int index, Endpoints endpoints, IPEndPoint[] gossipSeeds,
                                                     bool wait = true)
        {
            var node = new MiniClusterNode(
                PathName, index, endpoints.InternalTcp, endpoints.InternalTcpSec, endpoints.InternalHttp,
                endpoints.ExternalTcp,
                endpoints.ExternalTcpSec, endpoints.ExternalHttp, skipInitializeStandardUsersCheck: false,
                subsystems: new ISubsystem[] { }, gossipSeeds: gossipSeeds, inMemDb: false);

            return(node);
        }
Example #5
0
        private MiniClusterNode CreateNode(int index, Endpoints endpoints, IPEndPoint[] gossipSeeds)
        {
            _projections = new ProjectionsSubsystem(1, runProjections: ProjectionType.All,
                                                    startStandardProjections: false, projectionQueryExpiry: TimeSpan.FromMinutes(Opts.ProjectionsQueryExpiryDefault),
                                                    faultOutOfOrderProjections: Opts.FaultOutOfOrderProjectionsDefault);
            var node = new MiniClusterNode(
                PathName, index, endpoints.InternalTcp, endpoints.InternalTcpSec, endpoints.InternalHttp, endpoints.ExternalTcp,
                endpoints.ExternalTcpSec, endpoints.ExternalHttp, skipInitializeStandardUsersCheck: false,
                subsystems: new ISubsystem[] { _projections }, gossipSeeds: gossipSeeds);

            WaitIdle();
            return(node);
        }
Example #6
0
        private MiniClusterNode CreateNode(int index, Endpoints endpoints, EndPoint[] gossipSeeds)
        {
            _projections[index] = new ProjectionsSubsystem(1, runProjections: ProjectionType.All,
                                                           startStandardProjections: false,
                                                           projectionQueryExpiry: TimeSpan.FromMinutes(Opts.ProjectionsQueryExpiryDefault),
                                                           faultOutOfOrderProjections: Opts.FaultOutOfOrderProjectionsDefault);
            var node = new MiniClusterNode(
                PathName, index, endpoints.InternalTcp,
                endpoints.ExternalTcp, endpoints.HttpEndPoint,
                subsystems: new ISubsystem[] { _projections[index] }, gossipSeeds: gossipSeeds);

            return(node);
        }
        protected override MiniClusterNode CreateNode(int index, Endpoints endpoints, EndPoint[] gossipSeeds,
                                                      bool wait = true)
        {
            var isReadOnly = index == 2;
            var node       = new MiniClusterNode(
                PathName, index, endpoints.InternalTcp,
                endpoints.ExternalTcp, endpoints.HttpEndPoint, gossipSeeds, inMemDb: false,
                readOnlyReplica: isReadOnly);

            if (wait && !isReadOnly)
            {
                WaitIdle();
            }
            return(node);
        }
Example #8
0

        
        private async Task AddStreamAndWait(MiniClusterNode <TLogFormat, TStreamId> leader,
                                            MiniClusterNode <TLogFormat, TStreamId> follower, string streamName)
        {
            var leaderIndex = leader.Db.Config.IndexCheckpoint.Read();

            var response = await PostEvent(_followerEndPoint, $"streams/{streamName}", requireLeader : false);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);

            AssertEx.IsOrBecomesTrue(() => leader.Db.Config.IndexCheckpoint.Read() > leaderIndex,
                                     timeout: TimeSpan.FromSeconds(10),
                                     msg: "Waiting for event to be processed on leader timed out!");

            leaderIndex = leader.Db.Config.IndexCheckpoint.Read();
            AssertEx.IsOrBecomesTrue(() => follower.Db.Config.IndexCheckpoint.Read() >= leaderIndex,
                                     timeout: TimeSpan.FromSeconds(10),
                                     msg: $"Waiting for event to be synced with follower timed out! ({leaderIndex})");
        }
Example #10
0
        public static ClientMessage.WriteEventsCompleted WriteEvent(MiniClusterNode node, Event[] events, string streamId)
        {
            var resetEvent = new ManualResetEventSlim();

            ClientMessage.WriteEventsCompleted writeResult = null;
            node.Node.MainQueue.Publish(new ClientMessage.WriteEvents(Guid.NewGuid(), Guid.NewGuid(),
                                                                      new CallbackEnvelope(msg =>
            {
                writeResult = (ClientMessage.WriteEventsCompleted)msg;
                resetEvent.Set();
            }), false, streamId, -1, events,
                                                                      SystemAccount.Principal, SystemUsers.Admin, SystemUsers.DefaultAdminPassword));
            if (!resetEvent.Wait(_timeout))
            {
                Assert.Fail("Timed out waiting for event to be written");
                return(null);
            }
            return(writeResult);
        }
Example #11
0
        public static ClientMessage.ReadEventCompleted ReadEvent(MiniClusterNode node, string streamId, long eventNumber)
        {
            ClientMessage.ReadEventCompleted readResult = null;
            var resetEvent = new ManualResetEventSlim();
            var read       = new ClientMessage.ReadEvent(Guid.NewGuid(), Guid.NewGuid(), new CallbackEnvelope(msg =>
            {
                readResult = (ClientMessage.ReadEventCompleted)msg;
                resetEvent.Set();
            }), streamId, eventNumber,
                                                         false, false, SystemAccount.Principal);

            node.Node.MainQueue.Publish(read);

            if (!resetEvent.Wait(_timeout))
            {
                Assert.Fail("Timed out waiting for the event to be read");
                return(null);
            }
            return(readResult);
        }
        protected override async Task Given()
        {
            _expectedNumberOfRoleAssignments.Wait(5000);

            _liveNode = GetLeader();
            Assert.IsNotNull(_liveNode, "Could not get leader node");

            var events      = new Event[] { new Event(Guid.NewGuid(), "test-type", false, new byte[10], new byte[0]) };
            var writeResult = ReplicationTestHelper.WriteEvent(_liveNode, events, _streamId);

            Assert.AreEqual(OperationResult.Success, writeResult.Result);
            _commitPosition = writeResult.CommitPosition;

            var followers = GetFollowers();

            foreach (var s in followers)
            {
                await ShutdownNode(s.DebugIndex);
            }

            await base.Given();
        }
        public static ClientMessage.ReadStreamEventsBackwardCompleted ReadStreamEventsBackward <TLogFormat, TStreamId>(
            MiniClusterNode <TLogFormat, TStreamId> node,
            string streamId)
        {
            ClientMessage.ReadStreamEventsBackwardCompleted readResult = null;
            var resetEvent = new ManualResetEventSlim();
            var read       = new ClientMessage.ReadStreamEventsBackward(Guid.NewGuid(), Guid.NewGuid(), new CallbackEnvelope(
                                                                            msg => {
                readResult = (ClientMessage.ReadStreamEventsBackwardCompleted)msg;
                resetEvent.Set();
            }), streamId, 9, 10,
                                                                        false, false, null, SystemAccounts.System);

            node.Node.MainQueue.Publish(read);

            if (!resetEvent.Wait(_timeout))
            {
                Assert.Fail("Timed out waiting for the stream to be read backward");
                return(null);
            }

            return(readResult);
        }
        public static ClientMessage.ReadAllEventsBackwardCompleted ReadAllEventsBackward <TLogFormat, TStreamId>(
            MiniClusterNode <TLogFormat, TStreamId> node,
            long position)
        {
            ClientMessage.ReadAllEventsBackwardCompleted readResult = null;
            var resetEvent = new ManualResetEventSlim();
            var done       = false;

            while (!done)
            {
                resetEvent.Reset();
                var read = new ClientMessage.ReadAllEventsBackward(Guid.NewGuid(), Guid.NewGuid(), new CallbackEnvelope(
                                                                       msg => {
                    readResult = (ClientMessage.ReadAllEventsBackwardCompleted)msg;
                    resetEvent.Set();
                }),
                                                                   -1, -1, 100, false, false, null, SystemAccounts.System);
                node.Node.MainQueue.Publish(read);

                if (!resetEvent.Wait(_timeout))
                {
                    Assert.Fail("Timed out waiting for events to be read backward");
                    return(null);
                }

                if (readResult.Result == ReadAllResult.Error)
                {
                    Assert.Fail("Failed to read backwards. Read result error: {0}", readResult.Error);
                    return(null);
                }

                done = readResult.NextPos.CommitPosition < position;
            }

            return(readResult);
        }