Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional logic for Silo Cleanup test #8845

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public async Task CleanupDefunctSiloEntries(DateTimeOffset beforeDate)

foreach (var entry in allRegistrations)
{
if (entry.Registration.IAmAliveTime < beforeDate)
if (entry.Registration.IAmAliveTime < beforeDate && entry.Registration.Status != SiloStatus.Active)
{
await _consulClient.KV.DeleteTree(entry.RegistrationKey);
}
Expand Down
18 changes: 17 additions & 1 deletion test/TesterInternal/MembershipTests/MembershipTableTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,33 @@ protected async Task MembershipTable_CleanupDefunctSiloEntries(bool extendedProt
Assert.True(ok, "InsertRow failed");

data = await membershipTable.ReadAll();
newTableVersion = data.Version.Next();
logger.LogInformation("Membership.ReadAll returned TableVersion={TableVersion} Data={Data}", data.Version, data);

Assert.Equal(3, data.Members.Count);


// Every status other than Active should get cleared out if old
foreach (var siloStatus in Enum.GetValues<SiloStatus>())
{
var oldEntry = CreateMembershipEntryForTest();
oldEntry.IAmAliveTime = oldEntry.IAmAliveTime.AddDays(-10);
oldEntry.StartTime = oldEntry.StartTime.AddDays(-10);
oldEntry.Status = siloStatus;
ok = await membershipTable.InsertRow(oldEntry, newTableVersion);
table = await membershipTable.ReadAll();

Assert.True(ok, "InsertRow failed");

newTableVersion = table.Version.Next();
}

await membershipTable.CleanupDefunctSiloEntries(oldEntryDead.IAmAliveTime.AddDays(3));

data = await membershipTable.ReadAll();
logger.LogInformation("Membership.ReadAll returned TableVersion={TableVersion} Data={Data}", data.Version, data);

Assert.Single(data.Members);
Assert.Equal(2, data.Members.Count);
}

// Utility methods
Expand Down
Loading