Merge ~alexsander-souza/maas-ci/+git/system-tests:export_bin_journal into ~maas-committers/maas-ci/+git/system-tests:master

Proposed by Alexsander de Souza
Status: Merged
Approved by: Alexsander de Souza
Approved revision: 556ec834e6e2e6530f70fa7c5264ec472046b6e3
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~alexsander-souza/maas-ci/+git/system-tests:export_bin_journal
Merge into: ~maas-committers/maas-ci/+git/system-tests:master
Diff against target: 47 lines (+11/-7)
2 files modified
systemtests/collect_sos_report/test_collect.py (+10/-6)
systemtests/conftest.py (+1/-1)
Reviewer Review Type Date Requested Status
Christian Grabowski Approve
MAAS Lander Approve
Review via email: mp+451135@code.launchpad.net

Commit message

export complete system journal

exports system logs using the Journal Export Format (https://systemd.io/JOURNAL_EXPORT_FORMATS#journal-export-format)

Description of the change

This format can be converted back to the binary journal and filtered using regular journalctl options:

$ xzcat journal.xz | /lib/systemd/systemd-journal-remote -o test.journal -
$ journalctl --file=test.journal $ARGS

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b export_bin_journal lp:~alexsander-souza/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/system-tests-tester/707/console
COMMIT: dfbad6de000561aa285aca3b839affe08e87adef

review: Needs Fixing
b552395... by Alexsander de Souza

format

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b export_bin_journal lp:~alexsander-souza/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/system-tests-tester/708/console
COMMIT: b3acfa67e57894e655ad86b9adf9c37182c160e8

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b export_bin_journal lp:~alexsander-souza/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/system-tests-tester/709/console
COMMIT: b5523958f840b4c1840865c5ac9727d70115080c

review: Needs Fixing
556ec83... by Alexsander de Souza

fix mypy compatibility

latest mypy don't like this ignore

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b export_bin_journal lp:~alexsander-souza/maas-ci/+git/system-tests into -b master lp:~maas-committers/maas-ci/+git/system-tests

STATUS: SUCCESS
COMMIT: 556ec834e6e2e6530f70fa7c5264ec472046b6e3

review: Approve
Revision history for this message
Christian Grabowski (cgrabowski) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/systemtests/collect_sos_report/test_collect.py b/systemtests/collect_sos_report/test_collect.py
2index 8b275b2..7dfa70f 100644
3--- a/systemtests/collect_sos_report/test_collect.py
4+++ b/systemtests/collect_sos_report/test_collect.py
5@@ -12,19 +12,23 @@ if TYPE_CHECKING:
6
7 def collect_sos_report(instance: Instance, output: Path) -> None:
8 container_tmp = "/tmp/sosreport"
9- output_dir = output / "sosreport"
10 instance.execute(["apt", "install", "--yes", "sosreport"])
11 instance.execute(["rm", "-rf", container_tmp])
12 instance.execute(["mkdir", "-p", container_tmp])
13 instance.execute(
14 ["sos", "report", "--batch", "-o", "maas", "--tmp-dir", container_tmp]
15 )
16- output_dir.mkdir(parents=True, exist_ok=True)
17- journalctl = instance.execute(
18- ["journalctl", "--unit=vault", "--no-pager", "--output=cat"]
19+ instance.execute(
20+ [
21+ "sh",
22+ "-c",
23+ "journalctl --since='-12h' --output=export "
24+ f"| xz > {container_tmp}/journal.xz",
25+ ]
26 )
27- if journalctl.stdout:
28- (output_dir / "vault-journal").write_text(journalctl.stdout)
29+
30+ output_dir = output / "sosreport"
31+ output_dir.mkdir(parents=True, exist_ok=True)
32 with tempfile.TemporaryDirectory(prefix="sosreport") as tempdir:
33 instance.files[container_tmp].pull(tempdir)
34 for f in (Path(tempdir) / "sosreport").iterdir():
35diff --git a/systemtests/conftest.py b/systemtests/conftest.py
36index 6acabf7..08b5280 100644
37--- a/systemtests/conftest.py
38+++ b/systemtests/conftest.py
39@@ -194,7 +194,7 @@ def pytest_report_header(config: pytest.Config) -> list[str]:
40 return headers + ["END_SYSTEMTESTS_META"]
41
42
43-@pytest.hookimpl(tryfirst=True, hookwrapper=True) # type: ignore
44+@pytest.hookimpl(tryfirst=True, hookwrapper=True)
45 def pytest_runtest_makereport(item: Any, call: Any) -> Iterator[Any]:
46 # execute all other hooks to obtain the report object
47 del call

Subscribers

People subscribed via source and target branches