Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds flaky e2e report and restart functionality #11263

Merged
merged 31 commits into from
Dec 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fae8a15
Reverted old changes
DubeySandeep Nov 25, 2020
c6c9a8a
Adds checks for reporting.
DubeySandeep Nov 25, 2020
9562edd
Added url
DubeySandeep Nov 25, 2020
43f2ffd
Merge branch 'develop' of github.com:oppia/oppia into flake-e2e
DubeySandeep Nov 27, 2020
6353ea8
Fixes exit error issues.
DubeySandeep Nov 28, 2020
ea3af12
Adds checker file.
DubeySandeep Nov 28, 2020
d2bfd87
Adds correct url.
DubeySandeep Nov 28, 2020
7e6bf00
Adds correct url format.
DubeySandeep Nov 28, 2020
917c92f
Fixes test issues
DubeySandeep Nov 28, 2020
1f0544a
Address review comments.
DubeySandeep Dec 1, 2020
d33937e
Merge branch 'develop' into flake-e2e
U8NWXD Dec 11, 2020
f10e084
Update with review comments and for new server
U8NWXD Dec 11, 2020
58753c1
lint fixes
U8NWXD Dec 11, 2020
4f68414
Catch non-unicode characters and ignore them
U8NWXD Dec 11, 2020
4e28982
Merge branch 'develop' into flake-e2e
U8NWXD Dec 14, 2020
f203b29
Report passes and rerun non flaky e2e tests
U8NWXD Dec 15, 2020
2b66886
Fix e2e backend tests
U8NWXD Dec 15, 2020
17c4179
Fix lint errors
U8NWXD Dec 15, 2020
f55fff8
Fix backend tests
U8NWXD Dec 16, 2020
6209a6a
Silence pylint
U8NWXD Dec 16, 2020
426aace
Reach 100% coverage of run_e2e_tests.py
U8NWXD Dec 16, 2020
02210e2
Add tests for flake_checker.py
U8NWXD Dec 17, 2020
1826229
Lint fixes
U8NWXD Dec 17, 2020
545b794
Merge branch 'develop' into flake-e2e
U8NWXD Dec 18, 2020
19f43c1
Include unicode character directly for testing
U8NWXD Dec 18, 2020
8203f85
Make cleanup code more robust
U8NWXD Dec 18, 2020
a84928c
Improve unicode handling
U8NWXD Dec 18, 2020
49d3f05
Fix backend code coverage
U8NWXD Dec 18, 2020
c87d667
Fix CI errors
U8NWXD Dec 19, 2020
8c219b0
More robustly shut down processes
U8NWXD Dec 19, 2020
a2f3b67
Make killing reluctant processes more robust
U8NWXD Dec 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Report passes and rerun non flaky e2e tests
  • Loading branch information
U8NWXD committed Dec 15, 2020
commit f203b294e6c08064c192eefed07cd4ff48b7f41a
36 changes: 30 additions & 6 deletions scripts/flake_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@

import requests

FLAKE_REPORT_URL = (
FLAKE_CHECK_AND_REPORT_URL = (
'https://oppia-e2e-test-results-logger.herokuapp.com'
'/check-flake-and-report')
FLAKE_REPORT_API_KEY = '7Ccp062JVjv9LUYwnLMqcm5Eu5gYqqhpl3zQmcO3cDQ'
PASS_REPORT_URL = (
'https://oppia-e2e-test-results-logger.herokuapp.com'
'/check-flake-and-report')
REPORT_API_KEY = '7Ccp062JVjv9LUYwnLMqcm5Eu5gYqqhpl3zQmcO3cDQ'

CI_INFO = {
'circleCI': {
Expand Down Expand Up @@ -98,6 +101,25 @@ def _get_build_info():
raise Exception('Unknown build environment.')


def report_pass(suite_name):
"""Report a passing test to the logging server."""
metadata = _get_build_info()
payload = {
'suite': suite_name,
'metadata': metadata,
}
try:
response = requests.post(
PASS_REPORT_URL, json=payload,
allow_redirects=False,
headers={'report_key': REPORT_API_KEY})
except Exception 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))


def is_test_output_flaky(output_lines, suite_name):
"""Returns whether the test output matches any flaky test log."""
build_info = _get_build_info()
Expand All @@ -109,13 +131,14 @@ def is_test_output_flaky(output_lines, suite_name):
response = None
try:
response = requests.post(
FLAKE_REPORT_URL, json=payload, allow_redirects=False,
headers={'report_key': FLAKE_REPORT_API_KEY})
FLAKE_CHECK_AND_REPORT_URL, json=payload,
allow_redirects=False,
headers={'report_key': REPORT_API_KEY})
except Exception 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_REPORT_URL, e))
'Exception: %s') % (FLAKE_CHECK_AND_REPORT_URL, e))

return False

Expand All @@ -131,8 +154,9 @@ def is_test_output_flaky(output_lines, suite_name):
_print_color_message('Unable to convert json response: %s' % e)

if 'log' in report:
log_str = '\n'.join(report['log'])
_print_color_message(
'Logs from test result logging server:\n %s' % report['log'])
'Logs from test result logging server:\n %s' % log_str)

flaky = report['result'] if 'result' in report else False
if flaky:
Expand Down
26 changes: 16 additions & 10 deletions scripts/run_e2e_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from scripts import install_third_party_libs

MAX_RETRY_COUNT = 3
RERUN_NON_FLAKY = True
WEB_DRIVER_PORT = 4444
GOOGLE_APP_ENGINE_PORT = 9001
OPPIA_SERVER_PORT = 8181
Expand Down Expand Up @@ -572,21 +573,26 @@ def main(args=None):
portserver_process = start_portserver()
atexit.register(cleanup_portserver, portserver_process)

return_code = 1

for attempt_num in python_utils.RANGE(MAX_RETRY_COUNT):
python_utils.PRINT('***Attempt %s.***' % (attempt_num + 1))
# Only rerun tests on CI.
output, return_code = run_tests(parsed_args)
# Don't rerun passing tests.
if return_code == 0:
flake_checker.report_pass(parsed_args.suite)
break
flaky = flake_checker.is_test_output_flaky(
output, parsed_args.suite)
# Don't rerun if the test was non-flaky or if we are not
# rerunning non-flaky tests.
if not flaky or not RERUN_NON_FLAKY:
break
# Don't rerun off of CI.
if not flake_checker.check_if_on_ci():
python_utils.PRINT('No reruns because not running on CI.')
break
output, return_code = run_tests(parsed_args)
if return_code == 0 or not flake_checker.is_test_output_flaky(
output, parsed_args.suite):
break
else:
cleanup_portserver(portserver_process)
cleanup()
# Prepare for rerun.
cleanup_portserver(portserver_process)
cleanup()

sys.exit(return_code)

Expand Down
Loading