balena-supervisor/docker-compose.test.yml
Felipe Lalanne ee4974a105 Use local socket for tests instead of dind
While this breaks a bit the isolation of the tests, is a bit more
realistic in the sense that the supervisor is running in the same engine
as the rest of the containers.

Change-type: patch
2022-11-11 13:03:59 -03:00

106 lines
2.8 KiB
YAML

version: '2.3'
services:
# Override the supervisor service configuration. The tests will
# be run through the `sut` service
balena-supervisor:
build:
context: ./
dockerfile: Dockerfile.template
args:
ARCH: ${ARCH:-amd64}
image: ${ARCH:-amd64}-supervisor
command: ['/wait-for-it.sh', '--', '/usr/src/app/entry.sh']
# Use bridge networking for the tests
network_mode: 'bridge'
networks:
- default
environment:
DOCKER_HOST: unix:///var/run/docker.sock
DBUS_SYSTEM_BUS_ADDRESS: unix:path=/run/dbus/system_bus_socket
# Required by migrations
CONFIG_MOUNT_POINT: /mnt/root/mnt/boot/config.json
# Read by constants to setup `bootMountpoint`
BOOT_MOUNTPOINT: /mnt/boot
depends_on:
- dbus
- dbus-services
volumes:
- dbus:/run/dbus
- ./test/data/root:/mnt/root
- ./test/lib/wait-for-it.sh:/wait-for-it.sh
- /var/run/docker.sock:/var/run/docker.sock
tmpfs:
- /data # sqlite3 database
dbus:
image: balenablocks/dbus
environment:
DBUS_CONFIG: session.conf
DBUS_ADDRESS: unix:path=/run/dbus/system_bus_socket
volumes:
- dbus:/run/dbus
# Fake system service to listen for supervisor
# requests
dbus-services:
build: ./test/lib/dbus
depends_on:
- dbus
volumes:
- dbus:/run/dbus
environment:
DBUS_SYSTEM_BUS_ADDRESS: unix:path=/run/dbus/system_bus_socket
sut:
# Build the supervisor code for development and testing
build:
context: ./
dockerfile: Dockerfile.template
target: test
args:
# Change this if testing in another architecture
ARCH: ${ARCH:-amd64}
command:
[
'./test/lib/wait-for-it.sh',
'--supervisor',
'--',
'npm',
'run',
'test:integration',
]
depends_on:
- balena-supervisor
- dbus
- dbus-services
volumes:
- dbus:/run/dbus
- /var/run/docker.sock:/var/run/docker.sock
# Set required supervisor configuration variables here
environment:
DOCKER_HOST: unix:///var/run/docker.sock
DBUS_SYSTEM_BUS_ADDRESS: unix:path=/run/dbus/system_bus_socket
BALENA_SUPERVISOR_ADDRESS: http://balena-supervisor:48484
# Required by migrations
CONFIG_MOUNT_POINT: /mnt/root/mnt/boot/config.json
# Read by constants to setup `bootMountpoint`
BOOT_MOUNTPOINT: /mnt/boot
# Set required mounts as tmpfs or volumes here
# if specific files need to be backed up between tests,
# make sure to add them to the `testfs` configuration under
# .mochapodrc.yml
tmpfs:
- /data
- /mnt/root
volumes:
dbus:
driver_opts:
# Use tmpfs to avoid files remaining between runs
type: tmpfs
device: tmpfs
networks:
default: