mirror of
https://github.com/apache/nifi.git
synced 2025-02-27 22:19:08 +00:00
NIFI-12177 Added integration tests for MiNiFi and C2 Docker
This closes #7919 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
a3e4f89fe3
commit
2e8d0214c0
17
minifi/minifi-c2/minifi-c2-docker/dockermaven/.dockerignore
Normal file
17
minifi/minifi-c2/minifi-c2-docker/dockermaven/.dockerignore
Normal file
@ -0,0 +1,17 @@
|
||||
# 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.
|
||||
|
||||
# Place files you want to exclude from the docker build here similar to .gitignore https://docs.docker.com/engine/reference/builder/#dockerignore-file
|
||||
integration-test.sh
|
@ -60,7 +60,7 @@ ENV MINIFI_C2_HOME ${MINIFI_C2_BASE_DIR}/minifi-c2-current
|
||||
RUN groupadd -g ${GID} ${MINIFI_C2_USER} \
|
||||
&& useradd --shell /bin/bash -u ${UID} -g ${GID} -m ${MINIFI_C2_USER}
|
||||
|
||||
COPY --from=builder ${MINIFI_C2_BASE_DIR} ${MINIFI_C2_BASE_DIR}
|
||||
COPY --chown=c2:c2 --from=builder ${MINIFI_C2_BASE_DIR} ${MINIFI_C2_BASE_DIR}
|
||||
|
||||
USER ${MINIFI_C2_USER}
|
||||
|
||||
|
74
minifi/minifi-c2/minifi-c2-docker/dockermaven/integration-test.sh
Executable file
74
minifi/minifi-c2/minifi-c2-docker/dockermaven/integration-test.sh
Executable file
@ -0,0 +1,74 @@
|
||||
#!/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-minifi-c2-${TAG}-integration-test"
|
||||
image_name="apache/nifi-minifi-c2:${TAG}"
|
||||
port=10090
|
||||
|
||||
trap '{ 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 C2"
|
||||
test -z "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c "find /opt/minifi-c2 ! -user c2")"
|
||||
echo
|
||||
|
||||
echo "Checking environment variables"
|
||||
test "/opt/minifi-c2/minifi-c2-current" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'echo -n ${MINIFI_C2_HOME}')"
|
||||
test "/opt/minifi-c2/minifi-c2-${VERSION}" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'readlink ${MINIFI_C2_BASE_DIR}/minifi-c2-current')"
|
||||
|
||||
test "/opt/minifi-c2" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'echo -n ${MINIFI_C2_BASE_DIR}')"
|
||||
echo
|
||||
|
||||
echo "Starting MiNiFi C2 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 MiNiFi C2 startup - iteration: ${i}"
|
||||
if docker exec "${container_name}" bash -c " echo Running < /dev/tcp/${ip}/${port}"; then
|
||||
echo "MiNiFi C2 found active on port ${port}"
|
||||
break
|
||||
fi
|
||||
echo
|
||||
if [ "${i}" -eq "${max_iterations}" ]; then
|
||||
echo "MiNiFi C2 did not start within expected time"
|
||||
exit 1
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
echo
|
||||
|
||||
echo "Checking MiNiFi C2 Config Access (Invalid request)"
|
||||
test "400" = "$(docker exec "${container_name}" bash -c "curl -sSo /dev/null -w %{http_code} -m 10 --retry 5 --retry-connrefused --retry-max-time 60 http://${ip}:${port}/c2/config")"
|
||||
echo
|
||||
|
||||
echo "Stopping MiNiFi C2 container"
|
||||
time docker stop "${container_name}"
|
||||
echo
|
@ -95,6 +95,71 @@ limitations under the License.
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>Docker integration tests</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>
|
||||
<argument>${project.version}-maven</argument>
|
||||
<argument>${project.version}</argument>
|
||||
</arguments>
|
||||
<executable>${project.basedir}/dockermaven/integration-test.sh</executable>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>docker-skip-tests</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>skipTests</name>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>Docker integration tests</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>docker-test-skip-test</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>maven.test.skip</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>Docker integration tests</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
17
minifi/minifi-docker/dockermaven/.dockerignore
Normal file
17
minifi/minifi-docker/dockermaven/.dockerignore
Normal file
@ -0,0 +1,17 @@
|
||||
# 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.
|
||||
|
||||
# Place files you want to exclude from the docker build here similar to .gitignore https://docs.docker.com/engine/reference/builder/#dockerignore-file
|
||||
integration-test.sh
|
@ -64,7 +64,7 @@ ENV MINIFI_HOME ${MINIFI_BASE_DIR}/minifi-current
|
||||
RUN groupadd -g ${GID} ${MINIFI_USER} \
|
||||
&& useradd --shell /bin/bash -u ${UID} -g ${GID} -m ${MINIFI_USER}
|
||||
|
||||
COPY --from=builder ${MINIFI_BASE_DIR} ${MINIFI_BASE_DIR}
|
||||
COPY --chown=minifi:minifi --from=builder ${MINIFI_BASE_DIR} ${MINIFI_BASE_DIR}
|
||||
|
||||
USER ${MINIFI_USER}
|
||||
|
||||
|
69
minifi/minifi-docker/dockermaven/integration-test.sh
Executable file
69
minifi/minifi-docker/dockermaven/integration-test.sh
Executable file
@ -0,0 +1,69 @@
|
||||
#!/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-minifi-${TAG}-integration-test"
|
||||
image_name="apache/nifi-minifi:${TAG}"
|
||||
|
||||
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 MiNiFi"
|
||||
test -z "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c "find /opt/minifi ! -user minifi")"
|
||||
echo
|
||||
|
||||
echo "Checking environment variables"
|
||||
test "/opt/minifi/minifi-current" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'echo -n ${MINIFI_HOME}')"
|
||||
test "/opt/minifi/minifi-${VERSION}" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'readlink ${MINIFI_BASE_DIR}/minifi-current')"
|
||||
|
||||
test "/opt/minifi" = "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c 'echo -n ${MINIFI_BASE_DIR}')"
|
||||
echo
|
||||
|
||||
echo "Starting MiNiFi 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 MiNiFi startup - iteration: ${i}"
|
||||
if docker exec "${container_name}" bash -c './bin/minifi.sh status | grep -F "Apache MiNiFi is currently running"'; then
|
||||
echo "MiNiFi found active"
|
||||
break
|
||||
fi
|
||||
echo
|
||||
if [ "${i}" -eq "${max_iterations}" ]; then
|
||||
echo "MiNiFi did not start within expected time"
|
||||
exit 1
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
echo
|
||||
|
||||
echo "Stopping MiNiFi container"
|
||||
time docker stop "${container_name}"
|
||||
echo
|
@ -111,6 +111,71 @@ limitations under the License.
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>Docker integration tests</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>
|
||||
<argument>${project.version}-maven</argument>
|
||||
<argument>${project.version}</argument>
|
||||
</arguments>
|
||||
<executable>${project.basedir}/dockermaven/integration-test.sh</executable>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>docker-skip-tests</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>skipTests</name>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>Docker integration tests</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>docker-test-skip-test</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>maven.test.skip</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>Docker integration tests</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
@ -20,41 +20,59 @@ set -exuo pipefail
|
||||
TAG=$1
|
||||
VERSION=$2
|
||||
|
||||
container_name="nifi-${TAG}-integration-test"
|
||||
image_name="apache/nifi:${TAG}"
|
||||
port=8443
|
||||
|
||||
trap '{ docker rm -f nifi-${TAG}-integration-test; }' EXIT
|
||||
trap '{ docker logs "${container_name}" | tail -10; docker inspect -f "{{json .State}}" "${container_name}"; docker rm -f "${container_name}"; }' EXIT
|
||||
|
||||
echo "Deleting any existing nifi-${TAG}-integration-test containers"
|
||||
docker rm -f nifi-${TAG}-integration-test;
|
||||
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 "apache/nifi:${TAG}" -c "find /opt/nifi ! -user nifi")"
|
||||
test -z "$(docker run --rm --entrypoint /bin/bash "${image_name}" -c "find /opt/nifi ! -user nifi")"
|
||||
echo
|
||||
|
||||
echo "Checking environment variables"
|
||||
test "/opt/nifi/nifi-current" = "$(docker run --rm --entrypoint /bin/bash "apache/nifi:${TAG}" -c 'echo -n $NIFI_HOME')"
|
||||
test "/opt/nifi/nifi-current" = "$(docker run --rm --entrypoint /bin/bash "apache/nifi:${TAG}" -c "readlink \${NIFI_BASE_DIR}/nifi-${VERSION}")"
|
||||
test "/opt/nifi/nifi-toolkit-current" = "$(docker run --rm --entrypoint /bin/bash "apache/nifi:${TAG}" -c "readlink \${NIFI_BASE_DIR}/nifi-toolkit-${VERSION}")"
|
||||
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}")"
|
||||
|
||||
test "/opt/nifi/nifi-current/logs" = "$(docker run --rm --entrypoint /bin/bash "apache/nifi:${TAG}" -c 'echo -n $NIFI_LOG_DIR')"
|
||||
test "/opt/nifi/nifi-current/run" = "$(docker run --rm --entrypoint /bin/bash "apache/nifi:${TAG}" -c 'echo -n $NIFI_PID_DIR')"
|
||||
test "/opt/nifi" = "$(docker run --rm --entrypoint /bin/bash "apache/nifi:${TAG}" -c 'echo -n $NIFI_BASE_DIR')"
|
||||
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
|
||||
|
||||
echo "Starting NiFi container..."
|
||||
docker run -d --name "nifi-${TAG}-integration-test" "apache/nifi:${TAG}"
|
||||
docker run -d --name "${container_name}" "${image_name}"
|
||||
ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "${container_name}")
|
||||
echo
|
||||
|
||||
IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "nifi-${TAG}-integration-test")
|
||||
max_iterations=10
|
||||
sleep_time=10
|
||||
|
||||
for i in $(seq 1 10) :; do
|
||||
sleep ${sleep_time}
|
||||
for i in $(seq 1 "${max_iterations}") :; do
|
||||
echo "Waiting for NiFi startup - iteration: ${i}"
|
||||
if docker exec "nifi-${TAG}-integration-test" bash -c " echo Running < /dev/tcp/${IP}/8443"; then
|
||||
echo "NiFi found active on port 8443"
|
||||
if docker exec "${container_name}" bash -c " echo Running < /dev/tcp/${ip}/${port}"; then
|
||||
echo "NiFi found active on port ${port}"
|
||||
break
|
||||
fi
|
||||
echo
|
||||
if [ "${i}" -eq "${max_iterations}" ]; then
|
||||
echo "NiFi did not start within expected time"
|
||||
exit 1
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
echo
|
||||
|
||||
echo "Checking NiFi REST API Access"
|
||||
echo "Checking NiFi REST API Access (expect status: 400)"
|
||||
# Return code is 400 instead of 200 because of an invalid SNI
|
||||
test "400" = "$(docker exec "nifi-${TAG}-integration-test" bash -c "curl -s -o /dev/null -w %{http_code} -k https://${IP}:8443/nifi-api/access")"
|
||||
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/access")"
|
||||
echo
|
||||
|
||||
echo "Stopping NiFi container"
|
||||
time docker stop "nifi-${TAG}-integration-test"
|
||||
time docker stop "${container_name}"
|
||||
echo
|
||||
|
@ -59,7 +59,8 @@ RUN curl -fSL ${NIFI_TOOLKIT_BINARY_URL} -o ${NIFI_REGISTRY_BASE_DIR}/${NIFI_TOO
|
||||
&& unzip ${NIFI_REGISTRY_BASE_DIR}/${NIFI_TOOLKIT_BINARY} -d ${NIFI_REGISTRY_BASE_DIR} \
|
||||
&& rm ${NIFI_REGISTRY_BASE_DIR}/${NIFI_TOOLKIT_BINARY} \
|
||||
&& mv ${NIFI_REGISTRY_BASE_DIR}/nifi-toolkit-${NIFI_REGISTRY_VERSION} ${NIFI_TOOLKIT_HOME} \
|
||||
&& ln -s ${NIFI_TOOLKIT_HOME} ${NIFI_REGISTRY_BASE_DIR}/nifi-toolkit-${NIFI_REGISTRY_VERSION}
|
||||
&& ln -s ${NIFI_TOOLKIT_HOME} ${NIFI_REGISTRY_BASE_DIR}/nifi-toolkit-${NIFI_REGISTRY_VERSION} \
|
||||
&& chown -h nifi:nifi ${NIFI_TOOLKIT_HOME}
|
||||
|
||||
# Download, validate, and expand Apache NiFi-Registry binary.
|
||||
RUN curl -fSL ${NIFI_REGISTRY_BINARY_URL} -o ${NIFI_REGISTRY_BASE_DIR}/${NIFI_REGISTRY_BINARY} \
|
||||
@ -68,6 +69,7 @@ RUN curl -fSL ${NIFI_REGISTRY_BINARY_URL} -o ${NIFI_REGISTRY_BASE_DIR}/${NIFI_RE
|
||||
&& rm ${NIFI_REGISTRY_BASE_DIR}/${NIFI_REGISTRY_BINARY} \
|
||||
&& mv ${NIFI_REGISTRY_BASE_DIR}/nifi-registry-${NIFI_REGISTRY_VERSION} ${NIFI_REGISTRY_HOME} \
|
||||
&& ln -s ${NIFI_REGISTRY_HOME} ${NIFI_REGISTRY_BASE_DIR}/nifi-registry-${NIFI_REGISTRY_VERSION} \
|
||||
&& chown -h nifi:nifi ${NIFI_REGISTRY_HOME} \
|
||||
&& chown -R nifi:nifi ${NIFI_REGISTRY_HOME}
|
||||
|
||||
# Web HTTP(s) ports
|
||||
|
@ -41,14 +41,12 @@ RUN chmod -R +x ${NIFI_REGISTRY_BASE_DIR}/scripts/*.sh \
|
||||
|
||||
COPY $NIFI_REGISTRY_BINARY $NIFI_REGISTRY_BASE_DIR
|
||||
RUN unzip ${NIFI_REGISTRY_BASE_DIR}/${NIFI_REGISTRY_BINARY_NAME} -d ${NIFI_REGISTRY_BASE_DIR} \
|
||||
&& rm ${NIFI_REGISTRY_BASE_DIR}/${NIFI_REGISTRY_BINARY_NAME} \
|
||||
&& ln -s ${NIFI_REGISTRY_BASE_DIR}/nifi-registry-${NIFI_REGISTRY_VERSION} ${NIFI_REGISTRY_HOME}
|
||||
&& rm ${NIFI_REGISTRY_BASE_DIR}/${NIFI_REGISTRY_BINARY_NAME}
|
||||
|
||||
COPY $NIFI_TOOLKIT_BINARY $NIFI_REGISTRY_BASE_DIR
|
||||
RUN unzip ${NIFI_REGISTRY_BASE_DIR}/nifi-toolkit-${NIFI_REGISTRY_VERSION}-bin.zip -d ${NIFI_REGISTRY_BASE_DIR} \
|
||||
&& rm ${NIFI_REGISTRY_BASE_DIR}/nifi-toolkit-${NIFI_REGISTRY_VERSION}-bin.zip \
|
||||
&& mv ${NIFI_REGISTRY_BASE_DIR}/nifi-toolkit-${NIFI_REGISTRY_VERSION} ${NIFI_TOOLKIT_HOME} \
|
||||
&& ln -s ${NIFI_TOOLKIT_HOME} ${NIFI_REGISTRY_BASE_DIR}/nifi-toolkit-${NIFI_REGISTRY_VERSION}
|
||||
&& mv ${NIFI_REGISTRY_BASE_DIR}/nifi-toolkit-${NIFI_REGISTRY_VERSION} ${NIFI_TOOLKIT_HOME}
|
||||
|
||||
|
||||
FROM ${IMAGE_NAME}:${IMAGE_TAG}
|
||||
@ -57,6 +55,7 @@ LABEL site="https://nifi.apache.org"
|
||||
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
ARG NIFI_REGISTRY_VERSION
|
||||
|
||||
ENV NIFI_REGISTRY_BASE_DIR /opt/nifi-registry
|
||||
ENV NIFI_REGISTRY_HOME ${NIFI_REGISTRY_BASE_DIR}/nifi-registry-current
|
||||
@ -73,6 +72,10 @@ RUN groupadd -g ${GID} nifi || groupmod -n nifi `getent group ${GID} | cut -d: -
|
||||
|
||||
COPY --chown=nifi:nifi --from=artifactbase $NIFI_REGISTRY_BASE_DIR $NIFI_REGISTRY_BASE_DIR
|
||||
|
||||
RUN ln -s ${NIFI_REGISTRY_BASE_DIR}/nifi-registry-${NIFI_REGISTRY_VERSION} ${NIFI_REGISTRY_HOME} \
|
||||
&& ln -s ${NIFI_TOOLKIT_HOME} ${NIFI_REGISTRY_BASE_DIR}/nifi-toolkit-${NIFI_REGISTRY_VERSION} \
|
||||
&& chown -h nifi:nifi ${NIFI_REGISTRY_HOME} ${NIFI_REGISTRY_BASE_DIR}/nifi-toolkit-${NIFI_REGISTRY_VERSION}
|
||||
|
||||
USER nifi
|
||||
|
||||
# Web HTTP(s) ports
|
||||
|
@ -20,36 +20,56 @@ set -exuo pipefail
|
||||
TAG=$1
|
||||
VERSION=$2
|
||||
|
||||
container_name=nifi-registry-${TAG}-integration-test
|
||||
container_name="nifi-registry-${TAG}-integration-test"
|
||||
image_name="apache/nifi-registry:${TAG}"
|
||||
port=18080
|
||||
|
||||
trap "{ docker rm -f ${container_name}; }" EXIT
|
||||
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};
|
||||
docker rm -f "${container_name}"
|
||||
echo
|
||||
|
||||
echo "Checking that all files are owned by NiFi"
|
||||
test -z $(docker run --rm --entrypoint /bin/bash apache/nifi-registry:${TAG} -c "find /opt/nifi-registry ! -user 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 apache/nifi-registry:${TAG} -c 'echo -n $NIFI_REGISTRY_HOME')"
|
||||
test "/opt/nifi-registry" = "$(docker run --rm --entrypoint /bin/bash apache/nifi-registry:${TAG} -c 'echo -n $NIFI_REGISTRY_BASE_DIR')"
|
||||
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
|
||||
|
||||
docker run -d --name ${container_name} apache/nifi-registry:${TAG}
|
||||
max_iterations=10
|
||||
sleep_time=10
|
||||
|
||||
IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${container_name})
|
||||
|
||||
for i in $(seq 1 10) :; do
|
||||
echo "Iteration: ${i}"
|
||||
if docker exec ${container_name} bash -c " echo Running < /dev/tcp/${IP}/18080"; then
|
||||
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 -s -o /dev/null -w %{http_code} -k http://${IP}:18080/nifi-registry-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}
|
||||
time docker stop "${container_name}"
|
||||
echo
|
||||
|
@ -1,18 +1,38 @@
|
||||
#!/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 -xuo pipefail
|
||||
|
||||
VERSION=${1:-}
|
||||
VERSION="${1}"
|
||||
|
||||
image_name=apache/nifi-toolkit:${VERSION}
|
||||
image_name="apache/nifi-toolkit:${VERSION}"
|
||||
|
||||
echo "Testing return values on missing input:"
|
||||
docker run --rm "${image_name}"
|
||||
test 0 -eq $? || exit 1
|
||||
echo
|
||||
|
||||
echo "Testing return values on invalid input for all commands:"
|
||||
echo "encrypt-config"
|
||||
docker run --rm "${image_name}" encrypt-config invalid 1>/dev/null 2>&1
|
||||
test 2 -eq $? || exit 1
|
||||
echo
|
||||
|
||||
echo "cli"
|
||||
docker run --rm "${image_name}" cli invalid 1>/dev/null 2>&1
|
||||
test 255 -eq $? || exit 1
|
||||
echo
|
||||
|
@ -28,7 +28,6 @@ language governing permissions and limitations under the License. -->
|
||||
<excludes combine.children="append">
|
||||
<exclude>src/main/resources/conf/config-client.json</exclude>
|
||||
<exclude>src/main/resources/conf/config-server.json</exclude>
|
||||
<exclude>docker/tests/exit-codes.sh</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
Loading…
x
Reference in New Issue
Block a user