0

[fuchsia] dump metric results

c9944b69f2/734
is the metric data and being uploaded to exception-db.

Also several drive-by comment fixes.

Cq-Include-Trybots: luci.chrome.try:fuchsia-ava-nelson
Bug: 40935291
Change-Id: I130bdf41d671e6c3f10a28d1daaa86b4ce165582
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6003211
Reviewed-by: David Song <wintermelons@google.com>
Commit-Queue: Zijie He <zijiehe@google.com>
Cr-Commit-Position: refs/heads/main@{#1381376}
This commit is contained in:
Hzj_jie
2024-11-11 20:53:51 +00:00
committed by Chromium LUCI CQ
parent 8cda2cb3ce
commit b58c02ef9b
3 changed files with 60 additions and 41 deletions
build/util/lib/proto
fuchsia_web/av_testing

@@ -57,16 +57,16 @@ def time_consumption(*name_pieces: str) -> TimeConsumption:
def clear() -> None: def clear() -> None:
"""Clear all the registered Measures.""" """Clears all the registered Measures."""
_metric.clear() _metric.clear()
def size() -> int: def size() -> int:
"""Get the current size of registered Measures.""" """Gets the current size of registered Measures."""
return _metric.size() return _metric.size()
def to_dict() -> dict: def to_dict() -> dict:
"""Convert all the registered Measures to a dict. """Converts all the registered Measures to a dict.
The records are wrapped in protobuf Any message before exported as dict The records are wrapped in protobuf Any message before exported as dict
so that an additional key "@type" is included. so that an additional key "@type" is included.
@@ -77,7 +77,7 @@ def to_dict() -> dict:
def to_json() -> str: def to_json() -> str:
"""Convert all the registered Measures to a json str.""" """Converts all the registered Measures to a json str."""
return json.dumps(to_dict(), sort_keys=True, indent=2) return json.dumps(to_dict(), sort_keys=True, indent=2)
# TODO(crbug.com/343242386): May need to implement a lock and reset logic to # TODO(crbug.com/343242386): May need to implement a lock and reset logic to

@@ -31,7 +31,7 @@ import monitors
import version import version
from browser_runner import BrowserRunner from browser_runner import BrowserRunner
from chrome_driver_wrapper import ChromeDriverWrapper from chrome_driver_wrapper import ChromeDriverWrapper
from common import get_ffx_isolate_dir, get_free_local_port from common import get_build_info, get_ffx_isolate_dir, get_free_local_port
from compatible_utils import running_unattended from compatible_utils import running_unattended
from isolate_daemon import IsolateDaemon from isolate_daemon import IsolateDaemon
from run_webpage_test import WebpageTestRunner, capture_devtools_addr from run_webpage_test import WebpageTestRunner, capture_devtools_addr
@@ -86,55 +86,70 @@ def parameters_of(file: str) -> camera.Parameters:
return result return result
def run_test(proc: subprocess.Popen) -> None: def run_video_perf_test(file: str, driver: ChromeDriverWrapper,
device, port = capture_devtools_addr(proc, LOG_DIR) host: str) -> None:
logging.warning('DevTools is now running on %s:%s', device, port) if running_unattended():
camera_params = parameters_of('720p24fpsVP9_gangnam_sync.webm') param = f'file={file}'
with ChromeDriverWrapper((device, port)) as driver: else:
# Replace the last byte to 1, by default it's the ip address of the host param = 'local'
# machine being accessible on the device. camera_params = parameters_of(file)
host = '.'.join(device.split('.')[:-1] + ['1']) driver.get(f'http://{host}:{HTTP_SERVER_PORT}/video.html?{param}')
if running_unattended(): with StartProcess(camera.start, [camera_params], False):
param = f'file={camera_params.file}' video = driver.find_element_by_id('video')
proxy_host = os.environ.get('GCS_PROXY_HOST') video.click()
if proxy_host: # Video playback should finish almost within the same time as the camera
# This is a hacky way to get the ip address of the host machine # recording, and this check is only necessary to indicate a very heavy
# being accessible on the device. # network laggy and buffering.
host = proxy_host + '0' # TODO(crbug.com/40935291): May need to adjust the strategy here, the
else: # final frame / barcode is considered laggy and drops the score.
param = 'local' with monitors.time_consumption('video_perf', 'playback', 'laggy', file):
driver.get(f'http://{host}:{HTTP_SERVER_PORT}/video.html?{param}') while not driver.execute_script('return arguments[0].ended;', video):
with StartProcess(camera.start, [camera_params], False): time.sleep(1)
video = driver.find_element_by_id('video') logging.warning('Video %s finished', file)
video.click()
# Video playback should finish almost within the same time as the camera
# recording, and this check is only necessary to indicate a very heavy
# network laggy and buffering.
# TODO(crbug.com/40935291): May need to adjust the strategy here, the
# final frame / barcode is considered laggy and drops the score.
with monitors.time_consumption('video_perf', 'playback', 'laggy'):
while not driver.execute_script('return arguments[0].ended;',
video):
time.sleep(1)
logging.warning('Video finished')
# Download the original video file for local comparison. # Download the original video file for local comparison.
original_video = os.path.join(TEMP_DIR, camera_params.file) original_video = os.path.join(TEMP_DIR, file)
assert camera_params.video_file != original_video assert camera_params.video_file != original_video
# The http address should match the one in video.html. # The http address should match the one in video.html.
urllib.request.urlretrieve( urllib.request.urlretrieve(
f'http://172.31.186.18/test_site/mediaFiles/videostack/' f'http://172.31.186.18/test_site/mediaFiles/videostack/{file}',
f'{camera_params.file}', original_video) original_video)
results = video_analyzer.from_original_video(camera_params.video_file, results = video_analyzer.from_original_video(camera_params.video_file,
original_video) original_video)
logging.warning('Video analysis result: %s', results)
def record(key: str) -> None:
monitors.average(file, key).record(results[key])
record('smoothness')
record('freezing')
record('dropped_frame_count')
record('total_frame_count')
record('dropped_frame_percentage')
logging.warning('Video analysis result of %s: %s', file, results)
# Move the info csv to the cas-output for debugging purpose. Video files are # Move the info csv to the cas-output for debugging purpose. Video files are
# huge and will be ignored. # huge and will be ignored.
shutil.move(camera_params.info_file, LOG_DIR) shutil.move(camera_params.info_file, LOG_DIR)
def run_test(proc: subprocess.Popen) -> None:
device, port = capture_devtools_addr(proc, LOG_DIR)
logging.warning('DevTools is now running on %s:%s', device, port)
# Replace the last byte to 1, by default it's the ip address of the host
# machine being accessible on the device.
host = '.'.join(device.split('.')[:-1] + ['1'])
if running_unattended():
proxy_host = os.environ.get('GCS_PROXY_HOST')
if proxy_host:
# This is a hacky way to get the ip address of the host machine
# being accessible on the device.
host = proxy_host + '0'
with ChromeDriverWrapper((device, port)) as driver:
for file in ['720p24fpsVP9_gangnam_sync.webm']:
run_video_perf_test(file, driver, host)
def main() -> int: def main() -> int:
proc = subprocess.Popen([ proc = subprocess.Popen([
os.path.join(TEST_SCRIPTS_ROOT, os.path.join(TEST_SCRIPTS_ROOT,
@@ -150,6 +165,9 @@ def main() -> int:
finally: finally:
proc.terminate() proc.terminate()
proc.wait() proc.wait()
# May need to merge with the existing file created by run_test.py
# webpage process.
monitors.dump(os.path.join(LOG_DIR, 'invocations'))
if __name__ == '__main__': if __name__ == '__main__':
@@ -163,6 +181,7 @@ if __name__ == '__main__':
# command line flags. # command line flags.
logging.warning('Chrome version %s %s', version.chrome_version_str(), logging.warning('Chrome version %s %s', version.chrome_version_str(),
version.git_revision()) version.git_revision())
logging.warning('Fuchsia build info %s', get_build_info())
# Setting a temporary isolate daemon dir and share it with the webpage # Setting a temporary isolate daemon dir and share it with the webpage
# runner. # runner.
with StartProcess(server.start, [HTTP_SERVER_PORT], True), \ with StartProcess(server.start, [HTTP_SERVER_PORT], True), \

@@ -36,7 +36,7 @@ class Parameters:
def start(parameters: Parameters) -> None: def start(parameters: Parameters) -> None:
"""Starts an av_sync_record process to record the video from the camera. """Starts an av_sync_record process to record the video from the camera.
Executing of this function shouldn't be terminated as it would create a Executing of this function shouldn't be terminated as it would create a
bad constructed mp4 file. If the recorder binary does not exist, the bad constructed video file. If the recorder binary does not exist, the
function returns immediately.""" function returns immediately."""
assert parameters.output_path assert parameters.output_path
assert parameters.file assert parameters.file