Repository: oppia/oppia

Issue:
Remove Logging Server Reports from E2E Test
We no longer have a logging server to track E2E failures, so we should remove the associated code:

* All of the code in `scripts/flake_checker.py`
* Some of the code in `scripts/run_e2e_tests.py`, for example the rerun logic:
  https://github.com/oppia/oppia/blob/3442cbd068419f48074a01df1ca060cc9d9a7a0b/scripts/run_e2e_tests.py#L275


The presence of this code is leading to the following error messages (though these don't cause the tests to fail):

```
Failed request with response code: 404 (Not Found)
```


Discussion:

Resolving patch:
diff --git a/scripts/flake_checker.py b/scripts/flake_checker.py
deleted file mode 100644
--- a/scripts/flake_checker.py
+++ /dev/null
@@ -1,240 +0,0 @@
-# Copyright 2020 The Oppia Authors. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the 'License');
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an 'AS-IS' BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Python execution for checking whether the tests output is flaky."""
-
-from __future__ import annotations
-
-import datetime
-import os
-
-import requests
-
-from typing import Dict, Final, List, Optional, TypedDict
-
-
-class FlakeReportDict(TypedDict):
-    """Dictionary representation of flake's report."""
-
-    log: List[str]
-    result: bool
-    flake: Dict[str, str]
-    rerun: str
-
-
-class EnvVarDict(TypedDict):
-    """Dictionary representation of environment variables."""
-
-    identifier: str
-    user_info: str
-    branch: str
-    build_url_template_vars: List[str]
-
-
-class CIInfoValueDict(TypedDict):
-    """Dictionary representation of CI_INFO dict's values."""
-
-    env: EnvVarDict
-    build_url_template: str
-
-
-FLAKE_CHECK_AND_REPORT_URL: Final = (
-    'https://oppia-e2e-test-results-logger.herokuapp.com'
-    '/check-flake-and-report')
-PASS_REPORT_URL: Final = (
-    'https://oppia-e2e-test-results-logger.herokuapp.com'
-    '/report-pass')
-REPORT_API_KEY: Final = '7Ccp062JVjv9LUYwnLMqcm5Eu5gYqqhpl3zQmcO3cDQ'
-
-CI_INFO: Dict[str, CIInfoValueDict] = {
-    'githubActions': {
-        'env': {
-            'identifier': 'GITHUB_ACTIONS',
-            'user_info': 'GITHUB_ACTOR',
-            'branch': 'GITHUB_REF',
-            'build_url_template_vars': ['GITHUB_REPOSITORY', 'GITHUB_RUN_ID'],
-        },
-        'build_url_template': 'https://github.com/%s/actions/runs/%s',
-    },
-    'circleCI': {
-        'env': {
-            'identifier': 'CIRCLECI',
-            'user_info': 'CIRCLE_USERNAME',
-            'branch': 'CIRCLE_BRANCH',
-            'build_url_template_vars': ['CIRCLE_BUILD_URL']
-        },
-        'build_url_template': '%s',
-    }
-}
-
-REQUEST_EXCEPTIONS: Final = (
-    requests.RequestException, requests.ConnectionError,
-    requests.HTTPError, requests.TooManyRedirects, requests.Timeout)
-
-# Rerun policy overrides from logging server.
-
-# Yes, rerun, even if rerun policy says otherwise.
-RERUN_YES: Final = 'rerun yes'
-# No, do not rerun, even if rerun policy says otherwise.
-RERUN_NO: Final = 'rerun no'
-# No instructions from logging server, so follow rerun policy.
-RERUN_UNKNOWN: Final = 'rerun unknown'
-
-
-def _print_color_message(message: str) -> None:
-    """Prints the given message in red color.
-
-    Args:
-        message: str. The success message to print.
-    """
-    # \033[91m is the ANSI escape sequences for green color.
-    print('\033[92m' + message + '\033[0m\n')
-
-
-def check_if_on_ci() -> bool:
-    """Check if the script is running on a CI server.
-
-    Returns: bool. Whether we are running on a CI server.
-    """
-    for info in CI_INFO.values():
-        ci_identifier = info['env']['identifier']
-        if os.getenv(ci_identifier):
-            return True
-    return False
-
-
-def _get_build_info() -> Dict[str, Optional[str]]:
-    """Returns the info related to the build container."""
-    build_info = {}
-
-    for info in CI_INFO.values():
-        ci_env = info['env']
-
-        if not os.getenv(ci_env['identifier']):
-            continue
-
-        template_values = []
-        for template_var in ci_env['build_url_template_vars']:
-            value = os.getenv(template_var)
-            if value is None:
-                raise RuntimeError(
-                    'Expected environment variable %s missing' %
-                    template_var)
-            template_values.append(value)
-        build_url = info['build_url_template'] % tuple(template_values)
-        timestamp = datetime.datetime.utcnow().isoformat() + '+00:00'
-
-        build_info['username'] = os.getenv(ci_env['user_info'])
-        build_info['build_url'] = build_url
-        build_info['timestamp'] = timestamp
-        build_info['branch'] = os.getenv(ci_env['branch'])
-
-        return build_info
-
-    raise Exception('Unknown build environment.')
-
-
-def report_pass(suite_name: str) -> None:
-    """Report a passing test to the logging server."""
-    metadata = _get_build_info()
-    payload = {
-        'suite': suite_name,
-        'metadata': metadata,
-    }
-    try:
-        requests.post(
-            PASS_REPORT_URL, json=payload,
-            allow_redirects=False,
-            headers={'report_key': REPORT_API_KEY})
-    except REQUEST_EXCEPTIONS as e:
-        _print_color_message((
-            'Failed to contact E2E test logging server at %s.'
-            'Please report to E2E team in case server is down.'
-            'Exception: %s') % (PASS_REPORT_URL, e))
-    _print_color_message(
-        'Reported pass to E2E logging server at {}.'.format(
-            PASS_REPORT_URL))
-
-
-def check_test_flakiness(output_lines: List[bytes], suite_name: str) -> bool:
-    """Checks whether the test output matches any flaky test log.
-
-    Whether the test is flaky is printed to the console.
-
-    Args:
-        output_lines: list(bytes). The output from the test run.
-        suite_name: str. Name of the E2E test suite.
-
-    Returns:
-        bool. Whether the test should be rerun.
-
-    Raises:
-        ValueError. Raised if the response from the logging server is invalid.
-    """
-    build_info = _get_build_info()
-    payload = {
-        'suite': suite_name,
-        'output_lines': output_lines,
-        'metadata': build_info,
-    }
-    response = None
-    try:
-        response = requests.post(
-            FLAKE_CHECK_AND_REPORT_URL, json=payload,
-            allow_redirects=False,
-            headers={'report_key': REPORT_API_KEY})
-    except REQUEST_EXCEPTIONS as e:
-        _print_color_message((
-            'Failed to contact E2E test logging server at %s.'
-            'Please report to E2E team in case server is down.'
-            'Exception: %s') % (FLAKE_CHECK_AND_REPORT_URL, e))
-
-        return False
-
-    if not response.ok:
-        _print_color_message('Failed request with response code: %s (%s)' % (
-            response.status_code, response.reason))
-        return False
-
-    try:
-        report: FlakeReportDict = response.json()
-    except ValueError as e:
-        _print_color_message('Unable to convert json response: %s' % e)
-        return False
-
-    if 'log' in report:
-        log_str = '\n'.join(report['log'])
-        _print_color_message(
-            'Logs from test result logging server:\n %s' % log_str)
-
-    flaky = report['result'] if 'result' in report else False
-    _print_color_message(
-        'E2E logging server says test flaky: {}.'.format(flaky))
-    if flaky:
-        flake = report['flake']
-        _print_color_message('Flake Detected:')
-        _print_color_message('    Suite: %s' % flake['suite'])
-        _print_color_message('    Test: %s' % flake['test'])
-        _print_color_message(
-            '    Error Message: %s' % flake['flake_id'])
-    rerun = report['rerun']
-    if rerun not in (RERUN_YES, RERUN_NO):
-        _print_color_message(
-            'Invalid rerun instruction from logging server: %s' % rerun)
-        return False
-    else:
-        _print_color_message(
-            'Rerun instruction from logging server: %s' %
-            'rerun' if rerun == RERUN_YES else 'do not rerun')
-    return rerun == RERUN_YES


Test patch:
diff --git a/scripts/backend_test_shards.json b/scripts/backend_test_shards.json
--- a/scripts/backend_test_shards.json
+++ b/scripts/backend_test_shards.json
@@ -93,7 +93,6 @@
         "scripts.servers_test",
         "scripts.concurrent_task_utils_test",
         "core.storage.storage_models_test",
-        "scripts.flake_checker_test",
         "core.platform.cache.redis_cache_services_test",
         "core.utils_test",
         "scripts.linters.linter_utils_test",
diff --git a/scripts/flake_checker_test.py b/scripts/flake_checker_test.py
deleted file mode 100644
--- a/scripts/flake_checker_test.py
+++ /dev/null
@@ -1,633 +0,0 @@
-# Copyright 2020 The Oppia Authors. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS-IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Unit tests for scripts/flake_checker.py."""
-
-from __future__ import annotations
-
-import datetime
-import os
-
-from core.tests import test_utils
-from scripts import flake_checker
-
-import requests
-
-from typing import Dict, Optional, Union
-from typing_extensions import TypedDict
-
-
-class FlakeReportDictWithoutLog(TypedDict):
-    """Dictionary representation of flake's report without log."""
-
-    result: bool
-    flake: Dict[str, str]
-    rerun: str
-
-
-AllowedMockJsonTypes = Union[
-    flake_checker.FlakeReportDict,
-    FlakeReportDictWithoutLog, Dict[str, str], str, None
-]
-
-
-class CheckIfOnCITests(test_utils.GenericTestBase):
-
-    def test_returns_true_when_on_ci(self) -> None:
-
-        def mock_getenv(variable: str) -> bool:
-            return variable == 'CIRCLECI'
-
-        getenv_swap = self.swap_with_checks(
-            os, 'getenv', mock_getenv, expected_args=[
-                ('GITHUB_ACTIONS',),
-                ('CIRCLECI',),
-            ])
-
-        with getenv_swap:
-            on_ci = flake_checker.check_if_on_ci()
-        self.assertTrue(on_ci)
-
-    def test_returns_false_when_off_ci(self) -> None:
-
-        def mock_getenv(unused_variable: str) -> bool:
-            return False
-
-        getenv_swap = self.swap_with_checks(
-            os, 'getenv', mock_getenv, expected_args=[
-                ('GITHUB_ACTIONS',),
-                ('CIRCLECI',),
-            ])
-
-        with getenv_swap:
-            on_ci = flake_checker.check_if_on_ci()
-        self.assertFalse(on_ci)
-
-
-class MockDatetime:
-
-    def __init__(self, date: datetime.datetime) -> None:
-        self.date = date
-
-    def utcnow(self) -> datetime.datetime:
-        """Get datetime.datetime object."""
-        return self.date
-
-
-class ReportPassTests(test_utils.GenericTestBase):
-
-    def setUp(self) -> None:
-        super().setUp()
-        self.example_date = datetime.datetime(2020, 1, 1, 0, 0, 0, 1)
-
-    def test_successful_report(self) -> None:
-
-        def mock_getenv(variable: str) -> Optional[Union[str, int]]:
-            environment_vars: Dict[str, Union[str, int]] = {
-                'CIRCLECI': 1,
-                'CIRCLE_USERNAME': 'user',
-                'CIRCLE_BUILD_URL': 'https://example.com',
-                'CIRCLE_BRANCH': 'develop',
-            }
-            return environment_vars.get(variable)
-
-        def mock_post(
-            url: str,  # pylint: disable=unused-argument
-            json: Dict[str, str],  # pylint: disable=unused-argument
-            allow_redirects: bool,  # pylint: disable=unused-argument
-            headers: Dict[str, str]  # pylint: disable=unused-argument
-        ) -> None:
-            pass
-
-        expected_payload = {
-            'suite': 'suiteName',
-            'metadata': {
-                'username': 'user',
-                'build_url': 'https://example.com',
-                'timestamp': '2020-01-01T00:00:00.000001+00:00',
-                'branch': 'develop',
-            }
-        }
-
-        getenv_swap = self.swap(os, 'getenv', mock_getenv)
-        datetime_swap = self.swap(
-            datetime, 'datetime', MockDatetime(self.example_date))
-        post_swap = self.swap_with_checks(
-            requests, 'post', mock_post, expected_args=[
-                (flake_checker.PASS_REPORT_URL,)],
-            expected_kwargs=[{
-                'json': expected_payload,
-                'allow_redirects': False,
-                'headers': {
-                    'report_key': flake_checker.REPORT_API_KEY
-                },
-            }])
-
-        with getenv_swap, datetime_swap, post_swap:
-            flake_checker.report_pass('suiteName')
-
-    def test_successful_report_construct_url(self) -> None:
-
-        def mock_getenv(variable: str) -> Optional[Union[str, int]]:
-            environment_vars: Dict[str, Union[str, int]] = {
-                'GITHUB_ACTIONS': 1,
-                'GITHUB_ACTOR': 'user',
-                'GITHUB_RUN_ID': 1234,
-                'GITHUB_REF': 'develop',
-                'GITHUB_REPOSITORY': 'foo/oppia',
-            }
-            return environment_vars.get(variable)
-
-        def mock_post(
-            url: str,  # pylint: disable=unused-argument
-            json: Dict[str, str],  # pylint: disable=unused-argument
-            allow_redirects: bool,  # pylint: disable=unused-argument
-            headers: Dict[str, str]  # pylint: disable=unused-argument
-        ) -> None:
-            pass
-
-        expected_payload = {
-            'suite': 'suiteName',
-            'metadata': {
-                'username': 'user',
-                'build_url': 'https://github.com/foo/oppia/actions/runs/1234',
-                'timestamp': '2020-01-01T00:00:00.000001+00:00',
-                'branch': 'develop',
-            }
-        }
-
-        getenv_swap = self.swap(os, 'getenv', mock_getenv)
-        datetime_swap = self.swap(
-            datetime, 'datetime', MockDatetime(self.example_date))
-        post_swap = self.swap_with_checks(
-            requests, 'post', mock_post, expected_args=[
-                (flake_checker.PASS_REPORT_URL,)],
-            expected_kwargs=[{
-                'json': expected_payload,
-                'allow_redirects': False,
-                'headers': {
-                    'report_key': flake_checker.REPORT_API_KEY
-                },
-            }])
-
-        with getenv_swap, datetime_swap, post_swap:
-            flake_checker.report_pass('suiteName')
-
-    def test_unsuccessful_report(self) -> None:
-
-        def mock_getenv(variable: str) -> Optional[Union[str, int]]:
-            environment_vars: Dict[str, Union[str, int]] = {
-                'CIRCLECI': 1,
-                'CIRCLE_USERNAME': 'user',
-                'CIRCLE_BUILD_URL': 'https://example.com',
-                'CIRCLE_BRANCH': 'develop',
-            }
-            return environment_vars.get(variable)
-
-        def mock_post(
-            url: str,
-            json: Dict[str, str],
-            allow_redirects: bool,
-            headers: Dict[str, str]
-        ) -> None:
-            raise requests.HTTPError()
-
-        expected_payload = {
-            'suite': 'suiteName',
-            'metadata': {
-                'username': 'user',
-                'build_url': 'https://example.com',
-                'timestamp': '2020-01-01T00:00:00.000001+00:00',
-                'branch': 'develop',
-            },
-        }
-
-        getenv_swap = self.swap(os, 'getenv', mock_getenv)
-        datetime_swap = self.swap(
-            datetime, 'datetime', MockDatetime(self.example_date))
-        post_swap = self.swap_with_checks(
-            requests, 'post', mock_post, expected_args=[
-                (flake_checker.PASS_REPORT_URL,)],
-            expected_kwargs=[{
-                'json': expected_payload,
-                'allow_redirects': False,
-                'headers': {
-                    'report_key': flake_checker.REPORT_API_KEY,
-                },
-            }])
-
-        with getenv_swap, datetime_swap, post_swap:
-            flake_checker.report_pass('suiteName')
-
-    def test_unknown_build_environment(self) -> None:
-
-        def mock_getenv(unused_variable: str) -> None:
-            return None
-
-        def mock_post(
-            url: str,
-            json: Dict[str, str],
-            allow_redirects: bool,
-            headers: Dict[str, str]
-        ) -> None:
-            raise AssertionError('requests.post called.')
-
-        getenv_swap = self.swap(os, 'getenv', mock_getenv)
-        post_swap = self.swap(requests, 'post', mock_post)
-
-        with getenv_swap, post_swap:
-            with self.assertRaisesRegex(
-                Exception, 'Unknown build environment.'):
-                flake_checker.report_pass('suiteName')
-
-    def test_missing_environment_variable(self) -> None:
-
-        def mock_getenv(variable: str) -> Optional[Union[str, int]]:
-            environment_vars: Dict[str, Union[str, int]] = {
-                'CIRCLECI': 1,
-                'CIRCLE_USERNAME': 'user',
-                'CIRCLE_BRANCH': 'develop',
-            }
-            return environment_vars.get(variable)
-
-        def mock_post(
-            url: str,
-            json: Dict[str, str],
-            allow_redirects: bool,
-            headers: Dict[str, str]
-        ) -> None:
-            raise AssertionError('requests.post called.')
-
-        getenv_swap = self.swap(os, 'getenv', mock_getenv)
-        post_swap = self.swap(requests, 'post', mock_post)
-
-        with getenv_swap, post_swap:
-            with self.assertRaisesRegex(
-                RuntimeError,
-                'Expected environment variable CIRCLE_BUILD_URL missing'):
-                flake_checker.report_pass('suiteName')
-
-
-class MockResponse:
-
-    def __init__(
-        self,
-        ok: bool = True,
-        json: AllowedMockJsonTypes = None,
-        status_code: int = 200,
-        reason: str = 'foo'
-    ) -> None:
-        if json is None:
-            json = {}
-        self.ok = ok
-        self.json_dict = json
-        self.status_code = status_code
-        self.reason = reason
-
-    def json(self) -> AllowedMockJsonTypes:
-        """Get json dict or raise ValueError if json_dict not a dict."""
-        if not isinstance(self.json_dict, dict):
-            raise ValueError('Payload not JSON.')
-        return self.json_dict
-
-
-class IsTestOutputFlakyTests(test_utils.GenericTestBase):
-
-    def setUp(self) -> None:
-        super().setUp()
-        self.example_date = datetime.datetime(2020, 1, 1, 0, 0, 0, 1)
-
-    def test_successful_report(self) -> None:
-
-        def mock_getenv(variable: str) -> Optional[Union[str, int]]:
-            environment_vars: Dict[str, Union[str, int]] = {
-                'CIRCLECI': 1,
-                'CIRCLE_USERNAME': 'user',
-                'CIRCLE_BUILD_URL': 'https://example.com',
-                'CIRCLE_BRANCH': 'develop',
-            }
-            return environment_vars.get(variable)
-
-        def mock_post(
-            url: str,  # pylint: disable=unused-argument
-            json: Dict[str, str],  # pylint: disable=unused-argument
-            allow_redirects: bool,  # pylint: disable=unused-argument
-            headers: Dict[str, str]  # pylint: disable=unused-argument
-        ) -> MockResponse:
-            response: flake_checker.FlakeReportDict = {
-                'log': ['log1', 'log2'],
-                'result': True,
-                'flake': {
-                    'suite': 'suiteName',
-                    'test': 'testName',
-                    'flake_id': 'flake',
-                },
-                'rerun': 'rerun yes',
-            }
-            return MockResponse(True, response)
-
-        expected_payload = {
-            'suite': 'suiteName',
-            'output_lines': [b'line1', b'line2'],
-            'metadata': {
-                'username': 'user',
-                'build_url': 'https://example.com',
-                'timestamp': '2020-01-01T00:00:00.000001+00:00',
-                'branch': 'develop',
-            }
-        }
-
-        getenv_swap = self.swap(os, 'getenv', mock_getenv)
-        datetime_swap = self.swap(
-            datetime, 'datetime', MockDatetime(self.example_date))
-        post_swap = self.swap_with_checks(
-            requests, 'post', mock_post, expected_args=[
-                (flake_checker.FLAKE_CHECK_AND_REPORT_URL,)],
-            expected_kwargs=[{
-                'json': expected_payload,
-                'allow_redirects': False,
-                'headers': {
-                    'report_key': flake_checker.REPORT_API_KEY
-                },
-            }])
-
-        with getenv_swap, datetime_swap, post_swap:
-            rerun = flake_checker.check_test_flakiness(
-                [b'line1', b'line2'], 'suiteName')
-            self.assertTrue(rerun)
-
-    def test_successful_report_unknown_rerun(self) -> None:
-
-        def mock_getenv(variable: str) -> Optional[Union[str, int]]:
-            environment_vars: Dict[str, Union[str, int]] = {
-                'CIRCLECI': 1,
-                'CIRCLE_USERNAME': 'user',
-                'CIRCLE_BUILD_URL': 'https://example.com',
-                'CIRCLE_BRANCH': 'develop',
-            }
-            return environment_vars.get(variable)
-
-        def mock_post(
-            url: str,  # pylint: disable=unused-argument
-            json: Dict[str, str],  # pylint: disable=unused-argument
-            allow_redirects: bool,  # pylint: disable=unused-argument
-            headers: Dict[str, str]  # pylint: disable=unused-argument
-        ) -> MockResponse:
-            response: flake_checker.FlakeReportDict = {
-                'log': ['log1', 'log2'],
-                'result': True,
-                'flake': {
-                    'suite': 'suiteName',
-                    'test': 'testName',
-                    'flake_id': 'flake',
-                },
-                'rerun': 'unknown',
-            }
-            return MockResponse(True, response)
-
-        expected_payload = {
-            'suite': 'suiteName',
-            'output_lines': [b'line1', b'line2'],
-            'metadata': {
-                'username': 'user',
-                'build_url': 'https://example.com',
-                'timestamp': '2020-01-01T00:00:00.000001+00:00',
-                'branch': 'develop',
-            }
-        }
-
-        getenv_swap = self.swap(os, 'getenv', mock_getenv)
-        datetime_swap = self.swap(
-            datetime, 'datetime', MockDatetime(self.example_date))
-        post_swap = self.swap_with_checks(
-            requests, 'post', mock_post, expected_args=[
-                (flake_checker.FLAKE_CHECK_AND_REPORT_URL,)],
-            expected_kwargs=[{
-                'json': expected_payload,
-                'allow_redirects': False,
-                'headers': {
-                    'report_key': flake_checker.REPORT_API_KEY
-                },
-            }])
-
-        with getenv_swap, datetime_swap, post_swap:
-            rerun = flake_checker.check_test_flakiness(
-                [b'line1', b'line2'], 'suiteName')
-            self.assertFalse(rerun)
-
-    def test_successful_report_construct_url(self) -> None:
-
-        def mock_getenv(variable: str) -> Optional[Union[str, int]]:
-            environment_vars: Dict[str, Union[str, int]] = {
-                'GITHUB_ACTIONS': 1,
-                'GITHUB_ACTOR': 'user',
-                'GITHUB_RUN_ID': 1234,
-                'GITHUB_REF': 'develop',
-                'GITHUB_REPOSITORY': 'foo/oppia'
-            }
-            return environment_vars.get(variable)
-
-        def mock_post(
-            url: str,  # pylint: disable=unused-argument
-            json: Dict[str, str],  # pylint: disable=unused-argument
-            allow_redirects: bool,  # pylint: disable=unused-argument
-            headers: Dict[str, str]  # pylint: disable=unused-argument
-        ) -> MockResponse:
-            response: FlakeReportDictWithoutLog = {
-                'result': False,
-                'flake': {
-                    'suite': 'suiteName',
-                    'test': 'testName',
-                    'flake_id': 'flake',
-                },
-                'rerun': 'rerun no',
-            }
-            return MockResponse(True, response)
-
-        expected_payload = {
-            'suite': 'suiteName',
-            'output_lines': [b'line1', b'line2'],
-            'metadata': {
-                'username': 'user',
-                'build_url': 'https://github.com/foo/oppia/actions/runs/1234',
-                'timestamp': '2020-01-01T00:00:00.000001+00:00',
-                'branch': 'develop',
-            }
-        }
-
-        getenv_swap = self.swap(os, 'getenv', mock_getenv)
-        datetime_swap = self.swap(
-            datetime, 'datetime', MockDatetime(self.example_date))
-        post_swap = self.swap_with_checks(
-            requests, 'post', mock_post, expected_args=[
-                (flake_checker.FLAKE_CHECK_AND_REPORT_URL,)],
-            expected_kwargs=[{
-                'json': expected_payload,
-                'allow_redirects': False,
-                'headers': {
-                    'report_key': flake_checker.REPORT_API_KEY
-                },
-            }])
-
-        with getenv_swap, datetime_swap, post_swap:
-            rerun = flake_checker.check_test_flakiness(
-                [b'line1', b'line2'], 'suiteName')
-            self.assertFalse(rerun)
-
-    def test_unsuccessful_report_exception(self) -> None:
-
-        def mock_getenv(variable: str) -> Optional[Union[str, int]]:
-            environment_vars: Dict[str, Union[str, int]] = {
-                'CIRCLECI': 1,
-                'CIRCLE_USERNAME': 'user',
-                'CIRCLE_BUILD_URL': 'https://example.com',
-                'CIRCLE_BRANCH': 'develop',
-            }
-            return environment_vars.get(variable)
-
-        def mock_post(
-            url: str,
-            json: Dict[str, str],
-            allow_redirects: bool,
-            headers: Dict[str, str]
-        ) -> None:
-            raise requests.HTTPError()
-
-        expected_payload = {
-            'suite': 'suiteName',
-            'output_lines': [b'line1', b'line2'],
-            'metadata': {
-                'username': 'user',
-                'build_url': 'https://example.com',
-                'timestamp': '2020-01-01T00:00:00.000001+00:00',
-                'branch': 'develop',
-            },
-        }
-
-        getenv_swap = self.swap(os, 'getenv', mock_getenv)
-        datetime_swap = self.swap(
-            datetime, 'datetime', MockDatetime(self.example_date))
-        post_swap = self.swap_with_checks(
-            requests, 'post', mock_post, expected_args=[
-                (flake_checker.FLAKE_CHECK_AND_REPORT_URL,)],
-            expected_kwargs=[{
-                'json': expected_payload,
-                'allow_redirects': False,
-                'headers': {
-                    'report_key': flake_checker.REPORT_API_KEY,
-                },
-            }])
-
-        with getenv_swap, datetime_swap, post_swap:
-            rerun = flake_checker.check_test_flakiness(
-                [b'line1', b'line2'], 'suiteName')
-            self.assertFalse(rerun)
-
-    def test_unsuccessful_report_not_ok(self) -> None:
-
-        def mock_getenv(variable: str) -> Optional[Union[str, int]]:
-            environment_vars: Dict[str, Union[str, int]] = {
-                'CIRCLECI': 1,
-                'CIRCLE_USERNAME': 'user',
-                'CIRCLE_BUILD_URL': 'https://example.com',
-                'CIRCLE_BRANCH': 'develop',
-            }
-            return environment_vars.get(variable)
-
-        def mock_post(
-            url: str,  # pylint: disable=unused-argument
-            json: Dict[str, str],  # pylint: disable=unused-argument
-            allow_redirects: bool,  # pylint: disable=unused-argument
-            headers: Dict[str, str]  # pylint: disable=unused-argument
-        ) -> MockResponse:
-            return MockResponse(False, None)
-
-        expected_payload = {
-            'suite': 'suiteName',
-            'output_lines': [b'line1', b'line2'],
-            'metadata': {
-                'username': 'user',
-                'build_url': 'https://example.com',
-                'timestamp': '2020-01-01T00:00:00.000001+00:00',
-                'branch': 'develop',
-            },
-        }
-
-        getenv_swap = self.swap(os, 'getenv', mock_getenv)
-        datetime_swap = self.swap(
-            datetime, 'datetime', MockDatetime(self.example_date))
-        post_swap = self.swap_with_checks(
-            requests, 'post', mock_post, expected_args=[
-                (flake_checker.FLAKE_CHECK_AND_REPORT_URL,)],
-            expected_kwargs=[{
-                'json': expected_payload,
-                'allow_redirects': False,
-                'headers': {
-                    'report_key': flake_checker.REPORT_API_KEY,
-                },
-            }])
-
-        with getenv_swap, datetime_swap, post_swap:
-            rerun = flake_checker.check_test_flakiness(
-                [b'line1', b'line2'], 'suiteName')
-            self.assertFalse(rerun)
-
-    def test_unsuccessful_report_bad_payload(self) -> None:
-
-        def mock_getenv(variable: str) -> Optional[Union[str, int]]:
-            environment_vars: Dict[str, Union[str, int]] = {
-                'CIRCLECI': 1,
-                'CIRCLE_USERNAME': 'user',
-                'CIRCLE_BUILD_URL': 'https://example.com',
-                'CIRCLE_BRANCH': 'develop',
-            }
-            return environment_vars.get(variable)
-
-        def mock_post(
-            url: str,  # pylint: disable=unused-argument
-            json: Dict[str, str],  # pylint: disable=unused-argument
-            allow_redirects: bool,  # pylint: disable=unused-argument
-            headers: Dict[str, str]  # pylint: disable=unused-argument
-        ) -> MockResponse:
-            return MockResponse(True, 'not json')
-
-        expected_payload = {
-            'suite': 'suiteName',
-            'output_lines': [b'line1', b'line2'],
-            'metadata': {
-                'username': 'user',
-                'build_url': 'https://example.com',
-                'timestamp': '2020-01-01T00:00:00.000001+00:00',
-                'branch': 'develop',
-            },
-        }
-
-        getenv_swap = self.swap(os, 'getenv', mock_getenv)
-        datetime_swap = self.swap(
-            datetime, 'datetime', MockDatetime(self.example_date))
-        post_swap = self.swap_with_checks(
-            requests, 'post', mock_post, expected_args=[
-                (flake_checker.FLAKE_CHECK_AND_REPORT_URL,)],
-            expected_kwargs=[{
-                'json': expected_payload,
-                'allow_redirects': False,
-                'headers': {
-                    'report_key': flake_checker.REPORT_API_KEY,
-                },
-            }])
-
-        with getenv_swap, datetime_swap, post_swap:
-            rerun = flake_checker.check_test_flakiness(
-                [b'line1', b'line2'], 'suiteName')
-            self.assertFalse(rerun)
diff --git a/scripts/run_e2e_tests.py b/scripts/run_e2e_tests.py
--- a/scripts/run_e2e_tests.py
+++ b/scripts/run_e2e_tests.py
@@ -31,7 +31,6 @@
 
 from core.constants import constants  # isort:skip
 from scripts import build  # isort:skip
-from scripts import flake_checker  # isort:skip
 from scripts import install_third_party_libs  # isort:skip
 from scripts import servers  # isort:skip
 
@@ -272,29 +271,7 @@ def main(args: Optional[List[str]] = None) -> None:
     parsed_args = _PARSER.parse_args(args=args)
 
     with servers.managed_portserver():
-        for attempt_num in range(1, MAX_RETRY_COUNT + 1):
-            print('***Attempt %d.***' % attempt_num)
-            output, return_code = run_tests(parsed_args)
-
-            if not flake_checker.check_if_on_ci():
-                # Don't rerun off of CI.
-                print('No reruns because not running on CI.')
-                break
-
-            if return_code == 0:
-                # Don't rerun passing tests.
-                flake_checker.report_pass(parsed_args.suite)
-                break
-
-            # Check whether we should rerun based on the instructions from the
-            # flake checker server.
-            rerun = flake_checker.check_test_flakiness(
-                output, parsed_args.suite)
-            if rerun:
-                print('Rerunning.')
-            else:
-                print('Not rerunning.')
-                break
+        _, return_code = run_tests(parsed_args)
 
     sys.exit(return_code)
 
diff --git a/scripts/run_e2e_tests_test.py b/scripts/run_e2e_tests_test.py
--- a/scripts/run_e2e_tests_test.py
+++ b/scripts/run_e2e_tests_test.py
@@ -26,7 +26,6 @@
 from core.tests import test_utils
 from scripts import build
 from scripts import common
-from scripts import flake_checker
 from scripts import install_third_party_libs
 from scripts import run_e2e_tests
 from scripts import scripts_test_utils
@@ -264,11 +263,6 @@ def test_start_tests_when_no_other_instance_running(self) -> None:
                     'stdout': subprocess.PIPE,
                 },
             ]))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'check_if_on_ci', lambda: True))
