ashb commented on a change in pull request #6654: AIRFLOW-6055: Option for
exponential backoff in Sensors
URL: https://github.com/apache/airflow/pull/6654#discussion_r350088366
##########
File path: tests/sensors/test_base_sensor.py
##########
@@ -502,3 +502,28 @@ def test_sensor_with_invalid_timeout(self):
return_value=None,
poke_interval=10,
timeout=positive_timeout)
+
+ def test_sensor_with_exponential_backoff_off(self):
+ sensor = self._make_sensor(
+ return_value=None,
+ poke_interval=5,
+ timeout=60,
+ exponential_backoff=False)
+
+ started_at = timezone.utcnow() - timedelta(seconds=10)
+ self.assertEqual(sensor._get_next_poke_interval(started_at, 1),
sensor.poke_interval)
+ self.assertEqual(sensor._get_next_poke_interval(started_at, 2),
sensor.poke_interval)
+
+ def test_sensor_with_exponential_backoff_on(self):
+ sensor = self._make_sensor(
+ return_value=None,
+ poke_interval=5,
+ timeout=60,
+ exponential_backoff=True)
+
+ started_at = timezone.utcnow() - timedelta(seconds=10)
+
+ interval1 = sensor._get_next_poke_interval(started_at, 1)
+ interval2 = sensor._get_next_poke_interval(started_at, 2)
+
+ self.assertTrue(interval2 >= sensor.poke_interval >= interval1)
Review comment:
Here too.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services