Skip to content

Commit

Permalink
improvement(events): add rack aware policy event
Browse files Browse the repository at this point in the history
Add RackAwarePolicy cassandra-stress log event when a test runs with
multiple availability zone
  • Loading branch information
juliayakovlev committed Jan 2, 2025
1 parent 2bfc791 commit eebcada
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions defaults/severities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ CassandraStressLogEvent.OperationOnKey: CRITICAL
# TODO: mechanism.
CassandraStressLogEvent.TooManyHintsInFlight: ERROR
CassandraStressLogEvent.ShardAwareDriver: NORMAL
CassandraStressLogEvent.RackAwarePolicy: NORMAL
CassandraStressLogEvent.SchemaDisagreement: WARNING
CqlStressCassandraStressLogEvent.ReadValidationError: CRITICAL
SchemaDisagreementErrorEvent: ERROR
Expand Down
3 changes: 3 additions & 0 deletions sdcm/report_templates/results_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ <h3>Test details</h3>
{% if shard_awareness_driver %}
<li> Cassandra-stress uses shared-aware driver</li>
{% endif %}
{% if rack_aware_policy %}
<li> Cassandra-stress uses RackAwareRoundRobinPolicy with provided rack name</li>
{% endif %}
</ul>
</div>

Expand Down
5 changes: 4 additions & 1 deletion sdcm/sct_events/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class CassandraStressLogEvent(LogEvent, abstract=True):
OperationOnKey: Type[LogEventProtocol]
TooManyHintsInFlight: Type[LogEventProtocol]
ShardAwareDriver: Type[LogEventProtocol]
RackAwarePolicy: Type[LogEventProtocol]
SchemaDisagreement: Type[LogEventProtocol]


Expand Down Expand Up @@ -230,6 +231,8 @@ def msgfmt(self):
regex="Using optimized driver")
CassandraStressLogEvent.add_subevent_type("SchemaDisagreement", severity=Severity.WARNING,
regex="No schema agreement")
CassandraStressLogEvent.add_subevent_type("RackAwarePolicy", severity=Severity.NORMAL,
regex=r"Using provided rack name '.+' for RackAwareRoundRobinPolicy")


CS_ERROR_EVENTS = (
Expand All @@ -239,7 +242,7 @@ def msgfmt(self):
CassandraStressLogEvent.ConsistencyError(),
CassandraStressLogEvent.SchemaDisagreement(),
)
CS_NORMAL_EVENTS = (CassandraStressLogEvent.ShardAwareDriver(), )
CS_NORMAL_EVENTS = (CassandraStressLogEvent.ShardAwareDriver(), CassandraStressLogEvent.RackAwarePolicy(), )

CS_ERROR_EVENTS_PATTERNS: List[Tuple[re.Pattern, LogEventProtocol]] = \
[(re.compile(event.regex), event) for event in CS_ERROR_EVENTS]
Expand Down
1 change: 1 addition & 0 deletions sdcm/send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class BaseEmailReporter:
"test_status",
"username",
"shard_awareness_driver",
"rack_aware_policy",
"restore_monitor_job_base_link",
)
_fields = ()
Expand Down
9 changes: 9 additions & 0 deletions sdcm/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -3808,6 +3808,7 @@ def _get_common_email_data(self) -> Dict[str, Any]:
"test_status": test_status,
"username": get_username(),
"shard_awareness_driver": self.is_shard_awareness_driver,
"rack_aware_policy": self.is_rack_aware_policy,
"restore_monitor_job_base_link": restore_monitor_job_base_link,
"relocatable_pkg": get_relocatable_pkg_url(scylla_version)}

Expand Down Expand Up @@ -3848,6 +3849,14 @@ def is_shard_awareness_driver(self) -> bool:
return True
return False

@property
def is_rack_aware_policy(self) -> bool:
all_events = get_events_grouped_by_category()
for event_str in all_events["NORMAL"]:
if "type=RackAwarePolicy" in event_str:
return True
return False

def get_cs_range_histogram(self, stress_operation: str,
start_time: float, end_time: float,
tag_type: CSHistogramTagTypes = CSHistogramTagTypes.LATENCY) -> dict[str, Any]:
Expand Down
7 changes: 7 additions & 0 deletions unit_tests/test_sct_events_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ def test_known_cs_errors(self):

def test_known_cs_normal(self):
self.assertTrue(issubclass(CassandraStressLogEvent.ShardAwareDriver, CassandraStressLogEvent))
self.assertTrue(issubclass(CassandraStressLogEvent.RackAwarePolicy, CassandraStressLogEvent))

def test_cs_all_events_list(self):
self.assertSetEqual(set(dir(CassandraStressLogEvent)) - set(dir(LogEvent)),
Expand Down Expand Up @@ -442,6 +443,12 @@ def test_cs_normal_shared_awarnes_event(self):
expected_type='ShardAwareDriver',
expected_severity=Severity.NORMAL)

def test_cs_normal_rack_awarnes_event(self):
self.get_event(line="Using provided rack name '1a' for RackAwareRoundRobinPolicy (if this is incorrect, please provide the correct "
"rack name with RackAwareRoundRobinPolicy constructor",
expected_type='RackAwarePolicy',
expected_severity=Severity.NORMAL)


class TestScyllaBenchLogEvent(unittest.TestCase):
def test_known_scylla_bench_errors(self):
Expand Down

0 comments on commit eebcada

Please sign in to comment.