MINOR: Fix Jmxtool to honour wait option when MBean is not yet avaibale in MBean server (#13995)

In JmxTool.scala, we will wait till all the object names are available from MBean server. But in the newer version, we only wait for subset of object names. Due to this, we may not enforce wait option and prematurely return the result if the objects are not yet registered in MBean sever.

Reviewers: Luke Chen <showuon@gmail.com>, Federico Valeri <fvaleri@redhat.com>
This commit is contained in:
Manikumar Reddy 2023-07-12 17:01:10 +05:30 committed by GitHub
parent aafbe34443
commit 4e85bc9f80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -169,7 +169,7 @@ public class JmxTool {
long waitTimeoutMs = 10_000;
Set<ObjectName> result = new HashSet<>();
Set<ObjectName> querySet = new HashSet<>(queries);
BiPredicate<Set<ObjectName>, Set<ObjectName>> foundAllObjects = Set::containsAll;
BiPredicate<Set<ObjectName>, Set<ObjectName>> foundAllObjects = Set::equals;
long start = System.currentTimeMillis();
do {
if (!result.isEmpty()) {

View File

@ -337,6 +337,19 @@ public class JmxToolTest {
assertTrue(validDateFormat(dateFormat, csv.get("time")));
}
@Test
public void unknownObjectName() {
String[] args = new String[]{
"--jmx-url", jmxUrl,
"--object-name", "kafka.server:type=DummyMetrics,name=MessagesInPerSec",
"--wait"
};
String err = executeAndGetErr(args);
assertCommandFailure();
assertTrue(err.contains("Could not find all requested object names after 10000 ms"));
}
private static int findRandomOpenPortOnAllLocalInterfaces() throws Exception {
try (ServerSocket socket = new ServerSocket(0)) {
return socket.getLocalPort();