protected async Task MembershipTable_CleanupDefunctSiloEntries(bool extendedProtocol = true) { MembershipTableData data = await membershipTable.ReadAll(); logger.Info("Membership.ReadAll returned VableVersion={0} Data={1}", data.Version, data); Assert.Equal(0, data.Members.Count); TableVersion newTableVersion = data.Version.Next(); var oldEntryDead = CreateMembershipEntryForTest(); oldEntryDead.IAmAliveTime = oldEntryDead.IAmAliveTime.AddDays(-10); oldEntryDead.StartTime = oldEntryDead.StartTime.AddDays(-10); oldEntryDead.Status = SiloStatus.Dead; bool ok = await membershipTable.InsertRow(oldEntryDead, newTableVersion); var table = await membershipTable.ReadAll(); Assert.True(ok, "InsertRow Dead failed"); newTableVersion = table.Version.Next(); var oldEntryJoining = CreateMembershipEntryForTest(); oldEntryJoining.IAmAliveTime = oldEntryJoining.IAmAliveTime.AddDays(-10); oldEntryJoining.StartTime = oldEntryJoining.StartTime.AddDays(-10); oldEntryJoining.Status = SiloStatus.Joining; ok = await membershipTable.InsertRow(oldEntryJoining, newTableVersion); table = await membershipTable.ReadAll(); Assert.True(ok, "InsertRow Joining failed"); newTableVersion = table.Version.Next(); var newEntry = CreateMembershipEntryForTest(); ok = await membershipTable.InsertRow(newEntry, newTableVersion); Assert.True(ok, "InsertRow failed"); data = await membershipTable.ReadAll(); logger.Info("Membership.ReadAll returned VableVersion={0} Data={1}", data.Version, data); Assert.Equal(3, data.Members.Count); await membershipTable.CleanupDefunctSiloEntries(oldEntryDead.IAmAliveTime.AddDays(3)); data = await membershipTable.ReadAll(); logger.Info("Membership.ReadAll returned VableVersion={0} Data={1}", data.Version, data); Assert.Equal(1, data.Members.Count); }
protected async Task MembershipTable_CleanupDefunctSiloEntries(bool extendedProtocol = true) { MembershipTableData data = await membershipTable.ReadAll(); logger.Info("Membership.ReadAll returned VableVersion={0} Data={1}", data.Version, data); Assert.Equal(0, data.Members.Count); TableVersion newTableVersion = data.Version.Next(); MembershipEntry oldEntry = CreateMembershipEntryForTest(); oldEntry.IAmAliveTime = oldEntry.IAmAliveTime.AddDays(-10); oldEntry.StartTime = oldEntry.StartTime.AddDays(-10); bool ok = await membershipTable.InsertRow(oldEntry, newTableVersion); Assert.True(ok, "InsertRow failed"); newTableVersion = newTableVersion.Next(); MembershipEntry newEntry = CreateMembershipEntryForTest(); ok = await membershipTable.InsertRow(newEntry, newTableVersion); Assert.True(ok, "InsertRow failed"); data = await membershipTable.ReadAll(); logger.Info("Membership.ReadAll returned VableVersion={0} Data={1}", data.Version, data); Assert.Equal(2, data.Members.Count); await membershipTable.CleanupDefunctSiloEntries(oldEntry.IAmAliveTime.AddDays(3)); data = await membershipTable.ReadAll(); logger.Info("Membership.ReadAll returned VableVersion={0} Data={1}", data.Version, data); Assert.Equal(1, data.Members.Count); }