-        self.exit_stack.enter_context(self.swap_with_checks(
-            flake_checker, 'report_pass', lambda _: None,
-            expected_args=[('full',)]))
         self.exit_stack.enter_context(self.swap_with_checks(
             sys, 'exit', lambda _: None, expected_args=[(0,)]))
 
@@ -327,22 +321,11 @@ def mock_managed_webdriverio_server(
     def test_rerun_when_tests_fail_with_rerun_yes(self) -> None:
         def mock_run_tests(unused_args: str) -> Tuple[str, int]:
             return 'sample\noutput', 1
-        def mock_check_test_flakiness(*_: str) -> bool:
-            return True
 
         self.exit_stack.enter_context(self.swap_with_checks(
             servers, 'managed_portserver', mock_managed_process))
         self.exit_stack.enter_context(self.swap(
             run_e2e_tests, 'run_tests', mock_run_tests))
-        self.exit_stack.enter_context(self.swap_with_checks(
-            flake_checker, 'check_test_flakiness',
-            mock_check_test_flakiness, expected_args=[
-                ('sample\noutput', 'navigation'),
-                ('sample\noutput', 'navigation'),
-                ('sample\noutput', 'navigation'),
-            ]))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'check_if_on_ci', lambda: True))
         self.exit_stack.enter_context(self.swap_with_checks(
             sys, 'exit', lambda _: None, expected_args=[(1,)]))
 
