Update CQ dataflow script to use new_cq_attempts.

This CL updates new_cq_attempts.py to emit to the cq_attempts table, and use the
fail_type 'FAILED_PRESUBMIT_BOT', in order to maintain consistent behavior for
CQ SLOs.

Bug: 937519
Change-Id: I29f0d80849ec1ca3357281bbb158f013b6cd4e5e
Reviewed-on: https://chromium-review.googlesource.com/c/infra/infra/+/1548231
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Erik Chen <erikchen@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#22005}
Cr-Mirrored-From: https://chromium.googlesource.com/infra/infra
Cr-Mirrored-Commit: e4a40a853e694daba2f0b9fe1d874c2c38ad5f52
diff --git a/new_cq_attempts.py b/new_cq_attempts.py
index fec488b..9cce13e 100644
--- a/new_cq_attempts.py
+++ b/new_cq_attempts.py
@@ -46,7 +46,7 @@
       elif bb_result['status'] != 'SUCCESS':
         other_failures += 1
     if presubmit_failures >= 1 and other_failures == 0:
-      cq_attempt['fail_type'] = 'PRESUBMIT_FAILURE'
+      cq_attempt['fail_type'] = 'FAILED_PRESUBMIT_BOT'
 
   # Dictionaries are supposed to be returned in a single element list.
   return [cq_attempt]
@@ -57,7 +57,7 @@
   This function performs two tasks:
     1) Computes CQ attempts from raw CQ events. This includes data sanitization.
     2) If a CQ attempt fails only because of 'chromium_presubmit' builder, sets
-       the failure status to 'PRESUBMIT_FAILURE'.
+       the failure status to 'FAILED_PRESUBMIT_BOT'.
   """
   # Pcol of cq_attempt_as_dict
   sanitized_cq_attempts = (
@@ -92,7 +92,7 @@
   )
 
   # Uses BuildBucket entries associated with a CQ attempt to potentially change
-  # the failure reason to PRESUBMIT_FAILURE. Creates a Pcol of
+  # the failure reason to FAILED_PRESUBMIT_BOT. Creates a Pcol of
   # cq_attempt_as_dict.
   results = ({
     'cq_attempts' : cq_attempts_with_key,
@@ -117,7 +117,7 @@
   results = process_input(cq_events_pcol, bb_entries_pcol)
 
   # pylint: disable=expression-not-assigned
-  results | chops_beam.BQWrite('chrome-infra-events', 'new_cq_attempts')
+  results | chops_beam.BQWrite('chrome-infra-events', 'cq_attempts')
 
   p.run()
 
diff --git a/test/new_cq_attempts_test.py b/test/new_cq_attempts_test.py
index a7409a1..b585328 100644
--- a/test/new_cq_attempts_test.py
+++ b/test/new_cq_attempts_test.py
@@ -105,7 +105,7 @@
     # There should be exactly 1 CQ attempt, with no fail type.
     def expectation_checker(cq_attempts):
       _beam_equals(len(cq_attempts), 1)
-      _beam_equals(cq_attempts[0]['fail_type'], 'PRESUBMIT_FAILURE')
+      _beam_equals(cq_attempts[0]['fail_type'], 'FAILED_PRESUBMIT_BOT')
 
     util.assert_that(results, expectation_checker)
     self.pipeline.run()