def test_is_running() -> None: fake_client = FakeClient() bootstrapper = Bootstrapper(fake_client, FakeLowLevelAPI()) assert bootstrapper.is_running("core") is False fake_core = FakeContainer(Bootstrapper.CORE_CONTAINER_NAME) fake_client.set_active_dockers([fake_core]) assert bootstrapper.is_running("core")
def test_start_core_no_config(self) -> None: self.fs.create_file(Bootstrapper.DEFAULT_FILE_PATH, contents=SAMPLE_JSON) self.fs.create_dir(Path(Bootstrapper.DOCKER_CONFIG_PATH)) fake_client = FakeClient() bootstrapper = Bootstrapper(fake_client, FakeLowLevelAPI()) bootstrapper.start("core")
def test_bootstrap_start_bad_json(self) -> None: self.fs.create_file(Bootstrapper.DEFAULT_FILE_PATH, contents=SAMPLE_JSON) self.fs.create_file(Bootstrapper.DOCKER_CONFIG_FILE_PATH, contents=json.dumps({"potato": "bread"})) bootstrapper = Bootstrapper(FakeClient(), FakeLowLevelAPI()) bootstrapper.run() assert bootstrapper.is_running("core")
def test_start_core_and_ttyd(self) -> None: self.fs.create_file(Bootstrapper.DOCKER_CONFIG_FILE_PATH, contents=SAMPLE_JSON) fake_client = FakeClient() bootstrapper = Bootstrapper(fake_client, FakeLowLevelAPI()) bootstrapper.start("core") bootstrapper.start("ttyd") assert bootstrapper.is_running("core") assert bootstrapper.is_running("ttyd")
def test_bootstrap_start(self) -> None: self.fs.create_file(Bootstrapper.DOCKER_CONFIG_FILE_PATH, contents=SAMPLE_JSON) bootstrapper = Bootstrapper(FakeClient(), FakeLowLevelAPI()) assert bootstrapper.is_running("core") is False bootstrapper.run() assert bootstrapper.is_running("core")
#!/usr/bin/env python3 import os import sys import docker from bootstrap.bootstrap import Bootstrapper if __name__ == "__main__": if os.environ.get("BLUEOS_CONFIG_PATH", None) is None: print( "Please supply the host path for the config files as the BLUEOS_CONFIG_PATH environment variable." ) print("Example docker command line:") print( "docker run -it -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.config/blueos:" "/root/.config/blueos -e BLUEOS_CONFIG_PATH=$HOME/.config/blueos" "bluerobotics/blueos-bootstrap:master") sys.exit(1) bootstrapper = Bootstrapper(docker.client.from_env()) bootstrapper.run()
def test_start_core(self) -> None: self.fs.create_file(Bootstrapper.DOCKER_CONFIG_FILE_PATH, contents=SAMPLE_JSON) fake_client = FakeClient() bootstrapper = Bootstrapper(fake_client, FakeLowLevelAPI()) bootstrapper.start_core()