This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 2e8d0214c0 NIFI-12177 Added integration tests for MiNiFi and C2 Docker
2e8d0214c0 is described below

commit 2e8d0214c0317a25277cf55b651aca19a9b1f8d8
Author: Chris Sampson <[email protected]>
AuthorDate: Sun Oct 15 17:30:41 2023 +0100

    NIFI-12177 Added integration tests for MiNiFi and C2 Docker
    
    This closes #7919
    
    Signed-off-by: David Handermann <[email protected]>
---
 .../minifi-c2-docker/dockermaven/.dockerignore     | 17 +++++
 .../minifi-c2-docker/dockermaven/Dockerfile        |  2 +-
 .../dockermaven/integration-test.sh                | 74 ++++++++++++++++++++++
 minifi/minifi-c2/minifi-c2-docker/pom.xml          | 65 +++++++++++++++++++
 minifi/minifi-docker/dockermaven/.dockerignore     | 17 +++++
 minifi/minifi-docker/dockermaven/Dockerfile        |  2 +-
 .../minifi-docker/dockermaven/integration-test.sh  | 69 ++++++++++++++++++++
 minifi/minifi-docker/pom.xml                       | 65 +++++++++++++++++++
 nifi-docker/dockermaven/integration-test.sh        | 54 ++++++++++------
 .../nifi-registry-docker/dockerhub/Dockerfile      |  4 +-
 .../dockermaven/Dockerfile                         | 11 ++--
 .../dockermaven/integration-test.sh                | 48 ++++++++++----
 .../docker/tests/exit-codes.sh                     | 24 ++++++-
 nifi-toolkit/nifi-toolkit-assembly/pom.xml         |  1 -
 14 files changed, 411 insertions(+), 42 deletions(-)

diff --git a/minifi/minifi-c2/minifi-c2-docker/dockermaven/.dockerignore 
b/minifi/minifi-c2/minifi-c2-docker/dockermaven/.dockerignore
new file mode 100644
index 0000000000..c46cae92af
--- /dev/null
+++ b/minifi/minifi-c2/minifi-c2-docker/dockermaven/.dockerignore
@@ -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
diff --git a/minifi/minifi-c2/minifi-c2-docker/dockermaven/Dockerfile 
b/minifi/minifi-c2/minifi-c2-docker/dockermaven/Dockerfile
index e33a8980ec..98b6b05cfd 100644
--- a/minifi/minifi-c2/minifi-c2-docker/dockermaven/Dockerfile
+++ b/minifi/minifi-c2/minifi-c2-docker/dockermaven/Dockerfile
@@ -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}
 
diff --git a/minifi/minifi-c2/minifi-c2-docker/dockermaven/integration-test.sh 
b/minifi/minifi-c2/minifi-c2-docker/dockermaven/integration-test.sh
new file mode 100755
index 0000000000..aa0ce17ed5
--- /dev/null
+++ b/minifi/minifi-c2/minifi-c2-docker/dockermaven/integration-test.sh
@@ -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
diff --git a/minifi/minifi-c2/minifi-c2-docker/pom.xml 
b/minifi/minifi-c2/minifi-c2-docker/pom.xml
index 2ef6a4833e..5a3355a820 100644
--- a/minifi/minifi-c2/minifi-c2-docker/pom.xml
+++ b/minifi/minifi-c2/minifi-c2-docker/pom.xml
@@ -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>
diff --git a/minifi/minifi-docker/dockermaven/.dockerignore 
b/minifi/minifi-docker/dockermaven/.dockerignore
new file mode 100644
index 0000000000..c46cae92af
--- /dev/null
+++ b/minifi/minifi-docker/dockermaven/.dockerignore
@@ -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
diff --git a/minifi/minifi-docker/dockermaven/Dockerfile 
b/minifi/minifi-docker/dockermaven/Dockerfile
index 2d3033143f..d321d8b8e2 100644
--- a/minifi/minifi-docker/dockermaven/Dockerfile
+++ b/minifi/minifi-docker/dockermaven/Dockerfile
@@ -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}
 
diff --git a/minifi/minifi-docker/dockermaven/integration-test.sh 
b/minifi/minifi-docker/dockermaven/integration-test.sh
new file mode 100755
index 0000000000..01cc35a828
--- /dev/null
+++ b/minifi/minifi-docker/dockermaven/integration-test.sh
@@ -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
diff --git a/minifi/minifi-docker/pom.xml b/minifi/minifi-docker/pom.xml
index 033220c28d..8bbbde6649 100644
--- a/minifi/minifi-docker/pom.xml
+++ b/minifi/minifi-docker/pom.xml
@@ -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>
diff --git a/nifi-docker/dockermaven/integration-test.sh 
b/nifi-docker/dockermaven/integration-test.sh
index 5bce176083..ff3d75c93e 100755
--- a/nifi-docker/dockermaven/integration-test.sh
+++ b/nifi-docker/dockermaven/integration-test.sh
@@ -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
diff --git 
a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/Dockerfile 
b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/Dockerfile
index 0ca25391a4..2cfab25d0b 100644
--- a/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/Dockerfile
+++ b/nifi-registry/nifi-registry-core/nifi-registry-docker/dockerhub/Dockerfile
@@ -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
diff --git a/nifi-registry/nifi-registry-docker-maven/dockermaven/Dockerfile 
b/nifi-registry/nifi-registry-docker-maven/dockermaven/Dockerfile
index de819b3859..71fd7ac1b5 100644
--- a/nifi-registry/nifi-registry-docker-maven/dockermaven/Dockerfile
+++ b/nifi-registry/nifi-registry-docker-maven/dockermaven/Dockerfile
@@ -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
diff --git 
a/nifi-registry/nifi-registry-docker-maven/dockermaven/integration-test.sh 
b/nifi-registry/nifi-registry-docker-maven/dockermaven/integration-test.sh
index 2a79e45213..642b459ee8 100755
--- a/nifi-registry/nifi-registry-docker-maven/dockermaven/integration-test.sh
+++ b/nifi-registry/nifi-registry-docker-maven/dockermaven/integration-test.sh
@@ -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}")"
 
-echo "Starting NiFi Registry container..."
+test "/opt/nifi-registry" = "$(docker run --rm --entrypoint /bin/bash 
"${image_name}" -c 'echo -n ${NIFI_REGISTRY_BASE_DIR}')"
+echo
 
-docker run -d --name ${container_name} apache/nifi-registry:${TAG}
+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
 
-IP=$(docker inspect -f '{{range 
.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${container_name})
+max_iterations=10
+sleep_time=10
 
-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
diff --git a/nifi-toolkit/nifi-toolkit-assembly/docker/tests/exit-codes.sh 
b/nifi-toolkit/nifi-toolkit-assembly/docker/tests/exit-codes.sh
index 2b6336a05c..7cc3c28ae3 100755
--- a/nifi-toolkit/nifi-toolkit-assembly/docker/tests/exit-codes.sh
+++ b/nifi-toolkit/nifi-toolkit-assembly/docker/tests/exit-codes.sh
@@ -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
diff --git a/nifi-toolkit/nifi-toolkit-assembly/pom.xml 
b/nifi-toolkit/nifi-toolkit-assembly/pom.xml
index 3c48abb434..ed472c5ff5 100644
--- a/nifi-toolkit/nifi-toolkit-assembly/pom.xml
+++ b/nifi-toolkit/nifi-toolkit-assembly/pom.xml
@@ -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>

Reply via email to