summaryrefslogtreecommitdiff
path: root/tests/vmtests/test_journald_reporter.py
blob: d29b4d4615ac0f6cab1b9dea7bfdbaa2c7a0133e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# This file is part of curtin. See LICENSE file for copyright and license info.

from . import VMBaseClass
from .releases import base_vm_classes as relbase

import json


class TestJournaldReporter(VMBaseClass):
    # Test that curtin with no config does the right thing
    conf_file = "examples/tests/journald_reporter.yaml"
    test_type = 'config'
    extra_disks = []
    extra_nics = []
    extra_collect_scripts = []

    def test_output_files_exist(self):
        self.output_files_exist(["root/journalctl.curtin_events.log",
                                 "root/journalctl.curtin_events.json"])

    def test_journal_reporter_events(self):
        events = json.loads(
            self.load_collect_file("root/journalctl.curtin_events.json"))
        self.assertGreater(len(events), 0)
        e1 = events[0]
        for key in ['CURTIN_EVENT_TYPE', 'CURTIN_MESSAGE', 'CURTIN_NAME',
                    'PRIORITY', 'SYSLOG_IDENTIFIER']:
            self.assertIn(key, e1)


class BionicTestJournaldReporter(relbase.bionic, TestJournaldReporter):
    __test__ = True


class EoanTestJournaldReporter(relbase.eoan, TestJournaldReporter):
    __test__ = True


class FocalTestJournaldReporter(relbase.focal, TestJournaldReporter):
    __test__ = True


# vi: ts=4 expandtab syntax=python