Skip to content

Commit

Permalink
Fixed DinD integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
virtualzone committed Apr 24, 2022
1 parent 8125e20 commit eb3ef22
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
- name: Build integration test image
run: docker build -t compose-test -f test.Dockerfile .
- name: Run integration test
run: docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro -t compose-test
run: docker run --rm --add-host=host.docker.internal:host-gateway -v /var/run/docker.sock:/var/run/docker.sock:ro -t compose-test
1 change: 1 addition & 0 deletions test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ RUN \
WORKDIR /test
ADD ./test/ /test/
COPY --from=builder /go/src/app/main /test/docker-compose-watcher
EXPOSE 1883
CMD ["/test/run-test.sh"]
3 changes: 3 additions & 0 deletions test/mqtt.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM eclipse-mosquitto:2
ADD mosquitto.conf /mosquitto/config/
ADD mqpass /mosquitto/config/
8 changes: 5 additions & 3 deletions test/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ function checkMqttLogContains() {
function runComposeUpdateAndLog() {
sh -c "docker exec compose-test-mqtt mosquitto_sub -h 127.0.0.1 -u compose-updater -P ${MQTT_PASS} -t 'composeupdater/#' -v" &> ${WORKDIR}/mqtt.log &
sleep 1
ONCE=1 PRINT_SETTINGS=1 MQTT_BROKER=tcp://127.0.0.1:1883 MQTT_USERNAME=compose-updater MQTT_PASSWORD=${MQTT_PASS} ${WORKDIR}/docker-compose-watcher &> ${WORKDIR}/test.log
ONCE=1 PRINT_SETTINGS=1 MQTT_BROKER=tcp://host.docker.internal:1883 MQTT_USERNAME=compose-updater MQTT_PASSWORD=${MQTT_PASS} ${WORKDIR}/docker-compose-watcher &> ${WORKDIR}/test.log
sleep 1
kill $(ps | grep "docker exec compose-test-mqtt mosquitto_sub" | grep -v "grep" | cut -d' ' -f 1)
kill $(ps | grep "docker exec compose-test-mqtt mosquitto_sub" | grep -v "grep" | sed -e 's/^[[:space:]]*//' | cut -d' ' -f 1)
echo "------------ Compose Updater Log ------------"
cat ${WORKDIR}/test.log
echo "----------------- MQTT Log ------------------"
Expand Down Expand Up @@ -148,6 +148,7 @@ mkdir -p ${WORKDIR} ${WORKDIR}/c1 ${WORKDIR}/c2 ${WORKDIR}/src
cp ./test.Dockerfile ${WORKDIR}/Dockerfile
cp ./mosquitto.conf ${WORKDIR}
cp ./mqpass ${WORKDIR}
cp ./mqtt.Dockerfile ${WORKDIR}
PWD=$(echo ${WORKDIR} | sed 's_/_\\/_g')
cat ./c1.yaml | sed "s/\${PWD}/${PWD}/g" > ${WORKDIR}/c1/compose1.yaml
cat ./c2.yaml | sed "s/\${PWD}/${PWD}/g" > ${WORKDIR}/c2/docker-compose.yml
Expand All @@ -158,7 +159,8 @@ docker build -q --no-cache -t watcher-test-1 ${WORKDIR}
docker build -q --no-cache -t watcher-test-2 ${WORKDIR}

echo "Starting MQTT broker..."
docker run --rm -p 1883:1883 --name compose-test-mqtt -v ${WORKDIR}/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro -v ${WORKDIR}/mqpass:/mosquitto/config/mqpass:ro -d eclipse-mosquitto:latest
docker build -t compose-test-mqtt -f ${WORKDIR}/mqtt.Dockerfile ${WORKDIR}
docker run --rm -p 1883:1883 --name compose-test-mqtt -d compose-test-mqtt

echo "Starting composition 1..."
docker compose -f ${WORKDIR}/c1/compose1.yaml up -d --quiet-pull
Expand Down

0 comments on commit eb3ef22

Please sign in to comment.