~offspring-committers/offspring/trunk

« back to all changes in this revision

Viewing changes to lib/offspring/master/tests/test_master.py

  • Committer: Kevin McDermott
  • Date: 2013-08-16 16:07:34 UTC
  • mfrom: (170.1.2 indicate-server-error)
  • Revision ID: kevin@canonical.com-20130816160734-3e0p7uh1y2cr8mnz
Merge indicate-server-error [r=schwuk]

This addresses an issue to do with our builder_error_limit, we now set the
"is_okay" flag to false on Builders as they hit the error limit, and send a
notification email to the admins to warn that we've disabled the builder.

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
        master.scanSlaves()
131
131
        self.assertEqual(1, builder.contiguous_errors)
132
132
 
 
133
    def test_scan_slaves_error_count_over_limit(self):
 
134
        """
 
135
        When we detect the master going over the limit, we should set the
 
136
        builder is_okay flag to false and notify a problem.
 
137
        """
 
138
        log_file = self.capture_logging(log_level=logging.DEBUG)
 
139
        self.config.set("master", "builder_error_limit", "3")
 
140
        master, builder = self.build_builder_and_slave_with_job_and_result(
 
141
            result=ProjectBuildStates.FAILED,
 
142
            contiguous_errors=3)
 
143
        master.scanSlaves()
 
144
        self.assertEqual(4, builder.contiguous_errors)
 
145
        self.assertFalse(
 
146
            builder.is_okay, "Builder.is_okay is True when it should be false")
 
147
        # We get two emails, one for the failed build, which is sent to the
 
148
        # people subscribed to the project and the other...
 
149
        self.assertEqual(2, len(self.mailer.mails))
 
150
        sender, recpt, message = self.mailer.mails[1]
 
151
        self.assertTrue(
 
152
            "Subject: Build slave %s has reached error limit" %
 
153
            builder.name in message,
 
154
            "Incorrect subject for notification email")
 
155
 
133
156
    def test_scan_slaves_non_error_resets_error_count(self):
134
157
        """
135
158
        When a builder has a non-erroring build, the contiguous_errors