-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Save to custom table node: improvements #10581
base: develop/3.7.1
Are you sure you want to change the base?
Save to custom table node: improvements #10581
Conversation
void givenCassandraClusterIsMissing_whenInit_thenThrowsException() { | ||
var configuration = new TbNodeConfiguration(JacksonUtil.valueToTree(config)); | ||
assertThatThrownBy(() -> node.init(ctxMock, configuration)) | ||
.isInstanceOf(RuntimeException.class) |
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.
By default, TB tries to init the node 10 times before stopping the actor. For cases when the issue is unrecoverable, we use TbNodeException with unrecoverable flag set to true.
Could you please check if this issue might be recoverable? Try to stop the Cassandra cluster and after that initiate the node. After a certain number of retry attempts, start the Cassandra cluster back. If the node will be started then change the exception to TbNodeException with unrecoverable flag set to false, otherwise set it to true.
TbMsg msg = TbMsg.newMsg(TbMsgType.POST_TELEMETRY_REQUEST, DEVICE_ID, TbMsgMetaData.EMPTY, TbMsg.EMPTY_STRING); | ||
assertThatThrownBy(() -> node.onMsg(ctxMock, msg)) | ||
.isInstanceOf(IllegalStateException.class) | ||
.hasMessage("Invalid message structure, it is not a JSON Object:" + null); |
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.
.hasMessage("Invalid message structure, it is not a JSON Object:" + null); | |
.hasMessage("Invalid message structure, it is not a JSON Object: " + null); |
node.onMsg(ctxMock, msg); | ||
|
||
verify(sessionMock).prepare("INSERT INTO cs_tb_readings(entityId) VALUES(?)"); | ||
verify(boundStatementBuilderMock).setUuid(anyInt(), eq(DEVICE_ID.getId())); |
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.
why anyInt()?
Consumer<BoundStatementBuilder> mockBuilderConsumer, | ||
Consumer<BoundStatementBuilder> verifyBuilderConsumer) throws TbNodeException { | ||
config.setTableName("sensor_readings"); | ||
config.setFieldsMapping(Map.of("msgField1", "tableColumn1", "msgField2", "tableColumn2")); |
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.
why we need msgField2 in this test? Is it used in the test somehow? Maybe it's better to add as many fields as you supported data types and replace the parameterized test then?
Pull Request description
General checklist
Back-End feature checklist