Skip to content

Commit

Permalink
broker resource group test optimize fail msg (#12438)
Browse files Browse the repository at this point in the history
(cherry picked from commit 86f40c1)
  • Loading branch information
shoothzj authored and codelipenghui committed Dec 20, 2021
1 parent ad4e665 commit e8a629c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import com.google.common.collect.Sets;
import io.prometheus.client.Summary;
import java.util.Collections;
import org.apache.pulsar.broker.resourcegroup.ResourceGroup.BytesAndMessagesCount;
import org.apache.pulsar.broker.resourcegroup.ResourceGroup.ResourceGroupMonitoringClass;
import org.apache.pulsar.broker.resourcegroup.ResourceGroupService.ResourceGroupUsageStatsType;
Expand Down Expand Up @@ -59,7 +58,7 @@
// The tenants and namespaces in those topics are associated with a set of resource-groups (RGs).
// After sending/receiving all the messages, traffic usage statistics, and Prometheus-metrics
// are verified on the RGs.
public class RGUsageMTAggrWaitForAllMesgsTest extends ProducerConsumerBase {
public class RGUsageMTAggrWaitForAllMsgsTest extends ProducerConsumerBase {
@BeforeClass
@Override
protected void setup() throws Exception {
Expand Down Expand Up @@ -350,13 +349,12 @@ private boolean tenantRGEqualsNamespaceRG(String[] topicStrings) throws PulsarCl
}
}
if ((numEqualRGs + numUnEqualRGs != numTopics) || (numEqualRGs > 0 && numUnEqualRGs > 0)) {
String errMesg = String.format("Found {} topics with equal RGs and {} with unequal, on {} topics",
String errMesg = String.format("Found %s topics with equal RGs and %s with unequal, on %s topics",
numEqualRGs, numUnEqualRGs, numTopics);
throw new PulsarClientException(errMesg);
} else if (numEqualRGs == numTopics) {
return true;
} else {
return numEqualRGs == numTopics;
}
return false;
}

private void registerTenantsAndNamespaces(String[] topicStrings) throws Exception {
Expand Down Expand Up @@ -788,7 +786,7 @@ private void verifyRGMetrics(String[] topicStrings,
Assert.assertNotEquals(ninetethPercentileValue, 0);
}

private static final Logger log = LoggerFactory.getLogger(RGUsageMTAggrWaitForAllMesgsTest.class);
private static final Logger log = LoggerFactory.getLogger(RGUsageMTAggrWaitForAllMsgsTest.class);

// Empirically, there appears to be a 45-byte overhead for metadata, imposed by Pulsar runtime.
private static final int PER_MESSAGE_METADATA_OHEAD = 45;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public void acceptResourceUsage(String broker, ResourceUsage resourceUsage) {
.subscriptionType(SubscriptionType.Shared)
.subscribe();
} catch (PulsarClientException p) {
final String errMesg = String.format("Got exception while building consumer: ex={}", p.getMessage());
Assert.assertTrue(false, errMesg);
final String errMsg = String.format("Got exception while building consumer: ex=%s", p.getMessage());
Assert.fail(errMsg);
}

final TopicName myTopic = TopicName.get(topicString);
Expand All @@ -146,16 +146,15 @@ public void acceptResourceUsage(String broker, ResourceUsage resourceUsage) {
int recvdNumBytes = 0;
int recvdNumMsgs = 0;
for (int ix = 0; ix < NumMessagesToSend; ix++) {
MessageId prodMesgId = null;
byte[] mesg;
try {
mesg = String.format("Hi, ix={}", ix).getBytes();
mesg = String.format("Hi, ix=%s", ix).getBytes();
producer.send(mesg);
sentNumBytes += mesg.length;
sentNumMsgs++;
} catch (PulsarClientException p) {
final String errMesg = String.format("Got exception while sending {}-th time: ex={}", ix, p.getMessage());
Assert.assertTrue(false, errMesg);
final String errMsg = String.format("Got exception while sending %s-th time: ex=%s", ix, p.getMessage());
Assert.fail(errMsg);
}
}
producer.close();
Expand All @@ -169,9 +168,9 @@ public void acceptResourceUsage(String broker, ResourceUsage resourceUsage) {
message = consumer.receive();
recvdNumBytes += message.getValue().length;
} catch (PulsarClientException p) {
final String errMesg = String.format("Got exception in while receiving {}-th mesg at consumer: ex={}",
final String errMesg = String.format("Got exception in while receiving %s-th mesg at consumer: ex=%s",
recvdNumMsgs, p.getMessage());
Assert.assertTrue(false, errMesg);
Assert.fail(errMesg);
}
// log.info("consumer received message : {} {}", message.getMessageId(), new String(message.getData()));
recvdNumMsgs++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.pulsar.client.api.PulsarClientException;
import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.common.policies.data.ClusterData;
import org.apache.pulsar.common.policies.data.ClusterDataImpl;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand Down

0 comments on commit e8a629c

Please sign in to comment.