forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[improve] PIP-335: Pulsar with Oxia integration test (apache#22045)
- Loading branch information
Showing
13 changed files
with
397 additions
and
179 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
38 changes: 0 additions & 38 deletions
38
tests/docker-images/latest-version-image/scripts/init-cluster.sh
This file was deleted.
Oops, something went wrong.
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
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
76 changes: 76 additions & 0 deletions
76
...test/java/org/apache/pulsar/tests/integration/containers/PulsarInitMetadataContainer.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* 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.integration.containers; | ||
|
||
import java.io.IOException; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.Network; | ||
|
||
/** | ||
* Initialize the Pulsar metadata | ||
*/ | ||
@Slf4j | ||
public class PulsarInitMetadataContainer extends GenericContainer<PulsarInitMetadataContainer> { | ||
|
||
public static final String NAME = "init-metadata"; | ||
|
||
private final String clusterName; | ||
private final String metadataStoreUrl; | ||
private final String configurationMetadataStoreUrl; | ||
private final String brokerHostname; | ||
|
||
public PulsarInitMetadataContainer(Network network, | ||
String clusterName, | ||
String metadataStoreUrl, | ||
String configurationMetadataStoreUrl, | ||
String brokerHostname) { | ||
this.clusterName = clusterName; | ||
this.metadataStoreUrl = metadataStoreUrl; | ||
this.configurationMetadataStoreUrl = configurationMetadataStoreUrl; | ||
this.brokerHostname = brokerHostname; | ||
setDockerImageName(PulsarContainer.DEFAULT_IMAGE_NAME); | ||
withNetwork(network); | ||
|
||
setCommand("sleep 1000000"); | ||
} | ||
|
||
|
||
public void initialize() throws Exception { | ||
start(); | ||
ExecResult res = this.execInContainer( | ||
"/pulsar/bin/pulsar", "initialize-cluster-metadata", | ||
"--cluster", clusterName, | ||
"--metadata-store", metadataStoreUrl, | ||
"--configuration-metadata-store", configurationMetadataStoreUrl, | ||
"--web-service-url", "http://" + brokerHostname + ":8080/", | ||
"--broker-service-url", "pulsar://" + brokerHostname + ":6650/" | ||
); | ||
|
||
if (res.getExitCode() == 0) { | ||
log.info("Successfully initialized cluster"); | ||
} else { | ||
log.warn("Failed to initialize Pulsar cluster. exit code: " + res.getExitCode()); | ||
log.warn("STDOUT: " + res.getStdout()); | ||
log.warn("STDERR: " + res.getStderr()); | ||
throw new IOException("Failed to initialized Pulsar Cluster"); | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
tests/integration/src/test/java/org/apache/pulsar/tests/integration/oxia/OxiaContainer.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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.integration.oxia; | ||
|
||
import java.time.Duration; | ||
import org.apache.pulsar.tests.integration.containers.ChaosContainer; | ||
import org.apache.pulsar.tests.integration.containers.PulsarContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
|
||
public class OxiaContainer extends ChaosContainer<OxiaContainer> { | ||
|
||
public static final String NAME = "oxia"; | ||
|
||
public static final int OXIA_PORT = 6648; | ||
public static final int METRICS_PORT = 8080; | ||
private static final int DEFAULT_SHARDS = 1; | ||
|
||
private static final String DEFAULT_IMAGE_NAME = "streamnative/oxia:main"; | ||
|
||
public OxiaContainer(String clusterName) { | ||
this(clusterName, DEFAULT_IMAGE_NAME, DEFAULT_SHARDS); | ||
} | ||
|
||
@SuppressWarnings("resource") | ||
OxiaContainer(String clusterName, String imageName, int shards) { | ||
super(clusterName, imageName); | ||
if (shards <= 0) { | ||
throw new IllegalArgumentException("shards must be greater than zero"); | ||
} | ||
addExposedPorts(OXIA_PORT, METRICS_PORT); | ||
this.withCreateContainerCmdModifier(createContainerCmd -> { | ||
createContainerCmd.withHostName("oxia"); | ||
createContainerCmd.withName(getContainerName()); | ||
}); | ||
setCommand("oxia", "standalone", | ||
"--shards=" + shards, | ||
"--wal-sync-data=false"); | ||
waitingFor( | ||
Wait.forHttp("/metrics") | ||
.forPort(METRICS_PORT) | ||
.forStatusCode(200) | ||
.withStartupTimeout(Duration.ofSeconds(30))); | ||
|
||
PulsarContainer.configureLeaveContainerRunning(this); | ||
} | ||
|
||
public String getServiceAddress() { | ||
return OxiaContainer.NAME + ":" + OXIA_PORT; | ||
} | ||
|
||
@Override | ||
public String getContainerName() { | ||
return clusterName + "-oxia"; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
tests/integration/src/test/java/org/apache/pulsar/tests/integration/oxia/OxiaSmokeTest.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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.integration.oxia; | ||
|
||
import java.util.function.Supplier; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.pulsar.tests.integration.suites.PulsarTestSuite; | ||
import org.apache.pulsar.tests.integration.topologies.PulsarClusterSpec; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* Test pulsar produce/consume semantics | ||
*/ | ||
@Slf4j | ||
public class OxiaSmokeTest extends PulsarTestSuite { | ||
|
||
protected PulsarClusterSpec.PulsarClusterSpecBuilder beforeSetupCluster( | ||
String clusterName, PulsarClusterSpec.PulsarClusterSpecBuilder specBuilder) { | ||
specBuilder.enableOxia(true); | ||
return specBuilder; | ||
} | ||
|
||
// | ||
// Test Basic Publish & Consume Operations | ||
// | ||
|
||
@Test(dataProvider = "ServiceUrlAndTopics") | ||
public void testPublishAndConsume(Supplier<String> serviceUrl, boolean isPersistent) throws Exception { | ||
super.testPublishAndConsume(serviceUrl.get(), isPersistent); | ||
} | ||
|
||
} |
Oops, something went wrong.