Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add numFunctionWorkers and externalServices to cluster spec (#2160)
*Motivation* ClusterSpec is used for defining how a cluster looks like for integration testing. Add `numFunctionWorker` and `externalServices` in cluster spec, so we have a common place for setting up a cluster. *Changes* - `numFunctionWorkers`: define how many function workers to run in the cluster. When a cluster is created from the cluster spec, it will start the same number of worker containers. - `functionRuntimeType`: define how the worker will invoke functions, whether it is in process mode or thread mode. - `externalServices`: define whether there are more external services to run along with the cluster. for example, we need cassandra or kafka for testing connectors, and we need s3 mock for testing offloaders.
- Loading branch information
Showing
10 changed files
with
282 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...ion-tests-topologies/src/main/java/org/apache/pulsar/tests/containers/KafkaContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,63 @@ | |||
/** | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
package org.apache.pulsar.tests.containers; | |||
|
|||
import lombok.extern.slf4j.Slf4j; | |||
import org.testcontainers.containers.BindMode; | |||
import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy; | |||
|
|||
/** | |||
* Cassandra Container. | |||
*/ | |||
@Slf4j | |||
public class KafkaContainer<SelfT extends ChaosContainer<SelfT>> extends ChaosContainer<SelfT> { | |||
|
|||
public static final String NAME = "kafka"; | |||
public static final int INTERNAL_PORT = 9092; | |||
public static final int PORT = 9093; | |||
|
|||
public KafkaContainer(String clusterName) { | |||
super(clusterName, "confluentinc/cp-kafka:4.1.1"); | |||
} | |||
|
|||
@Override | |||
protected void configure() { | |||
super.configure(); | |||
this.withNetworkAliases(NAME) | |||
.withExposedPorts(INTERNAL_PORT, PORT) | |||
.withClasspathResourceMapping( | |||
"kafka-zookeeper.properties", "/zookeeper.properties", | |||
BindMode.READ_ONLY) | |||
.withCommand("sh", "-c", "zookeeper-server-start /zookeeper.properties & /etc/confluent/docker/run") | |||
.withEnv("KAFKA_LISTENERS", | |||
"INTERNAL://kafka:" + INTERNAL_PORT + ",PLAINTEXT://" + "0.0.0.0" + ":" + PORT) | |||
.withEnv("KAFKA_ZOOKEEPER_CONNECT", "localhost:2181") | |||
.withEnv("KAFKA_LISTENER_SECURITY_PROTOCOL_MAP", "INTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT") | |||
.withEnv("KAFKA_INTER_BROKER_LISTENER_NAME", "INTERNAL") | |||
.withEnv("KAFKA_BROKER_ID", "1") | |||
.withEnv("KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR", "1") | |||
.withEnv("KAFKA_OFFSETS_TOPIC_NUM_PARTITIONS", "1") | |||
.withEnv("KAFKA_LOG_FLUSH_INTERVAL_MESSAGES", Long.MAX_VALUE + "") | |||
.withCreateContainerCmdModifier(createContainerCmd -> { | |||
createContainerCmd.withHostName(NAME); | |||
createContainerCmd.withName(clusterName + "-" + NAME); | |||
}) | |||
.waitingFor(new HostPortWaitStrategy()); | |||
} | |||
} |
51 changes: 51 additions & 0 deletions
51
...ests-topologies/src/main/java/org/apache/pulsar/tests/containers/KafkaProxyContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,51 @@ | |||
/** | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
package org.apache.pulsar.tests.containers; | |||
|
|||
import lombok.extern.slf4j.Slf4j; | |||
import org.testcontainers.containers.SocatContainer; | |||
import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy; | |||
|
|||
/** | |||
* Cassandra Container. | |||
*/ | |||
@Slf4j | |||
public class KafkaProxyContainer extends SocatContainer { | |||
|
|||
public static final String NAME = "kafka-proxy"; | |||
|
|||
private final String clusterName; | |||
|
|||
public KafkaProxyContainer(String clusterName) { | |||
super(); | |||
this.clusterName = clusterName; | |||
} | |||
|
|||
@Override | |||
protected void configure() { | |||
super.configure(); | |||
this.withNetworkAliases(NAME) | |||
.withTarget(KafkaContainer.PORT, KafkaContainer.NAME) | |||
.withCreateContainerCmdModifier(createContainerCmd -> { | |||
createContainerCmd.withHostName(NAME); | |||
createContainerCmd.withName(clusterName + "-" + NAME); | |||
}) | |||
.waitingFor(new HostPortWaitStrategy()); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
tests/integration-tests-topologies/src/main/resources/kafka-zookeeper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,36 @@ | |||
# | |||
# Licensed to the Apache Software Foundation (ASF) under one | |||
# or more contributor license agreements. See the NOTICE file | |||
# distributed with this work for additional information | |||
# regarding copyright ownership. The ASF licenses this file | |||
# to you under the Apache License, Version 2.0 (the | |||
# "License"); you may not use this file except in compliance | |||
# with the License. You may obtain a copy of the License at | |||
# | |||
# http://www.apache.org/licenses/LICENSE-2.0 | |||
# | |||
# Unless required by applicable law or agreed to in writing, | |||
# software distributed under the License is distributed on an | |||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
# KIND, either express or implied. See the License for the | |||
# specific language governing permissions and limitations | |||
# under the License. | |||
# | |||
|
|||
# | |||
# Licensed under the Apache License, Version 2.0 (the "License"); | |||
# you may not use this file except in compliance with the License. | |||
# You may obtain a copy of the License at | |||
# | |||
# http://www.apache.org/licenses/LICENSE-2.0 | |||
# | |||
# Unless required by applicable law or agreed to in writing, software | |||
# distributed under the License is distributed on an "AS IS" BASIS, | |||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
# | |||
|
|||
clientPort=2181 | |||
dataDir=/var/lib/zookeeper/data | |||
dataLogDir=/var/lib/zookeeper/log |
Oops, something went wrong.