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

test: Harden JdbcProjectionTest atLeastOnceShouldRestartFromPreviousOffset #1084

Merged
merged 1 commit into from
Dec 6, 2023
Merged
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 @@ -670,7 +670,9 @@ class JdbcProjectionSpec
projectionTestKit.run(projection) {
result.toString shouldBe "e1|e2|e3|e4|e5|e6|"
}
offsetShouldBe(6L)
eventually {
offsetShouldBe(6L)
}
}
}

Expand All @@ -691,7 +693,9 @@ class JdbcProjectionSpec
projectionTestKit.run(projection) {
projectedValueShouldBe("e1|e2|e3|e4|e5|e6")
}
offsetShouldBe(6L)
eventually {
offsetShouldBe(6L)
}
}

"skip failing events when using RecoveryStrategy.skip, save after 1" in {
Expand All @@ -712,7 +716,9 @@ class JdbcProjectionSpec
projectionTestKit.run(projection) {
projectedValueShouldBe("e1|e2|e3|e5|e6")
}
offsetShouldBe(6L)
eventually {
offsetShouldBe(6L)
}
}

"skip failing events when using RecoveryStrategy.skip, save after 2" in {
Expand All @@ -733,7 +739,9 @@ class JdbcProjectionSpec
projectionTestKit.run(projection) {
projectedValueShouldBe("e1|e2|e3|e5|e6")
}
offsetShouldBe(6L)
eventually {
offsetShouldBe(6L)
}
}

"restart from previous offset - handler throwing an exception, save after 1" in {
Expand Down Expand Up @@ -775,7 +783,9 @@ class JdbcProjectionSpec
projectedValueShouldBe("e1|e2|e3|e4|e5|e6")
}

offsetShouldBe(6L)
eventually {
offsetShouldBe(6L)
}
}

"restart from previous offset - handler throwing an exception, save after 2" in {
Expand Down Expand Up @@ -1030,7 +1040,9 @@ class JdbcProjectionSpec
projectionTestKit.run(projection) {
projectedValueShouldBe("e1|e2|e3|e4|e5|e6")
}
offsetShouldBe(6L)
eventually {
offsetShouldBe(6L)
}

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,11 @@ public void atLeastOnceShouldRestartFromPreviousOffset() {
projectionTestKit.runWithTestSink(
projection,
(probe) -> {
/*
* We only want to process 3 elements through the handler, but given buffering within the projections
* at-least-once impl. we actually process +1 element than we requested with the TestSink probe.
*
* See https://github.com/akka/akka-projection/issues/462 for a possible solution.
*/
probe.request(2);
probe.expectNextN(2);
assertEquals("abc|def|ghi|", str.toString());
expectNextUntilErrorMessage(probe, failMessage(4));
probe.request(3);
testKit.createTestProbe().awaitAssert(() -> {
assertEquals("abc|def|ghi|", str.toString());
return null;
});
});

assertStoredOffset(projectionId, 3L);
Expand All @@ -360,6 +355,7 @@ public void atLeastOnceShouldRestartFromPreviousOffset() {
() -> {
assertEquals("abc|def|ghi|jkl|mno|pqr|", str.toString());
});
assertStoredOffset(projectionId, 6L);
}

@Test
Expand Down