Running tests¶
Running tests through a central server¶
When a client configuration is present, Jumpstarter uses the specified endpoint and token to authenticate with that server
Configuration¶
By default the libraries and CLI will look for a ~/.config/jumpstarter/client.yaml
file, which contains the endpoint and token to authenticate with the Jumpstarter
service.
Alternatively the client can receive the endpoint and token as environment variables:
export JMP_ENDPOINT=jumpstarter.my-lab.com:1443
export JMP_TOKEN=dGhpc2lzYXRva2VuLTEyMzQxMjM0MTIzNEyMzQtc2Rxd3Jxd2VycXdlcnF3ZXJxd2VyLTEyMzQxMjM0MTIz
This is useful for CI/CD systems that inject the environment variables into the pipeline.
Running tests locally (without a server)¶
When no client configuration or environment variables are set, the client will run in local mode and create an exporter instance to interact with the hardware.
Communication between the local client and exporter take place over a local
socket provided by $JUMPSTARTER_HOST
.
$ jmp-exporter shell -c /exporter-config.yaml
$$ echo $JUMPSTARTER_HOST
$$ j ...
$$ exit
$
Using jumpstarter from testing frameworks¶
Pytest¶
Jumpstarter provides a pytest base class that can be used to run tests, the base class will attempt to:
Use a local connection based on the
JUMPSTARTER_HOST
environment variableUse an existing lease based on the
JMP_LEASE
environment variable, and existing credentials. See the cli reference for jmp lease request.Request a lease based on the
filter_labels
provided in the test class.
- class jumpstarter.testing.pytest.JumpstarterTest¶
Base class for Jumpstarter test cases in pytest
This class provides a client fixture that can be used to interact with Jumpstarter services in test cases.
Looks for the JUMPSTARTER_HOST environment variable to connect to an established Jumpstarter shell, otherwise it will try to acquire a lease for a single exporter using the filter_labels annotation. i.e.:
import os import pytest import logging from jumpstarter.testing.pytest import JumpstarterTest log = logging.getLogger(__name__) class TestResource(JumpstarterTest): filter_labels = {"board":"rpi4"} @pytest.fixture() def console(self, client): with PexpectAdapter(client=client.dutlink.console) as console: yield console def test_setup_device(self, client, console): client.dutlink.power.off() log.info("Setting up device") client.dutlink.storage.write_local_file("2024-07-04-raspios-bookworm-arm64-lite.img") client.dutlink.storage.dut() client.dutlink.power.on()