-
Notifications
You must be signed in to change notification settings - Fork 8
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
Extend Karate tests for decentralized communication #1702
Extend Karate tests for decentralized communication #1702
Conversation
Pull reviewers statsStats of the last 30 days for popstellar:
|
…k-simone-extend-decentralized-tests
…k-simone-extend-decentralized-tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Some elements could be improved here and there (e.g. more heartbeat tests / more complex scenarios), but as a foundation, this is already pretty nice 👍
public void send(Map<String, Object> messageData){ | ||
this.send(mapToJsonString(messageData)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider renaming messageData
to something like wsMessage
or jsonRpcMsg
to indicate that we're talking about the lowest level.
messageData
is already pretty (over)loaded as a concept in this project.
@pierluca Yes, this is only a foundation so far. I realized that splitting the server tests from the client tests was probably not the best idea for more complex test scenarios 😅 I might add them back together, but I want to do this in a seperate PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just few comments
And def messageIds = [] | ||
And eval messageIds.push(message_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to initialize in-line?
And def messageIds = [message_id]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like Karate has some problem parsing this as a JSON array, I get an error if I try to do it this way.
|
||
Then assert heartbeatMessages.length > 0 | ||
Then assert heartbeatMessages.length > 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to check for the actual number? Or at least if we cannot determine it precisely we could add an upper threshold (just to be sure heartbeats are not spammed more than expected)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking to keep it more open in case it changes in the future, but right now it can absolutely just check that the number is 2.
*/ | ||
public void publish(Map<String, Object> highLevelMessageDataMap, String channel){ | ||
String highLevelMessageData = mapToJsonString(highLevelMessageDataMap); | ||
int messageId = new Random().nextInt(Integer.MAX_VALUE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integer.MAX_VALUE
is already the default max value for nextInt so it's redundant
|
||
private PublishMessageIds getPublishMessageIds(Map<String, Object> highLevelMessageDataMap){ | ||
String highLevelMessageData = mapToJsonString(highLevelMessageDataMap); | ||
PublishMessageIds message_ids = sentMessages.get(highLevelMessageData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: I'm not a great fan of snake case in Java 😬
[PoP - PoPCHA-Web-Client] Kudos, SonarCloud Quality Gate passed! |
[PoP - Be1-Go] Kudos, SonarCloud Quality Gate passed! |
[PoP - Be2-Scala] Kudos, SonarCloud Quality Gate passed! |
[PoP - Fe2-Android] Kudos, SonarCloud Quality Gate passed! |
[PoP - Fe1-Web] Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Are you satisfied @matteosz ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR:
JsonConverter
andMultiMsgWebSocketClient
to make them easier to understand,