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.
Split pulsar-client-and-admin-shade-test into two parts (apache#8716)
Motivation Add test for apache#8697 and other shade problems. Modifications splitting pulsar-client-and-admin-shade-test into two parts, before the pulsar-admin and pulsar-client shade tests were together, can cause some potential problems. * Add CI test for shade package * fix style * fix license * separate shade package * fix pom.xml * fix codestyle * remove unused import Co-authored-by: WeijieGuo <[email protected]>
- Loading branch information
Showing
12 changed files
with
292 additions
and
38 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
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
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.pulsar.tests</groupId> | ||
<artifactId>tests-parent</artifactId> | ||
<version>2.8.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>pulsar-client-shade-test</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Apache Pulsar :: Tests :: Pulsar-Client-Shade Test</name> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.apache.pulsar</groupId> | ||
<artifactId>pulsar-client</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<!-- only run tests when -DShadeTests is specified //--> | ||
<skipTests>true</skipTests> | ||
<systemPropertyVariables> | ||
<currentVersion>${project.version}</currentVersion> | ||
<maven.buildDirectory>${project.build.directory}</maven.buildDirectory> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>ShadeTests</id> | ||
<activation> | ||
<property> | ||
<name>ShadeTests</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<properties> | ||
<property> | ||
<name>testRetryCount</name> | ||
<value>0</value> | ||
</property> | ||
<property> | ||
<name>listener</name> | ||
<value>org.apache.pulsar.tests.PulsarTestListener,org.apache.pulsar.tests.AnnotationListener</value> | ||
</property> | ||
</properties> | ||
<argLine>-Xmx2G -XX:MaxDirectMemorySize=8G | ||
-Dio.netty.leakDetectionLevel=advanced | ||
</argLine> | ||
<skipTests>false</skipTests> | ||
<suiteXmlFiles> | ||
<file>src/test/resources/pulsar.xml</file> | ||
</suiteXmlFiles> | ||
<forkCount>1</forkCount> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
57 changes: 57 additions & 0 deletions
57
...-client-shade-test/src/test/java/org/apache/pulsar/tests/integration/PulsarContainer.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,57 @@ | ||
/** | ||
* 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; | ||
|
||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy; | ||
|
||
import java.time.Duration; | ||
|
||
import static java.time.temporal.ChronoUnit.SECONDS; | ||
|
||
public class PulsarContainer extends GenericContainer<PulsarContainer> { | ||
|
||
public static final int PULSAR_PORT = 6650; | ||
public static final int BROKER_HTTP_PORT = 8080; | ||
public static final String DEFAULT_IMAGE_NAME = "apachepulsar/pulsar-test-latest-version:latest"; | ||
|
||
public PulsarContainer() { | ||
this(DEFAULT_IMAGE_NAME); | ||
} | ||
|
||
public PulsarContainer(final String pulsarVersion) { | ||
super(pulsarVersion); | ||
withExposedPorts(BROKER_HTTP_PORT, PULSAR_PORT); | ||
withCommand("/pulsar/bin/pulsar standalone"); | ||
waitingFor(new HttpWaitStrategy() | ||
.forPort(BROKER_HTTP_PORT) | ||
.forStatusCode(200) | ||
.forPath("/admin/v2/namespaces/public/default") | ||
.withStartupTimeout(Duration.of(300, SECONDS))); | ||
} | ||
|
||
public String getPlainTextPulsarBrokerUrl() { | ||
return String.format("pulsar://%s:%s", this.getContainerIpAddress(), this.getMappedPort(PULSAR_PORT)); | ||
} | ||
|
||
public String getPulsarAdminUrl() { | ||
return String.format("http://%s:%s", this.getContainerIpAddress(), this.getMappedPort(BROKER_HTTP_PORT)); | ||
} | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
...pulsar-client-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.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,80 @@ | ||
/** | ||
* 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; | ||
|
||
import lombok.Cleanup; | ||
import org.apache.pulsar.client.api.Consumer; | ||
import org.apache.pulsar.client.api.Message; | ||
import org.apache.pulsar.client.api.Producer; | ||
import org.apache.pulsar.client.api.PulsarClient; | ||
import org.apache.pulsar.client.api.PulsarClientException; | ||
import org.apache.pulsar.client.api.Schema; | ||
import org.apache.pulsar.client.api.SubscriptionType; | ||
import org.testng.Assert; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
public class SmokeTest { | ||
|
||
private PulsarContainer pulsarContainer; | ||
|
||
@BeforeClass | ||
public void setup(){ | ||
pulsarContainer = new PulsarContainer(); | ||
pulsarContainer.start(); | ||
} | ||
|
||
@Test | ||
public void checkClient() throws PulsarClientException { | ||
|
||
@Cleanup | ||
PulsarClient client = PulsarClient.builder() | ||
.serviceUrl(pulsarContainer.getPlainTextPulsarBrokerUrl()) | ||
.build(); | ||
|
||
final String inputTopic = "input"; | ||
|
||
Producer<String> producer = client.newProducer(Schema.STRING) | ||
.topic(inputTopic) | ||
.enableBatching(false) | ||
.create(); | ||
|
||
Consumer<String> consumer = client.newConsumer(Schema.STRING) | ||
.topic(inputTopic) | ||
.subscriptionName("test-subs") | ||
.ackTimeout(10, TimeUnit.SECONDS) | ||
.subscriptionType(SubscriptionType.Exclusive) | ||
.subscribe(); | ||
|
||
producer.send("Hello!"); | ||
Message<String> message = consumer.receive(10, TimeUnit.SECONDS); | ||
|
||
Assert.assertEquals(message.getValue(), "Hello!"); | ||
|
||
} | ||
|
||
@AfterClass | ||
public void cleanup(){ | ||
pulsarContainer.stop(); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
tests/pulsar-client-shade-test/src/test/resources/pulsar.xml
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,30 @@ | ||
<!-- | ||
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. | ||
--> | ||
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" > | ||
<!-- TODO: we have to put suite files in one file to avoid executing TESTNG test suites multiple times. | ||
see {@link https://github.com/cbeust/testng/issues/508} --> | ||
<suite name="Pulsar Shade Tests" verbose="2" annotations="JDK"> | ||
<test name="pulsar-client-shade-suite" preserve-order="true" > | ||
<classes> | ||
<class name="org.apache.pulsar.tests.integration.SmokeTest" /> | ||
</classes> | ||
</test> | ||
</suite> |