@@ -351,18 +334,9 @@ def mock_check_test_flakiness(*_: str) -> bool:
     def test_no_rerun_when_tests_flake_with_rerun_no(self) -> None:
         def mock_run_tests(unused_args: str) -> Tuple[str, int]:
             return 'sample\noutput', 1
-        def mock_check_test_flakiness(*_: str) -> bool:
-            return False
 
         self.exit_stack.enter_context(self.swap(
             run_e2e_tests, 'run_tests', mock_run_tests))
-        self.exit_stack.enter_context(self.swap_with_checks(
-            flake_checker, 'check_test_flakiness',
-            mock_check_test_flakiness, expected_args=[
-                ('sample\noutput', 'navigation'),
-            ]))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'check_if_on_ci', lambda: True))
         self.exit_stack.enter_context(self.swap_with_checks(
             sys, 'exit', lambda _: None, expected_args=[(1,)]))
         self.exit_stack.enter_context(self.swap_with_checks(
@@ -373,18 +347,9 @@ def mock_check_test_flakiness(*_: str) -> bool:
     def test_no_rerun_when_tests_flake_with_rerun_unknown(self) -> None:
         def mock_run_tests(unused_args: str) -> Tuple[str, int]:
             return 'sample\noutput', 1
-        def mock_check_test_flakiness(*_: str) -> bool:
-            return False
 
         self.exit_stack.enter_context(self.swap(
             run_e2e_tests, 'run_tests', mock_run_tests))
-        self.exit_stack.enter_context(self.swap_with_checks(
-            flake_checker, 'check_test_flakiness',
-            mock_check_test_flakiness, expected_args=[
-                ('sample\noutput', 'navigation'),
-            ]))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'check_if_on_ci', lambda: True))
         self.exit_stack.enter_context(self.swap_with_checks(
             sys, 'exit', lambda _: None, expected_args=[(1,)]))
         self.exit_stack.enter_context(self.swap_with_checks(
@@ -396,19 +361,10 @@ def test_no_reruns_off_ci_fail(self) -> None:
         def mock_run_tests(unused_args: str) -> Tuple[str, int]:
             return 'sample\noutput', 1
 
-        def mock_check_test_flakiness(
-            unused_output: str, unused_suite_name: str
-        ) -> None:
-            raise AssertionError('Tried to Check Flakiness.')
-
         self.exit_stack.enter_context(self.swap_with_checks(
             servers, 'managed_portserver', mock_managed_process))
         self.exit_stack.enter_context(self.swap(
             run_e2e_tests, 'run_tests', mock_run_tests))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'check_test_flakiness', mock_check_test_flakiness))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'check_if_on_ci', lambda: False))
         self.exit_stack.enter_context(self.swap_with_checks(
             sys, 'exit', lambda _: None, expected_args=[(1,)]))
 
