Skip to content

Commit

Permalink
Enhanced and more verbose testing in Travis (openhab#859)
Browse files Browse the repository at this point in the history
* ZRAM tests to work if on ARM but lxc
* cond_echo cmd in tryUntil()
* restrict container to 1G for RPi3
* dont allow for failure of BATS tests
* add warning 64bit on aarch64 is NOT supposed to work; check if OH downgrades to 32bit
* reduce to a single shellcheck run (else builds succeed when there's no error in the last run)
* increased verbosity on test cases

Signed-off-by: Markus Storm <[email protected]>
  • Loading branch information
mstormi committed May 4, 2020
1 parent c49196f commit 17ef368
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 48 deletions.
78 changes: 54 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ stages:
- Run unattended openHABian installation

install:
# prepare configuration for tests, select debug level here:
# prepare configuration for tests, select debug level here:
- sed -iE 's#mode=.*$#mode=unattended_debug#' build-image/openhabian.conf
- #sed -iE 's#mode=.*$#mode=debug_maximum#' build-image/openhabian.conf
- echo "Cloning openHABian repo from https://github.com/${TRAVIS_REPO_SLUG}.git"
Expand All @@ -34,60 +34,90 @@ install:

jobs:
fast_finish: true
allow_failures:
- env: aarch64
# allow_failures:
# - env: aarch64
include:
- stage: Dev & Unit tests
env: aarch64
arch: arm64
script:
- sed -i 's/java_arch=32-bit$/java_arch=64-bit/' build-image/openhabian.conf
- docker build -t openhabian/generic-openhabian -f Dockerfile.openhabian-x86 .
- docker run -it openhabian/generic-openhabian bash -c '/usr/local/bin/bats -r -f "dev-." .'
- docker run -it openhabian/generic-openhabian bash -c '/usr/local/bin/bats -r -f "unit-." .'
- docker build -t openhabian/dev-openhabian -f Dockerfile.openhabian-aarch64-native .
- docker run -i openhabian/dev-openhabian bash -c '/usr/local/bin/bats -r -f "dev-." .'
- docker run -i openhabian/dev-openhabian bash -c '/usr/local/bin/bats -r -f "unit-." .'
- stage: BATS and shellcheck tests
env: arm32hf
arch: arm64
script:
- docker build -t openhabian/rpi-openhabian -f Dockerfile.openhabian-emulated .
- docker run --name "bats-inst-tests" -d openhabian/rpi-openhabian bash -c '/usr/local/bin/bats -r -f "installation-." .'
- docker run --name "bats-dest-tests" -d openhabian/rpi-openhabian bash -c '/usr/local/bin/bats -r -f "destructive-." .'
- shellcheck -x -s bash openhabian-setup.sh && echo "shellcheck openhabian-setup.sh - OK";
shellcheck -x -s bash functions/*.bash && echo "shellcheck functions/*.bash - OK";
shellcheck -x -s bash build-image/*.bash && echo "shellcheck build-image/*.bash - OK";
shellcheck -x -s bash build.bash && echo "shellcheck build.bash - OK"
- docker build -t openhabian/bats-openhabian -f Dockerfile.openhabian-aarch64-native .
- docker run --name "bats-inst-tests" -d openhabian/bats-openhabian bash -c '/usr/local/bin/bats -r -f "installation-." .'
- docker run --name "bats-dest-tests" -d openhabian/bats-openhabian bash -c '/usr/local/bin/bats -r -f "destructive-." .'
- shellcheck -x -s bash openhabian-setup.sh functions/*.bash build-image/*.bash build.bash && echo "shellcheck - OK"
- stage: Run unattended openHABian installation
env: amd64
script:
# 64bit Azul Java native on 64bit x86 on 64bit OS on Travis AMD64 HW
- export HW=x86
- sed -i 's/java_arch=32-bit$/java_arch=64-bit/' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-x86 .
- echo -e "\n\e[36mopenHABian test installation 64bit Azul Enterprise Java on virtual $HW ...\n"
- docker run --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
docker exec -i "openhabian-${HW}" bash -c \
'VIRT=$(sudo virt-what); echo -e "\n\e[37mTesting openhabian install on ${VIRT} ...\n"; ./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: arm32hf
arch: arm64
script:
- docker run --rm --privileged multiarch/qemu-user-static:register --reset
- export HW=rpi2
# 32bit Azul Java on 32bit ARMv6hf (RPi0(W) and RPi1) on 32bit OS on Travis Arm64 HW
- export HW=rpi01
- sed -i 's/java_arch=64-bit$/java_arch=32-bit/' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-emulated .
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-ARMv6hf-native .
- echo -e "\n\e[36mopenHABian test installation 32bit Azul Embedded Java on virtual $HW ...\n"
- docker run --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
docker exec -i "openhabian-${HW}" bash -c \
'VIRT=$(sudo virt-what); echo -e "\n\e[37mTesting openhabian install on ${VIRT} ...\n"; ./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: arm32hf
arch: arm64
script:
- docker run --rm --privileged multiarch/qemu-user-static:register --reset
- export HW=rpi01
# 32bit Azul Java on 32bit ARMv7l (RPi2) on 32bit OS on Travis Arm64 HW
- export HW=rpi2
- sed -i 's/java_arch=64-bit$/java_arch=32-bit/' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-ARMv6hf-emulated .
- docker run --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
docker exec -i "openhabian-${HW}" bash -c \
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-arm32hf-native .
- echo -e "\n\e[36mopenHABian test installation 32bit Azul Embedded Java on virtual $HW ...\n"
- docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian
- docker exec -i "openhabian-${HW}" bash -c \
'VIRT=$(sudo virt-what); echo -e "\n\e[37mTesting openhabian install on ${VIRT} ...\n"; ./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: aarch64
arch: arm64
script:
# 64bit Azul Java on 64bit ARMv8 (RPi3, CM3) on 32bit OS on Travis Arm64 HW -- supposed to fail !
- export HW=rpi3
- sed -i 's/java_arch=32-bit$/java_arch=64-bit/' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-aarch64-native .
# Docker doesn't work on Travis ARM yet (it's still alpha), cannot access privileged FS for now ?
# - docker run --name "openhabian-${HW}" --privileged -t -d openhabian/${HW}-openhabian;
- docker run --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
- echo -e "\n\e[36mopenHABian test installation 64bit Azul Embedded Java on virtual $HW ..."
- echo -e "\e[31m ** This is known to not work. openHABian is supposed to force install down to 32bit **\n"
- docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
- docker exec -i "openhabian-${HW}" bash -c \
'VIRT=$(sudo virt-what); echo -e "\n\e[37mTesting openhabian install on ${VIRT} ...\n"; ./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: arm32hf
arch: arm64
script:
# 32bit Azul Java on 64bit ARMv8 (CM3, RPi3) on 32bit OS on Travis Arm64 HW
- export HW=cm3
- sed -i 's/java_arch=64-bit$/java_arch=32-bit/' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-arm32hf-CM3 .
- echo -e "\n\e[36mopenHABian test installation 32bit Azul Embedded Java on virtual $HW ...\n"
- docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
- docker exec -i "openhabian-${HW}" bash -c \
'VIRT=$(sudo virt-what); echo -e "\n\e[37mTesting openhabian install on ${VIRT} ...\n"; ./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'
- env: aarch64
arch: arm64
script:
# 64bit Azul Java on 64bit ARMv8 (RPi3,4) on 64bit OS on Travis Arm64 HW
- export HW=rpi4
- sed -i 's/java_arch=32-bit$/java_arch=64-bit/' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.openhabian-aarch64-64bit .
- echo -e "\n\e[36mopenHABian test installation 64bit Azul Embedded Java \e[31m on 64bit OS\e[36m on virtual $HW ...\n"
- docker run --memory="2G" --memory-reservation="2G" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
docker exec -i "openhabian-${HW}" bash -c \
'VIRT=$(sudo virt-what); echo -e "\n\e[37mTesting openhabian install on ${VIRT} ...\n"; ./build.bash local-test && mv ~/.profile ~/.bash_profile && /etc/rc.local'

54 changes: 54 additions & 0 deletions Dockerfile.openhabian-ARMv6hf-native
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# RPi1, RPi0W (ARMv6hf arch)
FROM balenalib/raspberry-pi-debian-node:latest-buster


ENV container docker
ENV INITSYSTEM on
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn

RUN apt-get update -qq \
&& apt-get install -y -qq --no-install-recommends systemd systemd-sysv git wget python python-pip python3 python3-pip apt-utils jq virt-what \
&& rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/bats-core/bats-core.git && \
cd bats-core && \
./install.sh /usr/local

# We never want these to run in a container
# Feel free to edit the list but this is the one we used
RUN systemctl mask \
dev-hugepages.mount \
sys-fs-fuse-connections.mount \
sys-kernel-config.mount \
display-manager.service \
[email protected] \
systemd-logind.service \
systemd-remount-fs.service \
getty.target \
graphical.target

WORKDIR /
COPY docker-tests/entry.sh /usr/bin/entry.sh
COPY docker-tests/resin.service /etc/systemd/system/resin.service

RUN systemctl enable /etc/systemd/system/resin.service

RUN git clone https://github.com/gdraheim/docker-systemctl-replacement
RUN cp docker-systemctl-replacement/files/docker/systemctl.py /bin/systemctl

ENTRYPOINT ["/usr/bin/entry.sh"]

RUN adduser openhabian --gecos "Openhabian,,," --disabled-password
RUN echo "openhabian:openhabian" | chpasswd
RUN /bin/echo -n "Running on " && /usr/bin/arch

COPY . /opt/openhabian/
COPY build-image/openhabian.conf /etc/openhabian.conf

WORKDIR /opt/openhabian/
COPY docker-tests/start.sh ./

VOLUME ["/sys/fs/cgroup"]
STOPSIGNAL 37

CMD ["bash", "start.sh"]

55 changes: 55 additions & 0 deletions Dockerfile.openhabian-aarch64-64bit
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Note RPi3 base (first RPi to have aarch64 available) WITH 64bit OS
#FROM balenalib/raspberrypi3-debian-node:latest-buster
#FROM balenalib/generic-aarch64-debian-node
FROM balenalib/raspberrypi4-64-debian-node


ENV container docker
ENV INITSYSTEM on
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn

RUN apt-get update -qq \
&& apt-get install -y -qq --no-install-recommends systemd systemd-sysv git wget python python-pip python3 python3-pip apt-utils jq virt-what \
&& rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/bats-core/bats-core.git && \
cd bats-core && \
./install.sh /usr/local

# We never want these to run in a container
# Feel free to edit the list but this is the one we used
RUN systemctl mask \
dev-hugepages.mount \
sys-fs-fuse-connections.mount \
sys-kernel-config.mount \
display-manager.service \
[email protected] \
systemd-logind.service \
systemd-remount-fs.service \
getty.target \
graphical.target

WORKDIR /
COPY docker-tests/entry.sh /usr/bin/entry.sh
COPY docker-tests/resin.service /etc/systemd/system/resin.service

RUN systemctl enable /etc/systemd/system/resin.service

RUN git clone https://github.com/gdraheim/docker-systemctl-replacement
RUN cp docker-systemctl-replacement/files/docker/systemctl.py /bin/systemctl

ENTRYPOINT ["/usr/bin/entry.sh"]

RUN adduser openhabian --gecos "Openhabian,,," --disabled-password
RUN echo "openhabian:openhabian" | chpasswd
RUN /bin/echo -n "Running on " && /usr/bin/arch

COPY . /opt/openhabian/
COPY build-image/openhabian.conf /etc/openhabian.conf

WORKDIR /opt/openhabian/
COPY docker-tests/start.sh ./

VOLUME ["/sys/fs/cgroup"]
STOPSIGNAL 37

CMD ["bash", "start.sh"]
6 changes: 3 additions & 3 deletions Dockerfile.openhabian-aarch64-native
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Note RPi3 base (first RPi to have aarch64 available)
#FROM balenalib/raspberrypi3-debian-node:latest-buster
FROM balenalib/generic-aarch64-debian-node
#FROM balenalib/raspberrypi3-64-debian-node
# ATTENTION: Zulu Java on raspberrypi3 images fails to run
FROM balenalib/raspberrypi3-debian-node:latest-buster
#FROM balenalib/generic-aarch64-debian-node


ENV container docker
Expand Down
54 changes: 54 additions & 0 deletions Dockerfile.openhabian-arm32hf-CM3
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# CM3 is like RPi3 but without BT,WiFi,Ethernet
# ATTENTION: Zulu Java on raspberrypi3 images fails to run
FROM balenalib/fincm3-debian-node:latest-buster


ENV container docker
ENV INITSYSTEM on
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn

RUN apt-get update -qq \
&& apt-get install -y -qq --no-install-recommends systemd systemd-sysv git wget python python-pip python3 python3-pip apt-utils jq virt-what \
&& rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/bats-core/bats-core.git && \
cd bats-core && \
./install.sh /usr/local

# We never want these to run in a container
# Feel free to edit the list but this is the one we used
RUN systemctl mask \
dev-hugepages.mount \
sys-fs-fuse-connections.mount \
sys-kernel-config.mount \
display-manager.service \
[email protected] \
systemd-logind.service \
systemd-remount-fs.service \
getty.target \
graphical.target

WORKDIR /
COPY docker-tests/entry.sh /usr/bin/entry.sh
COPY docker-tests/resin.service /etc/systemd/system/resin.service

RUN systemctl enable /etc/systemd/system/resin.service

RUN git clone https://github.com/gdraheim/docker-systemctl-replacement
RUN cp docker-systemctl-replacement/files/docker/systemctl.py /bin/systemctl

ENTRYPOINT ["/usr/bin/entry.sh"]

RUN adduser openhabian --gecos "Openhabian,,," --disabled-password
RUN echo "openhabian:openhabian" | chpasswd
RUN /bin/echo -n "Running on " && /usr/bin/arch

COPY . /opt/openhabian/
COPY build-image/openhabian.conf /etc/openhabian.conf

WORKDIR /opt/openhabian/
COPY docker-tests/start.sh ./

VOLUME ["/sys/fs/cgroup"]
STOPSIGNAL 37

CMD ["bash", "start.sh"]
File renamed without changes.
53 changes: 53 additions & 0 deletions Dockerfile.openhabian-arm32hf-native
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# assumes at least ARMv71 but not ARMv8 (aarch64) yet
FROM balenalib/raspberry-pi2-debian-node:latest-buster

ENV container docker
ENV INITSYSTEM on
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn

RUN apt-get update -qq \
&& apt-get install -y -qq --no-install-recommends systemd systemd-sysv git wget python python-pip python3 python3-pip apt-utils jq virt-what \
&& rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/bats-core/bats-core.git && \
cd bats-core && \
./install.sh /usr/local

# We never want these to run in a container
# Feel free to edit the list but this is the one we used
RUN systemctl mask \
dev-hugepages.mount \
sys-fs-fuse-connections.mount \
sys-kernel-config.mount \
display-manager.service \
[email protected] \
systemd-logind.service \
systemd-remount-fs.service \
getty.target \
graphical.target

WORKDIR /
COPY docker-tests/entry.sh /usr/bin/entry.sh
COPY docker-tests/resin.service /etc/systemd/system/resin.service

RUN systemctl enable /etc/systemd/system/resin.service

RUN git clone https://github.com/gdraheim/docker-systemctl-replacement
RUN cp docker-systemctl-replacement/files/docker/systemctl.py /bin/systemctl

ENTRYPOINT ["/usr/bin/entry.sh"]

RUN adduser openhabian --gecos "Openhabian,,," --disabled-password
RUN echo "openhabian:openhabian" | chpasswd
RUN /bin/echo -n "Running on " && /usr/bin/arch

COPY . /opt/openhabian/
COPY build-image/openhabian.conf /etc/openhabian.conf

WORKDIR /opt/openhabian/
COPY docker-tests/start.sh ./

VOLUME ["/sys/fs/cgroup"]
STOPSIGNAL 37

CMD ["bash", "start.sh"]

5 changes: 5 additions & 0 deletions build-image/first-boot.bash
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,9 @@ if hash python3 2>/dev/null; then bash /boot/webif.bash inst_done; fi
sleep 12
if hash python3 2>/dev/null; then bash /boot/webif.bash cleanup; fi

if [ -z "$SILENT" ]; then
echo -e "\n\e[36mMemory usage:"
free -m && ps -auxq "$(cat /var/lib/openhab2/tmp/karaf.pid)" |awk '/openhab/ {print "size/res="$5"/"$6" KB"}'
fi

# vim: filetype=sh
Loading

0 comments on commit 17ef368

Please sign in to comment.