IF Commons GitHub

physical/machine

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-lab-machine FR-005, 0002-lab-machine FR-004

A disposable machine on a container runtime: the image made from the machine's Containerfile (kept by the hash of its text), the container run with systemd as its first process and the host's network, a key pair made for this run and thrown away with it, sshd set to a free port that only the machine's own address answers, the host key pinned in a file of known hosts, and an executor of Headless that runs a program in it. stop removes the container and the folder of keys whatever happened, and a test that cannot have a runtime says why and is skipped, never passed.

import { runtimeUsable } from "./machine.ts";
// const reason = await runtimeUsable("docker"); // undefined where containers can be run, else why not

Source: commons/lab/src/physical/machine.ts

Mutation score of this file: 92.1% (20 of 253 changes to its code were not noticed by a test).

2 of 6 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

physical.Machinetypeno test imports it
type Machine = { readonly spec: MachineSpec; readonly container: string; /** The port sshd listens on, on 127.0.0.… (599 characters)
type Machine = {
  readonly spec: MachineSpec;
  readonly container: string;
  /** The port sshd listens on, on 127.0.0.1. */
  readonly port: number;
  /** The private key made for this run, which every user of the machine accepts. */
  readonly identityFile: string;
  /** The host key of the machine, pinned: the file a client checks the machine against. */
  readonly knownHostsFile: string;
  /** Runs a program in the machine as root, with no shell between. */
  readonly executor: Executor;
  /** Removes the container and the folder of keys; safe to run twice. */
  stop(): Promise<void>;
};

A running disposable machine.

physical.runtimeUsablefunctionno test imports it
function runtimeUsable(runtime?: Runtime): Promise<string | undefined>

Why containers cannot be run here, or nothing where they can.

physical.startMachinefunctionno test imports it
function startMachine(spec: MachineSpec, runtime?: Runtime): Promise<Result<Machine, string>>

Starts a machine, or says why it could not be: the image is built, the container run, systemd waited for until it is running (or degraded, as a container's usually is), the key and sshd set up and the host key pinned.

Machinetypeno test imports it
type Machine = { readonly spec: MachineSpec; readonly container: string; /** The port sshd listens on, on 127.0.0.… (599 characters)
type Machine = {
  readonly spec: MachineSpec;
  readonly container: string;
  /** The port sshd listens on, on 127.0.0.1. */
  readonly port: number;
  /** The private key made for this run, which every user of the machine accepts. */
  readonly identityFile: string;
  /** The host key of the machine, pinned: the file a client checks the machine against. */
  readonly knownHostsFile: string;
  /** Runs a program in the machine as root, with no shell between. */
  readonly executor: Executor;
  /** Removes the container and the folder of keys; safe to run twice. */
  stop(): Promise<void>;
};

A running disposable machine.

runtimeUsablefunction
function runtimeUsable(runtime?: Runtime): Promise<string | undefined>

Why containers cannot be run here, or nothing where they can.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

startMachinefunction
function startMachine(spec: MachineSpec, runtime?: Runtime): Promise<Result<Machine, string>>

Starts a machine, or says why it could not be: the image is built, the container run, systemd waited for until it is running (or degraded, as a container's usually is), the key and sshd set up and the host key pinned.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.