showuon commented on code in PR #13102: URL: https://github.com/apache/kafka/pull/13102#discussion_r1067632210
########## raft/src/test/java/org/apache/kafka/raft/FileBasedStateStoreTest.java: ########## @@ -90,6 +98,43 @@ public void testWriteElectionState() throws IOException { assertFalse(stateFile.exists()); } + @Test + public void testCompatibilityWithClusterId() throws IOException { + final File stateFile = TestUtils.tempFile(); + stateStore = new FileBasedStateStore(stateFile); + + // We initialized a state from the metadata log + assertTrue(stateFile.exists()); + + String jsonString = "{\"clusterId\":\"abc\",\"leaderId\":0,\"leaderEpoch\":0,\"votedId\":-1,\"appliedOffset\":0,\"currentVoters\":[],\"data_version\":0}"; + writeToStateFile(stateFile, jsonString); + + // verify that we can read the state file that contains the removed "cluserId" field. + assertEquals(stateStore.readElectionState(), new ElectionState(0, + OptionalInt.of(0), OptionalInt.empty(), Collections.emptySet())); Review Comment: 1. we should put the expected result in the first parameter, so that the failed output will be meaningful. (ref: [here](https://junit.org/junit5/docs/5.0.1/api/org/junit/jupiter/api/Assertions.html#assertEquals-java.lang.Object-java.lang.Object-)) 2. I saw we use `ElectionState.withElectedLeader`, instead of `new ElectionState`. Do you think we can use the former one for consistency? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org