2018-05-29 07:27:45 -04:00
|
|
|
#!/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
|
|
|
|
|
2023-10-15 12:30:41 -04:00
|
|
|
container_name="nifi-${TAG}-integration-test"
|
|
|
|
image_name="apache/nifi:${TAG}"
|
|
|
|
port=8443
|
2021-07-13 04:29:23 -04:00
|
|
|
|
2023-10-15 12:30:41 -04:00
|
|
|
trap '{ docker logs "${container_name}" | tail -10; docker inspect -f "{{json .State}}" "${container_name}"; docker rm -f "${container_name}"; }' EXIT
|
2021-07-13 04:29:23 -04:00
|
|
|
|
2023-10-15 12:30:41 -04:00
|
|
|
echo "Deleting any existing ${container_name} containers"
|
|
|
|
docker rm -f "${container_name}"
|
|
|
|
echo
|
2018-05-29 07:27:45 -04:00
|
|
|
|
|
|
|
echo "Checking that all files are owned by NiFi"
|
2023-10-15 12:30:41 -04:00
|
|
|
test -z "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c "find /opt/nifi ! -user nifi")"
|
|
|
|
echo
|
2018-05-29 07:27:45 -04:00
|
|
|
|
|
|
|
echo "Checking environment variables"
|
2023-10-15 12:30:41 -04:00
|
|
|
test "/opt/nifi/nifi-current" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'echo -n ${NIFI_HOME}')"
|
|
|
|
test "/opt/nifi/nifi-current" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c "readlink \${NIFI_BASE_DIR}/nifi-${VERSION}")"
|
|
|
|
test "/opt/nifi/nifi-toolkit-current" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c "readlink \${NIFI_BASE_DIR}/nifi-toolkit-${VERSION}")"
|
2018-08-08 08:03:10 -04:00
|
|
|
|
2023-10-15 12:30:41 -04:00
|
|
|
test "/opt/nifi/nifi-current/logs" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'echo -n ${NIFI_LOG_DIR}')"
|
|
|
|
test "/opt/nifi/nifi-current/run" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'echo -n ${NIFI_PID_DIR}')"
|
|
|
|
test "/opt/nifi" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'echo -n ${NIFI_BASE_DIR}')"
|
|
|
|
echo
|
2018-05-29 07:27:45 -04:00
|
|
|
|
|
|
|
echo "Starting NiFi container..."
|
2023-10-15 12:30:41 -04:00
|
|
|
docker run -d --name "${container_name}" "${image_name}"
|
|
|
|
ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "${container_name}")
|
|
|
|
echo
|
2018-05-29 07:27:45 -04:00
|
|
|
|
2023-10-15 12:30:41 -04:00
|
|
|
max_iterations=10
|
|
|
|
sleep_time=10
|
2018-05-29 07:27:45 -04:00
|
|
|
|
2023-10-15 12:30:41 -04:00
|
|
|
sleep ${sleep_time}
|
|
|
|
for i in $(seq 1 "${max_iterations}") :; do
|
2023-09-26 10:08:32 -04:00
|
|
|
echo "Waiting for NiFi startup - iteration: ${i}"
|
2023-10-15 12:30:41 -04:00
|
|
|
if docker exec "${container_name}" bash -c " echo Running < /dev/tcp/${ip}/${port}"; then
|
|
|
|
echo "NiFi found active on port ${port}"
|
2018-05-29 07:27:45 -04:00
|
|
|
break
|
|
|
|
fi
|
2023-10-15 12:30:41 -04:00
|
|
|
echo
|
|
|
|
if [ "${i}" -eq "${max_iterations}" ]; then
|
|
|
|
echo "NiFi did not start within expected time"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-05-29 07:27:45 -04:00
|
|
|
sleep 10
|
|
|
|
done
|
2023-10-15 12:30:41 -04:00
|
|
|
echo
|
2018-05-29 07:27:45 -04:00
|
|
|
|
2023-10-15 12:30:41 -04:00
|
|
|
echo "Checking NiFi REST API Access (expect status: 400)"
|
2023-09-26 10:08:32 -04:00
|
|
|
# Return code is 400 instead of 200 because of an invalid SNI
|
2024-07-19 09:15:19 -04:00
|
|
|
test "400" = "$(docker exec "${container_name}" bash -c "curl -ksSo /dev/null -w %{http_code} -m 10 --retry 5 --retry-connrefused --retry-max-time 60 https://${ip}:${port}/nifi-api/authentication/configuration")"
|
2023-10-15 12:30:41 -04:00
|
|
|
echo
|
2018-08-08 08:03:10 -04:00
|
|
|
|
2018-05-29 07:27:45 -04:00
|
|
|
echo "Stopping NiFi container"
|
2023-10-15 12:30:41 -04:00
|
|
|
time docker stop "${container_name}"
|
|
|
|
echo
|