@@ -418,17 +374,10 @@ def test_no_reruns_off_ci_pass(self) -> None:
         def mock_run_tests(unused_args: str) -> Tuple[str, int]:
             return 'sample\noutput', 0
 
-        def mock_report_pass(unused_suite_name: str) -> None:
-            raise AssertionError('Tried to Report Pass')
-
         self.exit_stack.enter_context(self.swap_with_checks(
             servers, 'managed_portserver', mock_managed_process))
         self.exit_stack.enter_context(self.swap(
             run_e2e_tests, 'run_tests', mock_run_tests))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'report_pass', mock_report_pass))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'check_if_on_ci', lambda: False))
         self.exit_stack.enter_context(self.swap_with_checks(
             sys, 'exit', lambda _: None, expected_args=[(0,)]))
 
@@ -473,11 +422,6 @@ def test_start_tests_skip_build(self) -> None:
                     'stdout': subprocess.PIPE,
                 },
             ]))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'check_if_on_ci', lambda: True))
-        self.exit_stack.enter_context(self.swap_with_checks(
-            flake_checker, 'report_pass', lambda _: None,
-            expected_args=[('full',)]))
         self.exit_stack.enter_context(self.swap_with_checks(
             sys, 'exit', lambda _: None, expected_args=[(0,)]))
 
