public void read_all_forward_returns_all_events()
        {
            var events = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100).Records.Select(r => r.Event).ToArray();

            Assert.AreEqual(2, events.Length);
            Assert.AreEqual(_event0, events[0]);
            Assert.AreEqual(_event1, events[1]);
        }
Esempio n. 2
0
        public void read_all_forward_does_not_return_scavenged_deleted_stream_events_and_return_remaining()
        {
            var events = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100).Records.Select(r => r.Event).ToArray();

            Assert.AreEqual(2, events.Length);
            Assert.AreEqual(_event7, events[0]);
            Assert.AreEqual(_event9, events[1]);
        }
        public void read_all_events_forward_returns_all_events_in_correct_order()
        {
            var records = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 10).Records;

            Assert.AreEqual(2, records.Count);
            Assert.AreEqual(_id1, records[0].Event.EventId);
            Assert.AreEqual(_id2, records[1].Event.EventId);
        }
        public void read_all_forward_from_beginning_of_second_chunk_with_max_1_record_returns_5th_record()
        {
            var events = ReadIndex.ReadAllEventsForward(new TFPos(10000, 10000), 1).EventRecords()
                         .Select(r => r.Event)
                         .ToArray();

            Assert.AreEqual(1, events.Length);
            Assert.AreEqual(_event3, events[0]);
        }
        public void read_all_events_forward_returns_all_events_in_correct_order()
        {
            var records = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 10, false).Records;

            Assert.AreEqual(3, records.Count);
            Assert.AreEqual(_p1, records[0].Event);
            Assert.AreEqual(_p2, records[1].Event);
            Assert.AreEqual(_p3, records[2].Event);
        }
        public void return_all_events_on_read_all_forward()
        {
            var events = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100).Records.Select(r => r.Event).ToArray();

            Assert.AreEqual(3, events.Length);
            Assert.AreEqual(_prepare1, events[0]);
            Assert.AreEqual(_delete1, events[1]);
            Assert.AreEqual(_prepare2, events[2]);
        }
        public void read_all_forward_returns_events_only_from_uncompleted_chunk_and_delete_record()
        {
            var events = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100).Records.Select(r => r.Event).ToArray();

            Assert.AreEqual(3, events.Length);
            Assert.AreEqual(_event3, events[0]);
            Assert.AreEqual(_event4, events[1]);
            Assert.AreEqual(_delete, events[2]);
        }
        public void the_metastream_is_absent_physically()
        {
            var headOfTf = new TFPos(Db.Config.WriterCheckpoint.Read(), Db.Config.WriterCheckpoint.Read());

            Assert.IsEmpty(ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 1000).Records
                           .Where(x => x.Event.EventStreamId == _deletedMetaStream));
            Assert.IsEmpty(ReadIndex.ReadAllEventsBackward(headOfTf, 1000).Records
                           .Where(x => x.Event.EventStreamId == _deletedMetaStream));
        }
