Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced and more verbose testing in Travis #859

Merged
merged 19 commits into from
May 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions functions/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ tryUntil() {
local i=$count
interval=${3:-1}
until [ "$i" -le 0 ]; do
cond_echo "Executing ${cmd}"
eval "${cmd}"
ret=$?
if [ $ret -eq 0 ]; then break; fi
Expand Down
6 changes: 2 additions & 4 deletions functions/zram.bats
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ check_zram_removal() {
}

@test "destructive-zram" {
VIRT=$(virt-what)
if [ "${VIRT}" != "native HW" ]; then skip "Not deploying zram because on (emulated ?) architecture."; fi
if ! is_arm; then skip "Not deploying zram because not on ARM (emulated ?) architecture."; fi

echo -e "# \e[36mZRAM test installation starting..." >&3
run init_zram_mounts install
Expand All @@ -78,8 +77,7 @@ check_zram_removal() {
}

@test "dev-zram" {
VIRT=$(virt-what)
if ! is_arm || [ "${VIRT:-native HW}" != "native HW" ]; then skip "Not executing zram test because not on native ARM architecture hardware."; fi
if ! is_arm; then skip "Not executing zram test because not on native ARM architecture hardware."; fi

echo -e "# \e[36mZRAM test installation starting..." >&3
run init_zram_mounts install
Expand Down