Skip to content

Commit 4c82830

Browse files
authored
Add retries to the FTL integration test runs (#876)
* Add retries to the FTL integration test runs * Fix ModuleNotFound problems * Make Analytics intentionally fail * Revert "Make Analytics intentionally fail" This reverts commit 6969172.
1 parent 3061aef commit 4c82830

File tree

4 files changed

+35
-12
lines changed

4 files changed

+35
-12
lines changed

.github/workflows/integration_tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,8 @@ jobs:
526526
testapp_dir: testapps
527527
test_type: "game-loop"
528528
test_devices: ${{ matrix.device_detail }}
529+
max_attempts: 3
530+
validator: ${GITHUB_WORKSPACE}/scripts/gha/read_ftl_test_result.py
529531
- name: Read FTL Test Result
530532
if: ${{ matrix.device_type == 'real' && !cancelled() }}
531533
timeout-minutes: 60

scripts/gha/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Copyright 2023 Google
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Copyright 2023 Google

scripts/gha/read_ftl_test_result.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@
3232
import attr
3333
import subprocess
3434
import json
35+
import sys
3536

3637
from absl import app
3738
from absl import flags
3839
from absl import logging
3940

41+
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
4042
from integration_testing import test_validation
4143
from integration_testing import gcs
4244

@@ -59,18 +61,7 @@ def main(argv):
5961
test_result = json.loads(FLAGS.test_result)
6062
tests = []
6163
for app in test_result.get("apps"):
62-
app_path = app.get("testapp_path")
63-
return_code = app.get("return_code")
64-
logging.info("testapp: %s\nreturn code: %s" % (app_path, return_code))
65-
if return_code == 0:
66-
gcs_dir = app.get("raw_result_link").replace("https://console.developers.google.com/storage/browser/", "gs://")
67-
logging.info("gcs_dir: %s" % gcs_dir)
68-
logs = _get_testapp_log_text_from_gcs(gcs_dir)
69-
logging.info("Test result: %s", logs)
70-
tests.append(Test(testapp_path=app_path, logs=logs))
71-
else:
72-
logging.error("Test failed: %s", app)
73-
tests.append(Test(testapp_path=app_path, logs=None))
64+
tests.append(_parse_testapp_to_test(app))
7465

7566
(output_dir, file_name) = os.path.split(os.path.abspath(FLAGS.output_path))
7667
return test_validation.summarize_test_results(
@@ -80,6 +71,22 @@ def main(argv):
8071
file_name=file_name)
8172

8273

74+
def _parse_testapp_to_test(app):
75+
"""Parsed the given testapp run into a Test object."""
76+
app_path = app.get("testapp_path")
77+
return_code = app.get("return_code")
78+
logging.info("testapp: %s\nreturn code: %s" % (app_path, return_code))
79+
if return_code == 0:
80+
gcs_dir = app.get("raw_result_link").replace("https://console.developers.google.com/storage/browser/", "gs://")
81+
logging.info("gcs_dir: %s" % gcs_dir)
82+
logs = _get_testapp_log_text_from_gcs(gcs_dir)
83+
logging.info("Test result: %s", logs)
84+
return Test(testapp_path=app_path, logs=logs)
85+
else:
86+
logging.error("Test failed: %s", app)
87+
return Test(testapp_path=app_path, logs=None)
88+
89+
8390
def _get_testapp_log_text_from_gcs(gcs_path):
8491
"""Gets the testapp log text generated by game loops."""
8592
try:
@@ -130,6 +137,18 @@ def _gcs_read_file(gcs_path):
130137
return result.stdout
131138

132139

140+
141+
def validate(test_summary):
142+
"""Validates a given test summary, assuming it is from a Unity testapp."""
143+
if not test_summary:
144+
logging.error("Nothing to be validate! Please provide test_summary")
145+
return False
146+
147+
test = _parse_testapp_to_test(test_summary)
148+
result = test_validation.validate_results(test.logs, "unity")
149+
return result.complete and result.fails == 0
150+
151+
133152
if __name__ == '__main__':
134153
flags.mark_flag_as_required("test_result")
135154
flags.mark_flag_as_required("output_path")

0 commit comments

Comments
 (0)