diff --git a/cabot/cabotapp/models/base.py b/cabot/cabotapp/models/base.py index 69c0728c8..efadd3e61 100644 --- a/cabot/cabotapp/models/base.py +++ b/cabot/cabotapp/models/base.py @@ -59,6 +59,9 @@ def default_calculate_debounced_passing(recent_results, debounce=0): """ if not recent_results: return True + # fix when the first run, if the first 0 - debounce checks all error and mark result faild + if len(recent_results) < debounce: + return True debounce_window = recent_results[:debounce + 1] for r in debounce_window: if r.succeeded: diff --git a/cabot/cabotapp/models/jenkins_check_plugin.py b/cabot/cabotapp/models/jenkins_check_plugin.py index 32a216df9..b48fe4a1e 100644 --- a/cabot/cabotapp/models/jenkins_check_plugin.py +++ b/cabot/cabotapp/models/jenkins_check_plugin.py @@ -78,6 +78,7 @@ def calculate_debounced_passing(self, recent_results, debounce=0): return last_result.consecutive_failures <= debounce + class JenkinsConfig(models.Model): name = models.CharField(max_length=30, blank=False) jenkins_api = models.CharField(max_length=2000, blank=False) diff --git a/cabot/cabotapp/tests/tests_jenkins.py b/cabot/cabotapp/tests/tests_jenkins.py index 8983e6cd6..ee598d25b 100644 --- a/cabot/cabotapp/tests/tests_jenkins.py +++ b/cabot/cabotapp/tests/tests_jenkins.py @@ -82,6 +82,7 @@ def test_job_failing(self, mock_jenkins): self.assertEqual(result.consecutive_failures, 1) self.assertFalse(result.succeeded) + @freeze_time('2017-03-02 10:30') @patch("cabot.cabotapp.jenkins._get_jenkins_client") def test_job_queued_last_succeeded(self, mock_jenkins): diff --git a/cabot/cabotapp/views.py b/cabot/cabotapp/views.py index 1b8c16113..decd2ba37 100644 --- a/cabot/cabotapp/views.py +++ b/cabot/cabotapp/views.py @@ -1072,7 +1072,7 @@ def get(self, request): return Response(users_json) - + # Misc JSON api and other stuff