Exemple #1
0
  def testGetLatestBuildFailuresWhenAlertsAreForTwoTestsInTheSameStep(self):
    alerts_content = textwrap.dedent("""
        {
          "last_posted": 1434668974,
          "alerts": [
            {
              "master_url": "https://build.chromium.org/p/m3",
              "builder_name": "b3",
              "last_failing_build": 3,
              "step_name": "s3",
              "reason": "suite1.test1"
            },
            {
              "master_url": "https://build.chromium.org/p/m3",
              "builder_name": "b3",
              "last_failing_build": 3,
              "step_name": "s3",
              "reason": "suite1.test2"
            }
          ]
        }""")
    expected_build_failures = [
        {
            'master_name': 'm3',
            'builder_name': 'b3',
            'build_number': 3,
            'failed_steps': ['s3'],
        },
    ]

    http_client = _MockedHttpClient(200, alerts_content)
    self.assertEqual(expected_build_failures,
                     monitor_alerts._GetLatestBuildFailures(http_client))
    def testGetLatestBuildFailuresWhenAlertsAreForTwoStepsInTheSameBuild(self):
        alerts_content = textwrap.dedent(
            """
        {
          "last_posted": 1434668974,
          "alerts": [
            {
              "master_url": "https://build.chromium.org/p/m3",
              "builder_name": "b3",
              "last_failing_build": 4,
              "step_name": "s1",
              "reason": null
            },
            {
              "master_url": "https://build.chromium.org/p/m3",
              "builder_name": "b3",
              "last_failing_build": 4,
              "step_name": "s2",
              "reason": null
            }
          ]
        }
        """
        )

        expected_build_failures = [
            {"master_name": "m3", "builder_name": "b3", "build_number": 4, "failed_steps": ["s1", "s2"]}
        ]

        http_client = _MockedHttpClient(200, alerts_content)
        build_failures = monitor_alerts._GetLatestBuildFailures(http_client)
        self.assertEqual(expected_build_failures, build_failures)
Exemple #3
0
 def testGetLatestBuildFailuresWhenMasterNotSupported(self):
   alerts_content = textwrap.dedent("""
       {
         "last_posted": 1434668974,
         "alerts": [
           {
             "master_url": "https://build.chromium.org/p/m0",
             "builder_name": "b2",
             "last_failing_build": 2,
             "step_name": "s2",
             "reason": null
           }
         ]
       }""")
   http_client = _MockedHttpClient(200, alerts_content)
   self.assertEqual([], monitor_alerts._GetLatestBuildFailures(http_client))
Exemple #4
0
 def testGetLatestBuildFailuresWhenIllegalMasterUrl(self):
   alerts_content = textwrap.dedent("""
       {
         "last_posted": 1434668974,
         "alerts": [
           {
             "master_url": "https://not/a/url/to/a/master",
             "builder_name": "b1",
             "last_failing_build": 1,
             "step_name": "s1",
             "reason": null
           }
         ]
       }""")
   http_client = _MockedHttpClient(200, alerts_content)
   self.assertEqual([], monitor_alerts._GetLatestBuildFailures(http_client))
Exemple #5
0
 def testGetLatestBuildFailuresWhenFailedToPullAlerts(self):
   http_client = _MockedHttpClient(404, 'Not Found')
   self.assertEqual([], monitor_alerts._GetLatestBuildFailures(http_client))