Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-v committed Jul 12, 2024
1 parent a8de185 commit 832574f
Showing 1 changed file with 54 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void testSelectWhenLessThanFanout() {

for (int i = 0; i < 10; i++) {
memberSelector.nextGossipMembers();
assertEquals(3, gossipMembers.size());
assertEquals(remoteMembers.size(), gossipMembers.size());
assertThat(gossipMembers, hasItems(isOneOf(fooMember, barMember, bazMember)));
}
}
Expand All @@ -59,7 +59,7 @@ void testSelectWhenEqualToFanout() {

for (int i = 0; i < 10; i++) {
memberSelector.nextGossipMembers();
assertEquals(3, gossipMembers.size());
assertEquals(remoteMembers.size(), gossipMembers.size());
assertThat(gossipMembers, hasItems(isOneOf(fooMember, barMember, bazMember)));
}
}
Expand All @@ -76,13 +76,61 @@ void testSelectWhenGreaterThanFanout() {
remoteMembers.add(abcMember);
remoteMembers.add(xyzMember);

final MemberSelector memberSelector = new MemberSelector(3, remoteMembers, gossipMembers);
final int gossipFanout = 3;
final MemberSelector memberSelector =
new MemberSelector(gossipFanout, remoteMembers, gossipMembers);

for (int i = 0; i < 10; i++) {
memberSelector.nextGossipMembers();
assertEquals(gossipFanout, gossipMembers.size());
assertThat(
gossipMembers,
hasItems(
isOneOf(
fooMember,
barMember,
bazMember,
aliceMember,
bobMember,
johnMember,
eveMember,
abcMember,
xyzMember)));
}
}

@Test
void testSelectWhenGreaterThanFanoutWithReminder() {
remoteMembers.add(fooMember);
remoteMembers.add(barMember);
remoteMembers.add(bazMember);
remoteMembers.add(aliceMember);
remoteMembers.add(bobMember);
remoteMembers.add(johnMember);
remoteMembers.add(eveMember);
remoteMembers.add(abcMember);
remoteMembers.add(xyzMember);

final int gossipFanout = 4;
final MemberSelector memberSelector =
new MemberSelector(gossipFanout, remoteMembers, gossipMembers);

for (int i = 0; i < 10; i++) {
memberSelector.nextGossipMembers();
assertEquals(3, gossipMembers.size());
System.err.println(gossipMembers);
// assertThat(gossipMembers, hasItems(isOneOf(fooMember, barMember, bazMember)));
assertEquals(gossipFanout, gossipMembers.size());
assertThat(
gossipMembers,
hasItems(
isOneOf(
fooMember,
barMember,
bazMember,
aliceMember,
bobMember,
johnMember,
eveMember,
abcMember,
xyzMember)));
}
}
}

0 comments on commit 832574f

Please sign in to comment.