Skip to content

Commit

Permalink
Add BC Testing sample smoke test (apache#3355)
Browse files Browse the repository at this point in the history
  • Loading branch information
aahmed-se authored and srkukarni committed Jan 11, 2019
1 parent 69ab1f5 commit 4b8bd04
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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.backwardscompatibility;

import org.apache.pulsar.tests.integration.containers.PulsarContainer;
import org.apache.pulsar.tests.integration.topologies.PulsarStandaloneTestBase;
import org.testng.ITest;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;

public class PulsarStandaloneTestSuite2_2 extends PulsarStandaloneTestBase implements ITest {

@BeforeSuite
public void setUpCluster() throws Exception {
super.startCluster(PulsarContainer.PULSAR_2_2_IMAGE_NAME);
}

@AfterSuite
public void tearDownCluster() throws Exception {
super.stopCluster();
}

@Override
public String getTestName() {
return "pulsar-standalone-suite";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* 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.backwardscompatibility;

import org.testng.annotations.Test;

public class SmokeTest2_2 extends PulsarStandaloneTestSuite2_2 {

@Test(dataProvider = "StandaloneServiceUrlAndTopics")
public void testPublishAndConsume(String serviceUrl, boolean isPersistent) throws Exception {
super.testPublishAndConsume(serviceUrl, isPersistent);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ public abstract class PulsarContainer<SelfT extends PulsarContainer<SelfT>> exte
public static final int BROKER_PORT = 6650;
public static final int BROKER_HTTP_PORT = 8080;

private static final String IMAGE_NAME = "apachepulsar/pulsar-test-latest-version:latest";
public static final String DEFAULT_IMAGE_NAME = "apachepulsar/pulsar-test-latest-version:latest";
public static final String PULSAR_2_2_IMAGE_NAME = "apachepulsar/pulsar:2.2.0";
public static final String PULSAR_2_1_IMAGE_NAME = "apachepulsar/pulsar:2.1.0";
public static final String PULSAR_2_0_IMAGE_NAME = "apachepulsar/pulsar:2.0.0";

private final String hostname;
private final String serviceName;
Expand All @@ -65,7 +68,24 @@ public PulsarContainer(String clusterName,
int servicePort,
int httpPort,
String httpPath) {
super(clusterName, IMAGE_NAME);
super(clusterName, DEFAULT_IMAGE_NAME);
this.hostname = hostname;
this.serviceName = serviceName;
this.serviceEntryPoint = serviceEntryPoint;
this.servicePort = servicePort;
this.httpPort = httpPort;
this.httpPath = httpPath;
}

public PulsarContainer(String clusterName,
String hostname,
String serviceName,
String serviceEntryPoint,
int servicePort,
int httpPort,
String httpPath,
String pulsarImageName) {
super(clusterName, pulsarImageName);
this.hostname = hostname;
this.serviceName = serviceName;
this.serviceEntryPoint = serviceEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ public StandaloneContainer(String clusterName) {
BROKER_HTTP_PORT);
}

public StandaloneContainer(String clusterName, String pulsarImageName) {
super(clusterName,
NAME,
NAME + "-cluster",
"bin/pulsar",
BROKER_PORT,
BROKER_HTTP_PORT,
"",
pulsarImageName);
}

@Override
protected void configure() {
super.configure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.pulsar.tests.integration.suites.PulsarStandaloneTestSuite;
import org.testng.annotations.Test;


public class SmokeTest extends PulsarStandaloneTestSuite {

@Test(dataProvider = "StandaloneServiceUrlAndTopics")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.pulsar.tests.integration.suites;

import org.apache.pulsar.tests.integration.containers.PulsarContainer;
import org.apache.pulsar.tests.integration.topologies.PulsarStandaloneTestBase;
import org.testng.ITest;
import org.testng.annotations.AfterSuite;
Expand All @@ -27,15 +28,14 @@ public class PulsarStandaloneTestSuite extends PulsarStandaloneTestBase implemen

@BeforeSuite
public void setUpCluster() throws Exception {
super.startCluster();
super.startCluster(PulsarContainer.DEFAULT_IMAGE_NAME);
}

@AfterSuite
public void tearDownCluster() throws Exception {
super.stopCluster();
}


@Override
public String getTestName() {
return "pulsar-standalone-suite";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ public void start() throws Exception {

// start bookies
bookieContainers.values().forEach(BKContainer::start);
log.info("Successfully started {} bookie conntainers.", bookieContainers.size());
log.info("Successfully started {} bookie containers.", bookieContainers.size());

// start brokers
this.startAllBrokers();
log.info("Successfully started {} broker conntainers.", brokerContainers.size());
log.info("Successfully started {} broker containers.", brokerContainers.size());

// create proxy
proxyContainer.start();
Expand Down Expand Up @@ -394,7 +394,7 @@ private void startFunctionWorkersWithThreadContainerFactory(String suffix, int n
public synchronized void startWorkers() {
// Start workers that have been initialized
workerContainers.values().parallelStream().forEach(WorkerContainer::start);
log.info("Successfully started {} worker conntainers.", workerContainers.size());
log.info("Successfully started {} worker containers.", workerContainers.size());
}

public synchronized void stopWorkers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import lombok.Setter;
import lombok.experimental.Accessors;

import org.apache.pulsar.tests.integration.containers.PulsarContainer;
import org.testcontainers.containers.GenericContainer;

/**
Expand Down Expand Up @@ -78,11 +79,10 @@ public class PulsarClusterSpec {
@Default
int numFunctionWorkers = 0;


/**
* Enable a Preto Worker Node
* Enable a Presto Worker Node
*
* @return the flag whether presto worker is eanbled
* @return the flag whether presto worker is enabled
*/
@Default
boolean enablePrestoWorker = false;
Expand Down Expand Up @@ -116,4 +116,12 @@ public class PulsarClusterSpec {
*/
@Builder.Default
Map<String, String> classPathVolumeMounts = new TreeMap<>();

/**
* Pulsar Test Image Name
*
* @return the version of the pulsar test image to use
*/
@Default
String pulsarTestImage = PulsarContainer.DEFAULT_IMAGE_NAME;
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public static Object[][] serviceUrlAndTopics() {
protected static Network network;
protected static StandaloneContainer container;

protected void startCluster() throws Exception {
protected void startCluster(final String pulsarImageName) throws Exception {
network = Network.newNetwork();
String clusterName = PulsarClusterTestBase.randomName(8);
container = new StandaloneContainer(clusterName)
container = new StandaloneContainer(clusterName, pulsarImageName)
.withNetwork(network)
.withNetworkAliases(StandaloneContainer.NAME + "-" + clusterName);
container.start();
Expand Down

0 comments on commit 4b8bd04

Please sign in to comment.