diff --git a/ttl_test.py b/ttl_test.py index b9845acfdd..6f2eeaed8e 100644 --- a/ttl_test.py +++ b/ttl_test.py @@ -1,5 +1,7 @@ import os import time +import datetime + import pytest import logging @@ -362,21 +364,13 @@ def test_expiration_overflow_policy_reject(self): def test_expiration_overflow_policy_reject_default_ttl(self): self._base_expiration_overflow_policy_test(default_ttl=True, policy='REJECT') - @since('4.2') - def test_expiration_overflow_policy_none(self): - self._base_expiration_overflow_policy_test(default_ttl=False, policy='NONE') - - @since('4.2') - def test_expiration_overflow_policy_none_default_ttl(self): - self._base_expiration_overflow_policy_test(default_ttl=True, policy='NONE') - def _base_expiration_overflow_policy_test(self, default_ttl, policy): """ Checks that expiration date overflow policy is correctly applied @jira_ticket CASSANDRA-14092 and CASSANDRA-14227 - - Notice this is using the legacy 20y limitation. Newer versions support up to 68y """ + # Post 4.2 C14227 won't overflow until year 2086 + overflow_policy_applies = self.cluster.version() < '4.2' or datetime.date.today().year >= 2086 MAX_TTL = 20 * 365 * 24 * 60 * 60 # 20 years in seconds default_time_to_live = MAX_TTL if default_ttl else None self.prepare(default_time_to_live=default_time_to_live) @@ -394,9 +388,9 @@ def _base_expiration_overflow_policy_test(self, default_ttl, policy): try: result = self.session1.execute_async(query + ";") result.result() - if policy == 'REJECT': + if policy == 'REJECT' and overflow_policy_applies: pytest.fail("should throw InvalidRequest") - if self.cluster.version() >= '3.0': # client warn only on 3.0+ + if self.cluster.version() >= '3.0' and overflow_policy_applies: # client warn only on 3.0+ if policy == 'CAP': logger.debug("Warning is {}".format(result.warnings[0])) assert 'exceeds maximum supported expiration' in result.warnings[0], 'Warning not found' @@ -409,10 +403,10 @@ def _base_expiration_overflow_policy_test(self, default_ttl, policy): self.cluster.flush() # Data should be present unless policy is reject - assert_row_count(self.session1, 'ttl_table', 0 if policy == 'REJECT' else 1) + assert_row_count(self.session1, 'ttl_table', 0 if (policy == 'REJECT' and overflow_policy_applies) else 1) # Check that warning is always logged, unless policy is REJECT - if policy != 'REJECT' and policy != 'NONE': + if policy != 'REJECT' and overflow_policy_applies: node1 = self.cluster.nodelist()[0] prefix = 'default ' if default_ttl else '' warning = node1.grep_log("Request on table {}.{} with {}ttl of {} seconds exceeds maximum supported expiration"