Я запускаю тестирование multi-jvm: на моем экземпляре Amazon linux ec2 с 4vcpu и емкостью 16 ГБ (t2.xlarge). Я бегу 2 узла. Всякий раз, когда я запускаю команду sbt multi-jvm: test,
java.lang.AssertionError: timeout (3 seconds) during expectMessage while waiting for com.psing069.akka.sample.BankAccount$Account@30331109
Я пробовал все. Я указатель высоко ценится. Спасибо.
Мой тест:
"handle updates directly after start" in within(60.seconds) {
runOn(node2) {
bankAccount ! new BankAccount.Deposit(200)
bankAccount ! new BankAccount.Withdraw(100)
}
enterBarrier("updates-done")
awaitAssert {
val probe = TestProbe[Account]()
bankAccount ! new BankAccount.GetBalance(probe.ref)
// val state = probe.expectMessageType[Account](60.seconds)
// state.balance should be (100)
probe.expectMessage(new Account(100))
}
enterBarrier("after-2")
}
и мой актер:
public static class Account {
//String account_number;
int balance;
public Account(int balance){
this.balance = balance;
//this.account_number = account_number;
}
}
private static class InternalGetResponse implements Command {
public final GetResponse<PNCounter> rsp;
public final ActorRef<Account> replyTo;
private InternalGetResponse(GetResponse<PNCounter> rsp, ActorRef<Account> replyTo) {
this.rsp = rsp;
this.replyTo = replyTo;
}
}
private Behavior<Command> onGetBalance(GetBalance command) {
replicator.askGet(
askReplyTo -> new Get<>(dataKey, readMajority, askReplyTo),
rsp -> new InternalGetResponse(rsp, command.replyTo)
);
return Behaviors.same();
}
private Behavior<Command> onInternalGetResponse(InternalGetResponse msg) {
if (msg.rsp instanceof GetSuccess) {
PNCounter data = ((GetSuccess<PNCounter>) msg.rsp).get(dataKey);
msg.replyTo.tell(new Account(data.getValue().intValue()));
} else if (msg.rsp instanceof NotFound) {
msg.replyTo.tell(new Account(0));
} else if (msg.rsp instanceof GetFailure) {
// ReadMajority failure, try again with local read
replicator.askGet(
askReplyTo -> new Get<>(dataKey, Replicator.readLocal(), askReplyTo),
rsp -> new InternalGetResponse(rsp, msg.replyTo)
);
}
return Behaviors.same();
}