4.4 KiB
PR#131: Legacy Sandbox Rename and Instance Restart Check Split into Steps
WARNING: This document describes only the change applied in this PR. It may already be outdated once the next PR is merged. Historic PR-documentation is not maintained along with new PRs — treat it as a snapshot, not as current documentation.
The Problem
Two methods of ConfigLoader stand at or above the Mutation-CRAP target of 15 in the nightly mutation build:
| Method | Mutation-CRAP | Complexity | Killed / eligible |
|---|---|---|---|
ConfigLoader.renameLegacySandbox |
15.93 | 14 | 11 / 14 |
ConfigLoader.checkRestartsInstance |
15.00 | 15 | 14 / 14 |
renameLegacySandbox walked the sections, the entries and the rename in one method, with nested labelled returns.
It was 14.57 in one night and 15.93 in the next: one mutant decides.
checkRestartsInstance has every mutant killed, but its complexity alone is 15, so it has no room below the target.
Non-Goals
- No change of the behaviour: the same rename, the same warning, the same refusals.
The Scenarios
Feature: The legacy bwrap section
Scenario#131.01: An explicit werkdock section wins over the legacy bwrap one
So that a file in the middle of its rename means what its new name says.
- Given a build definition with a
bwrapsection naming a rootfs and a binary - And a
werkdocksection in the same definition naming another rootfs - When the configuration is loaded
- Then the rootfs of
werkdockapplies - And the binary of
bwrap.werkdockbecomeswerkdock.binary
Verified by
Scenario#131.02: A configuration in the old branch format keeps its sandbox binary
So that an installation that has not moved its configuration to build definitions yet still runs its builds with the werkdock binary it names.
- Given a configuration in the old branch format, whose branch
mainnames its werkdock binary under the old section namebwrap - When the configuration is loaded
- Then the branch
mainbuilds with that werkdock binary
Verified by
Scenario#131.03: The legacy name is warned about once per file
So that the log asks for the rename without repeating it on every load, and stays quiet for a file that uses the new name.
- Given a file with a
bwrapsection - When the same loader loads it twice
- Then the warning "reading the 'bwrap' section of …" is logged once
- And a file with a
werkdocksection logs no such warning
Verified by
The Solution
renameLegacySandboxmaps thebuildsandbranchessections throughwithRenamedSandboxes, which maps each entry throughwithRenamedSandbox.- Whether anything was renamed is no longer a flag set inside the lambda: a legacy section is always removed, so the result differs from the input exactly then.
checkRestartsInstancepicks the definitions withrestartsInstance: true;checkRestartingDefinitionrefusesbuilds.defaultand a definition withouttrigger.branches.
Measured locally with PIT on ConfigLoader:
| Method | Mutation-CRAP before | after |
|---|---|---|
ConfigLoader.renameLegacySandbox |
15.93 | 6.17 |
ConfigLoader.withRenamedSandboxes |
new | 3.14 |
ConfigLoader.withRenamedSandbox |
new | 8.00 |
ConfigLoader.checkRestartsInstance |
15.00 | 7.00 |
ConfigLoader.checkRestartingDefinition |
new | 8.00 |
highest of ConfigLoader |
15.93 | 13.93 |
The gate stays at 15. With PR#129 and PR#130, no method of the last nightly report is above 15 any more.
Prerequisite PRs
- PR#130 — this branch is stacked on it, for the version and the release notes.