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.
[Issue 8542]Add smoke test for shade package (apache#8574)
### Motivation Fixes apache#8542, Add smoke test for shade package. ### Modifications Add CI test for pulsar-client-all、pulsar-client and pulsar-client-admin to test if the shade plugin works.
- Loading branch information
Showing
10 changed files
with
720 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
name: CI - Shade - Test | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
push: | ||
branches: | ||
- branch-* | ||
|
||
env: | ||
MAVEN_OPTS: -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.wagon.http.retryHandler.count=3 | ||
|
||
jobs: | ||
|
||
shade-check: | ||
name: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 120 | ||
|
||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 25 | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Cache local Maven repository | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: Check if this pull request only changes documentation | ||
id: docs | ||
uses: apache/pulsar-test-infra/diff-only@master | ||
with: | ||
args: site2 deployment .asf.yaml .ci ct.yaml | ||
|
||
- name: Set up JDK 1.8 | ||
uses: actions/setup-java@v1 | ||
if: steps.docs.outputs.changed_only == 'no' | ||
with: | ||
java-version: 1.8 | ||
|
||
- name: clean disk | ||
if: steps.docs.outputs.changed_only == 'no' | ||
run: | | ||
sudo swapoff -a | ||
sudo rm -rf /swapfile /usr/share/dotnet /usr/local/lib/android /opt/ghc | ||
sudo apt clean | ||
docker rmi $(docker images -q) -f | ||
df -h | ||
- name: run install by skip tests | ||
if: steps.docs.outputs.changed_only == 'no' | ||
run: mvn -q -B -ntp clean install -DskipTests | ||
|
||
- name: build pulsar image | ||
if: steps.docs.outputs.changed_only == 'no' | ||
run: mvn -B -f docker/pulsar/pom.xml install -am -Pdocker -DskipTests -Ddocker.nocache=true | ||
|
||
- name: build pulsar-all image | ||
if: steps.docs.outputs.changed_only == 'no' | ||
run: mvn -B -f docker/pulsar-all/pom.xml install -am -Pdocker -DskipTests -Ddocker.nocache=true | ||
|
||
- name: build artifacts and docker pulsar latest test image | ||
if: steps.docs.outputs.changed_only == 'no' | ||
run: mvn -B -f tests/docker-images/pom.xml install -am -Pdocker -DskipTests | ||
|
||
- name: run shade tests | ||
if: steps.docs.outputs.changed_only == 'no' | ||
run: mvn -B -f tests/pom.xml test -DShadeTests -DredirectTestOutputToFile=false |
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,125 @@ | ||
<?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.7.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>pulsar-client-all-shade-test</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Apache Pulsar :: Tests :: Pulsar-Client-All-Shade Test</name> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.pulsar</groupId> | ||
<artifactId>pulsar-client-all</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
...ent-all-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)); | ||
} | ||
|
||
} |
93 changes: 93 additions & 0 deletions
93
...ar-client-all-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,93 @@ | ||
/** | ||
* 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.admin.PulsarAdmin; | ||
import org.apache.pulsar.client.admin.PulsarAdminException; | ||
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.ArrayList; | ||
import java.util.List; | ||
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!"); | ||
|
||
} | ||
|
||
@Test | ||
public void checkAdmin() throws PulsarClientException, PulsarAdminException { | ||
PulsarAdmin admin = PulsarAdmin.builder().serviceHttpUrl(pulsarContainer.getPulsarAdminUrl()).build(); | ||
List<String> expectedNamespacesList = new ArrayList<>(); | ||
expectedNamespacesList.add("public/default"); | ||
expectedNamespacesList.add("public/functions"); | ||
Assert.assertEquals(admin.namespaces().getNamespaces("public"), expectedNamespacesList); | ||
} | ||
|
||
@AfterClass | ||
public void cleanup(){ | ||
pulsarContainer.stop(); | ||
} | ||
|
||
} |
Oops, something went wrong.