How to develop Greenboot
November 18, 2021 · View on GitHub
How to test your changes
Container
Ideal for quick development and making sure GitHub tests are going to pass but before creating a pull request, try it out first in a VM with Fedora IoT and/or RHEL For Edge
Comment the line ENTRYPOINT [ "/bin/bash", "launch_all_tests.sh" ] in Dockerfile.
Add this to a docker-compose.yml file:
version: "3.8"
services:
greenboot:
privileged: true
build: .
container_name: greenboot
image: greenboot
volumes:
- /run/systemd/journal:/run/systemd/journal
working_dir: /testing
command: sleep infinity
Run this script
#!/bin/bash
set -e
# Bring down the previous environment in case there was one
docker-compose down
docker-compose up --build -d
docker exec -it greenboot /bin/bash
docker-compose down
Fedora IoT or RFE:
As /usr is mounted as a read-only directory:
-
If you want to test health checks, place them under
/etc/greenboot/check/required.dor/etc/greenboot/check/wanted.d. I personally would go forwanted.dfirst to make sure that you don't end up in a full loop of reboots in case your script goes wrong. -
If you’re editing any of the services under
/usr/libor/usr/libexec, you have two options:- place the updated file under
/etc/systemd/system/{same_name_as_in_usr_lib}and systemd will take this file with more priority. - Advanced version: unlock the deployment and add your files in the proper
/usrdirectory.
- place the updated file under
Unit testing
Health checks, when possible, have been unit-tested with BATS. These tests are placed under the tests folder.
Every file with the .bats extension will be tested.
For declaring/using common environment variables, use common.bash. You can source them in your BATS file.
If you need to add a file, please use tests/testing_files folder.