def test_pragma_no_cache(self, header_name, header_value): cached_value, miss_values = get_timestamp_until_hit('/timestamp/cached') assert cached_value in miss_values # Should fetch resource from the master no_cache_value = get_timestamp('/timestamp/cached', extra_headers={header_name: header_value}) assert no_cache_value != cached_value # Checking that the new response was cached hit_value, miss_values = get_timestamp_until_hit('/timestamp/cached') assert hit_value in [no_cache_value] + miss_values
def test_expires_after_ttl(self): """We have set the expire times to > 1 sec because the docker image we use Cassandra acceptance testing does not run in-memory Cassandra. This needs to be fixed with PERF-1679.""" cached_value, miss_values = get_timestamp_until_hit('/timestamp/ttl') assert cached_value in miss_values # Cache entry should be expired after 2 seconds time.sleep(2) new_value = get_timestamp('/timestamp/ttl') assert new_value != cached_value
def test_purge_cassandra(self): val1_before = get_timestamp('/timestamp/purge/1') val2_before = get_timestamp('/timestamp/purge/2') val3_before = get_timestamp('/long_ttl/no-purge') response = purge_resource({'namespace': 'backend.main', 'cache_name': 'timestamp'}) assert response == 'Purged namespace: backend.main & cache_name: timestamp' val1_after = get_timestamp('/timestamp/purge/1') val2_after = get_timestamp('/timestamp/purge/2') val3_after, miss_values = get_timestamp_until_hit('/long_ttl/no-purge') # Both val1 and val2 should be deleted after purge; # however, val3 should remain as is before and after the purge. assert val1_before != val1_after assert val2_before != val2_after assert val3_before in [val3_after] + miss_values
def test_endpoint_cached(self): hit_value, miss_values = get_timestamp_until_hit('/timestamp/cached') assert hit_value in miss_values