Skip to content

Commit

Permalink
MAX_TTL back to 20y
Browse files Browse the repository at this point in the history
  • Loading branch information
bereng committed Jan 30, 2023
1 parent a0977f3 commit 32863f1
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions ttl_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import time
import datetime

import pytest
import logging

Expand Down Expand Up @@ -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)
Expand All @@ -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'
Expand All @@ -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"
Expand Down

0 comments on commit 32863f1

Please sign in to comment.