You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thanks for contributing to the Docker-Selenium project! A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines, applied for this repository.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
feat: Video recording with dynamic file name based on metadata in tests
Motivation and Context
Video recording with dynamic file name based on metadata in tests
Based on the support of Metadata in tests. When the video recorder is sidecar deployed with the browser node with enabling SE_VIDEO_FILE_NAME=auto and adding metadata to your tests, video file name will extract value of capability se:name and use it as the video file name.
The output video file name will be test_visit_basic_auth_secured_page_ChromeTests_<sessionId>.mp4.
If your test name is handled by the test framework, and it is unique for sure, you also can disable the session id appends to the video file name by setting SE_VIDEO_FILE_NAME_SUFFIX=false.
File name will be trimmed to 255 characters to avoid long file names. Moreover, space character will be replaced by _ and only characters alphabets, numbers, - (hyphen), _ (underscore) are retained in the file name.
The trim regex is able to be customized by setting SE_VIDEO_FILE_NAME_TRIM_REGEX environment variable. The default value is [:alnum:]-_. The regex should be compatible with the tr command in bash.
At deployment level, the recorder container is up always. In addition, you can disable video recording process via session capability se:recordVideo. For example in Python binding:
options.set_capability('se:recordVideo', False)
In recorder container will perform query GraphQL in Hub based on Node SessionId and extract the value of se:recordVideo in capabilities before deciding to start video recording process or not.
Notes: To reach the GraphQL endpoint, the recorder container needs to know the Hub URL. The Hub URL can be passed via environment variable SE_NODE_GRID_URL. For example SE_NODE_GRID_URL is http://selenium-hub:4444.
After test executed, under (${PWD}/assets) you can see the video file name in path /<sessionId>/test_visit_basic_auth_secured_page_ChromeTests.mp4
The file name will be trimmed to 255 characters to avoid long file names. Moreover, the space character will be replaced by _, and only the characters alphabets, numbers, - (hyphen), and _ (underscore) are retained in the file name. (This feat is available once this SeleniumHQ/selenium#13907 merged)
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
4, because the PR involves multiple complex changes across various scripts, configurations, and test setups. It requires a thorough understanding of the video recording feature, environment variable configurations, and potential impacts on existing functionalities.
🧪 Relevant tests
Yes
⚡ Possible issues
Possible Bug: The use of pgrep ffmpeg in stop_recording function might not reliably capture the correct process ID if multiple ffmpeg processes are running. Consider using a more specific method to track and kill the ffmpeg process started by this script.
Performance Concern: The addition of logging with timestamps in multiple places might introduce slight delays. While generally minimal, this could affect performance in high-load scenarios or when precise timing is critical.
Improve the reliability of stopping ffmpeg processes.
Replace the kill -INT $(pgrep ffmpeg) command with pkill -INT ffmpeg to ensure that all ffmpeg processes are targeted more reliably without needing to spawn a subshell for pgrep.
Improve filename sanitization by using a more explicit character set.
Replace the use of tr -dc "${VIDEO_FILE_NAME_TRIM}" with a more explicit and controlled regex pattern or set of characters to ensure that the filename sanitization is robust and predictable.
Conditionally execute the video integrity check based on the presence of video files.
To ensure that the make test_video_integrity command only runs when necessary, consider adding a condition to check if video files exist before executing the command.
-make test_video_integrity+if [ -n "$$(find ./tests/videos -type f -name '*.mp4')" ]; then make test_video_integrity; fi
Allow dynamic configuration of the video file name suffix to enhance flexibility.
Instead of hardcoding the video file name suffix as "true" or "false", consider using a more flexible approach that allows configuration through an environment variable or a configuration file.
Add detailed logging and error handling to the video file integrity check process.
To improve the robustness of the video file integrity check, consider adding logging for each step and more detailed error messages to help in troubleshooting.
Document or comment on the logic behind dynamic video file naming for better maintainability and clarity.
Since SE_VIDEO_FILE_NAME is set to 'auto' for dynamic naming, it's crucial to document or provide inline comments on how the naming convention is derived (e.g., based on timestamp, session ID, etc.) to aid in maintainability and understanding for new developers or during debugging sessions.
-- SE_VIDEO_FILE_NAME=auto+- SE_VIDEO_FILE_NAME=auto # Naming based on timestamp and session ID
Security
Enhance security by preventing potential command injection and ensuring proper variable quoting.
To avoid potential command injection vulnerabilities, consider using array variables for commands and ensure that variables in command contexts are properly quoted.
Use a case statement for more robust boolean string handling.
Use a more robust method to handle boolean string comparisons by using a case statement or a function to avoid potential issues with different case inputs.
Improve environment variable naming for clarity and to avoid potential conflicts.
It's recommended to use more descriptive variable names for environment variables to avoid conflicts and increase clarity. For example, VIDEO_FILE_NAME could be more specific to its usage context.
Ensure compatibility and clarity by verifying dynamic file naming support and removing deprecated environment variables.
It appears that the commented-out environment variable FILE_NAME is replaced by SE_VIDEO_FILE_NAME with a value of 'auto'. If the intention is to dynamically generate file names based on metadata, ensure that the system or application using these variables supports the 'auto' setting and behaves as expected. If FILE_NAME is no longer needed, it should be removed entirely to avoid confusion.
Use a variable for the video directory path to enhance maintainability and flexibility.
To avoid potential issues with hardcoded paths, consider using a variable for the video directory path, which can be set at the top of the Makefile or passed as an environment variable.
-list_files=$$(find ./tests/videos -type f -name "*.mp4");+VIDEO_DIR=./tests/videos; \+list_files=$$(find $$VIDEO_DIR -type f -name "*.mp4");
Reduce redundancy and potential for errors by defining shared environment variables globally.
The addition of SE_NODE_GRID_URL to each service's environment suggests a centralized Selenium Grid URL. To avoid redundancy and potential errors in URL updates, consider defining SE_NODE_GRID_URL globally for all services if the URL is the same across them.
Remove deprecated and unused configuration lines to clean up the environment settings.
The commented-out FILE_NAME variables are still present in the file. If these are no longer used due to the new SE_VIDEO_FILE_NAME setting, it would be cleaner and less confusing to remove these commented lines entirely.
-# - FILE_NAME=chrome_video.mp4+# (Remove this line if no longer needed)
Possible issue
Verify that the 'auto' setting for video file names generates unique and meaningful names to prevent file clashes.
The use of the auto value for SE_VIDEO_FILE_NAME across different services suggests a feature for automatic file naming. Confirm that the underlying system correctly interprets 'auto' to generate meaningful and unique file names, especially in a concurrent testing environment where file name clashes can occur.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Thanks for contributing to the Docker-Selenium project!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines, applied for this repository.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
feat: Video recording with dynamic file name based on metadata in tests
Motivation and Context
Video recording with dynamic file name based on metadata in tests
Based on the support of Metadata in tests. When the video recorder is sidecar deployed with the browser node with enabling
SE_VIDEO_FILE_NAME=auto
and adding metadata to your tests, video file name will extract value of capabilityse:name
and use it as the video file name.For example in Python binding:
The output video file name will be
test_visit_basic_auth_secured_page_ChromeTests_<sessionId>.mp4
.If your test name is handled by the test framework, and it is unique for sure, you also can disable the session id appends to the video file name by setting
SE_VIDEO_FILE_NAME_SUFFIX=false
.File name will be trimmed to 255 characters to avoid long file names. Moreover,
space
character will be replaced by_
and only characters alphabets, numbers,-
(hyphen),_
(underscore) are retained in the file name.The trim regex is able to be customized by setting
SE_VIDEO_FILE_NAME_TRIM_REGEX
environment variable. The default value is[:alnum:]-_
. The regex should be compatible with thetr
command in bash.At deployment level, the recorder container is up always. In addition, you can disable video recording process via session capability
se:recordVideo
. For example in Python binding:In recorder container will perform query GraphQL in Hub based on Node SessionId and extract the value of
se:recordVideo
in capabilities before deciding to start video recording process or not.Notes: To reach the GraphQL endpoint, the recorder container needs to know the Hub URL. The Hub URL can be passed via environment variable
SE_NODE_GRID_URL
. For exampleSE_NODE_GRID_URL
ishttp://selenium-hub:4444
.For example, docker-compose-v3-video.yml
Dynamic Grid
From language bindings, you can set the
se:name
capability to change output video file name dynamically. For example, in Python binding:After test executed, under (
${PWD}/assets
) you can see the video file name in path/<sessionId>/test_visit_basic_auth_secured_page_ChromeTests.mp4
The file name will be trimmed to 255 characters to avoid long file names. Moreover, the
space
character will be replaced by_
, and only the characters alphabets, numbers,-
(hyphen), and_
(underscore) are retained in the file name. (This feat is available once this SeleniumHQ/selenium#13907 merged)Types of changes
Checklist
PR Type
enhancement, bug_fix
Description
Changes walkthrough 📝
8 files
upload.sh
Enhance upload script with improved cleanup and signal handling
Video/upload.sh
EXIT.
video.sh
Refactor video recording script with improved logging and process
handling
Video/video.sh
process_name
to tag log entries.pkill
tokill
usingpgrep
for stopping ffmpeg to improvereliability.
video_graphQLQuery.sh
Support dynamic video file naming based on session metadata
Video/video_graphQLQuery.sh
SE_VIDEO_FILE_NAME_SUFFIX
.chart_test.sh
Update Helm chart testing scripts with additional configurations and
cleanup
tests/charts/make/chart_test.sh
Helm chart tests.
test setups.
__init__.py
Enhance Selenium tests with video naming and post-test delay
tests/SeleniumTests/init.py
in Selenium tests.
helm-chart-test.yml
Enhance GitHub Actions for Helm chart tests with video checks
.github/workflows/helm-chart-test.yml
in GitHub Actions.
test-video.yml
Refactor GitHub Actions workflow for video upload consolidation
.github/workflows/test-video.yml
Makefile
Add new make targets for dynamic video testing and integrity checks
Makefile
1 files
_helpers.tpl
Fix uploader conditional checks in Helm chart templates
charts/selenium-grid/templates/_helpers.tpl
1 files
README.md
Update README with dynamic video file naming documentation
README.md
based on test metadata.