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
Update for video container (record & upload) work with standalone roles and dynamic grid (node-docker, standalone-docker)
Add test to cover upload function by starting a local FTP server and passing env variables to config RCLONE upload.
Potential Bug The new code for handling different session ID queries based on standalone or grid mode may not cover all possible scenarios, potentially leading to issues in session identification.
Performance Concern The new batch processing for rclone uploads might introduce delays or bottlenecks if not properly tuned, especially with the fixed batch size of 10.
Logic Change The modification to the video_ready check logic might affect the reliability of the readiness probe, potentially leading to false positives in certain scenarios.
Use environment variables for sensitive information instead of hardcoding
Consider using environment variables for sensitive information like passwords instead of hardcoding them in the docker-compose file. This improves security and makes the configuration more flexible.
Why: This suggestion addresses a significant security concern by recommending the use of environment variables for sensitive information like passwords, which enhances security and flexibility.
9
Use secrets management for sensitive information instead of environment variables
Consider using secrets management for sensitive information like passwords instead of environment variables. This provides an additional layer of security.
Why: This suggestion enhances security by recommending the use of secrets management for handling sensitive information, providing an additional layer of protection compared to environment variables.
9
Enhancement
Replace multiple if-else conditions with a case statement for better code structure
Consider using a case statement instead of multiple if-else conditions for better readability and maintainability when setting JQ_SESSION_ID_QUERY, SE_NODE_PORT, and NODE_STATUS_ENDPOINT based on SE_VIDEO_RECORD_STANDALONE.
Why: The suggestion to use a case statement improves code readability and maintainability by reducing the complexity of multiple if-else conditions. This change is beneficial for future modifications and understanding of the code structure.
8
✅ Simplify the logic for setting the grid_url variable using parameter expansion with default values
Consider using parameter expansion with default values to simplify the logic for setting the grid_url variable, reducing the number of conditional statements.
Why: Simplifying the logic for setting the grid_url variable using parameter expansion with default values reduces the number of conditional statements, making the code cleaner and easier to maintain. This is a good enhancement for code clarity.
8
Add a health check for the FTP server to ensure it's ready before dependent services start
Consider adding a health check for the FTP server to ensure it's ready before other services that depend on it start.
ftp_server:
image: delfer/alpine-ftp-server:latest
environment:
- USERS=seluser|selenium.dev
volumes:
# Mount the local directory `/tmp/upload` to the FTP server's `/ftp/seluser` directory to check out the uploaded videos
- /tmp/upload:/ftp/seluser
stop_grace_period: 30s
+ healthcheck:+ test: ["CMD", "nc", "-z", "localhost", "21"]+ interval: 10s+ timeout: 5s+ retries: 3
Apply this suggestion
Suggestion importance[1-10]: 7
Why: Adding a health check is a good practice that ensures the FTP server is ready before dependent services start, improving reliability and stability of the system.
7
Best practice
Add resource limits to containers to prevent potential resource exhaustion
Consider adding resource limits to the containers to prevent potential resource exhaustion issues.
Why: Setting resource limits is a best practice that helps prevent resource exhaustion, ensuring that the system remains stable and responsive under load.
8
Performance
Implement batch processing for more efficient file uploads
Consider using a more efficient approach for batch processing of rclone uploads by accumulating a list of files to upload and then processing them in batches, rather than checking the batch size after each file.
-function rclone_upload() {- local source=$1- local target=$2- echo "$(date +%FT%T%Z) [${process_name}] - Uploading ${source} to ${target}"- exec rclone --config ${UPLOAD_CONFIG_DIRECTORY}/${UPLOAD_CONFIG_FILE_NAME} ${UPLOAD_COMMAND} --cutoff-mode SOFT --metadata ${UPLOAD_OPTS} "${source}" "${target}" &+function rclone_upload_batch() {+ local -a sources=("$@")+ local -a targets=("${sources[@]/#/${UPLOAD_DESTINATION_PREFIX}/}")+ echo "$(date +%FT%T%Z) [${process_name}] - Uploading batch of ${#sources[@]} files"+ exec rclone --config ${UPLOAD_CONFIG_DIRECTORY}/${UPLOAD_CONFIG_FILE_NAME} ${UPLOAD_COMMAND} --cutoff-mode SOFT --metadata ${UPLOAD_OPTS} "${sources[@]}" "${targets[@]}" &
}
Apply this suggestion
Suggestion importance[1-10]: 7
Why: Implementing batch processing for rclone uploads can enhance performance by reducing the overhead of frequent checks and process initiations. This suggestion is valid and can lead to more efficient resource utilization.
7
Cache the result of process check to improve performance for multiple requests
Consider caching the result of the process check to avoid repeated iterations over all processes for each request, especially if the script handles multiple requests in quick succession.
-if environ.get('SE_VIDEO_UPLOAD_ENABLED', 'false').lower() != 'true' and environ.get('SE_VIDEO_FILE_NAME', 'video.mp4').lower() != 'auto':- video_ready = "ffmpeg" in (p.name().lower() for p in psutil.process_iter())-else:- video_ready = True+def is_ffmpeg_running():+ return any(p.name().lower() == "ffmpeg" for p in psutil.process_iter())+ffmpeg_running = is_ffmpeg_running()++class Handler(BaseHTTPRequestHandler):+ def do_GET(self):+ global ffmpeg_running+ if environ.get('SE_VIDEO_UPLOAD_ENABLED', 'false').lower() != 'true' and environ.get('SE_VIDEO_FILE_NAME', 'video.mp4').lower() != 'auto':+ video_ready = ffmpeg_running+ else:+ video_ready = True+
Apply this suggestion
Suggestion importance[1-10]: 6
Why: Caching the result of the process check can improve performance by reducing the need to repeatedly iterate over processes. However, the suggestion may require careful consideration of when to update the cache to ensure accuracy.
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
Motivation and Context
Reference
Configure video recording and uploading for Hub and Nodes: docker-compose-v3-video-upload.yml
Configure video recording and uploading for Standalone roles: docker-compose-v3-video-upload-standalone.yml
Configure video recording and uploading for Dynamic Grid (node-docker): docker-compose-v3-video-upload-dynamic-grid.yml
Configure video recording and uploading for Dynamic Grid standalone (standalone-docker): tests/docker-compose-v3-test-standalone-docker.yaml
Types of changes
Checklist
PR Type
Enhancement, Tests
Description
Changes walkthrough 📝
9 files
upload.sh
Enhance video upload script with batch processing and logging
Video/upload.sh
video.sh
Support standalone video recording and improve logging
Video/video.sh
video_graphQLQuery.sh
Adjust GraphQL endpoint configuration for video queries
Video/video_graphQLQuery.sh
video_gridUrl.sh
Add script to determine Selenium grid URL
Video/video_gridUrl.sh
chart_test.sh
Enhance Kubernetes resource description and uploader config
tests/charts/make/chart_test.sh
video_ready.py
Modify video readiness check logic
Video/video_ready.py
Makefile
Add test targets and improve resource preparation
Makefile
Dockerfile
Add video grid URL script to Docker image
Video/Dockerfile
supervisord.conf
Update supervisor configuration for video services
Video/supervisord.conf
3 files
bootstrap.sh
Add delay after test execution in bootstrap script
tests/bootstrap.sh
config.yml
Add test strategy for standalone video recording
.circleci/config.yml
docker-test.yml
Include standalone video recording test strategy
.github/workflows/docker-test.yml
1 files
README.md
Update documentation for video recording and uploading
README.md
2 files
docker-compose-v3-video-upload-dynamic-grid.yml
Add Docker Compose config for dynamic grid
docker-compose-v3-video-upload-dynamic-grid.yml
docker-compose-v3-video-upload-standalone.yml
Add Docker Compose config for standalone video upload
docker-compose-v3-video-upload-standalone.yml