Modify entrypoint/cmd on adml-http image to allow provide extra
arguments to the entrypoint. Also, the starter script will forward
de arguments $@ towards ADML start.sh script, so parameters like
'ft' or 'st' are now possible to specify on docker run statement
(ft by default).
Allow parametrize the build variant in ct.sh script. In this way
we could test Release or Debug variant. The ADML start.sh argument
is set to 'st' to avoid trace generation and traffic log.
Rebuild question is now 'n' by default.
Docker tag will be suffixed with '-debug' for Debug, and unchanged
for Release. In the same way, the container name is changed to
to know easily what is being deployed. Anyway, nginx port will
collide and then both cannot be started expect if 8074 port is
changed in any of them.
When configuring services in ct.sh script, we will parse the response
to know the success state (true/false) in order to interrupt the
component test procedure in case of fail.
Also, in this script, a bug is fixed: pgrep is not being escaped, and
the $(pgrep ADML) is going to be evaluated on host.
-> docker run --rm -d -p 8074:8074 --name anna-adml-http anna-adml-http:<version>
+> docker run --rm -d -p 8074:8074 --name anna-adml-http anna-adml-http:<version> [entrypoint arguments: <[ft]|st>]
+
+Entrypoint arguments are passed to ADML start script (`/opt/adml/start.sh` inside the container), and are mainly preconfigured variants for `ADML` command-line arguments. So, `ft` stands for `function test` (debug traces, traffic logs in real time, etc.) and `st` is `system test` (warning level for traces, no traffic logs dumped, etc.).
Service port is **8074**.
Service port is **8074**.
EXPOSE 8074
WORKDIR /opt/adml
EXPOSE 8074
WORKDIR /opt/adml
-CMD ["sh", "/var/starter.sh"]
+ENTRYPOINT ["sh", "/var/starter.sh"]
+CMD []
# Start ADML agent:
cd /opt/adml
# Start ADML agent:
cd /opt/adml
# Execute nginx server:
exec $(which nginx) -c /etc/nginx/nginx.conf -g "daemon off;"
# Execute nginx server:
exec $(which nginx) -c /etc/nginx/nginx.conf -g "daemon off;"
ENDPOINT=http://localhost:8074
PORT=$(echo ${ENDPOINT} | cut -d: -f3)
C_NAME=anna-adml-http
ENDPOINT=http://localhost:8074
PORT=$(echo ${ENDPOINT} | cut -d: -f3)
C_NAME=anna-adml-http
+# Entrypoint arguments (ft/st):
+EXTRA_ARGUMENTS= # default is ft (function test: debug traces and traffic logs)
+EXTRA_ARGUMENTS=st
+
+VARIANT=${1:-Release}
#############
# EXECUTION #
#############
#############
# EXECUTION #
#############
+
+echo
+echo "Variant: ${VARIANT}"
+echo "Remember usage: $0 [variant: <[Release]|Debug]>"
+echo
+
cd $(dirname $0)
# Basic requirement:
cd $(dirname $0)
# Basic requirement:
echo "Requirement found !"
echo
echo "Requirement found !"
echo
-echo "Rebuild ADML HTTP service image (y/n) [y]:"
+echo "Rebuild ADML HTTP service image (y/n) [n]:"
-[ -z "${opt}" ] && opt=y
-[ "${opt}" = "y" ] && ${REPO_DIR}/tools/build-anna-adml-http
+[ -z "${opt}" ] && opt=n
+if [ "${opt}" = "y" ]
+then
+ ${REPO_DIR}/tools/build-anna-adml-http ${VARIANT}
+fi
version=$(${REPO_DIR}/tools/version)
version=$(${REPO_DIR}/tools/version)
+[ "${VARIANT}" = "Debug" ] && { version=${version}-debug ; C_NAME=${C_NAME}-debug ; }
echo "Restart ADML HTTP service image (version '${version}') ..."
echo "Restart ADML HTTP service image (version '${version}') ..."
-docker kill ${C_NAME} >/dev/null
-cid=$(docker run --rm -d -p ${PORT}:${PORT} --name ${C_NAME} anna-adml-http:${version})
+docker kill ${C_NAME} &>/dev/null
+cid=$(docker run --rm -d -p ${PORT}:${PORT} --name ${C_NAME} anna-adml-http:${version} ${EXTRA_ARGUMENTS} >/dev/null)
+[ $? -ne 0 ] && exit 1
+
echo "Container id: ${cid} (deployed as '${C_NAME}')"
echo
echo "Configuring services (${SERVICES}) ..."
sleep 4 # wait for docker running
echo "Container id: ${cid} (deployed as '${C_NAME}')"
echo
echo "Configuring services (${SERVICES}) ..."
sleep 4 # wait for docker running
-nghttp -H ":method: POST" -d ${SERVICES} ${ENDPOINT}/services
-echo
+nghttp -H ":method: POST" -d ${SERVICES} ${ENDPOINT}/services | tee .response.json | jq '.'
+result=$(cat .response.json | jq -r '.["success"]')
+rm .response.json
+if [ "${result}" = "false" ]
+then
+ echo
+ echo "Check if another ADML HTTP service (anna-adml-http*) has been started (port ${PORT} busy ?)"
+ exit 1
+fi
echo
echo -n "Waiting for server-client connection ..."
while true
do
echo
echo -n "Waiting for server-client connection ..."
while true
do
- docker exec -it ${C_NAME} bash -c "netstat -p $(pgrep ADML) --numeric-ports | grep -w 3868 | grep -w ESTABLISHED" >/dev/null
+ docker exec -it ${C_NAME} bash -c "netstat -p \$(pgrep ADML) --numeric-ports | grep -w 3868 | grep -w ESTABLISHED" >/dev/null
[ $? -eq 0 ] && break
echo -n .
sleep 1
[ $? -eq 0 ] && break
echo -n .
sleep 1