public async Task SmokeTest() { var store = new NullCheckpointStore(); using (MasterCheckpointer master = await MasterCheckpointer.CreateAsync("checkpointer", store)) { ICheckpointer checkpointer1 = await master.CreateAsync("endpoint1"); ICheckpointer checkpointer2 = await master.CreateAsync("endpoint2"); Assert.Equal(Checkpointer.InvalidOffset, master.Offset); Assert.Equal(Checkpointer.InvalidOffset, checkpointer1.Offset); Assert.Equal(Checkpointer.InvalidOffset, checkpointer2.Offset); Assert.False(checkpointer1.HasOutstanding); Assert.False(checkpointer2.HasOutstanding); checkpointer1.Propose(MessageWithOffset(1)); Assert.Equal(Checkpointer.InvalidOffset, master.Offset); Assert.Equal(Checkpointer.InvalidOffset, checkpointer1.Offset); Assert.Equal(Checkpointer.InvalidOffset, checkpointer2.Offset); Assert.True(checkpointer1.HasOutstanding); Assert.False(checkpointer2.HasOutstanding); await checkpointer1.CommitAsync(new[] { MessageWithOffset(1) }, new IMessage[] { }, Option.None <DateTime>(), Option.None <DateTime>(), CancellationToken.None); Assert.Equal(1, master.Offset); Assert.Equal(1, checkpointer1.Offset); Assert.Equal(Checkpointer.InvalidOffset, checkpointer2.Offset); Assert.False(checkpointer1.HasOutstanding); Assert.False(checkpointer2.HasOutstanding); await master.CloseAsync(CancellationToken.None); } }
public async Task TestEmptyConstructor() { var store = new NullCheckpointStore(); Assert.Equal(Checkpointer.InvalidOffset, (await store.GetCheckpointDataAsync("id1", CancellationToken.None)).Offset); Assert.Equal(Checkpointer.InvalidOffset, (await store.GetCheckpointDataAsync("id2", CancellationToken.None)).Offset); }
public async Task TestAdmit() { var store = new NullCheckpointStore(14); MasterCheckpointer master = await MasterCheckpointer.CreateAsync("checkpointer", store); Assert.Equal(false, master.Admit(MessageWithOffset(10))); Assert.Equal(true, master.Admit(MessageWithOffset(15))); }
public async Task TestNoChildren() { var store = new NullCheckpointStore(); MasterCheckpointer master = await MasterCheckpointer.CreateAsync("checkpointer", store); Assert.Equal(Checkpointer.InvalidOffset, master.Offset); await master.CommitAsync(new [] { MessageWithOffset(3), MessageWithOffset(1) }, new [] { MessageWithOffset(2) }, Option.None <DateTime>(), Option.None <DateTime>(), CancellationToken.None); Assert.Equal(1, master.Offset); }
public async Task SmokeTest() { var store = new NullCheckpointStore(10L); Assert.Equal(10L, (await store.GetCheckpointDataAsync("id1", CancellationToken.None)).Offset); Assert.Equal(10L, (await store.GetCheckpointDataAsync("id2", CancellationToken.None)).Offset); await store.SetCheckpointDataAsync("id1", new CheckpointData(20L), CancellationToken.None); await store.SetCheckpointDataAsync("id2", new CheckpointData(20L), CancellationToken.None); Assert.Equal(10L, (await store.GetCheckpointDataAsync("id1", CancellationToken.None)).Offset); Assert.Equal(10L, (await store.GetCheckpointDataAsync("id2", CancellationToken.None)).Offset); await store.CloseAsync(CancellationToken.None); }
public async Task TestOutstanding() { var store = new NullCheckpointStore(1L); MasterCheckpointer master = await MasterCheckpointer.CreateAsync("checkpointer", store); ICheckpointer checkpointer1 = await master.CreateAsync("endpoint1"); // Propose two messages IMessage message1 = MessageWithOffset(2); IMessage message2 = MessageWithOffset(3); checkpointer1.Propose(message2); checkpointer1.Propose(message1); Assert.Equal(3L, checkpointer1.Proposed); Assert.Equal(1L, master.Offset); // Commit the first message await checkpointer1.CommitAsync(new[] { message1 }, new IMessage[] {}, Option.None <DateTime>(), Option.None <DateTime>(), CancellationToken.None); // Ensure the master represents the checkpointed message offset Assert.True(checkpointer1.HasOutstanding); Assert.Equal(2L, master.Offset); }