Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ jobs:
os: macos-latest
- python-version: "3.7"
os: macos-latest
include: # So run those legacy versions on Intel CPUs.
- python-version: "3.5"
os: macos-13
- python-version: "3.6"
os: macos-13
- python-version: "3.7"
os: macos-13

steps:
- uses: actions/checkout@v5
Expand Down
21 changes: 13 additions & 8 deletions configcatclienttests/test_autopollingcachepolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def test_init_wait_time_timeout(self):
end_time = time.time()
elapsed_time = end_time - start_time
self.assertEqual(config, None)
self.assertGreaterEqual(elapsed_time, 1)
wait_tolerance = 0.1
self.assertGreaterEqual(elapsed_time, 1 - wait_tolerance)
self.assertLess(elapsed_time, 2)
cache_policy.close()

Expand All @@ -69,7 +70,7 @@ def test_fetch_call_count(self):
cache_policy = ConfigService('', PollingMode.auto_poll(poll_interval_seconds=2,
max_init_wait_time_seconds=1),
Hooks(), config_fetcher, log, config_cache, False)
wait_tolerance = 0.1
wait_tolerance = 0.3
time.sleep(3 + wait_tolerance)
self.assertEqual(config_fetcher.get_call_count, 2)
config, _ = cache_policy.get_config()
Expand Down Expand Up @@ -126,7 +127,8 @@ def test_rerun(self):
cache_policy = ConfigService('', PollingMode.auto_poll(poll_interval_seconds=2,
max_init_wait_time_seconds=5),
Hooks(), config_fetcher, log, config_cache, False)
time.sleep(2.200)
wait_tolerance = 0.4
time.sleep(2 + wait_tolerance)
self.assertEqual(config_fetcher.get_call_count, 2)
cache_policy.close()

Expand All @@ -141,13 +143,14 @@ def test_callback(self):
max_init_wait_time_seconds=5),
hooks, config_fetcher, log, config_cache, False)
time.sleep(1)
wait_tolerance = 0.3
self.assertEqual(config_fetcher.get_call_count, 1)
self.assertEqual(hook_callbacks.changed_config_call_count, 1)
time.sleep(1.2)
time.sleep(1 + wait_tolerance)
self.assertEqual(config_fetcher.get_call_count, 2)
self.assertEqual(hook_callbacks.changed_config_call_count, 1)
config_fetcher.set_configuration_json(TEST_JSON2)
time.sleep(2.2)
time.sleep(2 + wait_tolerance)
self.assertEqual(config_fetcher.get_call_count, 3)
self.assertEqual(hook_callbacks.changed_config_call_count, 2)
cache_policy.close()
Expand All @@ -162,14 +165,15 @@ def test_callback_exception(self):
cache_policy = ConfigService('', PollingMode.auto_poll(poll_interval_seconds=2,
max_init_wait_time_seconds=5),
hooks, config_fetcher, log, config_cache, False)
wait_tolerance = 0.4
time.sleep(1)
self.assertEqual(config_fetcher.get_call_count, 1)
self.assertEqual(hook_callbacks.callback_exception_call_count, 1)
time.sleep(1.2)
time.sleep(1 + wait_tolerance)
self.assertEqual(config_fetcher.get_call_count, 2)
self.assertEqual(hook_callbacks.callback_exception_call_count, 1)
config_fetcher.set_configuration_json(TEST_JSON2)
time.sleep(2.2)
time.sleep(2 + wait_tolerance)
self.assertEqual(config_fetcher.get_call_count, 3)
self.assertEqual(hook_callbacks.callback_exception_call_count, 2)
cache_policy.close()
Expand Down Expand Up @@ -232,7 +236,8 @@ def test_return_cached_config_when_cache_is_not_expired(self):
self.assertEqual(config_fetcher.get_call_count, 0)
self.assertEqual(config_fetcher.get_fetch_count, 0)

time.sleep(3)
wait_tolerance = 0.1
time.sleep(3 + wait_tolerance)

config, _ = cache_policy.get_config()
settings = config.get(FEATURE_FLAGS)
Expand Down