diff --git a/.github/workflows/backward-compat-tests.yml b/.github/workflows/backward-compat-tests.yml new file mode 100644 index 00000000000..3789495a957 --- /dev/null +++ b/.github/workflows/backward-compat-tests.yml @@ -0,0 +1,58 @@ +# +# 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: Backward compatibility tests + +on: + push: + pull_request: + branches: + - master + - branch-* + paths-ignore: + - 'site/**' + workflow_dispatch: + +env: + MAVEN_OPTS: -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.wagon.http.retryHandler.count=3 + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Tune Runner VM + uses: ./.github/actions/tune-runner-vm + + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build + run: ./gradlew stream:server:build -x test + - name: Test current server with old clients + run: ./gradlew :tests:backward-compat:current-server-old-clients:test || (tail -n +1 tests/backward-compat/current-server-old-clients/build/reports/tests/test/classes/* && tail -n +1 tests/backward-compat/current-server-old-clients/build/container-logs/**/* && exit 1) + - name: Test progressive upgrade + run: ./gradlew :tests:backward-compat:upgrade:test || (tail -n +1 tests/backward-compat/upgrade/build/reports/tests/test/classes/* && tail -n +1 tests/backward-compat/upgrade/build/container-logs/**/* && exit 1) + - name: Other tests + run: ./gradlew :tests:backward-compat:test -x tests:backward-compat:upgrade:test -x :tests:backward-compat:current-server-old-clients:test diff --git a/bin/common_gradle.sh b/bin/common_gradle.sh index 3f65c23f3a6..ec704499468 100755 --- a/bin/common_gradle.sh +++ b/bin/common_gradle.sh @@ -139,8 +139,8 @@ CLI_GC_OPTS=${CLI_GC_OPTS:-"${DEFAULT_CLI_GC_OPTS}"} CLI_GC_LOGGING_OPTS=${CLI_GC_LOGGING_OPTS:-"${DEFAULT_CLI_GC_LOGGING_OPTS}"} # module names -BOOKIE_SERVER_MODULE_NAME="bookkeeper-server" -TABLE_SERVICE_MODULE_NAME="stream-storage-server" +BOOKIE_SERVER_MODULE_NAME="(org.apache.bookkeeper-)?bookkeeper-server" +TABLE_SERVICE_MODULE_NAME="(org.apache.bookkeeper-)?stream-storage-server" is_released_binary() { if [ -d ${BK_HOME}/lib ]; then diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java index 6e31819c2c3..5615338e297 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java @@ -1035,8 +1035,8 @@ public PlacementPolicyAdherence isEnsembleAdheringToPlacementPolicy(List exerciseClients(List toVerify) { String zookeeper = BookKeeperClusterUtils.zookeeperConnectString(docker) - String currentVersion = System.getProperty("currentVersion") + String currentVersion = BookKeeperClusterUtils.CURRENT_VERSION def ledgers = [] def yahooCL = MavenClassLoader.forArtifact(yahooRepo, yahooArtifact) @@ -191,7 +191,7 @@ class TestCompatUpgradeYahooCustom { @Test public void testUpgradeYahooCustom() throws Exception { - String currentVersion = System.getProperty("currentVersion") + String currentVersion = BookKeeperClusterUtils.CURRENT_VERSION String yahooVersion = "4.3-yahoo" BookKeeperClusterUtils.metadataFormatIfNeeded(docker, yahooVersion) diff --git a/tests/docker-images/all-released-versions-image/Dockerfile b/tests/docker-images/all-released-versions-image/Dockerfile index 1cf9c6fd5c1..9c0301fa205 100644 --- a/tests/docker-images/all-released-versions-image/Dockerfile +++ b/tests/docker-images/all-released-versions-image/Dockerfile @@ -30,35 +30,15 @@ RUN apt-get update && apt-get install -qy wget supervisor bash \ RUN mkdir /tarballs WORKDIR /tarballs -RUN wget -nv https://archive.apache.org/dist/zookeeper/bookkeeper/bookkeeper-4.0.0/binaries/bookkeeper-server-4.0.0-bin.tar.gz{,.sha1,.md5,.asc} RUN wget -nv https://archive.apache.org/dist/zookeeper/bookkeeper/bookkeeper-4.1.0/bookkeeper-server-4.1.0-bin.tar.gz{,.sha1,.md5,.asc} RUN wget -nv https://archive.apache.org/dist/zookeeper/bookkeeper/bookkeeper-4.2.0/bookkeeper-server-4.2.0-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/zookeeper/bookkeeper/bookkeeper-4.2.1/bookkeeper-server-4.2.1-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/zookeeper/bookkeeper/bookkeeper-4.2.2/bookkeeper-server-4.2.2-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/zookeeper/bookkeeper/bookkeeper-4.2.3/bookkeeper-server-4.2.3-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/zookeeper/bookkeeper/bookkeeper-4.3.0/bookkeeper-server-4.3.0-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.2.4/bookkeeper-server-4.2.4-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.3.0/bookkeeper-server-4.3.0-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.3.1/bookkeeper-server-4.3.1-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.3.2/bookkeeper-server-4.3.2-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.4.0/bookkeeper-server-4.4.0-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.5.0/bookkeeper-server-4.5.0-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.5.1/bookkeeper-server-4.5.1-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.6.0/bookkeeper-server-4.6.0-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.6.1/bookkeeper-server-4.6.1-bin.tar.gz{,.sha1,.md5,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.6.2/bookkeeper-server-4.6.2-bin.tar.gz{,.sha1,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.7.0/bookkeeper-server-4.7.0-bin.tar.gz{,.sha1,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.7.1/bookkeeper-server-4.7.1-bin.tar.gz{,.sha1,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.7.2/bookkeeper-server-4.7.2-bin.tar.gz{,.sha512,.asc} RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.8.2/bookkeeper-server-4.8.2-bin.tar.gz{,.sha512,.asc} RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.9.2/bookkeeper-server-4.9.2-bin.tar.gz{,.sha512,.asc} RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.10.0/bookkeeper-server-4.10.0-bin.tar.gz{,.sha512,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.11.0/bookkeeper-server-4.11.0-bin.tar.gz{,.sha512,.asc} RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.11.1/bookkeeper-server-4.11.1-bin.tar.gz{,.sha512,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.12.0/bookkeeper-server-4.12.0-bin.tar.gz{,.sha512,.asc} RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.12.1/bookkeeper-server-4.12.1-bin.tar.gz{,.sha512,.asc} RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.13.0/bookkeeper-server-4.13.0-bin.tar.gz{,.sha512,.asc} -RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.14.0/bookkeeper-server-4.14.0-bin.tar.gz{,.sha512,.asc} +RUN wget -nv https://archive.apache.org/dist/bookkeeper/bookkeeper-4.14.3/bookkeeper-server-4.14.3-bin.tar.gz{,.sha512,.asc} RUN wget -nv https://archive.apache.org/dist/incubator/pulsar/pulsar-1.21.0-incubating/apache-pulsar-1.21.0-incubating-bin.tar.gz{,.asc} RUN wget -nv https://dist.apache.org/repos/dist/release/bookkeeper/KEYS diff --git a/tests/docker-images/all-released-versions-image/image_builder.sh b/tests/docker-images/all-released-versions-image/image_builder.sh new file mode 100755 index 00000000000..a06c29e49b9 --- /dev/null +++ b/tests/docker-images/all-released-versions-image/image_builder.sh @@ -0,0 +1,32 @@ +#!/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 +IMAGE_NAME=apachebookkeeper/bookkeeper-all-released-versions:latest +FORCE_REBUILD="${BOOKKEEPER_DOCKER_IMAGES_FORCE_REBUILD:-false}" +if [[ "$FORCE_REBUILD" != "true" && "$(docker images -q $IMAGE_NAME 2> /dev/null)" != "" ]]; then + echo "reusing local image: $IMAGE_NAME" + exit 0 +fi + +SCRIPT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) + +## BASE_DIR will be ./bookkeeper/ +BASE_DIR=${SCRIPT_DIR}/../../../ +docker build -t ${IMAGE_NAME} "${BASE_DIR}"/tests/docker-images/all-released-versions-image \ No newline at end of file diff --git a/tests/docker-images/all-released-versions-image/scripts/update-conf-and-boot.sh b/tests/docker-images/all-released-versions-image/scripts/update-conf-and-boot.sh index ba082d616ec..d22d135aa77 100755 --- a/tests/docker-images/all-released-versions-image/scripts/update-conf-and-boot.sh +++ b/tests/docker-images/all-released-versions-image/scripts/update-conf-and-boot.sh @@ -29,14 +29,5 @@ sed -i "s|metadataServiceUri=.*|metadataServiceUri=zk+hierarchical://$BK_ZKCONNE # 4.7.0 includes journalDirectories instead of `journalDirectory` sed -i "s|journalDirectories=.*|journalDirectories=$BK_JOURNALDIR|" /opt/bookkeeper/*/conf/{bk_server,bookkeeper}.conf -# 4.3.1 & 4.3.2 shipped with a broken confs -sed -i "s|\(# \)\?logSizeLimit=.*|logSizeLimit=1073741824|" /opt/bookkeeper/4.3.1/conf/bk_server.conf -sed -i "s|\(# \)\?logSizeLimit=.*|logSizeLimit=1073741824|" /opt/bookkeeper/4.3.2/conf/bk_server.conf - -# 4.5.1 shipped with a broken conf -sed -i "s|\(# \)\?statsProviderClass=.*|# disabled stats |" /opt/bookkeeper/4.5.1/conf/bk_server.conf - -# 4.6.0 breaks supervisor -echo "stopasgroup=true" >> /etc/supervisord/conf.d/bookkeeper-4.6.0.conf exec /usr/bin/supervisord -c /etc/supervisord.conf diff --git a/tests/docker-images/all-versions-image/image_builder.sh b/tests/docker-images/all-versions-image/image_builder.sh new file mode 100755 index 00000000000..7b553362303 --- /dev/null +++ b/tests/docker-images/all-versions-image/image_builder.sh @@ -0,0 +1,37 @@ +#!/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 +IMAGE_NAME=apachebookkeeper/bookkeeper-all-versions:latest +FORCE_REBUILD="${BOOKKEEPER_DOCKER_IMAGES_FORCE_REBUILD:-false}" +if [[ "$FORCE_REBUILD" != "true" && "$(docker images -q $IMAGE_NAME 2> /dev/null)" != "" ]]; then + echo "reusing local image: $IMAGE_NAME" + exit 0 +fi + +SCRIPT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) + +## BASE_DIR will be ./bookkeeper/ +BASE_DIR=${SCRIPT_DIR}/../../../ +VERSION=${1:-UNKNOWN} +mkdir -p "${BASE_DIR}"/tests/docker-images/all-versions-image/build +ls -la ${BASE_DIR}bookkeeper-dist/server/build/distributions +cp ${BASE_DIR}bookkeeper-dist/server/build/distributions/bookkeeper-server-${VERSION}-bin.tar.gz "${BASE_DIR}"/tests/docker-images/all-versions-image/build/ +TARBALL=build/bookkeeper-server-${VERSION}-bin.tar.gz +docker build -t ${IMAGE_NAME} "${BASE_DIR}"tests/docker-images/all-versions-image --build-arg BK_TARBALL="${TARBALL}" \ No newline at end of file diff --git a/tests/docker-images/all-versions-image/scripts/update-conf-and-boot.sh b/tests/docker-images/all-versions-image/scripts/update-conf-and-boot.sh index 6cddae39561..4248862648b 100644 --- a/tests/docker-images/all-versions-image/scripts/update-conf-and-boot.sh +++ b/tests/docker-images/all-versions-image/scripts/update-conf-and-boot.sh @@ -24,14 +24,4 @@ sed -i "s|journalDirectory=.*|journalDirectory=$BK_JOURNALDIR|" /opt/bookkeeper/ sed -i "s|ledgerDirectories=.*|ledgerDirectories=$BK_LEDGERDIR|" /opt/bookkeeper/*/conf/bk_server.conf sed -i "s|zkServers=.*|zkServers=$BK_ZKCONNECTSTRING|" /opt/bookkeeper/*/conf/bk_server.conf -# 4.3.1 & 4.3.2 shipped with a broken confs -sed -i "s|\(# \)\?logSizeLimit=.*|logSizeLimit=1073741824|" /opt/bookkeeper/4.3.1/conf/bk_server.conf -sed -i "s|\(# \)\?logSizeLimit=.*|logSizeLimit=1073741824|" /opt/bookkeeper/4.3.2/conf/bk_server.conf - -# 4.5.1 shipped with a broken conf -sed -i "s|\(# \)\?statsProviderClass=.*|# disabled stats |" /opt/bookkeeper/4.5.1/conf/bk_server.conf - -# 4.6.0 breaks supervisor -echo "stopasgroup=true" >> /etc/supervisord/conf.d/bookkeeper-4.6.0.conf - exec /usr/bin/supervisord -c /etc/supervisord.conf diff --git a/tests/docker-images/build.gradle b/tests/docker-images/build.gradle new file mode 100644 index 00000000000..20055067148 --- /dev/null +++ b/tests/docker-images/build.gradle @@ -0,0 +1,23 @@ +/* + * 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. + */ +task buildImages(type:Exec) { + dependsOn(':stream:server:distTar') + dependsOn(':bookkeeper-dist-server:distTar') + commandLine './images_builder.sh', project.rootProject.version +} diff --git a/tests/docker-images/current-version-image/Dockerfile b/tests/docker-images/current-version-image/Dockerfile index 4a73f2e9187..9a74fd9b74b 100644 --- a/tests/docker-images/current-version-image/Dockerfile +++ b/tests/docker-images/current-version-image/Dockerfile @@ -47,17 +47,17 @@ RUN set -x \ && yum clean all # untar tarballs -ADD target/${DISTRO_NAME}.tar.gz /opt +ADD build/package/${DISTRO_NAME}.tar.gz /opt RUN mv /opt/${PKG_NAME} /opt/bookkeeper WORKDIR /opt/bookkeeper -COPY target/scripts /opt/bookkeeper/scripts +COPY build/package/scripts /opt/bookkeeper/scripts COPY scripts/install-python-client.sh /opt/bookkeeper/scripts RUN chmod +x -R /opt/bookkeeper/scripts/ # copy the python client -ADD target/bookkeeper-client/ /opt/bookkeeper/bookkeeper-client +ADD build/package/bookkeeper-client/ /opt/bookkeeper/bookkeeper-client RUN /opt/bookkeeper/scripts/install-python-client.sh ENTRYPOINT [ "/bin/bash", "/opt/bookkeeper/scripts/entrypoint.sh" ] diff --git a/tests/docker-images/current-version-image/image_builder.sh b/tests/docker-images/current-version-image/image_builder.sh new file mode 100755 index 00000000000..8719bd5df4a --- /dev/null +++ b/tests/docker-images/current-version-image/image_builder.sh @@ -0,0 +1,46 @@ +#!/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 +IMAGE_NAME=apachebookkeeper/bookkeeper-current:latest +FORCE_REBUILD="${BOOKKEEPER_DOCKER_IMAGES_FORCE_REBUILD:-false}" +if [[ "$FORCE_REBUILD" != "true" && "$(docker images -q $IMAGE_NAME 2> /dev/null)" != "" ]]; then + echo "reusing local image: $IMAGE_NAME" + exit 0 +fi +SCRIPT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) + +## BASE_DIR will be ./bookkeeper/ +BASE_DIR=${SCRIPT_DIR}/../../../ + +mkdir -p ${BASE_DIR}/tests/docker-images/current-version-image/build +OUTPUT_DIR=${BASE_DIR}/tests/docker-images/current-version-image/build/package +rm -rf $OUTPUT_DIR +mkdir -p $OUTPUT_DIR + +# Python Client +${BASE_DIR}/stream/clients/python/scripts/docker_build.sh + +cp -Rp "${BASE_DIR}stream/clients/python/dist" "${OUTPUT_DIR}/bookkeeper-client" +cp -Rp "${BASE_DIR}docker/scripts" "${OUTPUT_DIR}/scripts" + +VERSION=${1:-UNKNOWN} +cp -p ${BASE_DIR}bookkeeper-dist/server/build/distributions/bookkeeper-server-${VERSION}-bin.tar.gz "${OUTPUT_DIR}"/bookkeeper-dist-server-${VERSION}-bin.tar.gz + +docker build -t ${IMAGE_NAME} --build-arg BK_VERSION="${VERSION}" "${BASE_DIR}"/tests/docker-images/current-version-image \ No newline at end of file diff --git a/tests/docker-images/images_builder.sh b/tests/docker-images/images_builder.sh new file mode 100755 index 00000000000..b000cb2a784 --- /dev/null +++ b/tests/docker-images/images_builder.sh @@ -0,0 +1,32 @@ +#!/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 +BK_VERSION=$1 +SCRIPT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) +echo "BK_VERSION=${BK_VERSION}" + +## BASE_DIR will be ./bookkeeper/ +BASE_DIR=${SCRIPT_DIR}/../../ +cd ${BASE_DIR} +time /bin/bash -e tests/docker-images/statestore-image/image_builder.sh +time /bin/bash -e tests/docker-images/all-released-versions-image/image_builder.sh +time /bin/bash -e tests/docker-images/all-versions-image/image_builder.sh ${BK_VERSION} +time /bin/bash -e tests/docker-images/current-version-image/image_builder.sh ${BK_VERSION} + diff --git a/tests/docker-images/statestore-image/Dockerfile b/tests/docker-images/statestore-image/Dockerfile index 0c8098a49f6..6d36bdacf6f 100644 --- a/tests/docker-images/statestore-image/Dockerfile +++ b/tests/docker-images/statestore-image/Dockerfile @@ -46,8 +46,8 @@ RUN mkdir /opt/bookkeeper/conf RUN mkdir /opt/bookkeeper/scripts ### -----Copy Jars------### -ADD ./dist/server.tar.gz /opt/ -RUN mv /opt/server/lib/*.jar /opt/bookkeeper/lib/ +ADD ./dist/server-bin.tar.gz /opt/ +RUN mv /opt/server-bin/lib/*.jar /opt/bookkeeper/lib/ ### --------------------### ### ----Copy scripts----------### diff --git a/tests/docker-images/statestore-image/image_builder.sh b/tests/docker-images/statestore-image/image_builder.sh index 6cc6cde1c46..e17ee608b75 100755 --- a/tests/docker-images/statestore-image/image_builder.sh +++ b/tests/docker-images/statestore-image/image_builder.sh @@ -18,22 +18,35 @@ # * limitations under the License. # */ +IMAGE_NAME=apachebookkeeper/bookkeeper-current:latest +FORCE_REBUILD="${BOOKKEEPER_DOCKER_IMAGES_FORCE_REBUILD:-false}" +if [[ "$FORCE_REBUILD" != "true" && "$(docker images -q $IMAGE_NAME 2> /dev/null)" != "" ]]; then + echo "reusing local image: $IMAGE_NAME" + exit 0 +fi SCRIPT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) ## BASE_DIR will be ./bookkeeper/ BASE_DIR=${SCRIPT_DIR}/../../../ +rm -rf "${BASE_DIR}"/tests/docker-images/statestore-image/dist +rm -rf "${BASE_DIR}"/tests/docker-images/statestore-image/scripts +rm -rf "${BASE_DIR}"/tests/docker-images/statestore-image/temp_conf +rm -rf "${BASE_DIR}"/tests/docker-images/statestore-image/temp_bin + mkdir "${BASE_DIR}"/tests/docker-images/statestore-image/dist mkdir "${BASE_DIR}"/tests/docker-images/statestore-image/scripts mkdir "${BASE_DIR}"/tests/docker-images/statestore-image/temp_conf mkdir "${BASE_DIR}"/tests/docker-images/statestore-image/temp_bin -cp "${BASE_DIR}"/stream/server/build/distributions/server.tar.gz "${BASE_DIR}"/tests/docker-images/statestore-image/dist +cp "${BASE_DIR}"/stream/server/build/distributions/server-bin.tar.gz "${BASE_DIR}"/tests/docker-images/statestore-image/dist cp "${BASE_DIR}"/docker/scripts/* "${BASE_DIR}"/tests/docker-images/statestore-image/scripts cp "${BASE_DIR}"/conf/* "${BASE_DIR}"/tests/docker-images/statestore-image/temp_conf cp "${BASE_DIR}"/bin/* "${BASE_DIR}"/tests/docker-images/statestore-image/temp_bin -docker build -t apachebookkeeper/bookkeeper-current:latest "${BASE_DIR}"/tests/docker-images/statestore-image +docker build -t ${IMAGE_NAME} "${BASE_DIR}"/tests/docker-images/statestore-image rm -rf "${BASE_DIR}"/tests/docker-images/statestore-image/dist rm -rf "${BASE_DIR}"/tests/docker-images/statestore-image/scripts rm -rf "${BASE_DIR}"/tests/docker-images/statestore-image/temp_conf -rm -rf "${BASE_DIR}"/tests/docker-images/statestore-image/temp_bin \ No newline at end of file +rm -rf "${BASE_DIR}"/tests/docker-images/statestore-image/temp_bin + + diff --git a/tests/integration-tests-topologies/src/main/java/org/apache/bookkeeper/tests/containers/wait/ZKWaitStrategy.java b/tests/integration-tests-topologies/src/main/java/org/apache/bookkeeper/tests/containers/wait/ZKWaitStrategy.java deleted file mode 100644 index 5b4104110a3..00000000000 --- a/tests/integration-tests-topologies/src/main/java/org/apache/bookkeeper/tests/containers/wait/ZKWaitStrategy.java +++ /dev/null @@ -1,63 +0,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. - */ - -package org.apache.bookkeeper.tests.containers.wait; - -import java.util.concurrent.TimeUnit; -import lombok.extern.slf4j.Slf4j; -import org.apache.bookkeeper.tests.integration.utils.BookKeeperClusterUtils; -import org.rnorth.ducttape.TimeoutException; -import org.rnorth.ducttape.unreliables.Unreliables; -import org.testcontainers.containers.ContainerLaunchException; -import org.testcontainers.containers.wait.strategy.AbstractWaitStrategy; - -/** - * Wait Strategy until zookeeper container is up. - */ -@Slf4j -public class ZKWaitStrategy extends AbstractWaitStrategy { - - private final int zkPort; - - public ZKWaitStrategy(int zkPort) { - this.zkPort = zkPort; - } - - @Override - protected void waitUntilReady() { - String hostname = waitStrategyTarget.getContainerIpAddress(); - int externalPort = waitStrategyTarget.getMappedPort(zkPort); - - try { - Unreliables.retryUntilTrue( - (int) startupTimeout.getSeconds(), - TimeUnit.SECONDS, - () -> getRateLimiter().getWhenReady( - () -> { - log.info("Check if zookeeper is running at {}:{}", hostname, externalPort); - return BookKeeperClusterUtils.zookeeperRunning( - hostname, externalPort - ); - })); - } catch (TimeoutException te) { - throw new ContainerLaunchException( - "Timed out waiting for zookeeper to be ready"); - } - } - -} diff --git a/tests/integration-tests-topologies/src/main/resources/cube-definitions/3-node-all-version-unstarted.yaml b/tests/integration-tests-topologies/src/main/resources/cube-definitions/3-node-all-version-unstarted.yaml index c0a2938fc51..a422f4372fc 100644 --- a/tests/integration-tests-topologies/src/main/resources/cube-definitions/3-node-all-version-unstarted.yaml +++ b/tests/integration-tests-topologies/src/main/resources/cube-definitions/3-node-all-version-unstarted.yaml @@ -22,7 +22,7 @@ networks: driver: bridge zookeeper*: - image: zookeeper:3.4.11 + image: zookeeper:3.6.2 await: strategy: org.apache.bookkeeper.tests.integration.utils.ZooKeeperAwaitStrategy aliases: @@ -41,6 +41,7 @@ bookkeeper1*: - customBeforeStopAction: strategy: org.apache.bookkeeper.tests.integration.utils.BookKeeperLogsToTargetDirStopAction networkMode: testnetwork* + exposedPorts: [3181/tcp, 8080/tcp] bookkeeper2*: image: apachebookkeeper/bookkeeper-all-versions @@ -51,6 +52,7 @@ bookkeeper2*: - customBeforeStopAction: strategy: org.apache.bookkeeper.tests.integration.utils.BookKeeperLogsToTargetDirStopAction networkMode: testnetwork* + exposedPorts: [ 3181/tcp, 8080/tcp ] bookkeeper3*: image: apachebookkeeper/bookkeeper-all-versions @@ -61,4 +63,5 @@ bookkeeper3*: - customBeforeStopAction: strategy: org.apache.bookkeeper.tests.integration.utils.BookKeeperLogsToTargetDirStopAction networkMode: testnetwork* + exposedPorts: [ 3181/tcp, 8080/tcp ] diff --git a/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/integration/utils/BookKeeperClusterUtils.java b/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/integration/utils/BookKeeperClusterUtils.java index 2d4fc27cc8b..56960061def 100644 --- a/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/integration/utils/BookKeeperClusterUtils.java +++ b/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/integration/utils/BookKeeperClusterUtils.java @@ -17,12 +17,9 @@ */ package org.apache.bookkeeper.tests.integration.utils; -import static java.nio.charset.StandardCharsets.UTF_8; - import com.github.dockerjava.api.DockerClient; - -import java.io.IOException; -import java.net.Socket; +import java.util.Arrays; +import java.util.List; import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -31,6 +28,7 @@ import lombok.Cleanup; +import lombok.SneakyThrows; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.Watcher.Event.KeeperState; import org.apache.zookeeper.ZooDefs.Ids; @@ -43,8 +41,22 @@ * Utils for interacting a bookkeeper cluster used for integration tests. */ public class BookKeeperClusterUtils { + public static final String CURRENT_VERSION = System.getProperty("currentVersion"); + public static final List OLD_CLIENT_VERSIONS = + Arrays.asList("4.8.2", "4.9.2", "4.10.0", "4.11.1", "4.12.1", "4.13.0", "4.14.3"); + private static final List OLD_CLIENT_VERSIONS_WITH_CURRENT_LEDGER_METADATA_FORMAT = + Arrays.asList("4.9.2", "4.10.0", "4.11.1", "4.12.1", "4.13.0", "4.14.3"); + + private static final List OLD_CLIENT_VERSIONS_WITH_OLD_BK_BIN_NAME = + Arrays.asList("4.9.2", "4.10.0", "4.11.1", "4.12.1", "4.13.0", "4.14.3", "4.3-yahoo"); + + private static final Logger LOG = LoggerFactory.getLogger(BookKeeperClusterUtils.class); + public static boolean hasVersionLatestMetadataFormat(String version) { + return OLD_CLIENT_VERSIONS_WITH_CURRENT_LEDGER_METADATA_FORMAT.contains(version); + } + public static String zookeeperConnectString(DockerClient docker) { return DockerUtils.cubeIdsMatching("zookeeper").stream() .map((id) -> DockerUtils.getContainerIP(docker, id)).collect(Collectors.joining(":")); @@ -63,22 +75,19 @@ public static ZooKeeper zookeeperClient(DockerClient docker) throws Exception { return zk; } + @SneakyThrows public static boolean zookeeperRunning(DockerClient docker, String containerId) { String ip = DockerUtils.getContainerIP(docker, containerId); - return zookeeperRunning(ip, 2181); - } - public static boolean zookeeperRunning(String ip, int port) { - try (Socket socket = new Socket(ip, port)) { - socket.setSoTimeout(1000); - socket.getOutputStream().write("ruok".getBytes(UTF_8)); - byte[] resp = new byte[4]; - if (socket.getInputStream().read(resp) == 4) { - return new String(resp, UTF_8).equals("imok"); - } - } catch (IOException e) { - // ignore, we'll return fallthrough to return false - } - return false; + CompletableFuture future = new CompletableFuture<>(); + @Cleanup + ZooKeeper zk = new ZooKeeper(ip + ":2181", 10000, + (e) -> { + if (e.getState().equals(KeeperState.SyncConnected)) { + future.complete(null); + } + }); + future.get(); + return true; } public static void legacyMetadataFormat(DockerClient docker) throws Exception { @@ -92,7 +101,7 @@ public static boolean metadataFormatIfNeeded(DockerClient docker, String version @Cleanup ZooKeeper zk = BookKeeperClusterUtils.zookeeperClient(docker); if (zk.exists("/ledgers", false) == null) { - String bookkeeper = "/opt/bookkeeper/" + version + "/bin/bookkeeper"; + String bookkeeper = "/opt/bookkeeper/" + version + "/bin/" + computeBinFilenameByVersion(version); runOnAnyBookie(docker, bookkeeper, "shell", "metaformat", "-nonInteractive"); return true; } else { @@ -122,7 +131,7 @@ public static String createDlogNamespaceIfNeeded(DockerClient docker, } public static void formatAllBookies(DockerClient docker, String version) throws Exception { - String bookkeeper = "/opt/bookkeeper/" + version + "/bin/bookkeeper"; + String bookkeeper = "/opt/bookkeeper/" + version + "/bin/" + computeBinFilenameByVersion(version); BookKeeperClusterUtils.runOnAllBookies(docker, bookkeeper, "shell", "bookieformat", "-nonInteractive"); } @@ -250,4 +259,11 @@ public static boolean waitAllBookieUp(DockerClient docker) { .map((b) -> waitBookieUp(docker, b, 10, TimeUnit.SECONDS)) .reduce(true, BookKeeperClusterUtils::allTrue); } + + private static String computeBinFilenameByVersion(String version) { + if (OLD_CLIENT_VERSIONS_WITH_OLD_BK_BIN_NAME.contains(version)) { + return "bookkeeper"; + } + return "bookkeeper_gradle"; + } } diff --git a/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/integration/utils/DockerUtils.java b/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/integration/utils/DockerUtils.java index 415c1b3e373..35d58e42dc9 100644 --- a/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/integration/utils/DockerUtils.java +++ b/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/integration/utils/DockerUtils.java @@ -54,9 +54,9 @@ public class DockerUtils { private static final Logger LOG = LoggerFactory.getLogger(DockerUtils.class); private static File getTargetDirectory(String containerId) { - String base = System.getProperty("maven.buildDirectory"); + String base = System.getProperty("gradle.buildDirectory"); if (base == null) { - base = "target"; + base = "build"; } File directory = new File(base + "/container-logs/" + containerId); if (!directory.exists() && !directory.mkdirs()) { diff --git a/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/integration/utils/MavenClassLoader.java b/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/integration/utils/MavenClassLoader.java index 2404f21a210..9c24186f920 100644 --- a/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/integration/utils/MavenClassLoader.java +++ b/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/integration/utils/MavenClassLoader.java @@ -21,7 +21,12 @@ import groovy.lang.Closure; +import java.io.Closeable; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; import java.lang.invoke.MethodHandles; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; @@ -29,37 +34,43 @@ import java.lang.reflect.Proxy; import java.net.URL; import java.net.URLClassLoader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional; +import java.util.zip.GZIPInputStream; +import org.apache.commons.compress.archivers.ArchiveStreamFactory; +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; +import org.apache.commons.io.IOUtils; import org.jboss.shrinkwrap.resolver.api.maven.ConfigurableMavenResolverSystem; import org.jboss.shrinkwrap.resolver.api.maven.Maven; import org.jboss.shrinkwrap.resolver.api.maven.ScopeType; import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependencies; import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependency; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * A maven class loader for resolving and loading maven artifacts. */ public class MavenClassLoader implements AutoCloseable { - private static final Logger LOG = LoggerFactory.getLogger(MavenClassLoader.class); - private MavenClassLoader(URLClassLoader cl) { + private static List currentVersionLibs; + + private MavenClassLoader(ClassLoader cl) { this.classloader = cl; } - private final URLClassLoader classloader; + private final ClassLoader classloader; public static MavenClassLoader forArtifact(String repo, String mainArtifact) throws Exception { return createClassLoader(Maven.configureResolver().withRemoteRepo("custom", repo, "default"), - mainArtifact); + mainArtifact); } public static MavenClassLoader forArtifact(String mainArtifact) throws Exception { @@ -69,55 +80,103 @@ public static MavenClassLoader forArtifact(String mainArtifact) throws Exception private static MavenClassLoader createClassLoader(ConfigurableMavenResolverSystem resolver, String mainArtifact) throws Exception { Optional slf4jVersion = Arrays.stream(resolver.resolve(mainArtifact) - .withTransitivity().asResolvedArtifact()) - .filter((a) -> a.getCoordinate().getGroupId().equals("org.slf4j") - && a.getCoordinate().getArtifactId().equals("slf4j-1.2-api")) - .map((a) -> a.getCoordinate().getVersion()) - .findFirst(); + .withTransitivity().asResolvedArtifact()) + .filter((a) -> a.getCoordinate().getGroupId().equals("org.slf4j") + && a.getCoordinate().getArtifactId().equals("slf4j-1.2-api")) + .map((a) -> a.getCoordinate().getVersion()) + .findFirst(); List deps = Lists.newArrayList( MavenDependencies.createDependency( - mainArtifact, ScopeType.COMPILE, false, - MavenDependencies.createExclusion("log4j:log4j"))); + mainArtifact, ScopeType.COMPILE, false)); if (slf4jVersion.isPresent()) { deps.add(MavenDependencies.createDependency("org.slf4j:slf4j-simple:" + slf4jVersion.get(), - ScopeType.COMPILE, false)); + ScopeType.COMPILE, false)); } File[] files = resolver.addDependencies(deps.toArray(new MavenDependency[0])) - .resolve().withTransitivity().asFile(); + .resolve().withTransitivity().asFile(); + return createClassLoader(files); + } + + private static MavenClassLoader createClassLoader(File[] jars) { + final ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); URLClassLoader cl = AccessController.doPrivileged( new PrivilegedAction() { @Override public URLClassLoader run() { - return new URLClassLoader(Arrays.stream(files) - .map((f) -> { - try { - return f.toURI().toURL(); - } catch (Throwable t) { - throw new RuntimeException(t); - } - }) - .toArray(URL[]::new), - ClassLoader.getSystemClassLoader()); + /** + * Child-first URLClassLoader. + * This is needed because Gradle uses a different version of + * Netty and it is placed in the System Class loader. + */ + return new URLClassLoader(Arrays.stream(jars) + .map((f) -> { + try { + return f.toURI().toURL(); + } catch (Throwable t) { + throw new RuntimeException(t); + } + }) + .toArray(URL[]::new), + systemClassLoader) { + + @Override + protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { + Class loadedClass = findLoadedClass(name); + if (loadedClass == null) { + try { + loadedClass = findClass(name); + } catch (ClassNotFoundException ignored) { + } + if (loadedClass == null) { + try { + loadedClass = systemClassLoader.loadClass(name); + } catch (ClassNotFoundException e) { + } + } + } + if (resolve && loadedClass != null) { + resolveClass(loadedClass); + } + return loadedClass; + } + }; } }); return new MavenClassLoader(cl); } public static MavenClassLoader forBookKeeperVersion(String version) throws Exception { - return forArtifact("org.apache.bookkeeper:bookkeeper-server:" + version); + if (version.equals(BookKeeperClusterUtils.CURRENT_VERSION)) { + return forBookkeeperCurrentVersion(); + } + return forArtifact("org.apache.bookkeeper:bookkeeper-server:" + version); } - public Object getClass(String className) throws Exception { - return Class.forName(className, true, classloader); + private static MavenClassLoader forBookkeeperCurrentVersion() throws Exception { + if (currentVersionLibs == null) { + final String version = BookKeeperClusterUtils.CURRENT_VERSION; + final String artifactName = "bookkeeper-server-" + version + "-bin"; + final Path tarFile = Paths.get("..", "..", "..", + "bookkeeper-dist", "server", "build", "distributions", artifactName + ".tar.gz"); + final File tempDir = new File("build"); + extractTarGz(tarFile.toFile(), tempDir); + List jars = new ArrayList<>(); + Files.list(Paths.get(tempDir.getAbsolutePath(), "bookkeeper-server-" + version, "lib")) + .forEach(path -> { + jars.add(path.toFile()); + }); + currentVersionLibs = jars; + } + return createClassLoader(currentVersionLibs.toArray(new File[]{})); } public Object callStaticMethod(String className, String methodName, ArrayList args) throws Exception { Class klass = Class.forName(className, true, classloader); try { - Class[] paramTypes = args.stream().map((a)-> a.getClass()).toArray(Class[]::new); + Class[] paramTypes = args.stream().map((a) -> a.getClass()).toArray(Class[]::new); return klass.getMethod(methodName, paramTypes).invoke(null, args.stream().toArray(Object[]::new)); } catch (NoSuchMethodException nsme) { // maybe the params are primitives @@ -164,12 +223,34 @@ public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { public Object newInstance(String className, Object... args) throws Exception { Class klass = Class.forName(className, true, classloader); - return klass.getConstructor(Arrays.stream(args).map((a)-> a.getClass()).toArray(Class[]::new)) - .newInstance(args); + return klass + .getConstructor(Arrays.stream(args).map((a) -> + a.getClass()) + .toArray(Class[]::new)) + .newInstance(args); } public Object newBookKeeper(String zookeeper) throws Exception { - return newInstance("org.apache.bookkeeper.client.BookKeeper", zookeeper); + Class clientConfigurationClass = Class + .forName("org.apache.bookkeeper.conf.ClientConfiguration", true, classloader); + Object clientConfiguration = newInstance("org.apache.bookkeeper.conf.ClientConfiguration"); + clientConfigurationClass + .getMethod("setZkServers", String.class) + .invoke(clientConfiguration, zookeeper); + + // relax timeouts in order to get tests passing in limited environments + clientConfigurationClass + .getMethod("setReadTimeout", int.class) + .invoke(clientConfiguration, 15); + + clientConfigurationClass + .getMethod("setZkTimeout", int.class) + .invoke(clientConfiguration, 30_000); + Class klass = Class.forName("org.apache.bookkeeper.client.BookKeeper", true, classloader); + return klass + .getConstructor(clientConfigurationClass) + .newInstance(clientConfiguration); + } public Object digestType(String type) throws Exception { @@ -184,6 +265,54 @@ public Object digestType(String type) throws Exception { @Override public void close() throws Exception { - classloader.close(); + if (classloader instanceof Closeable) { + ((Closeable) classloader).close(); + } + } + + private static void extractTarGz(File tarGz, File output) throws Exception { + File tarFile = new File(output, tarGz.getName().replace(".gz", "")); + tarFile.delete(); + deCompressGZipFile(tarGz, tarFile); + unTar(tarFile, output); } + + private static File deCompressGZipFile(File gZippedFile, File tarFile) throws IOException { + try (GZIPInputStream gZIPInputStream = new GZIPInputStream(new FileInputStream(gZippedFile)); + FileOutputStream fos = new FileOutputStream(tarFile)) { + byte[] buffer = new byte[1024]; + int len; + while ((len = gZIPInputStream.read(buffer)) > 0) { + fos.write(buffer, 0, len); + } + } + return tarFile; + } + + private static void unTar(final File inputFile, final File outputDir) throws Exception { + try (TarArchiveInputStream debInputStream = (TarArchiveInputStream) + new ArchiveStreamFactory().createArchiveInputStream("tar", + new FileInputStream(inputFile))) { + TarArchiveEntry entry = null; + while ((entry = (TarArchiveEntry) debInputStream.getNextEntry()) != null) { + final File outputFile = new File(outputDir, entry.getName()); + if (entry.isDirectory()) { + if (!outputFile.exists()) { + if (!outputFile.mkdirs()) { + throw new IllegalStateException( + String.format("Couldn't create directory %s.", outputFile.getAbsolutePath())); + } + } else { + outputFile.delete(); + } + } else { + try (final OutputStream outputFileStream = new FileOutputStream(outputFile)) { + IOUtils.copy(debInputStream, outputFileStream); + } + } + } + } + } + + } diff --git a/tests/integration/cluster/build.gradle b/tests/integration/cluster/build.gradle index f29fedfec84..4cf0dac30d0 100644 --- a/tests/integration/cluster/build.gradle +++ b/tests/integration/cluster/build.gradle @@ -45,13 +45,9 @@ dependencies { testAnnotationProcessor depLibs.lombok } -task buildImage(type:Exec) { - workingDir '../../..' - commandLine './tests/docker-images/statestore-image/image_builder.sh' -} test { - dependsOn buildImage + dependsOn(":tests:docker-images:buildImages") jvmArgs("-Djunit.timeout.test=600000", "-Djunit.max.retry=3", "-Djava.net.preferIPv4Stack=true", diff --git a/tests/integration/standalone/build.gradle b/tests/integration/standalone/build.gradle index 17044f7bce6..fe63dd3b52c 100644 --- a/tests/integration/standalone/build.gradle +++ b/tests/integration/standalone/build.gradle @@ -34,13 +34,8 @@ dependencies { testAnnotationProcessor depLibs.lombok } -task buildImage(type:Exec) { - workingDir '../../..' - commandLine './tests/docker-images/statestore-image/image_builder.sh' -} - test { - dependsOn buildImage + dependsOn(":tests:docker-images:buildImages") } publishing {