Skip to content

Commit

Permalink
refactor 2
Browse files Browse the repository at this point in the history
  • Loading branch information
heesung-sn committed Nov 1, 2024
1 parent ecfbca1 commit 2cb5c2d
Show file tree
Hide file tree
Showing 38 changed files with 299 additions and 59 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2565,6 +2565,9 @@ flexible messaging model and an intuitive client API.</description>
<module>pulsar-package-management</module>
<!-- package management releated modules (end) -->

<module>pulsar-inttest-lib</module>
<module>pulsar-inttest-client</module>

<!-- all these 3 modules should be put at the end in this exact sequence -->
<module>distribution</module>
<module>docker</module>
Expand Down Expand Up @@ -2621,6 +2624,9 @@ flexible messaging model and an intuitive client API.</description>

<module>pulsar-client-messagecrypto-bc</module>

<module>pulsar-inttest-lib</module>
<module>pulsar-inttest-client</module>

<!-- all these modules should be put at the end in this exact sequence -->
<module>distribution</module>
<module>pulsar-metadata</module>
Expand Down
95 changes: 95 additions & 0 deletions pulsar-inttest-client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0"?>
<!--
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
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar</artifactId>
<version>4.1.0-SNAPSHOT</version>
</parent>

<artifactId>pulsar-inttest-client</artifactId>
<description>Pulsar Integration Common Client Test Classes</description>

<dependencies>
<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-inttest-lib</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
</dependency>
<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-client-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-client-admin-api</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<configuration>
<failOnViolations>true</failOnViolations>
<javaVersion>8</javaVersion>
</configuration>
<executions>
<execution>
<id>modernizer</id>
<phase>verify</phase>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
package org.apache.pulsar.tests.integration.messaging;

import static org.apache.pulsar.tests.integration.IntegTestUtils.getNonPartitionedTopic;
import static org.apache.pulsar.tests.integration.IntegTestUtils.getPartitionedTopic;
import static org.apache.pulsar.tests.integration.utils.IntegTestUtils.getNonPartitionedTopic;
import static org.apache.pulsar.tests.integration.utils.IntegTestUtils.getPartitionedTopic;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
Expand Down Expand Up @@ -52,7 +52,6 @@
@Slf4j
public class TopicMessagingTest extends IntegTest {


public TopicMessagingTest(PulsarClient client, PulsarAdmin admin) {
super(client, admin);
}
Expand Down
94 changes: 94 additions & 0 deletions pulsar-inttest-lib/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0"?>
<!--
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
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar</artifactId>
<version>4.1.0-SNAPSHOT</version>
</parent>

<artifactId>pulsar-inttest-lib</artifactId>
<description>Pulsar Integration Common Library</description>

<dependencies>
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-core</artifactId>
<version>${docker-java.version}</version>
</dependency>
<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-client-admin-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>${apache-httpcomponents.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<configuration>
<failOnViolations>true</failOnViolations>
<javaVersion>8</javaVersion>
</configuration>
<executions>
<execution>
<id>modernizer</id>
<phase>verify</phase>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
package org.apache.pulsar.tests.integration.containers;

import com.github.dockerjava.api.DockerClient;

import java.util.Base64;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;

import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.tests.integration.docker.ContainerExecResult;
import org.apache.pulsar.tests.integration.utils.DockerUtils;
Expand Down Expand Up @@ -98,7 +96,8 @@ public ContainerExecResult execCmdAsUser(String userId, String... commands) thro
return DockerUtils.runCommandAsUser(userId, client, dockerId, commands);
}

public CompletableFuture<ContainerExecResult> execCmdAsyncAsUser(String userId, String... commands) throws Exception {
public CompletableFuture<ContainerExecResult> execCmdAsyncAsUser(String userId, String... commands)
throws Exception {
DockerClient client = this.getDockerClient();
String dockerId = this.getContainerId();
return DockerUtils.runCommandAsyncAsUser(userId, client, dockerId, commands);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
package org.apache.pulsar.tests.integration.containers;


import org.testcontainers.containers.wait.strategy.Wait;

import java.time.Duration;
import java.time.temporal.ChronoUnit;
import org.testcontainers.containers.wait.strategy.Wait;

public class DebeziumMsSqlContainer extends ChaosContainer<DebeziumMsSqlContainer> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
package org.apache.pulsar.tests.integration.containers;


import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;

import java.time.Duration;
import java.time.temporal.ChronoUnit;
import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;

public class DebeziumOracleDbContainer extends ChaosContainer<DebeziumOracleDbContainer> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,28 @@

public class HdfsContainer extends ChaosContainer<HdfsContainer> {

public static final String NAME = "HDFS";
static final Integer[] PORTS = { 8020, 8032, 8088, 9000, 10020, 19888, 50010, 50020, 50070, 50070, 50090 };

private static final String IMAGE_NAME = "harisekhon/hadoop:latest";

public HdfsContainer(String clusterName) {
super(clusterName, IMAGE_NAME);
}

public static final String NAME = "HDFS";
static final Integer[] PORTS = { 8020, 8032, 8088, 9000, 10020, 19888, 50010, 50020, 50070, 50070, 50090 };
private static final String IMAGE_NAME = "harisekhon/hadoop:latest";

public HdfsContainer(String clusterName) {
super(clusterName, IMAGE_NAME);
}

@Override
public String getContainerName() {
return clusterName;
}

@Override
protected void configure() {
super.configure();
this.withNetworkAliases(NAME)
.withExposedPorts(PORTS)
.withCreateContainerCmdModifier(createContainerCmd -> {
createContainerCmd.withHostName(NAME);
createContainerCmd.withName(clusterName + "-" + NAME);
})
.waitingFor(new HostPortWaitStrategy());
}

super.configure();
this.withNetworkAliases(NAME)
.withExposedPorts(PORTS)
.withCreateContainerCmdModifier(createContainerCmd -> {
createContainerCmd.withHostName(NAME);
createContainerCmd.withName(clusterName + "-" + NAME);
})
.waitingFor(new HostPortWaitStrategy());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.pulsar.tests.integration.containers;

import static java.time.temporal.ChronoUnit.SECONDS;

import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.testcontainers.containers.Network;

/**
* Initialize the Pulsar metadata
* Initialize the Pulsar metadata.
*/
@Slf4j
public class PulsarInitMetadataContainer extends GenericContainer<PulsarInitMetadataContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import lombok.extern.slf4j.Slf4j;

/**
* S3 simulation container
* S3 simulation container.
*/
@Slf4j
public class S3Container extends ChaosContainer<S3Container> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.pulsar.tests.integration.containers;

import static java.time.temporal.ChronoUnit.SECONDS;

import java.time.Duration;
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.pulsar.tests.integration.docker;

import static org.testng.Assert.assertTrue;
import lombok.Data;

/**
Expand All @@ -37,12 +36,14 @@ public void assertNoOutput() {
}

public void assertNoStdout() {
assertTrue(stdout.isEmpty(),
"stdout should be empty, but was '" + stdout + "'");
if (!stdout.isEmpty()) {
throw new IllegalArgumentException("stdout should be empty, but was '" + stdout + "'");
}
}

public void assertNoStderr() {
assertTrue(stderr.isEmpty(),
"stderr should be empty, but was '" + stderr + "'");
if (!stderr.isEmpty()) {
throw new IllegalArgumentException("stderr should be empty, but was '" + stderr + "'");
}
}
}
Loading

0 comments on commit 2cb5c2d

Please sign in to comment.