mirror of https://github.com/apache/nifi.git
76 lines
3.0 KiB
Bash
Executable File
76 lines
3.0 KiB
Bash
Executable File
#!/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 -exuo pipefail
|
|
|
|
TAG=$1
|
|
VERSION=$2
|
|
|
|
container_name="nifi-registry-${TAG}-integration-test"
|
|
image_name="apache/nifi-registry:${TAG}"
|
|
port=18080
|
|
|
|
trap '{ docker logs "${container_name}" | tail -10; docker inspect -f "{{json .State}}" "${container_name}"; docker rm -f "${container_name}"; }' EXIT
|
|
|
|
echo "Deleting any existing ${container_name} containers"
|
|
docker rm -f "${container_name}"
|
|
echo
|
|
|
|
echo "Checking that all files are owned by NiFi"
|
|
test -z "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c "find /opt/nifi-registry ! -user nifi")"
|
|
echo
|
|
|
|
echo "Checking environment variables"
|
|
test "/opt/nifi-registry/nifi-registry-current" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'echo -n ${NIFI_REGISTRY_HOME}')"
|
|
test "/opt/nifi-registry/nifi-registry-${VERSION}" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'readlink ${NIFI_REGISTRY_BASE_DIR}/nifi-registry-current')"
|
|
test "/opt/nifi-registry/nifi-toolkit-current" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c "readlink \${NIFI_REGISTRY_BASE_DIR}/nifi-toolkit-${VERSION}")"
|
|
|
|
test "/opt/nifi-registry" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'echo -n ${NIFI_REGISTRY_BASE_DIR}')"
|
|
echo
|
|
|
|
echo "Starting NiFi Registry container..."
|
|
docker run -d --name "${container_name}" "${image_name}"
|
|
ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "${container_name}")
|
|
echo
|
|
|
|
max_iterations=10
|
|
sleep_time=10
|
|
|
|
sleep ${sleep_time}
|
|
for i in $(seq 1 "${max_iterations}") :; do
|
|
echo "Waiting for NiFi Registry startup - iteration: ${i}"
|
|
if docker exec "${container_name}" bash -c " echo Running < /dev/tcp/${ip}/${port}"; then
|
|
echo "NiFi Registry found active on port ${port}"
|
|
break
|
|
fi
|
|
echo
|
|
if [ "${i}" -eq "${max_iterations}" ]; then
|
|
echo "NiFi Registry did not start within expected time"
|
|
exit 1
|
|
fi
|
|
sleep 10
|
|
done
|
|
echo
|
|
|
|
echo "Checking NiFi Registry REST API Access"
|
|
test "200" = "$(docker exec "${container_name}" bash -c "curl -sSo /dev/null -w %{http_code} -k http://${ip}:${port}/nifi-registry-api/access")"
|
|
echo
|
|
|
|
echo "Stopping NiFi Registry container"
|
|
time docker stop "${container_name}"
|
|
echo
|