<commit_before># This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright (c) 2021 ScyllaDB

from typing import Type, Optional

from sdcm.sct_events import Severity, SctEventProtocol
from sdcm.sct_events.base import InformationalEvent
from sdcm.sct_events.continuous_event import ContinuousEvent


class ClusterHealthValidatorSubEvents(InformationalEvent, abstract=True):

    def __init__(self, node: str = None, message: str = None, error: str = None, severity: Severity = Severity.UNKNOWN):
        super().__init__(severity=severity)
        self.node = str(node) if node else ""
        self.message = message if message else ""
        self.error = error if error else ""


class ClusterHealthValidatorEvent(ContinuousEvent):
    MonitoringStatus: Type[SctEventProtocol]
    NodeStatus: Type[SctEventProtocol]
    NodePeersNulls: Type[SctEventProtocol]
    NodeSchemaVersion: Type[SctEventProtocol]
    NodesNemesis: Type[SctEventProtocol]
    ScyllaCloudClusterServerDiagnostic: Type[SctEventProtocol]

    def __init__(self,
                 node=None,
                 message: Optional[str] = None,
                 error: Optional[str] = None,
                 severity=Severity.ERROR) -> None:
        super().__init__(severity=severity)

        self.node = str(node) if node else ""
        self.error = error if error else ""
        self.message = message if message else ""

    @property
    def msgfmt(self) -> str:
        message = super().msgfmt
        if self.type:
            message = message + ": type={0.type}"
        if self.node:
            message = message + " node={0.node}"
        if self.severity in (Severity.NORMAL, Severity.WARNING, ):
            if self.message:
                message = message + " message={0.message}"
            return message
        elif self.severity in (Severity.ERROR, Severity.CRITICAL, ):
            if self.error:
                message = message + " error={0.error}"
            return message
        return message


ClusterHealthValidatorEvent.add_subevent_type("NodeStatus", mixin=ClusterHealthValidatorSubEvents)
ClusterHealthValidatorEvent.add_subevent_type("NodePeersNulls", mixin=ClusterHealthValidatorSubEvents)
ClusterHealthValidatorEvent.add_subevent_type("NodeSchemaVersion", mixin=ClusterHealthValidatorSubEvents)
ClusterHealthValidatorEvent.add_subevent_type("NodesNemesis", mixin=ClusterHealthValidatorSubEvents)
ClusterHealthValidatorEvent.add_subevent_type("MonitoringStatus", mixin=ClusterHealthValidatorSubEvents)
ClusterHealthValidatorEvent.add_subevent_type("ScyllaCloudClusterServerDiagnostic",
                                              mixin=ClusterHealthValidatorSubEvents)

<commit_msg>fix(health event): fix default severity<commit_after># This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright (c) 2021 ScyllaDB

from typing import Type, Optional

from sdcm.sct_events import Severity, SctEventProtocol
from sdcm.sct_events.base import InformationalEvent
from sdcm.sct_events.continuous_event import ContinuousEvent


class ClusterHealthValidatorSubEvents(InformationalEvent, abstract=True):

    def __init__(self, node: str = None, message: str = None, error: str = None, severity: Severity = Severity.UNKNOWN):
        super().__init__(severity=severity)
        self.node = str(node) if node else ""
        self.message = message if message else ""
        self.error = error if error else ""


class ClusterHealthValidatorEvent(ContinuousEvent):
    MonitoringStatus: Type[SctEventProtocol]
    NodeStatus: Type[SctEventProtocol]
    NodePeersNulls: Type[SctEventProtocol]
    NodeSchemaVersion: Type[SctEventProtocol]
    NodesNemesis: Type[SctEventProtocol]
    ScyllaCloudClusterServerDiagnostic: Type[SctEventProtocol]

    def __init__(self,
                 node=None,
                 message: Optional[str] = None,
                 error: Optional[str] = None,
                 severity=Severity.NORMAL) -> None:
        super().__init__(severity=severity)

        self.node = str(node) if node else ""
        self.error = error if error else ""
        self.message = message if message else ""

    @property
    def msgfmt(self) -> str:
        message = super().msgfmt
        if self.type:
            message = message + ": type={0.type}"
        if self.node:
            message = message + " node={0.node}"
        if self.severity in (Severity.NORMAL, Severity.WARNING, ):
            if self.message:
                message = message + " message={0.message}"
            return message
        elif self.severity in (Severity.ERROR, Severity.CRITICAL, ):
            if self.error:
                message = message + " error={0.error}"
            return message
        return message


ClusterHealthValidatorEvent.add_subevent_type("NodeStatus", severity=Severity.ERROR,
                                              mixin=ClusterHealthValidatorSubEvents)
ClusterHealthValidatorEvent.add_subevent_type("NodePeersNulls", severity=Severity.ERROR,
                                              mixin=ClusterHealthValidatorSubEvents)
ClusterHealthValidatorEvent.add_subevent_type("NodeSchemaVersion", severity=Severity.ERROR,
                                              mixin=ClusterHealthValidatorSubEvents)
ClusterHealthValidatorEvent.add_subevent_type("NodesNemesis", severity=Severity.ERROR,
                                              mixin=ClusterHealthValidatorSubEvents)
ClusterHealthValidatorEvent.add_subevent_type("MonitoringStatus", severity=Severity.ERROR,
                                              mixin=ClusterHealthValidatorSubEvents)
ClusterHealthValidatorEvent.add_subevent_type("ScyllaCloudClusterServerDiagnostic", severity=Severity.ERROR,
                                              mixin=ClusterHealthValidatorSubEvents)


{'fraction_non_alphanumeric': 0.07708489857250188, 'fraction_numerical': 0.00270473328324568, 'mean_word_length': 3.051125989044431, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3594446', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1688, 'n_words': 464}