Skip to content

Commit

Permalink
Cleanup video recording (#13713)
Browse files Browse the repository at this point in the history
* Only call related functionallity when
  record_video is set to true
* Add settings options to config template

Co-authored-by: dosas <[email protected]>
(cherry picked from commit ad6b99f)
  • Loading branch information
dosas authored and web-flow committed Jan 12, 2024
1 parent 2bbcc3a commit 3738e59
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
4 changes: 3 additions & 1 deletion conf/ui.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ UI:
WEBDRIVER: chrome
# Binary location for selected wedriver (not needed if using saucelabs)
WEBDRIVER_BINARY: /usr/bin/chromedriver

RECORD_VIDEO: false
GRID_URL: http://infra-grid.example.com:4444
# Web_Kaifuku Settings (checkout https://github.com/RonnyPfannschmidt/webdriver_kaifuku)
WEBKAIFUKU:
webdriver: chrome/remote
webdriver_options:
command_executor: http://localhost:4444/wd/hub
desired_capabilities:
se:recordVideo: '@jinja {{ this.ui.record_video }}'
browserName: chrome
chromeOptions:
args:
Expand Down
17 changes: 9 additions & 8 deletions pytest_plugins/video_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@


def _clean_video(session_id, test):
logger.info(f"cleaning up video files for session: {session_id} and test: {test}")
if settings.ui.record_video:
logger.info(f"cleaning up video files for session: {session_id} and test: {test}")

if settings.ui.grid_url and session_id:
grid = urlparse(url=settings.ui.grid_url)
infra_grid = Host(hostname=grid.hostname)
infra_grid.execute(command=f'rm -rf /var/www/html/videos/{session_id}')
logger.info(f"video cleanup for session {session_id} is complete")
else:
logger.warning("missing grid_url or session_id. unable to clean video files.")
if settings.ui.grid_url and session_id:
grid = urlparse(url=settings.ui.grid_url)
infra_grid = Host(hostname=grid.hostname)
infra_grid.execute(command=f'rm -rf /var/www/html/videos/{session_id}')
logger.info(f"video cleanup for session {session_id} is complete")
else:
logger.warning("missing grid_url or session_id. unable to clean video files.")


def pytest_addoption(parser):
Expand Down
6 changes: 3 additions & 3 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1871,10 +1871,10 @@ def get_caller():
except Exception:
raise
finally:
video_url = settings.ui.grid_url.replace(
':4444', f'/videos/{ui_session.ui_session_id}/video.mp4'
)
if self.record_property is not None and settings.ui.record_video:
video_url = settings.ui.grid_url.replace(
':4444', f'/videos/{ui_session.ui_session_id}/video.mp4'
)
self.record_property('video_url', video_url)
self.record_property('session_id', ui_session.ui_session_id)

Expand Down

0 comments on commit 3738e59

Please sign in to comment.