sciclon2 commented on PR #15030:
URL: https://github.com/apache/kafka/pull/15030#issuecomment-1871195223
hey @divijvaidya if you dont mind I need a bit of help ofr the test, I have
created this:
` @ClusterTest
public void testAdminConfigCustomTimeouts() throws Exception {
int defaultApiTimeoutMs = 240000;
int requestTimeoutMs = 120000;
Path adminConfigPath = tempAdminConfig(defaultApiTimeoutMs,
requestTimeoutMs);
Admin adminMock = mock(Admin.class);
when(Admin.create(any(Properties.class))).thenReturn(adminMock);
LeaderElectionCommand.main(
"--bootstrap-server", cluster.bootstrapServers(),
"--election-type", "unclean",
"--admin-config", adminConfigPath.toString()
);
// I should verify the arguments (props) passed to my mocked admin
client.
}
private static Path tempAdminConfig(int defaultApiTimeoutMs, int
requestTimeoutMs) throws Exception {
String content = "default.api.timeout.ms=" + defaultApiTimeoutMs +
"\nrequest.timeout.ms=" + requestTimeoutMs;
java.io.File file = TestUtils.tempFile("admin-config",
".properties");
Files.write(file.toPath(), content.getBytes(StandardCharsets.UTF_8));
return file.toPath();
}
`
But I get an error:
` java.lang.NullPointerException
at
org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:107)
at
org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:145)
at
org.apache.kafka.clients.admin.AdminClientConfig.<init>(AdminClientConfig.java:280)
at org.apache.kafka.clients.admin.Admin.create(Admin.java:137)
at
org.apache.kafka.tools.LeaderElectionCommandTest.testAdminConfigCustomTimeouts(LeaderElectionCommandTest.java:132)
`
Line 132 is this one
`when(Admin.create(any(Properties.class))).thenReturn(adminMock);`
I can not find the way to make this work, TBH I have not experience in Java
but I spent a few hours on it 😢
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]