Skip to content

Commit aa8054b

Browse files
committed
revert test playground
1 parent 83e1c61 commit aa8054b

File tree

1 file changed

+37
-34
lines changed

1 file changed

+37
-34
lines changed

raft/src/test/scala/zio/raft/RaftIntegrationSpec.scala

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,18 @@ object RaftIntegrationSpec extends ZIOSpecDefault:
161161
killSwitch3
162162
) <- makeRaft()
163163

164-
_ <- r1.sendCommand(Increase).fork.repeatN(10)
165-
_ <- ZIO.sleep(100.millis) // Give raft the time to queue all writes
164+
// TODO (eran): This is not a good test, since sendCommmand is blocking we don't have pending writes, need to rethink this...
165+
_ <- r1.sendCommand(Increase)
166+
_ <- r1.sendCommand(Increase)
167+
_ <- r1.sendCommand(Increase)
168+
166169
readResult1 <- r1.readState
167170

168171
_ <- r1.sendCommand(Increase)
169172

170173
readResult2 <- r1.readState
171-
yield assertTrue(readResult1 == 11 && readResult2 == 12)
172-
} @@ TestAspect.nonFlaky,
174+
yield assertTrue(readResult1 == 3 && readResult2 == 4)
175+
},
173176
test("read returns the correct state when there are no pending writes.") {
174177
for
175178
(
@@ -187,7 +190,7 @@ object RaftIntegrationSpec extends ZIOSpecDefault:
187190
readResult <- r1.readState
188191

189192
yield assertTrue(readResult == 1)
190-
} @@ TestAspect.nonFlaky,
193+
},
191194
test("read returns the correct state when there are no writes and one follower is down.") {
192195
for
193196
(
@@ -223,37 +226,37 @@ object RaftIntegrationSpec extends ZIOSpecDefault:
223226
yield assertTrue(
224227
readResult.isLeft && readResult.left.exists(_.isInstanceOf[NotALeaderError])
225228
)
226-
}
227-
// test("isolated leader cannot apply commands") {
228-
// for
229-
// (
230-
// r1,
231-
// killSwitch1,
232-
// r2,
233-
// killSwitch2,
234-
// r3,
235-
// killSwitch3
236-
// ) <- makeRaft()
229+
},
230+
test("isolated leader cannot apply commands") {
231+
for
232+
(
233+
r1,
234+
killSwitch1,
235+
r2,
236+
killSwitch2,
237+
r3,
238+
killSwitch3
239+
) <- makeRaft()
237240

238-
// // Verify r1 is the leader initially
239-
// _ <- r1.sendCommand(Increase)
240-
// initialState <- r1.readState
241+
// Verify r1 is the leader initially
242+
_ <- r1.sendCommand(Increase)
243+
initialState <- r1.readState
241244

242-
// // Isolate the leader (r1) from the rest of the cluster
243-
// _ <- killSwitch1.set(false)
245+
// Isolate the leader (r1) from the rest of the cluster
246+
_ <- killSwitch1.set(false)
244247

245-
// // Try to send a command to the isolated leader
246-
// // This can either timeout (if leader hasn't detected isolation yet)
247-
// // or fail with NotALeaderError (if leader has stepped down)
248-
// commandResult <- r1.sendCommand(Increase).timeout(2.seconds).either
248+
// Try to send a command to the isolated leader
249+
// This can either timeout (if leader hasn't detected isolation yet)
250+
// or fail with NotALeaderError (if leader has stepped down)
251+
commandResult <- r1.sendCommand(Increase).timeout(2.seconds).either
249252

250-
// yield assertTrue(
251-
// initialState == 1 && // Verify initial command worked
252-
// (commandResult match {
253-
// case Right(None) => true // Command timed out - leader couldn't commit
254-
// case Left(_: NotALeaderError) => true // Leader stepped down due to isolation
255-
// case _ => false // Any other result is unexpected
256-
// })
257-
// )
258-
// } @@ TestAspect.timeout(5.seconds)
253+
yield assertTrue(
254+
initialState == 1 && // Verify initial command worked
255+
(commandResult match {
256+
case Right(None) => true // Command timed out - leader couldn't commit
257+
case Left(_: NotALeaderError) => true // Leader stepped down due to isolation
258+
case _ => false // Any other result is unexpected
259+
})
260+
)
261+
} @@ TestAspect.timeout(5.seconds)
259262
) @@ withLiveClock

0 commit comments

Comments
 (0)