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
|
# Optionally set the version of Python and requirements required to build your docs
|
||||||
python:
|
python:
|
||||||
version: 3.7
|
version: 3.8
|
||||||
install:
|
install:
|
||||||
- requirements: doc/requirements.txt
|
- requirements: doc/requirements.txt
|
||||||
- requirements: requirements.txt
|
- requirements: requirements-frozen.txt
|
||||||
|
|
|
@ -62,6 +62,9 @@
|
||||||
timeout: 900
|
timeout: 900
|
||||||
run: tools/gate/playbooks/build-charts.yaml
|
run: tools/gate/playbooks/build-charts.yaml
|
||||||
nodeset: armada-single-node-focal
|
nodeset: armada-single-node-focal
|
||||||
|
vars:
|
||||||
|
HTK_COMMIT: a7cd689280cdbc0acd04a7a1b745941260e8700b
|
||||||
|
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: armada-chart-build-latest-htk
|
name: armada-chart-build-latest-htk
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -78,14 +78,14 @@ check-tox:
|
||||||
exit 2; \
|
exit 2; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
images: check-docker build_armada run_armada
|
images: check-docker build_armada
|
||||||
|
|
||||||
docs: clean build_docs
|
docs: clean build_docs
|
||||||
|
|
||||||
build_docs:
|
build_docs:
|
||||||
tox -e docs
|
tox -e docs
|
||||||
|
|
||||||
run_images: run_armada
|
run_images: build_armada run_armada
|
||||||
|
|
||||||
run_armada: build_armada
|
run_armada: build_armada
|
||||||
./tools/armada_image_run.sh $(IMAGE)
|
./tools/armada_image_run.sh $(IMAGE)
|
||||||
|
|
|
@ -88,7 +88,6 @@ RUN set -ex \
|
||||||
/usr/share/doc-base
|
/usr/share/doc-base
|
||||||
|
|
||||||
COPY . ./
|
COPY . ./
|
||||||
COPY etc/armada /etc/armada
|
|
||||||
|
|
||||||
# Setting the version explicitly for PBR
|
# Setting the version explicitly for PBR
|
||||||
ENV PBR_VERSION 0.8.0
|
ENV PBR_VERSION 0.8.0
|
||||||
|
|
|
@ -88,7 +88,6 @@ RUN set -ex \
|
||||||
/usr/share/doc-base
|
/usr/share/doc-base
|
||||||
|
|
||||||
COPY . ./
|
COPY . ./
|
||||||
COPY etc/armada /etc/armada
|
|
||||||
|
|
||||||
# Setting the version explicitly for PBR
|
# Setting the version explicitly for PBR
|
||||||
ENV PBR_VERSION 0.8.0
|
ENV PBR_VERSION 0.8.0
|
||||||
|
|
|
@ -16,33 +16,58 @@
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
IMAGE=$1
|
IMAGE=$1
|
||||||
USE_PROXY=${USE_PROXY:-false}
|
ARMADA_CONTAINER_NAME=armada_test_$(date +%Y%m%d%H%M%s%s)
|
||||||
CONTAINER_NAME=armada_test_$(date +%Y%m%d%H%M%s%s)
|
|
||||||
|
|
||||||
docker create \
|
function generate_conf {
|
||||||
-p 8000:8000 \
|
tox -e genconfig > /dev/null
|
||||||
--name ${CONTAINER_NAME} ${IMAGE}
|
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} &
|
function test_armada {
|
||||||
sleep 5
|
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),
|
sleep 10
|
||||||
# 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
|
|
||||||
|
|
||||||
docker stop ${CONTAINER_NAME}
|
RESULT=$(curl --noproxy '*' -i 'http://127.0.0.1:8000/api/v1.0/health' | tr '\r' '\n' | head -1)
|
||||||
docker logs ${CONTAINER_NAME}
|
GOOD="HTTP/1.1 204 No Content"
|
||||||
docker rm ${CONTAINER_NAME}
|
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
|
if [[ ${RESULT} == ${GOOD} ]]
|
||||||
exit 0
|
then
|
||||||
else
|
RC=0
|
||||||
exit 1
|
else
|
||||||
fi
|
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-docker
|
||||||
- ensure-python
|
- ensure-python
|
||||||
- ensure-pip
|
- ensure-pip
|
||||||
|
- ensure-tox
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- include_vars: vars.yaml
|
- include_vars: vars.yaml
|
||||||
|
@ -56,6 +57,19 @@
|
||||||
executable: pip3
|
executable: pip3
|
||||||
become: True
|
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
|
- name: Make images
|
||||||
when: not publish
|
when: not publish
|
||||||
block:
|
block:
|
||||||
|
|
Loading…
Reference in New Issue