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

Fix #20139: Surface Acceptance Test results in a more convenient location #20171

Open
wants to merge 40 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
bf7bbb8
surface the result of acceptance tests
rahat2134 Apr 16, 2024
e602e83
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 Apr 16, 2024
4af3798
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 Apr 16, 2024
901b018
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 Apr 18, 2024
0ba363b
changes requested
rahat2134 Apr 21, 2024
987a4ea
Merge branch 'develop' of https://github.com/oppia/oppia into Accepta…
rahat2134 Apr 21, 2024
f5455aa
changes
rahat2134 Apr 21, 2024
92c1c1a
Merge branch 'Acceptance-Test_Result' of https://github.com/rahat2134…
rahat2134 Apr 21, 2024
cf107ca
changes
rahat2134 Apr 21, 2024
569c338
changes
rahat2134 Apr 21, 2024
7e03d23
changes
rahat2134 Apr 21, 2024
c1d157f
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 Apr 22, 2024
8501baf
changes
rahat2134 Apr 22, 2024
e7fb522
Merge branch 'develop' of https://github.com/oppia/oppia into Accepta…
rahat2134 Apr 22, 2024
392b5bc
Merge branch 'Acceptance-Test_Result' of https://github.com/rahat2134…
rahat2134 Apr 22, 2024
04653c6
Merge branch 'develop' of https://github.com/oppia/oppia into Accepta…
rahat2134 Apr 27, 2024
3a8e596
changes in tests
rahat2134 Apr 27, 2024
c566e51
Merge branch 'develop' of https://github.com/oppia/oppia into Accepta…
rahat2134 Apr 27, 2024
e239bcc
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 Apr 29, 2024
80108cb
Merge branch 'develop' of https://github.com/oppia/oppia into Accepta…
rahat2134 Apr 29, 2024
caec6d1
changes
rahat2134 Apr 29, 2024
14540d7
Merge branch 'Acceptance-Test_Result' of https://github.com/rahat2134…
rahat2134 Apr 29, 2024
18a9a48
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 Apr 29, 2024
b7a5149
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 Apr 30, 2024
138e167
change
rahat2134 Apr 30, 2024
50a1339
Merge branch 'develop' of https://github.com/oppia/oppia into Accepta…
rahat2134 Apr 30, 2024
fd0e56b
Merge branch 'Acceptance-Test_Result' of https://github.com/rahat2134…
rahat2134 Apr 30, 2024
36071fa
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 May 1, 2024
66bbd22
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 May 11, 2024
2683b98
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 May 19, 2024
35ba89b
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 May 26, 2024
ee07b5c
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 Jun 3, 2024
479daf1
Merge branch 'develop' of https://github.com/oppia/oppia into Accepta…
rahat2134 Jun 3, 2024
1692c11
changes
rahat2134 Jun 3, 2024
b72be13
Merge branch 'Acceptance-Test_Result' of https://github.com/rahat2134…
rahat2134 Jun 3, 2024
2068cec
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 Jun 3, 2024
ee736d9
Merge branch 'Acceptance-Test_Result' of https://github.com/rahat2134…
rahat2134 Jun 3, 2024
fc3bc12
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 Jun 11, 2024
4c225d5
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 Jun 13, 2024
7872f67
Merge branch 'develop' into Acceptance-Test_Result
rahat2134 Jun 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,12 @@ jobs:
run: python -m scripts.build --prod_env
- name: Run Desktop Acceptance Test ${{ matrix.suite }}
run: xvfb-run -a --server-args="-screen 0, 1285x1000x24" python -m scripts.run_acceptance_tests --skip-build --suite=${{ matrix.suite }} --prod_env
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a flag for this new behavior and set it here?

- name: Display Desktop Test Output
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Display Desktop Acceptance Test Output

run: cat test_output.log
- name: Run Mobile Acceptance Test ${{ matrix.suite }}
run: xvfb-run -a --server-args="-screen 0, 1285x1000x24" python -m scripts.run_acceptance_tests --skip-build --suite=${{ matrix.suite }} --prod_env --mobile
- name: Display Mobile Test Output
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Display Mobile Acceptance Test Output

run: cat test_output.log
- name: Uploading webpack bundles as an artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v3
Expand Down
22 changes: 21 additions & 1 deletion scripts/run_acceptance_tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Oppia Authors. All Rights Reserved.
# Copyright 2024 The Oppia Authors. All Rights Reserved.
#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! :)

# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -99,6 +99,21 @@ def compile_test_ts_files() -> None:
os.path.join(build_dir_path, 'images'))


def print_test_output(output_lines: List[bytes]) -> None:
"""Print the test output lines to a separate file."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think this is all very complex. You can just print all the lines.

In the event of a failure, I don't think this will print the call stack as well. Which we would want to see as it tells you where and why the test failed.

with open('test_output.log', 'w', encoding='utf-8') as output_file:
last_spec_started_line = None
for line in output_lines:
line_text = line.decode('utf-8')
if line_text.startswith('Spec started'):
last_spec_started_line = line_text
elif 'passed' in line_text.lower() or 'failed' in line_text.lower():
if last_spec_started_line:
output_file.write(last_spec_started_line + '\n')
last_spec_started_line = None
output_file.write(line_text + '\n')


def run_tests(args: argparse.Namespace) -> Tuple[List[bytes], int]:
"""Run the scripts to start acceptance tests."""
if common.is_oppia_server_already_running():
Expand Down Expand Up @@ -166,6 +181,8 @@ def run_tests(args: argparse.Namespace) -> Tuple[List[bytes], int]:
if proc.poll() is not None:
break

print_test_output(output_lines)

return_value = output_lines, proc.returncode
return return_value

Expand All @@ -177,6 +194,9 @@ def main(args: Optional[List[str]] = None) -> None:
with servers.managed_portserver():
_, return_code = run_tests(parsed_args)

with open('test_output.log', 'r', encoding='utf-8') as output_file:
print(output_file.read())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test output is being printed a second time here and that's not necessary.


sys.exit(return_code)


Expand Down
37 changes: 36 additions & 1 deletion scripts/run_acceptance_tests_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Oppia Authors. All Rights Reserved.
# Copyright 2024 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.
Expand All @@ -17,8 +17,10 @@
from __future__ import annotations

import contextlib
import os
import subprocess
import sys
from unittest import mock

from core.constants import constants
from core.tests import test_utils
Expand Down Expand Up @@ -349,3 +351,36 @@ def test_start_tests_for_long_lived_process(self) -> None:
with self.swap_mock_set_constants_to_default:
with self.swap(constants, 'EMULATOR_MODE', True):
run_acceptance_tests.main(args=['--suite', 'testSuite'])

def test_print_test_output(self) -> None:
test_input = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include the result of printing test output in the test name

b'Spec started: Test Suite 1',
b'Test case 1 passed',
b'Test case 2 failed',
b'Spec started: Test Suite 2',
b'Test case 3 skipped',
b'Test case 4 passed'
]
expected_output_lines = [
'Spec started: Test Suite 1\n',
'Test case 1 passed\n',
'Test case 2 failed\n',
'Spec started: Test Suite 2\n',
'Test case 4 passed\n'
]

with mock.patch('builtins.open', mock.mock_open()) as mock_file:
run_acceptance_tests.print_test_output(test_input)

mock_file.assert_called_once_with(
'test_output.log', 'w', encoding='utf-8')

mock_file_obj = mock_file.return_value

mock_file_obj.write.assert_has_calls(
[mock.call(line) for line in expected_output_lines],
any_order=False
)

if os.path.exists('test_output.log'):
os.remove('test_output.log')