Skip to content

Commit

Permalink
Add a basic noble migration check script
Browse files Browse the repository at this point in the history
Perform a number of checks to ensure the system is ready for the noble
migration. The results are written to a JSON file in /etc/ that other
things like the JI and the upgrade script itself can read from.

The script is run hourly on a systemd timer but can also be run
interactively for administrators who want slightly more details.

Refs #7322.
  • Loading branch information
legoktm committed Nov 22, 2024
1 parent 105a171 commit 7f8479a
Show file tree
Hide file tree
Showing 10 changed files with 1,810 additions and 177 deletions.
501 changes: 424 additions & 77 deletions Cargo.lock

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions molecule/testinfra/common/test_release_upgrades.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import json
import time

import pytest
import testutils

test_vars = testutils.securedrop_test_vars
Expand Down Expand Up @@ -27,3 +31,40 @@ def test_release_manager_upgrade_channel(host):
_, channel = raw_output.split("=")

assert channel == "never"


def test_migration_check(host):
"""Verify our migration check script works"""
if host.system_info.codename != "focal":
pytest.skip("only applicable/testable on focal")

with host.sudo():
# remove state file so we can see if it works
if host.file("/etc/securedrop-noble-migration.json").exists:
host.run("rm /etc/securedrop-noble-migration.json")
cmd = host.run("systemctl start securedrop-noble-migration-check")
assert cmd.rc == 0
while host.service("securedrop-noble-migration-check").is_running:
time.sleep(1)

# JSON state file was created
assert host.file("/etc/securedrop-noble-migration.json").exists

cmd = host.run("cat /etc/securedrop-noble-migration.json")
assert cmd.rc == 0

contents = json.loads(cmd.stdout)
print(contents)
# The script did not error out
if "error" in contents:
# Run the script manually to get the error message
cmd = host.run("securedrop-noble-migration-check")
print(cmd.stdout)
# We'll fail in the next line after this
assert "error" not in contents
# staging CI jobs don't have enough free space, so just check
# that it returned a value for it
assert "free_space" in contents
del contents["free_space"]
# All the values should be True
assert all(contents.values())
6 changes: 6 additions & 0 deletions noble-migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0.93"
rustix = { version = "0.38.40", features = ["process"] }
serde = { version = "1.0.215", features = ["derive"] }
serde_json = "1.0.132"
url = "2.5.3"
walkdir = "2.5.0"
Loading

0 comments on commit 7f8479a

Please sign in to comment.