Skip to content
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

[cleanup][test] CSContainer needs not to inherit from ZKContainer #20543

Merged
merged 1 commit into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ public abstract class PulsarTokenAuthenticationBaseSuite extends PulsarClusterTe
protected static final String PROXY_ROLE = "proxy";
protected static final String REGULAR_USER_ROLE = "client";

protected ZKContainer<?> cmdContainer;
protected ZKContainer cmdContainer;

@BeforeClass(alwaysRun = true)
@Override
public final void setupCluster() throws Exception {
incrementSetupNumber();
// Before starting the cluster, generate the secret key and the token
// Use Zk container to have 1 container available before starting the cluster
this.cmdContainer = new ZKContainer<>("cli-setup");
this.cmdContainer = new ZKContainer("cli-setup");
cmdContainer
.withNetwork(Network.newNetwork())
.withNetworkAliases(ZKContainer.NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testProduceConsumeThroughProxy() throws Exception {
private void testProduceConsume(String serviceUrl, String topicName) throws Exception {
List<String> data = randomStrings();
// Using the ZK container as it is separate from brokers, so its environment resembles real world usage more
ZKContainer<?> clientToolContainer = pulsarCluster.getZooKeeper();
ZKContainer clientToolContainer = pulsarCluster.getZooKeeper();
produce(clientToolContainer, serviceUrl, topicName, data);
List<String> consumed = consume(clientToolContainer, serviceUrl, topicName);
assertEquals(consumed, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void testProduce() throws Exception {
String serviceUrl = "pulsar://" + pulsarCluster.getProxy().getContainerName() + ":" + PulsarContainer.BROKER_PORT;
final String topicName = getNonPartitionedTopic("testProduce", true);
// Using the ZK container as it is separate from brokers, so its environment resembles real world usage more
ZKContainer<?> clientToolContainer = pulsarCluster.getZooKeeper();
ZKContainer clientToolContainer = pulsarCluster.getZooKeeper();
ContainerExecResult produceResult = produceWithPerfTool(clientToolContainer, serviceUrl, topicName, MESSAGE_COUNT);
checkOutputForLogs(produceResult,"PerformanceProducer - Aggregated throughput stats",
"PerformanceProducer - Aggregated latency stats");
Expand All @@ -49,7 +49,7 @@ public void testConsume() throws Exception {
String serviceUrl = "pulsar://" + pulsarCluster.getProxy().getContainerName() + ":" + PulsarContainer.BROKER_PORT;
final String topicName = getNonPartitionedTopic("testConsume", true);
// Using the ZK container as it is separate from brokers, so its environment resembles real world usage more
ZKContainer<?> clientToolContainer = pulsarCluster.getZooKeeper();
ZKContainer clientToolContainer = pulsarCluster.getZooKeeper();
ContainerExecResult consumeResult = consumeWithPerfTool(clientToolContainer, serviceUrl, topicName);
checkOutputForLogs(consumeResult,"PerformanceConsumer - Aggregated throughput stats",
"PerformanceConsumer - Aggregated latency stats");
Expand All @@ -60,7 +60,7 @@ public void testRead() throws Exception {
String serviceUrl = "pulsar://" + pulsarCluster.getProxy().getContainerName() + ":" + PulsarContainer.BROKER_PORT;
final String topicName = getNonPartitionedTopic("testRead", true);
// Using the ZK container as it is separate from brokers, so its environment resembles real world usage more
ZKContainer<?> clientToolContainer = pulsarCluster.getZooKeeper();
ZKContainer clientToolContainer = pulsarCluster.getZooKeeper();
ContainerExecResult readResult = readWithPerfTool(clientToolContainer, serviceUrl, topicName);
checkOutputForLogs(readResult,"PerformanceReader - Aggregated throughput stats ",
"PerformanceReader - Aggregated latency stats");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* A pulsar container that runs configuration store.
*/
public class CSContainer extends ZKContainer<CSContainer> {
public class CSContainer extends PulsarContainer<CSContainer> {
tisonkun marked this conversation as resolved.
Show resolved Hide resolved

public static final String NAME = "configuration-store";

Expand All @@ -34,4 +34,9 @@ public CSContainer(String clusterName) {
CS_PORT,
INVALID_PORT);
}

@Override
protected boolean isCodeCoverageEnabled() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@
*/
package org.apache.pulsar.tests.integration.containers;

import org.apache.pulsar.tests.integration.utils.DockerUtils;

/**
* A pulsar container that runs zookeeper.
*/
public class ZKContainer<SelfT extends PulsarContainer<SelfT>> extends PulsarContainer<SelfT> {
public class ZKContainer extends PulsarContainer<ZKContainer> {

public static final String NAME = "zookeeper";

private volatile boolean dumpZkDataBeforeStop = false;

public ZKContainer(String clusterName) {
super(
clusterName,
Expand All @@ -39,37 +35,6 @@ public ZKContainer(String clusterName) {
INVALID_PORT);
}

public ZKContainer(String clusterName,
String hostname,
String serviceName,
String serviceEntryPoint,
int servicePort,
int httpPort) {
super(
clusterName,
hostname,
serviceName,
serviceEntryPoint,
servicePort,
httpPort);
}

public void enableDumpZkDataBeforeStop(boolean enabled) {
this.dumpZkDataBeforeStop = enabled;
}

@Override
protected void beforeStop() {
super.beforeStop();
if (null != getContainerId() && dumpZkDataBeforeStop) {
DockerUtils.dumpContainerDirToTargetCompressed(
getDockerClient(),
getContainerId(),
"/pulsar/data/zookeeper"
);
}
}

@Override
protected boolean isCodeCoverageEnabled() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static PulsarCluster forSpec(PulsarClusterSpec spec, CSContainer csContai
@Getter
private final String clusterName;
private final Network network;
private final ZKContainer<?> zkContainer;
private final ZKContainer zkContainer;
private final CSContainer csContainer;
private final boolean sharedCsContainer;
private final Map<String, BKContainer> bookieContainers;
Expand Down