# SlopKit Jetlag

Run your software weeks ahead without restarting it. Jetlag changes the date and time that running processes see, so you can check what a trial, an expiry or a scheduled job does on a deployed environment without waiting for the day.

Jetlag 0.1.0 is a self-extracting binary for Linux x86-64. No Nix, no root, no dev shell:

```
mkdir -p ~/.local/bin
curl -fsSL -o ~/.local/bin/jetlag "https://gitlab.techtailors.net/api/v4/projects/slopkit%2Fjetlag/packages/generic/jetlag/0.1.0/jetlag-linux-amd64"
chmod +x ~/.local/bin/jetlag
jetlag version
```

First shifted process is on [Getting started](https://jetlag.slopkit.dev/start/). Commands, targets and the HTTP API are on [Docs](https://jetlag.slopkit.dev/docs/). Source: [slopkit/jetlag](https://gitlab.techtailors.net/slopkit/jetlag). Part of [SlopKit](https://slopkit.dev).

## Three commands

`jetlag shift`
: Move the clock of running processes ahead by an offset such as `30d`, or to a given time. Add `--freeze` to stop it there.

`jetlag run`
: Start a program already shifted. It needs no privilege, and it shifts the processes the program starts too.

`jetlag reset`
: Return the processes to real time, as if Jetlag had never touched them.

## Words used on this site

Clock Shift
: A change to the time a set of processes sees: a jump forward by an Offset, a Freeze, or both. It lasts until it is reset.

Target
: The processes a Clock Shift applies to: one process, a process and its descendants, a cgroup, the pods of a Kubernetes label selector, or the program `jetlag run` started. Processes that start inside a Target while the shift is active are shifted too.

Offset
: How far a Target's clock is ahead of real time, written like `30d`, `-2h` or `90m`.

Freeze
: Stopping a Target's clock at one instant until you advance it, unfreeze it or reset it.

## Why Jetlag

A date-dependent behavior is hard to test because it happens on a date. Jetlag moves the date for the processes you pick and leaves the rest of the machine alone.

- **No restart.** Jetlag shifts a process that is already running. Each process holds its own shift, so Jetlag keeps no database: any `jetlag` can read, advance or reset what another one shifted.
- **No change to the program.** It covers static Go and Rust binaries and Postgres. Clock fakers that preload a library into a program miss static binaries. The program needs no test hook for the clock.
- **Scoped.** A Clock Shift applies to the Target you name and to nothing else. `jetlag resolve` lists the processes a Target selects before you change anything.
- **Reversible.** A reset removes the change from every process.
- **Scriptable.** The command line and a small HTTP API do the same operations, so a test runner can shift and reset the clock.

## Where it fits

[Hunt](https://hunt.slopkit.dev) is the SlopKit test runner. It drives Jetlag through the HTTP API: a Scenario can shift the clock, and Hunt resets it when the Scenario ends. Jetlag also works alone, from a shell.

## Before you use it

- Jetlag is for Controlled Environments. It can change the time of any process it can reach, and on Kubernetes its node agent is close to root on its node.
- Shifting a process Jetlag did not start needs the `CAP_SYS_PTRACE` capability on the binary, or root. A program started with `jetlag run` needs nothing.
- Linux x86-64 only.
- The Kubernetes Targets and the node agent have not been run on a real cluster.
- Jetlag builds on [epochd](https://github.com/bkaznowski/epochd), which has one maintainer. Our changes to it live in a fork, [slopkit/epochd](https://gitlab.techtailors.net/slopkit/epochd) (v0.8.1 plus three changes), and have not been sent upstream.
- Timers that wait for an absolute deadline in the kernel still run on real time.

## Links

- Getting started: https://jetlag.slopkit.dev/start/
- Docs: https://jetlag.slopkit.dev/docs/
- Source: https://gitlab.techtailors.net/slopkit/jetlag
- Site map: https://jetlag.slopkit.dev/llms.txt
