Skip to content

Commit

Permalink
fix(validate_rows_per_partitions): use a new validation event
Browse files Browse the repository at this point in the history
	validate_rows_per_partitions has assertions for the expected number of rows.
	These assertions are now caught and generates a corresponding new event:
	"PartitionRowsValidationEvent". This prevents failing the nemesis thread.
	Fixes: #8292

(cherry picked from commit b6391f9)
  • Loading branch information
yarongilor authored and fruch committed Nov 27, 2024
1 parent d2ae6cd commit a151912
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions defaults/severities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ ScyllaSysconfigSetupEvent: NORMAL
TestStepEvent: ERROR
CpuNotHighEnoughEvent: ERROR
HWPerforanceEvent: CRITICAL
PartitionRowsValidationEvent: CRITICAL
12 changes: 11 additions & 1 deletion sdcm/sct_events/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,20 @@ def msgfmt(self) -> str:
return super().msgfmt


class PartitionRowsValidationEvent(InformationalEvent):
def __init__(self, message: str, severity: Severity = Severity.NORMAL):
super().__init__(severity)
self.message = message

@property
def msgfmt(self) -> str:
return super().msgfmt + ": message={0.message}"


DataValidatorEvent.add_subevent_type("DataValidator")
DataValidatorEvent.add_subevent_type("ImmutableRowsValidator")
DataValidatorEvent.add_subevent_type("UpdatedRowsValidator")
DataValidatorEvent.add_subevent_type("DeletedRowsValidator")


__all__ = ("ClusterHealthValidatorEvent", "DataValidatorEvent", )
__all__ = ("ClusterHealthValidatorEvent", "DataValidatorEvent", "PartitionRowsValidationEvent")
21 changes: 15 additions & 6 deletions sdcm/utils/database_query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from cassandra import ConsistencyLevel

from sdcm.sct_events import Severity
from sdcm.sct_events.health import PartitionRowsValidationEvent
from sdcm.sct_events.system import TestFrameworkEvent
from sdcm.utils.common import PageFetcher
from sdcm.utils.decorators import retrying
Expand Down Expand Up @@ -153,12 +154,20 @@ def validate_rows_per_partitions(self, ignore_limit_rows_number: bool = False):
if not ignore_limit_rows_number and self.limit_rows_number:
missing_rows = {key: val for key, val in partitions_dict_after.items() if
val < self.limit_rows_number}
assert not missing_rows, f"Found missing rows for partitions: {missing_rows}"
else:
self.tester.assertEqual(self.partitions_dict_before,
partitions_dict_after,
msg='Row amount in partitions is not same before and after running of nemesis: '
f' {partitions_dict_after}')
if missing_rows:
PartitionRowsValidationEvent(
message=f"Found missing rows for partitions: {missing_rows}",
severity=Severity.CRITICAL).publish()
return
elif partitions_dict_after != self.partitions_dict_before:
PartitionRowsValidationEvent(
message=f"Row amount in partitions is not same before and after running of nemesis: {partitions_dict_after}",
severity=Severity.CRITICAL).publish()
return

PartitionRowsValidationEvent(
message="Partition rows number is validated.",
severity=Severity.NORMAL).publish()


def get_table_clustering_order(ks_cf: str, ck_name: str, session) -> str:
Expand Down

0 comments on commit a151912

Please sign in to comment.