Skip to content

Commit 8d1906a

Browse files
committed
Test for checking node recovery resets global #1810
This is currently skipped as i'm not sure how to make it work as expected using the test framework.
1 parent 1bbd12a commit 8d1906a

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

src/Tests/ClientConcepts/ConnectionPooling/Sticky/SkipDeadNodes.doc.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,71 @@ await audit.TraceCalls(
117117
);
118118
}
119119

120+
[U(Skip = "Not sure how to trace this chain"), SuppressMessage("AsyncUsage", "AsyncFixer001:Unnecessary async/await usage", Justification = "Its a test")]
121+
public async Task FallsOverDeadNodesWithRecoverResetToPrimary()
122+
{
123+
/** A cluster with 2 nodes where the second node fails on ping */
124+
var audit = new Auditor(() => Framework.Cluster
125+
.Nodes(3)
126+
.ClientCalls(p => p.OnPort(9200).Fails(Twice))
127+
.ClientCalls(p => p.OnPort(9200).Succeeds(Once))
128+
.ClientCalls(p => p.OnPort(9201).Succeeds(Once))
129+
.ClientCalls(p => p.OnPort(9201).Fails(Once))
130+
.ClientCalls(p => p.OnPort(9202).FailAlways())
131+
.StickyConnectionPool()
132+
.Settings(p => p.DisablePing())
133+
);
134+
135+
await audit.TraceCalls(
136+
/** The first call goes to 9200 which fails, so we wrap to 9201 */
137+
new ClientCall {
138+
{ BadResponse, 9200},
139+
{ HealthyResponse, 9201},
140+
{ pool => pool.Nodes.Where(n=>!n.IsAlive).Should().HaveCount(1) }
141+
},
142+
/** The 2nd call does a ping on 9201 which is healthy */
143+
new ClientCall {
144+
{ HealthyResponse, 9201},
145+
/** Finally we assert that the connectionpool has one node that is marked as dead */
146+
{ pool => pool.Nodes.Where(n=>!n.IsAlive).Should().HaveCount(1) }
147+
},
148+
/** The 3rd call does a ping on 9201 which fails, then 9202 and 9203 as all fail */
149+
new ClientCall {
150+
{ BadResponse, 9201},
151+
{ BadResponse, 9202},
152+
{ MaxRetriesReached },
153+
{ pool => pool.Nodes.Where(n=>!n.IsAlive).Should().HaveCount(4) }
154+
},
155+
/** Try to resurrect first node 9200, which fails */
156+
new ClientCall {
157+
{ AllNodesDead },
158+
{ Resurrection, 9200},
159+
{ BadResponse, 9200},
160+
{ pool => pool.Nodes.Where(n=>!n.IsAlive).Should().HaveCount(4) }
161+
},
162+
/** Try to ressurect second node 9201 which succeeds */
163+
new ClientCall {
164+
{ AllNodesDead },
165+
{ Resurrection, 9201},
166+
{ HealthyResponse, 9201},
167+
{ pool => pool.Nodes.Where(n=>!n.IsAlive).Should().HaveCount(3) }
168+
},
169+
/** The ping on 9201 which returns a bad response leaving all nodes dead */
170+
new ClientCall {
171+
{ BadResponse, 9201},
172+
{ MaxRetriesReached },
173+
{ pool => pool.Nodes.Where(n=>!n.IsAlive).Should().HaveCount(4) }
174+
},
175+
/** Try ressurect from 9201 again which succeeded */
176+
new ClientCall {
177+
{ AllNodesDead },
178+
{ Resurrection, 9200},
179+
{ HealthyResponse, 9200},
180+
{ pool => pool.Nodes.Where(n=>!n.IsAlive).Should().HaveCount(3) }
181+
}
182+
);
183+
}
184+
120185
[U, SuppressMessage("AsyncUsage", "AsyncFixer001:Unnecessary async/await usage", Justification = "Its a test")]
121186
public async Task PicksADifferentNodeEachTimeAnodeIsDown()
122187
{

0 commit comments

Comments
 (0)