Runners in tests mode
Run review tests on your own Docker host or Kubernetes cluster with a runner that does nothing else.
A runner in tests mode runs the review tests of your merge requests on your own Docker host or Kubernetes cluster, and nothing else. It is the same program and image as the runner that carries your outbound calls, started with different settings, and it needs its own registration. Merge request code is untrusted, so a test runner holds as little as it can: its own credential, the Git key for one checkout at a time, and your registry logins.
Two kinds of runner
| Kind | Mode | Runs | Needed for |
|---|---|---|---|
| Egress runner | egress (the default) | Model, tool server, cloud, http_request and Git calls, from your network | Optional: when your calls must leave from your own network. See Runners. |
| Test runner | tests | Only test jobs, in throwaway containers or Pods | Review tests. With none, no tests run. |
- A test runner never takes egress work, and an egress runner never takes test jobs.
- A test runner does not move your organisation onto runners. Only an enabled egress runner does. You can run tests on your own machines while model and Git calls still go from the portal, or have both kinds.
- One registration is one mode. A runner that polled in one mode within the last hour is refused in the other; its row on Settings › Runners then says "Refused in the last hour: refused: this runner served egress within the last hour; a test runner needs its own registration (add a runner on Settings › Runners)". Add a second runner for the second mode.
- A test runner holds no model key: it refuses to start with any
ENTROPIX_RUNNER_LLM_*setting. - The runner image is
entropix-runner:0.2.0. An older runner never takes a test job.
Before you start
- Add a runner for tests on Settings › Runners and keep its registration token (see Add a runner). The Install <name> panel has Docker, tests mode and Helm, tests mode commands.
- Build the image from the Entropix source:
docker build -f deploy/runner/Dockerfile -t entropix-runner:0.2.0 . - Give the runner a host or node pool of its own, not beside the portal, an egress runner or production workloads.
Install on a Docker host
The runner runs in a container with the host's Docker socket mounted. For each run and side it makes a workspace volume, an internal network and one container per stage, and attaches itself to that network as entropix-proxy, so the install step reaches only its registry proxy. A runner started on the host itself, not in a container, refuses Docker tests mode.
docker run -d --name entropix-tests-runner --restart unless-stopped \
-e ENTROPIX_PORTAL_URL=https://portal.entropixs.com \
-e ENTROPIX_RUNNER_TOKEN=ereg_… \
-e ENTROPIX_RUNNER_MODE=tests \
-e ENTROPIX_RUNNER_TESTS=docker \
-e ENTROPIX_RUNNER_TEST_SLOTS=2 \
-v /var/run/docker.sock:/var/run/docker.sock \
--group-add "$(stat -c %g /var/run/docker.sock)" \
-v entropix-tests-runner:/var/lib/entropix-runner \
entropix-runner:0.2.0
- Every test container runs as a non-root user with a read-only root, a writable workspace and
/tmp, CPU, memory and process limits, all capabilities dropped and no new privileges. Never privileged, never a host path. - Setup and test stages have no network. Install reaches only the hosts in the registry list, through the runner's proxy.
- Peak CPU and memory are sampled every 5 seconds and shown on the run log.
The Docker socket is root on that host: anything that reaches it owns the machine. Keep the host for tests only, and prefer rootless Docker or gVisor (runsc, ENTROPIX_RUNNER_TESTS_GVISOR=true). Settings › Runners says "No sandbox: rootless Docker or gVisor recommended" when the runner finds neither.
Install with Helm
Install a second release, apart from any egress runner, with mode: tests. Helm runs the Kubernetes back end only. The chart takes the credential, so swap the token first:
CRED=$(docker run --rm \
-e ENTROPIX_PORTAL_URL=https://portal.entropixs.com \
-e ENTROPIX_RUNNER_TOKEN=ereg_… \
entropix-runner:0.2.0 register)
helm install entropix-tests deploy/runner/helm/entropix-runner \
--set portalURL=https://portal.entropixs.com \
--set credential="$CRED" \
--set mode=tests,tests.enabled=true \
--set tests.namespace=entropix-tests,tests.createNamespace=true
For each run and side the runner makes, in the tests namespace, a workspace volume claim, an install Pod, a test Pod and their network policies. The Git key never enters a Pod: the runner checks the code out itself and hands it once, with a one-time token, to the install Pod.
| Value | Default | What it does |
|---|---|---|
mode | egress | tests makes this release a test runner |
tests.namespace | entropix-tests | Where test Pods run; tests.createNamespace makes it |
tests.slots | 2 | Test environments one pod runs at once (a run's base and head are two) |
tests.images | golang, python, node, postgres, mysql, redis | The images a run may use |
tests.registryHosts | proxy.golang.org, sum.golang.org | The only hosts the install step may reach |
tests.registries.existingSecret | empty | A Secret in the tests namespace with private registry logins, mounted in the install Pod only |
tests.registries.goprivate | empty | Your private module patterns (GOPRIVATE) |
tests.cache.enabled, .size, .storageClass, .accessMode | on, 20Gi, default, ReadWriteOnce | The dependency cache volume, kept when the release is deleted |
tests.workspaceSize | 5Gi | Each run's workspace volume |
tests.imagePullSecrets | empty | Secrets every test Pod pulls its images with |
tests.gvisor, tests.runtimeClassName | off, empty | Run test Pods under gVisor (a class named gvisor, or the one you name) |
What the release adds
| Object | Where | What |
|---|---|---|
| Role and RoleBinding | The tests namespace | pods create, get, list, delete; pods/log get; persistentvolumeclaims and networkpolicies create, get, list, delete. Nothing cluster-wide, no pods/exec, no Secrets. |
| Cache volume claim | The tests namespace | The dependency cache, one folder per lock-file hash |
| Default-deny network policy | The tests namespace | No traffic in or out of any test Pod. Each run adds its own allow: the install Pod may reach only the runner's proxy (port 3128) and its workspace server (port 9465). |
| Runner ingress network policy | The release's namespace | The runner accepts 3128 and 9465 only from the tests namespace |
Network policies need a network plugin that enforces them, such as Calico or Cilium. Without one, test Pods can reach the network.
The cache volume is ReadWriteOnce by default, enough for one runner pod. With more than one pod, use a ReadWriteMany storage class or turn the cache off. Kubernetes runs do not report peak CPU or memory.
Registry logins and private modules
- Registry logins live only on the runner and are never sent to the portal. On Docker, give an env file in
ENTROPIX_RUNNER_TESTS_REGISTRY_ENVand a netrc file inENTROPIX_RUNNER_TESTS_NETRC; on Kubernetes, thetests.registries.existingSecretSecret. - They are given to the install step only, never to setup or test, and never for a change from outside the team.
- Keep them read-only and scoped to the packages the tests need. Values that look like them are masked in every log.
- An outside author's change whose
go.modneeds a module matching your private patterns (ENTROPIX_RUNNER_TESTS_GOPRIVATE) stops before install and waits for a person's Run on the review's Tests tab.
The dependency cache
Downloaded modules are kept between runs, keyed by the hash of go.sum, so only runs with the same lock file share an entry. A team member's run may write the cache. A run from outside the team reads it only, and keeps anything new in its own workspace. Setup and test stages always see the cache read-only. The run log says whether the cache was hit and whether it was read-only.
Runner settings for tests mode
| Setting | Default | What it does |
|---|---|---|
ENTROPIX_RUNNER_MODE | egress | tests makes it a test runner |
ENTROPIX_RUNNER_TESTS | required in tests mode | docker or kubernetes |
ENTROPIX_RUNNER_TEST_SLOTS | 2 | Test environments at once, 1 to 16. A run's base and head take one each; with 1 slot they run one after the other. |
ENTROPIX_RUNNER_TESTS_IMAGES | the official golang, python, node, postgres, mysql and redis images | The images a run may use, comma-separated |
ENTROPIX_RUNNER_TESTS_REGISTRY_HOSTS | proxy.golang.org,sum.golang.org | The only hosts the install step may reach |
ENTROPIX_RUNNER_TESTS_GOPRIVATE | none | Your private module patterns |
ENTROPIX_RUNNER_TESTS_REGISTRY_ENV, ENTROPIX_RUNNER_TESTS_NETRC | none | Docker: the registry logins for the install step |
ENTROPIX_RUNNER_TESTS_GVISOR | false | Docker: run every test container under runsc |
ENTROPIX_RUNNER_TESTS_IMAGE_PULL_SECRETS | none | Kubernetes: pull secrets for every test Pod, comma-separated (the chart sets it, and the other Kubernetes settings, from its values) |
Sizing
| Per | Need |
|---|---|
| Test environment (a run's base and head are two) | About 4 vCPU and 8 GiB |
| Runner host or node pool | 30 to 50 GB of disk for images and dependency caches |
| Outbound | The Git host, the package registries, the image registry and the portal |
How it works
- Taking a job. The runner polls as usual, saying it is in tests mode and how many runs it has room for. It takes only test jobs. A test job no test runner takes within 30 minutes is skipped.
- The run. It reads the job's body (the commits, the Git request, the tests, the settings and the limits), checks out the base and the head, runs each side's stages, and posts stage changes, log pieces of at most 256 KiB and each test's result back to the portal as it goes. Every log piece is masked before it is sent, and again when it is stored.
- Limits. Each stage has its own limit (see Limits). The runner's limit for the whole run is the stage limits plus 5 minutes, doubled when it has a single slot; the portal's covers both sides.
- Cancelling. A new push to the merge request cancels the run. The portal tells the runner on its next poll, and the runner stops and removes the run's containers or Pods.
- Stopping. On a stop signal the runner ends its runs, removes their environments (for up to about 2 minutes) and tells the portal the runner stopped. A run with no finished stage is retried once.
- Leftovers. Every 10 minutes the runner removes containers, volumes, networks and Pods of its runs that are more than an hour old.
The test endpoints
Besides the usual runner endpoints, a test runner calls two more. Both need Authorization: Bearer erun_… and act only on a job this runner holds; any other job is 404.
| Endpoint | What it does |
|---|---|
GET /hooks/runner/tests/{id} | The body of test job {id}, only while this runner holds its lease. It holds the Git request with its key; the portal keeps it sealed and clears it when the job ends. |
POST /hooks/runner/tests/{id}/events | The run's events: stages started and finished, log pieces, test results and the final state. At most 32 MiB a post. The answer says cancel when the run was called off. |
What you can and can't do
- Run tests on a Docker host or a Kubernetes cluster you own.
- Keep registry logins on the runner, away from the portal.
- Run tests without moving your other work onto runners.
- Isolate test containers with rootless Docker or gVisor.
- Use one runner for both egress work and tests.
- Run the Docker back end from a runner outside a container.
- Run the Docker back end through Helm.
- Let a test reach the network in setup or test.
Troubleshooting
- "a tests-mode runner needs ENTROPIX_RUNNER_TESTS=docker or kubernetes"
- Set
ENTROPIX_RUNNER_TESTS. - "a tests-mode runner holds no model credential: unset …"
- Remove the
ENTROPIX_RUNNER_LLM_*settings from the test runner. A model key belongs on an egress runner. - "Refused in the last hour: refused: this runner served egress within the last hour; …"
- The credential belongs to an egress runner. Add a new runner for tests and use its token.
- Reviews say "skipped: no test runner free within 30 minutes"
- Your test runners were busy or offline. Add one, or raise
ENTROPIX_RUNNER_TEST_SLOTSortests.slots.