Esempio n. 9
0
        public void read_all_forward_should_return_all_stream_records_except_uncommited()
        {
            var events = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100).EventRecords()
                         .Select(r => r.Event)
                         .ToArray();

            Assert.AreEqual(1, events.Length);
            Assert.AreEqual(_deleteTombstone, events[0]);
        }
        read_all_forward_from_beginning_of_2nd_chunk_with_max_2_record_returns_delete_record_and_record_from_3rd_chunk()
        {
            var events = ReadIndex.ReadAllEventsForward(new TFPos(10000, 10000), 2).Records.Select(r => r.Event)
                         .ToArray();

            Assert.AreEqual(2, events.Length);
            Assert.AreEqual(_event7, events[0]);
            Assert.AreEqual(_event9, events[1]);
        }
        public void read_all_forward_with_max_5_records_returns_3_records_from_second_chunk_and_delete_record()
        {
            var events = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 5).Records.Select(r => r.Event).ToArray();

            Assert.AreEqual(3, events.Length);
            Assert.AreEqual(_event3, events[0]);
            Assert.AreEqual(_event4, events[1]);
            Assert.AreEqual(_delete, events[2]);
        }
        public void read_all_forward_doesnt_return_expired_records()
        {
            var records = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100).Records;

            Assert.AreEqual(3, records.Count);
            Assert.AreEqual(_r1, records[0].Event);
            Assert.AreEqual(_r5, records[1].Event);
            Assert.AreEqual(_r6, records[2].Event);
        }
        public void read_all_forward_should_return_all_stream_records_except_uncommited()
        {
            var events = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100).Records.Select(r => r.Event).ToArray();

            Assert.AreEqual(3, events.Length);
            Assert.AreEqual(_event1, events[0]);
            Assert.AreEqual(_event2, events[1]);
            Assert.AreEqual(_event3, events[2]);
        }
        public void should_filter_out_disallowed_streams_when_reading_events_forward()
        {
            var records = ReadIndex.ReadAllEventsForward(_forwardReadPos, 10).EventRecords();

            Assert.AreEqual(2, records.Count);
            Assert.True(records.All(x => x.Event.EventStreamId != _disallowedStream));
            Assert.True(records.Any(x => x.Event.EventStreamId == _allowedStream1));
            Assert.True(records.Any(x => x.Event.EventStreamId == _allowedStream2));
        }
        public void read_all_returns_only_survived_events()
        {
            var res     = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100);
            var records = res.Records.Select(r => r.Event).ToArray();

            Assert.AreEqual(3, records.Length);
            Assert.AreEqual(_event1, records[0]);
            Assert.AreEqual(_event2, records[1]);
            Assert.AreEqual(_event3, records[2]);
        }
        public void read_all_forward_with_max_5_records_returns_2_records_from_2nd_chunk()
        {
            var events = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 5).EventRecords()
                         .Select(r => r.Event)
                         .ToArray();

            Assert.AreEqual(2, events.Length);
            Assert.AreEqual(_event7, events[0]);
            Assert.AreEqual(_event9, events[1]);
        }
        public void read_all_backward_from_last_truncated_record_returns_no_records()
        {
            var pos     = new TFPos(_event3.LogPosition, _event3.LogPosition);
            var res     = ReadIndex.ReadAllEventsForward(pos, 100);
            var records = res.EventRecords()
                          .Select(r => r.Event)
                          .ToArray();

            Assert.AreEqual(0, records.Length);
        }
        public void read_all_forward_doesnt_return_truncated_records()
        {
            var res     = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100);
            var records = res.EventRecords()
                          .Select(r => r.Event)
                          .ToArray();

            Assert.AreEqual(1, records.Length);
            Assert.AreEqual(_event1, records[0]);
        }
        public void the_metastream_is_present_physically()
        {
            var headOfTf = new TFPos(Db.Config.WriterCheckpoint.Read(), Db.Config.WriterCheckpoint.Read());

            Assert.AreEqual(1,
                            ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 1000).Records
                            .Count(x => x.Event.EventStreamId == "$$test"));
            Assert.AreEqual(1,
                            ReadIndex.ReadAllEventsBackward(headOfTf, 1000).Records.Count(x => x.Event.EventStreamId == "$$test"));
        }
Esempio n. 20
0
        public void should_be_able_to_read_the_all_stream()
        {
            var events = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100).Records.Select(r => r.Event).ToArray();

            Assert.AreEqual(5, events.Count());
            Assert.AreEqual(_event1.EventId, events[0].EventId);
            Assert.AreEqual(_event2.EventId, events[1].EventId);
            Assert.AreEqual(_deleted.EventId, events[2].EventId);
            Assert.AreEqual(_event3.EventId, events[3].EventId);
            Assert.AreEqual(_event4.EventId, events[4].EventId);
        }
 public void read_all_forward_returns_all_records()
 {
     var records = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100).Records;
     Assert.AreEqual(6,   records.Count);
     Assert.AreEqual(_r1, records[0].Event);
     Assert.AreEqual(_r2, records[1].Event);
     Assert.AreEqual(_r3, records[2].Event);
     Assert.AreEqual(_r4, records[3].Event);
     Assert.AreEqual(_r5, records[4].Event);
     Assert.AreEqual(_r6, records[5].Event);
 }
Esempio n. 22
0
        public void on_read_all_forward_all_metadata_is_ignored()
        {
            var records = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100).EventRecords();

            Assert.AreEqual(6, records.Count);
            Assert.AreEqual(_r1, records[0].Event);
            Assert.AreEqual(_r2, records[1].Event);
            Assert.AreEqual(_r3, records[2].Event);
            Assert.AreEqual(_r4, records[3].Event);
            Assert.AreEqual(_r5, records[4].Event);
            Assert.AreEqual(_r6, records[5].Event);
        }
Esempio n. 23
0
        public void read_all_events_forward_returns_all_events_in_correct_order()
        {
            var records = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 10).Records;

            Assert.AreEqual(6, records.Count);
            Assert.AreEqual(_p2.EventId, records[0].Event.EventId);
            Assert.AreEqual(_p4.EventId, records[1].Event.EventId);
            Assert.AreEqual(_p1.EventId, records[2].Event.EventId);
            Assert.AreEqual(_p3.EventId, records[3].Event.EventId);
            Assert.AreEqual(_p5.EventId, records[4].Event.EventId);
            Assert.AreEqual(_random1.EventId, records[5].Event.EventId);
        }
        public void read_all_events_forward_does_not_return_duplicate()
        {
            var events = ReadIndex.ReadAllEventsForward(new TFPos(0, 0), 100).Records.Select(r => r.Event).ToArray();

            Assert.AreEqual(11, events.Length);
            Assert.AreEqual(_event1, events[0]);
            Assert.AreEqual(_event2, events[1]);
            Assert.AreEqual(_event3, events[2]);
            Assert.AreEqual(_event4, events[3]);
            Assert.AreEqual(_event5, events[4]);
            Assert.AreEqual(_event6, events[5]);
            Assert.AreEqual(_event7, events[6]);
            Assert.AreEqual(_event8, events[7]);
        }
