Skip to content

Commit

Permalink
Refactored C++ tests (apache#3003)
Browse files Browse the repository at this point in the history
* Refactored C++ tests

* Refactored python tests

* Fixed format

* Mount maven repo from outside docker

* Fixed running test inside docker

* Wait to ensure change in dedup state is picked up

* Fixed ClientDeduplicationTest

* Fixed formatting
  • Loading branch information
merlimat authored Nov 20, 2018
1 parent 4f1b53c commit f8594e0
Show file tree
Hide file tree
Showing 19 changed files with 480 additions and 368 deletions.
2 changes: 1 addition & 1 deletion bin/pulsar-perf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
BINDIR=$(dirname "$0")
PULSAR_HOME=`cd $BINDIR/..;pwd`

DEFAULT_CLIENT_CONF=$PULSAR_HOME/conf/client.conf
DEFAULT_CLIENT_CONF=${PULSAR_CLIENT_CONF:-"$PULSAR_HOME/conf/client.conf"}
DEFAULT_LOG_CONF=$PULSAR_HOME/conf/log4j2.yaml

if [ -f "$PULSAR_HOME/conf/pulsar_env.sh" ]
Expand Down
98 changes: 98 additions & 0 deletions pulsar-client-cpp/pulsar-test-service-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash
#
# 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.
#

set -e

SRC_DIR=$(git rev-parse --show-toplevel)
cd $SRC_DIR

if [ -f /.dockerenv ]; then
# When running tests inside docker. Unpack the pulsar tgz
# because otherwise the classpath might not be correct
# in picking up the jars from local maven repo
export PULSAR_DIR=/tmp/pulsar-test-dist
rm -rf $PULSAR_DIR
mkdir $PULSAR_DIR
TGZ=$(ls -1 $SRC_DIR/distribution/server/target/apache-pulsar*bin.tar.gz | head -1)
tar xfz $TGZ -C $PULSAR_DIR --strip-components 1
else
export PULSAR_DIR=$SRC_DIR
fi

DATA_DIR=/tmp/pulsar-test-data
rm -rf $DATA_DIR
mkdir -p $DATA_DIR

# Copy TLS test certificates
mkdir -p $DATA_DIR/certs
cp $SRC_DIR/pulsar-broker/src/test/resources/authentication/tls/*.pem $DATA_DIR/certs

export PULSAR_STANDALONE_CONF=$SRC_DIR/pulsar-client-cpp/test-conf/standalone-ssl.conf
$PULSAR_DIR/bin/pulsar-daemon start standalone \
--no-functions-worker --no-stream-storage \
--zookeeper-dir $DATA_DIR/zookeeper \
--bookkeeper-dir $DATA_DIR/bookkeeper

echo "-- Wait for Pulsar service to be ready"
until curl http://localhost:8080/metrics > /dev/null 2>&1 ; do sleep 1; done

echo "-- Pulsar service is ready -- Configure permissions"

export PULSAR_CLIENT_CONF=$SRC_DIR/pulsar-client-cpp/test-conf/client-ssl.conf

# Create "standalone" cluster
$PULSAR_DIR/bin/pulsar-admin clusters create \
standalone \
--url http://localhost:8080/ \
--url-secure https://localhost:8443/ \
--broker-url pulsar://localhost:6650/ \
--broker-url-secure pulsar+ssl://localhost:6651/

# Create "public" tenant
$PULSAR_DIR/bin/pulsar-admin tenants create public -r "anonymous" -c "standalone"

# Create "public/default" with no auth required
$PULSAR_DIR/bin/pulsar-admin namespaces create public/default \
--clusters standalone
$PULSAR_DIR/bin/pulsar-admin namespaces grant-permission public/default \
--actions produce,consume \
--role "anonymous"

# Create "public/default-2" with no auth required
$PULSAR_DIR/bin/pulsar-admin namespaces create public/default-2 \
--clusters standalone
$PULSAR_DIR/bin/pulsar-admin namespaces grant-permission public/default-2 \
--actions produce,consume \
--role "anonymous"

# Create "public/default-3" with no auth required
$PULSAR_DIR/bin/pulsar-admin namespaces create public/default-3 \
--clusters standalone
$PULSAR_DIR/bin/pulsar-admin namespaces grant-permission public/default-3 \
--actions produce,consume \
--role "anonymous"

# Create "private" tenant
$PULSAR_DIR/bin/pulsar-admin tenants create private -r "" -c "standalone"

# Create "private/auth" with required authentication
$PULSAR_DIR/bin/pulsar-admin namespaces create private/auth --clusters standalone

echo "-- Ready to start tests"
26 changes: 26 additions & 0 deletions pulsar-client-cpp/pulsar-test-service-stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
#
# 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.
#

set -e

ROOT_DIR=$(git rev-parse --show-toplevel)
cd $ROOT_DIR

bin/pulsar-daemon stop standalone
Loading

0 comments on commit f8594e0

Please sign in to comment.