Update armada image run test
This PS improves armada image run test by enriching it with config generator. Also this test was removed from make images section of Makefile. Build images zuul gate has make run_images task to test the freshly built image now. Change-Id: I87e089e5d268d248cda1dad1cd417694d166fdfb
This commit is contained in:
parent
275dc4506f
commit
812546c875
@ -19,7 +19,7 @@ formats:
|
||||
|
||||
# Optionally set the version of Python and requirements required to build your docs
|
||||
python:
|
||||
version: 3.7
|
||||
version: 3.8
|
||||
install:
|
||||
- requirements: doc/requirements.txt
|
||||
- requirements: requirements.txt
|
||||
- requirements: requirements-frozen.txt
|
||||
|
@ -62,6 +62,9 @@
|
||||
timeout: 900
|
||||
run: tools/gate/playbooks/build-charts.yaml
|
||||
nodeset: armada-single-node-focal
|
||||
vars:
|
||||
HTK_COMMIT: a7cd689280cdbc0acd04a7a1b745941260e8700b
|
||||
|
||||
|
||||
- job:
|
||||
name: armada-chart-build-latest-htk
|
||||
|
4
Makefile
4
Makefile
@ -78,14 +78,14 @@ check-tox:
|
||||
exit 2; \
|
||||
fi
|
||||
|
||||
images: check-docker build_armada run_armada
|
||||
images: check-docker build_armada
|
||||
|
||||
docs: clean build_docs
|
||||
|
||||
build_docs:
|
||||
tox -e docs
|
||||
|
||||
run_images: run_armada
|
||||
run_images: build_armada run_armada
|
||||
|
||||
run_armada: build_armada
|
||||
./tools/armada_image_run.sh $(IMAGE)
|
||||
|
@ -88,7 +88,6 @@ RUN set -ex \
|
||||
/usr/share/doc-base
|
||||
|
||||
COPY . ./
|
||||
COPY etc/armada /etc/armada
|
||||
|
||||
# Setting the version explicitly for PBR
|
||||
ENV PBR_VERSION 0.8.0
|
||||
|
@ -88,7 +88,6 @@ RUN set -ex \
|
||||
/usr/share/doc-base
|
||||
|
||||
COPY . ./
|
||||
COPY etc/armada /etc/armada
|
||||
|
||||
# Setting the version explicitly for PBR
|
||||
ENV PBR_VERSION 0.8.0
|
||||
|
@ -16,33 +16,58 @@
|
||||
set -x
|
||||
|
||||
IMAGE=$1
|
||||
USE_PROXY=${USE_PROXY:-false}
|
||||
CONTAINER_NAME=armada_test_$(date +%Y%m%d%H%M%s%s)
|
||||
ARMADA_CONTAINER_NAME=armada_test_$(date +%Y%m%d%H%M%s%s)
|
||||
|
||||
docker create \
|
||||
-p 8000:8000 \
|
||||
--name ${CONTAINER_NAME} ${IMAGE}
|
||||
function generate_conf {
|
||||
tox -e genconfig > /dev/null
|
||||
tox -e genpolicy > /dev/null
|
||||
ETCDIR=$(mktemp -d)/armada
|
||||
mkdir -p ${ETCDIR} > /dev/null
|
||||
cp etc/armada/api-paste.ini ${ETCDIR}/api-paste.ini
|
||||
cp etc/armada/policy.yaml.sample ${ETCDIR}/policy.yaml
|
||||
echo ${ETCDIR}
|
||||
}
|
||||
|
||||
docker start ${CONTAINER_NAME} &
|
||||
sleep 5
|
||||
function test_armada {
|
||||
TMPETC=$1
|
||||
docker run \
|
||||
-d --name "${ARMADA_CONTAINER_NAME}" --net host \
|
||||
-v ${TMPETC}:/etc/armada \
|
||||
${IMAGE}
|
||||
|
||||
# If the image build pipeline is running in a pod/docker (docker-in-docker),
|
||||
# we'll need to exec into the nested container's network namespace to acces the
|
||||
# armada api.
|
||||
GOOD="HTTP/1.1 204 No Content"
|
||||
RESULT="$(curl -i 'http://127.0.0.1:8000/api/v1.0/health' --noproxy '*' | tr '\r' '\n' | head -1)"
|
||||
if [[ "${RESULT}" != "${GOOD}" ]]; then
|
||||
if docker exec -t ${CONTAINER_NAME} /bin/bash -c "curl -i 'http://127.0.0.1:8000/api/v1.0/health' --noproxy '*' | tr '\r' '\n' | head -1 "; then
|
||||
RESULT="${GOOD}"
|
||||
fi
|
||||
fi
|
||||
sleep 10
|
||||
|
||||
docker stop ${CONTAINER_NAME}
|
||||
docker logs ${CONTAINER_NAME}
|
||||
docker rm ${CONTAINER_NAME}
|
||||
RESULT=$(curl --noproxy '*' -i 'http://127.0.0.1:8000/api/v1.0/health' | tr '\r' '\n' | head -1)
|
||||
GOOD="HTTP/1.1 204 No Content"
|
||||
if [[ "${RESULT}" != "${GOOD}" ]]; then
|
||||
if docker exec -t ${CONTAINER_NAME} /bin/bash -c "curl -i 'http://127.0.0.1:8000/api/v1.0/health' --noproxy '*' | tr '\r' '\n' | head -1 "; then
|
||||
RESULT="${GOOD}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ${RESULT} == ${GOOD} ]]; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
if [[ ${RESULT} == ${GOOD} ]]
|
||||
then
|
||||
RC=0
|
||||
else
|
||||
RC=1
|
||||
fi
|
||||
|
||||
docker logs "${ARMADA_CONTAINER_NAME}"
|
||||
return $RC
|
||||
}
|
||||
|
||||
function cleanup {
|
||||
TMPDIR=$1
|
||||
docker stop "${ARMADA_CONTAINER_NAME}"
|
||||
docker rm "${ARMADA_CONTAINER_NAME}"
|
||||
rm -rf $TMPDIR
|
||||
}
|
||||
|
||||
TMPETC=$(generate_conf)
|
||||
|
||||
test_armada $TMPETC
|
||||
RC=$?
|
||||
|
||||
cleanup $TMPETC
|
||||
|
||||
exit $RC
|
||||
|
@ -18,6 +18,7 @@
|
||||
- ensure-docker
|
||||
- ensure-python
|
||||
- ensure-pip
|
||||
- ensure-tox
|
||||
|
||||
tasks:
|
||||
- include_vars: vars.yaml
|
||||
@ -56,6 +57,19 @@
|
||||
executable: pip3
|
||||
become: True
|
||||
|
||||
|
||||
|
||||
- name: Run images
|
||||
when: not publish
|
||||
shell: |
|
||||
make run_images
|
||||
args:
|
||||
chdir: "{{ zuul.project.src_dir }}"
|
||||
executable: /bin/bash
|
||||
become: True
|
||||
|
||||
|
||||
|
||||
- name: Make images
|
||||
when: not publish
|
||||
block:
|
||||
|
Loading…
Reference in New Issue
Block a user