Esempio n. 25
0
        public void read_all_events_forward_returns_correct_events_starting_in_the_middle_of_tf()
        {
            var res1 = ReadIndex.ReadAllEventsForward(new TFPos(_t2CommitPos, _p4.LogPosition), 10);

            Assert.AreEqual(4, res1.Records.Count);
            Assert.AreEqual(_p4, res1.Records[0].Event);
            Assert.AreEqual(_p1, res1.Records[1].Event);
            Assert.AreEqual(_p3, res1.Records[2].Event);
            Assert.AreEqual(_p5, res1.Records[3].Event);

            var res2 = ReadIndex.ReadAllEventsBackward(res1.PrevPos, 10);

            Assert.AreEqual(1, res2.Records.Count);
            Assert.AreEqual(_p2, res2.Records[0].Event);
        }
Esempio n. 26
0
        public void read_all_events_backward_returns_correct_events_starting_in_the_middle_of_tf()
        {
            var pos  = new TFPos(Db.Config.WriterCheckpoint.Read(), _p4.LogPosition);            // p3 post-pos
            var res1 = ReadIndex.ReadAllEventsBackward(pos, 10);

            Assert.AreEqual(4, res1.Records.Count);
            Assert.AreEqual(_p3, res1.Records[0].Event);
            Assert.AreEqual(_p1, res1.Records[1].Event);
            Assert.AreEqual(_p4, res1.Records[2].Event);
            Assert.AreEqual(_p2, res1.Records[3].Event);

            var res2 = ReadIndex.ReadAllEventsForward(res1.PrevPos, 10);

            Assert.AreEqual(1, res2.Records.Count);
            Assert.AreEqual(_p5, res2.Records[0].Event);
        }
Esempio n. 27
0
        public void read_all_events_backward_returns_correct_events_starting_in_the_middle_of_tf()
        {
            var pos  = new TFPos(_postCommitPos, _p4.LogPosition);            // p3 post position
            var res1 = ReadIndex.ReadAllEventsBackward(pos, 10);

            Assert.AreEqual(4, res1.Records.Count);
            Assert.AreEqual(_p3.EventId, res1.Records[0].Event.EventId);
            Assert.AreEqual(_p1.EventId, res1.Records[1].Event.EventId);
            Assert.AreEqual(_p4.EventId, res1.Records[2].Event.EventId);
            Assert.AreEqual(_p2.EventId, res1.Records[3].Event.EventId);

            var res2 = ReadIndex.ReadAllEventsForward(res1.PrevPos, 10);

            Assert.AreEqual(2, res2.Records.Count);
            Assert.AreEqual(_p5.EventId, res2.Records[0].Event.EventId);
        }
        public void all_records_can_be_read_sequentially_page_by_page_in_forward_pass()
        {
            var recs = new[] { _p2, _p4, _p1, _p3, _p5 }; // in committed order

            int count = 0;
            var pos   = new TFPos(0, 0);
            IndexReadAllResult result;

            while ((result = ReadIndex.ReadAllEventsForward(pos, 1)).Records.Count != 0)
            {
                Assert.AreEqual(1, result.Records.Count);
                Assert.AreEqual(recs[count], result.Records[0].Event);
                pos    = result.NextPos;
                count += 1;
            }
            Assert.AreEqual(recs.Length, count);
        }
        public void reading_all_forward_at_the_very_end_returns_prev_pos_that_allows_to_traverse_back()
        {
            var res1 = ReadIndex.ReadAllEventsForward(new TFPos(Db.Config.WriterCheckpoint.Read(), 0), 100);

            Assert.AreEqual(0, res1.Records.Count);

            var recs  = new[] { _p5, _p3, _p1, _p4, _p2 }; // in reverse committed order
            int count = 0;
            IndexReadAllResult result;
            TFPos pos = res1.PrevPos;

            while ((result = ReadIndex.ReadAllEventsBackward(pos, 1)).Records.Count != 0)
            {
                Assert.AreEqual(1, result.Records.Count);
                Assert.AreEqual(recs[count], result.Records[0].Event);
                pos    = result.NextPos;
                count += 1;
            }
            Assert.AreEqual(recs.Length, count);
        }
        public void reading_all_backward_at_the_very_beginning_returns_prev_pos_that_allows_to_traverse_forward()
        {
            var res1 = ReadIndex.ReadAllEventsBackward(new TFPos(0, int.MaxValue), 100);

            Assert.AreEqual(0, res1.Records.Count);

            var recs  = new[] { _p2, _p4, _p1, _p3, _p5 };
            int count = 0;
            IndexReadAllResult result;
            TFPos pos = res1.PrevPos;

            while ((result = ReadIndex.ReadAllEventsForward(pos, 1)).Records.Count != 0)
            {
                Assert.AreEqual(1, result.Records.Count);
                Assert.AreEqual(recs[count], result.Records[0].Event);
                pos    = result.NextPos;
                count += 1;
            }
            Assert.AreEqual(recs.Length, count);
        }