One upgrade for nixos-router and the packages
Check, preview and apply look at the repository's release tags and the channel together; the new nixos-router is a highlighted row in the preview table. The update server section and the separate git update are gone; bundles stay. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+42
-32
@@ -351,14 +351,15 @@ pkgs.testers.runNixOSTest {
|
||||
pinned()
|
||||
target.wait_for_unit("router-webui.service")
|
||||
|
||||
with subtest("the same update, pulled from a server in the web UI, can be confirmed"):
|
||||
with subtest("the same update, pulled from a server, can be confirmed in the web UI"):
|
||||
login()
|
||||
token = csrf("/update")
|
||||
form = lambda path, data: builder.succeed(
|
||||
f"curl -sk -b /tmp/jar -o /tmp/out -w '%{{http_code}}' --data-urlencode csrf={token} {data} {ui}{path}").strip()
|
||||
assert form("/update/url", "--data-urlencode url=http://${builderIp}:8004/") == "303"
|
||||
assert "Available: <strong>2.0.0</strong>" in (form("/update/check", "") and builder.succeed("cat /tmp/out"))
|
||||
assert form("/update/install", "") == "303"
|
||||
# The page has no update server to set any more; the command line still pulls.
|
||||
page = builder.succeed(f"curl -sk -b /tmp/jar {ui}/update")
|
||||
assert "Update server" not in page, page
|
||||
# (As the unit, like the web UI starts it: the switch restarts the web UI.)
|
||||
target.succeed("mkdir -p /var/lib/router/update"
|
||||
" && echo '{\"mode\":\"url\",\"url\":\"http://${builderIp}:8004\",\"force\":false}' > /var/lib/router/update/request.json"
|
||||
" && systemctl start --no-block router-update.service")
|
||||
update_finished()
|
||||
assert version() == "2.0.0"
|
||||
target.succeed("systemctl is-active router-rollback.timer")
|
||||
@@ -382,7 +383,14 @@ pkgs.testers.runNixOSTest {
|
||||
assert rc != 0 and "not newer" in out, out
|
||||
assert version() == "2.0.0"
|
||||
|
||||
with subtest("a release in a git repository is found, built and installed like a bundle"):
|
||||
def upgrade_finished():
|
||||
target.wait_until_succeeds(
|
||||
"state=$(systemctl show -p ActiveState --value router-upgrade.service);"
|
||||
" test $state = inactive -o $state = failed", timeout=300)
|
||||
result = target.succeed("systemctl show -p Result --value router-upgrade.service").strip()
|
||||
assert result == "success", (result, target.succeed("journalctl -u router-upgrade.service --no-pager | tail -30"))
|
||||
|
||||
with subtest("a release in a git repository is found with the packages, previewed and installed like any upgrade"):
|
||||
repo = "http://${builderIp}:8005/router.git"
|
||||
builder.succeed("cp -r ${v3.src} /root/v3 && chmod -R u+w /root/v3")
|
||||
builder.succeed("cd /root/v3 && git init -q -b main && git add -A"
|
||||
@@ -401,30 +409,33 @@ pkgs.testers.runNixOSTest {
|
||||
form = lambda path, data: builder.succeed(
|
||||
f"curl -sk -b /tmp/jar -o /tmp/out -w '%{{http_code}}' --data-urlencode csrf={token} {data} {ui}{path}").strip()
|
||||
assert form("/update/repository", f"--data-urlencode repository={repo}") in ("404", "405")
|
||||
assert form("/update/gitcheck", "") == "303"
|
||||
target.wait_until_succeeds(
|
||||
"test $(systemctl show -p ActiveState --value router-update-check.service) = inactive"
|
||||
" && test $(systemctl show -p Result --value router-update-check.service) = success", timeout=120)
|
||||
check = json.loads(target.succeed("cat /var/lib/router/update/check.json"))
|
||||
assert check["newer"] is True and check["newest"] == {"tag": "v3.0.0", "version": "3.0.0", "rev": commit} and check["installed"] == "2.0.0", check
|
||||
assert form("/update/gitcheck", "") in ("404", "405")
|
||||
# One check looks at both: the repository and the channel.
|
||||
assert form("/upgrade/check", "") == "303"
|
||||
upgrade_finished()
|
||||
check = json.loads(target.succeed("cat /var/lib/router/upgrade/check.json"))
|
||||
assert check["router"]["newer"] is True and check["router"]["newest"] == {"tag": "v3.0.0", "version": "3.0.0", "rev": commit}, check
|
||||
assert check["router"]["installed"] == "2.0.0" and check["packagesUpToDate"] is True and check["upToDate"] is False, check
|
||||
assert "nixos-router 3.0.0 is out" in builder.succeed(f"curl -sk -b /tmp/jar {ui}/")
|
||||
assert "Install 3.0.0" in builder.succeed(f"curl -sk -b /tmp/jar {ui}/update")
|
||||
page = builder.succeed(f"curl -sk -b /tmp/jar {ui}/update")
|
||||
assert "<strong>3.0.0</strong>" in page and "A newer version is available" in page, page
|
||||
|
||||
# Only tags that are versions are releases; a newer tag of another kind is ignored.
|
||||
builder.succeed("cd /root/v3 && git tag nightly && git tag v4.0 && git push -q /srv/git/router.git nightly v4.0")
|
||||
target.succeed("router-update check >&2")
|
||||
assert json.loads(target.succeed("cat /var/lib/router/update/check.json"))["newest"]["tag"] == "v3.0.0"
|
||||
target.succeed("router-upgrade check >&2")
|
||||
assert json.loads(target.succeed("cat /var/lib/router/upgrade/check.json"))["router"]["newest"]["tag"] == "v3.0.0"
|
||||
|
||||
rc, out = target.execute("router-update --git v9.9.9 2>&1")
|
||||
assert rc != 0 and "no such release tag" in out, out
|
||||
rc, out = target.execute("router-update --git 'v3.0.0; reboot' 2>&1")
|
||||
assert rc != 0 and "not a release tag" in out, out
|
||||
assert version() == "2.0.0"
|
||||
# The preview names the router's own update, in the table with the packages.
|
||||
assert form("/upgrade/preview", "") == "303"
|
||||
upgrade_finished()
|
||||
preview = json.loads(target.succeed("cat /var/lib/router/upgrade/preview.json"))
|
||||
assert preview["router"]["from"] == "2.0.0" and preview["router"]["to"] == "3.0.0", preview
|
||||
page = builder.succeed(f"curl -sk -b /tmp/jar {ui}/update")
|
||||
assert 'class="highlight"' in page and "<td>nixos-router</td>" in page and "Upgrade nixos-router to 3.0.0 and" in page, page
|
||||
# Nothing has changed on the router until the upgrade is applied.
|
||||
assert version() == "2.0.0" and "v3.0.0" not in target.succeed("cat /var/lib/router/config/flake.nix")
|
||||
|
||||
login()
|
||||
token = csrf("/update")
|
||||
assert form("/update/gitinstall", "--data-urlencode tag=v3.0.0") == "303"
|
||||
update_finished()
|
||||
target.succeed("router-upgrade apply 5min >&2")
|
||||
assert version() == "3.0.0", release_json()
|
||||
flake = target.succeed("cat /var/lib/router/config/flake.nix")
|
||||
assert f"git+{repo}?ref=refs/tags/v3.0.0&rev={commit}" in flake, flake
|
||||
@@ -433,7 +444,6 @@ pkgs.testers.runNixOSTest {
|
||||
assert locked["type"] == "git" and locked["rev"] == commit, locked
|
||||
settings = target.succeed("cat /var/lib/router/config/settings.json")
|
||||
assert '"version": 2' in settings and "Europe/Paris" in settings, settings
|
||||
assert "router-update-check" not in settings
|
||||
pinned()
|
||||
target.succeed("systemctl is-active router-rollback.timer")
|
||||
login()
|
||||
@@ -449,10 +459,10 @@ pkgs.testers.runNixOSTest {
|
||||
assert "no changes" in out, out
|
||||
builder.succeed("systemd-run --unit=git-server-again /etc/git-server.py /srv/git 8005")
|
||||
builder.wait_for_open_port(8005, "${builderIp}")
|
||||
target.succeed("router-update check >&2")
|
||||
check = json.loads(target.succeed("cat /var/lib/router/update/check.json"))
|
||||
assert check["newer"] is False and check["installed"] == "3.0.0", check
|
||||
rc, out = target.execute("router-update --git latest 2>&1")
|
||||
assert rc != 0 and "not newer" in out, out
|
||||
target.succeed("router-upgrade check >&2")
|
||||
check = json.loads(target.succeed("cat /var/lib/router/upgrade/check.json"))
|
||||
assert check["router"]["newer"] is False and check["router"]["installed"] == "3.0.0" and check["upToDate"] is True, check
|
||||
out = target.succeed("router-upgrade preview 2>&1")
|
||||
assert "up to date" in out, out
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user