@@ -517,11 +461,6 @@ def test_start_tests_in_debug_mode(self) -> None:
                     'stdout': subprocess.PIPE,
                 },
             ]))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'check_if_on_ci', lambda: True))
-        self.exit_stack.enter_context(self.swap_with_checks(
-            flake_checker, 'report_pass', lambda _: None,
-            expected_args=[('full',)]))
         self.exit_stack.enter_context(self.swap_with_checks(
             sys, 'exit', lambda _: None, expected_args=[(0,)]))
 
@@ -561,11 +500,6 @@ def test_start_tests_in_with_chromedriver_flag(self) -> None:
                     'stdout': subprocess.PIPE,
                 },
             ]))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'check_if_on_ci', lambda: True))
-        self.exit_stack.enter_context(self.swap_with_checks(
-            flake_checker, 'report_pass', lambda _: None,
-            expected_args=[('full',)]))
         self.exit_stack.enter_context(self.swap_with_checks(
             sys, 'exit', lambda _: None, expected_args=[(0,)]))
 
@@ -606,11 +540,6 @@ def test_start_tests_in_webdriverio(self) -> None:
                     'stdout': subprocess.PIPE,
                 },
             ]))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'check_if_on_ci', lambda: True))
-        self.exit_stack.enter_context(self.swap_with_checks(
-            flake_checker, 'report_pass', lambda _: None,
-            expected_args=[('collections',)]))
         self.exit_stack.enter_context(self.swap_with_checks(
             sys, 'exit', lambda _: None, expected_args=[(0,)]))
 
@@ -638,8 +567,6 @@ def test_do_not_run_with_test_non_mobile_suite_in_mobile_mode(self) -> None:
             servers, 'managed_portserver', mock_managed_process))
         self.exit_stack.enter_context(self.swap_with_checks(
             servers, 'managed_cloud_datastore_emulator', mock_managed_process))
-        self.exit_stack.enter_context(self.swap(
-            flake_checker, 'check_if_on_ci', lambda: True))
 
         with self.assertRaisesRegex(SystemExit, '^1$'):
             run_e2e_tests.main(args=['--mobile', '--suite', 'collections'])