Skip to content

Commit

Permalink
Fix InvokeOrderingTest (#158)
Browse files Browse the repository at this point in the history
Also add listName argument (this might help in future with parallel tests)
  • Loading branch information
slinkydeveloper authored Jun 27, 2023
1 parent c7fde35 commit 53b2bf2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions contracts/src/main/proto/coordinator.proto
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ message TimeoutResponse {

message InvokeSequentiallyRequest {
repeated bool execute_as_background_call = 1;
string list_name = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,15 @@ public void invokeSequentially(
List<Awaitable<?>> collectedAwaitables = new ArrayList<>();

for (int i = 0; i < request.getExecuteAsBackgroundCallCount(); i++) {
var appendRequest =
AppendRequest.newBuilder()
.setListName(request.getListName())
.setValue(String.valueOf(i))
.build();
if (request.getExecuteAsBackgroundCall(i)) {
ctx.backgroundCall(
ListServiceGrpc.getAppendMethod(),
AppendRequest.newBuilder()
.setListName("invokeSequentially")
.setValue(String.valueOf(i))
.build());
ctx.backgroundCall(ListServiceGrpc.getAppendMethod(), appendRequest);
} else {
collectedAwaitables.add(
ctx.call(
ListServiceGrpc.getAppendMethod(),
AppendRequest.newBuilder()
.setListName("invokeSequentially")
.setValue(String.valueOf(i))
.build()));
collectedAwaitables.add(ctx.call(ListServiceGrpc.getAppendMethod(), appendRequest));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import dev.restate.e2e.services.coordinator.CoordinatorProto.InvokeSequentiallyR
import dev.restate.e2e.utils.InjectBlockingStub
import dev.restate.e2e.utils.RestateDeployer
import dev.restate.e2e.utils.RestateDeployerExtension
import java.util.UUID
import java.util.stream.Stream
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.extension.RegisterExtension
Expand All @@ -29,9 +30,14 @@ class InvokeOrderingTest {

@JvmStatic
fun ordering(): Stream<Arguments> {
// To enforce ordering wrt listClient.clear(...) executed in the test code,
// the last call must be sync!
return Stream.of(
Arguments.of(booleanArrayOf(true, false, true)),
Arguments.of(booleanArrayOf(false, true, false)))
Arguments.of(booleanArrayOf(true, false, false)),
Arguments.of(booleanArrayOf(false, true, false)),
Arguments.of(
booleanArrayOf(true, true, false),
))
}
}

Expand All @@ -42,12 +48,15 @@ class InvokeOrderingTest {
@InjectBlockingStub coordinatorClient: CoordinatorBlockingStub,
@InjectBlockingStub listClient: ListServiceBlockingStub
) {
val listName = UUID.randomUUID().toString()

coordinatorClient.invokeSequentially(
InvokeSequentiallyRequest.newBuilder()
.addAllExecuteAsBackgroundCall(ordering.asIterable())
.setListName(listName)
.build())

val listClientRequest = Request.newBuilder().setListName("invokeSequentially").build()
val listClientRequest = Request.newBuilder().setListName(listName).build()

assertThat(listClient.clear(listClientRequest).valuesList).containsExactly("0", "1", "2")
}
Expand Down

0 comments on commit 53b2bf2

Please sign in to comment.