Skip to content

Commit

Permalink
improve container execution logging
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Bueno <49003339+tlbueno@users.noreply.github.com>
  • Loading branch information
tlbueno committed Aug 8, 2024
1 parent 9715012 commit abe02f1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ OPERATOR_SUITE_DIR = ${ROOT_DIR}/operator-suite
STANDALONE_SUITE_DIR = ${ROOT_DIR}/standalone-suite
VERSION_PROPERTIES_FILE ?= ${ROOT_DIR}/claire_properties.yaml
BUILD_PROPERTIES = ${ROOT_DIR}/build_properties.yaml
COMMIT_ID = $(shell git rev-parse HEAD)

### Commands variables
MVN_DEFAULT_CMD = mvn --no-transfer-progress --update-snapshots -Dmaven.repo.local=./.m2/repository
Expand Down Expand Up @@ -445,6 +446,7 @@ build_container:
if [[ "${OPERATOR_CONTAINER_SKIP_BUILD}" == "false" ]]; then \
podman build --arch=$${arch} --tag $${FULL_VERSION_WITH_ARCH} --build-arg buildArch=$${arch} \
--build-arg operatorType=${OPERATOR_TYPE_FINAL} --build-arg operatorVersion=${OPERATOR_VERSION} \
--build-arg commitId=${COMMIT_ID} \
--file operator-suite/container/Containerfile . ;\
if [[ "${OPERATOR_TYPE_FINAL}" == "amq-broker" ]]; then \
echo "Creating tag from $${FULL_VERSION_WITH_ARCH} to $${MMM_VERSION_WITH_ARCH}" ;\
Expand Down
4 changes: 4 additions & 0 deletions operator-suite/container/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ARG operatorVersion
ARG claireUser=claire
ARG claireUserUid=1000
ARG claireUserGroup=root
ARG commitId

# Create claire user
RUN useradd -u "${claireUserUid}" -d "/app" -m -g "${claireUserGroup}" "${claireUser}" && \
Expand Down Expand Up @@ -84,6 +85,9 @@ USER ${CLAIRE_USER_UID}
ENTRYPOINT ["/app/operator-suite/container/entrypoint.sh"]
CMD ["/bin/bash"]

# Set the current commit id
ENV COMMIT_ID=${commitId}

# Copy cliare files
COPY --chown=${CLAIRE_USER_UID}:${CLAIRE_USER_GROUP} . /app/

Expand Down
5 changes: 3 additions & 2 deletions operator-suite/container/scripts/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ if [[ "${#_arg_make_envvar[@]}" -gt 0 ]]; then
fi
yq -i e '(.metadata.namespace = strenv(NAMESPACE))' "${SCRIPT_DIR}/yaml/030-pod.yaml.$$"
yq -i e '(.spec.containers[].image = strenv(IMAGE))' "${SCRIPT_DIR}/yaml/030-pod.yaml.$$"
yq -i e '.spec.containers[].env[] |= select(.name == "CONTAINER_IMAGE") |= .value = strenv(IMAGE)' "${SCRIPT_DIR}/yaml/030-pod.yaml.$$"
tee >(kubectl apply -f -) < "${SCRIPT_DIR}/yaml/030-pod.yaml.$$"
rm -rf "${SCRIPT_DIR}/yaml/030-pod.yaml.$$"
sleep 5
Expand All @@ -83,8 +84,8 @@ if kubectl wait -n "${NAMESPACE}" --for=jsonpath='{.status.phase}'='Running' pod
log "Waiting execution to finish"
set +e
while ! kubectl -n "${NAMESPACE}" exec claire-test-suite -- /bin/ls /app/test-results/tests.execution.completed > /dev/null 2>&1; do
log "Execution not completed. Waiting for ${_arg_test_completion_wait_check} seconds before check again"
sleep "${_arg_test_completion_wait_check}"
log "Execution not completed. Waiting for ${_arg_test_completion_wait_check} seconds before check again"
sleep "${_arg_test_completion_wait_check}"
done
set -e

Expand Down
3 changes: 3 additions & 0 deletions operator-suite/container/scripts/yaml/020-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ data:
fi
}
log ""
log "Running with git commit id: $${COMMIT_ID}"
log "Running with image: $${CONTAINER_IMAGE}"
log ""
log "Creating test-results directory: $${OPERATOR_TEST_RESULTS_DIR}"
mkdir -p "$${OPERATOR_TEST_RESULTS_DIR}"
Expand Down
3 changes: 3 additions & 0 deletions operator-suite/container/scripts/yaml/030-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ spec:
image: ${IMAGE}
imagePullPolicy: Always
command: ["/app/run.sh"]
env:
- name: CONTAINER_IMAGE
value: ${IMAGE}
volumeMounts:
- name: run-script-volume
mountPath: /app/run.sh
Expand Down

0 comments on commit abe02f1

Please sign in to comment.