Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #72 from seleniumhq-community/4.19.1 [deploy]
Browse files Browse the repository at this point in the history
Sync upstream 4.19.1

Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Mar 31, 2024
2 parents 80438d8 + 2339d4a commit 496b79a
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 29 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ workflows:
jobs:
- deploy-multi-arch-full-grid:
name: deploy-multi-arch-base
platforms: linux/arm64,linux/amd64,linux/arm/v7
platforms: linux/arm64,linux/amd64
build-args: --push
make-targets: base_multi
machine-type: ubuntu2004arm64large
Expand All @@ -349,7 +349,7 @@ workflows:
- deploy-multi-arch-full-grid:
name: deploy-multi-arch-full-grid
requires: [deploy-multi-arch-base]
platforms: linux/arm64,linux/amd64,linux/arm/v7
platforms: linux/arm64,linux/amd64
build-args: --push
make-targets: grid_multi
machine-type: ubuntu2004arm64
Expand All @@ -360,7 +360,7 @@ workflows:
- deploy-multi-arch-full-grid:
name: deploy-multi-arch-node-base
requires: [deploy-multi-arch-base]
platforms: linux/arm64,linux/amd64,linux/arm/v7
platforms: linux/arm64,linux/amd64
build-args: --push
make-targets: node_base_multi
machine-type: ubuntu2004arm64large
Expand All @@ -371,7 +371,7 @@ workflows:
- deploy-multi-arch-full-grid:
name: deploy-multi-arch-firefox
requires: [deploy-multi-arch-node-base]
platforms: linux/arm64,linux/amd64,linux/arm/v7
platforms: linux/arm64,linux/amd64
build-args: --push
make-targets: firefox_multi
machine-type: ubuntu2004arm64large
Expand All @@ -382,7 +382,7 @@ workflows:
- deploy-multi-arch-full-grid:
name: deploy-multi-arch-chromium
requires: [deploy-multi-arch-node-base]
platforms: linux/arm64,linux/amd64,linux/arm/v7
platforms: linux/arm64,linux/amd64
build-args: --push
make-targets: chromium_multi
machine-type: ubuntu2004arm64large
Expand All @@ -393,7 +393,7 @@ workflows:
- deploy-multi-arch-full-grid:
name: deploy-multi-arch-release-notes
requires: [deploy-multi-arch-firefox,deploy-multi-arch-chromium]
platforms: linux/arm64,linux/amd64,linux/arm/v7
platforms: linux/arm64,linux/amd64
build-args: --push
make-targets: tag_and_push_multi_arch_browser_images
machine-type: ubuntu2004arm64
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-video.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test video files
name: Test Docker Selenium
concurrency:
group: ${{ github.workflow }}

Expand Down Expand Up @@ -36,7 +36,7 @@ jobs:
strategy:
fail-fast: false
matrix:
test-strategy: [test_video, test_parallel]
test-strategy: [test_video, test_parallel, test_node_docker]
steps:
- uses: actions/checkout@main
- name: Output Docker info
Expand Down
4 changes: 2 additions & 2 deletions Base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ LABEL authors="Selenium <[email protected]>"
ARG VERSION
ARG RELEASE=selenium-${VERSION}
# Default value should be aligned with upstream Selenium (https://github.com/SeleniumHQ/selenium/blob/trunk/java/maven_deps.bzl)
ARG OPENTELEMETRY_VERSION=1.35.0
ARG GRPC_VERSION=1.61.1
ARG OPENTELEMETRY_VERSION=1.36.0
ARG GRPC_VERSION=1.62.2

#Arguments to define the user running Selenium
ARG SEL_USER=seluser
Expand Down
23 changes: 21 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ NAME := $(or $(NAME),$(NAME),selenium)
CURRENT_DATE := $(shell date '+%Y%m%d')
BUILD_DATE := $(or $(BUILD_DATE),$(BUILD_DATE),$(CURRENT_DATE))
BASE_RELEASE := $(or $(BASE_RELEASE),$(BASE_RELEASE),selenium-4.19.0)
BASE_VERSION := $(or $(BASE_VERSION),$(BASE_VERSION),4.19.0)
BASE_VERSION := $(or $(BASE_VERSION),$(BASE_VERSION),4.19.1)
BASE_RELEASE_NIGHTLY := $(or $(BASE_RELEASE_NIGHTLY),$(BASE_RELEASE_NIGHTLY),nightly)
BASE_VERSION_NIGHTLY := $(or $(BASE_VERSION_NIGHTLY),$(BASE_VERSION_NIGHTLY),4.20.0-SNAPSHOT)
VERSION := $(or $(VERSION),$(VERSION),4.19.0)
VERSION := $(or $(VERSION),$(VERSION),4.19.1)
TAG_VERSION := $(VERSION)-$(BUILD_DATE)
CHART_VERSION_NIGHTLY := $(or $(CHART_VERSION_NIGHTLY),$(CHART_VERSION_NIGHTLY),1.0.0-nightly)
NAMESPACE := $(or $(NAMESPACE),$(NAMESPACE),$(NAME))
Expand Down Expand Up @@ -569,6 +569,25 @@ test_video: video hub chrome firefox edge
docker run -u $$(id -u) -v $$(pwd):$$(pwd) -w $$(pwd) $(FFMPEG_BASED_NAME)/ffmpeg:$(FFMPEG_BASED_TAG) -v error -i ./tests/videos/firefox_video.mp4 -f null - 2>error.log
docker run -u $$(id -u) -v $$(pwd):$$(pwd) -w $$(pwd) $(FFMPEG_BASED_NAME)/ffmpeg:$(FFMPEG_BASED_TAG) -v error -i ./tests/videos/edge_video.mp4 -f null - 2>error.log

test_node_docker: docker hub chrome firefox edge
rm -rf ./tests/videos; mkdir -p ./tests/videos
for node in StandaloneChrome StandaloneFirefox StandaloneEdge ; do \
cd tests || true ; \
echo NAMESPACE=$(NAME) > .env ; \
echo TAG=$(TAG_VERSION) >> .env ; \
echo VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) >> .env ; \
echo TEST_DRAIN_AFTER_SESSION_COUNT=$(or $(TEST_DRAIN_AFTER_SESSION_COUNT), 0) >> .env ; \
echo TEST_PARALLEL_HARDENING=$(or $(TEST_PARALLEL_HARDENING), "false") >> .env ; \
echo LOG_LEVEL=$(or $(LOG_LEVEL), "INFO") >> .env ; \
echo REQUEST_TIMEOUT=$(or $(REQUEST_TIMEOUT), 30) >> .env ; \
echo NODE=$$node >> .env ; \
echo UID=$$(id -u) >> .env ; \
export $$(cat .env | xargs) ; \
envsubst < config.toml > ./videos/config.toml ; \
docker-compose -f docker-compose-v3-test-node-docker.yaml up --no-log-prefix --exit-code-from tests --build ; \
if [ $$? -ne 0 ]; then exit 1; fi ; \
done

test_custom_ca_cert:
VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/customCACert/bootstrap.sh

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Docker images for Selenium, built for Debian ARM64, ARM/v7, and AMD64

[![seleniumhq-community](https://circleci.com/gh/seleniumhq-community/docker-seleniarm.svg?style=shield)](https://app.circleci.com/pipelines/github/seleniumhq-community/docker-seleniarm)
Expand Down
2 changes: 1 addition & 1 deletion build-and-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RELEASE=$(grep BASE_RELEASE Makefile | sed 's/.*,\([^)]*\))/\1/p' | head -n 1)
NAME="${NAME:-seleniarm}"
VERSION="${VERSION:-$SELENIUM_VERSION}"
BUILD_DATE="${BUILD_DATE:-$(date '+%Y%m%d')}"
PLATFORMS="${PLATFORMS:-linux/arm64,linux/arm/v7,linux/amd64}"
PLATFORMS="${PLATFORMS:-linux/arm64,linux/amd64}"
BUILD_ARGS=--push

FROM_IMAGE_ARGS="--build-arg NAMESPACE=$NAME --build-arg VERSION=$VERSION-$BUILD_DATE"
Expand Down
2 changes: 1 addition & 1 deletion build-locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RELEASE=$(grep BASE_RELEASE Makefile | sed 's/.*,\([^)]*\))/\1/p' | head -n 1)
NAME="${NAME:-seleniarm}"
VERSION="${VERSION:-$SELENIUM_VERSION}"
BUILD_DATE="${BUILD_DATE:-$(date '+%Y%m%d')}"
PLATFORMS="${PLATFORMS:-linux/arm64,linux/arm/v7,linux/amd64}"
PLATFORMS="${PLATFORMS:-linux/arm64,linux/amd64}"
#BUILD_ARGS=--push

FROM_IMAGE_ARGS="--build-arg NAMESPACE=$NAME --build-arg VERSION=$VERSION-$BUILD_DATE"
Expand Down
18 changes: 15 additions & 3 deletions charts/selenium-grid/configs/node/nodePreStop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
probe_name="lifecycle.${1:-"preStop"}"

max_time=3
retry_time=5

ID=$(echo $RANDOM)
tmp_node_file="/tmp/nodeProbe${ID}"

function on_exit() {
rm -rf ${tmp_node_file}
echo "$(date +%FT%T%Z) [${probe_name}] - Exiting Node preStop..."
}
trap on_exit EXIT

Expand Down Expand Up @@ -89,8 +91,12 @@ if curl -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/st
fi
signal_node_to_drain
# Wait for the current session to be finished if any
while curl -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/status -o ${tmp_node_file};
do
while true; do
# Attempt the cURL request and capture the exit status
endpoint_http_code=$(curl --retry ${retry_time} -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/status -o ${tmp_node_file} -w "%{http_code}")
endpoint_status=$?
echo "$(date +%FT%T%Z) [${probe_name}] - Fetch the Node status via cURL with exit status: ${endpoint_status}, HTTP code: ${endpoint_http_code}"

SLOT_HAS_SESSION=$(jq -e ".value.node.slots[]|select(.session != null).id.id" ${tmp_node_file} | tr -d '"' || "")
if [ -z "${SLOT_HAS_SESSION}" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - There is no session running. Node is ready to be terminated."
Expand All @@ -99,7 +105,13 @@ if curl -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/st
exit 0
else
echo "$(date +%FT%T%Z) [${probe_name}] - Node preStop is waiting for current session on slot ${SLOT_HAS_SESSION} to be finished. Node details: message: $(jq -r '.value.message' ${tmp_node_file} || "unknown"), availability: $(jq -r '.value.node.availability' ${tmp_node_file} || "unknown")"
sleep 1;
sleep 2;
fi

# If the cURL command failed, break the loop
if [ ${endpoint_status} -ne 0 ] || [ "${endpoint_http_code}" != "200" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - Node endpoint returned status ${endpoint_http_code:-"exit ${endpoint_status}"}, probably Node draining complete!"
break
fi
done
else
Expand Down
10 changes: 5 additions & 5 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ nodeConfigMap:
# Directory where the extra scripts are mounted to
extraScriptsDirectory: "/opt/selenium"
extraScripts:
nodePreStop.sh:
nodeProbe.sh:
nodePreStop.sh: ""
nodeProbe.sh: ""
# Name of volume mount is used to mount scripts in the ConfigMap
scriptVolumeMountName:
# Automatic browser leftovers cleanup stuck browser processes, tmp files
Expand All @@ -136,8 +136,8 @@ recorderConfigMap:
extraScriptsDirectory: "/opt/bin"
# List of extra scripts to be mounted to the container. Format as `filename: content`
extraScripts:
# video.sh:
# video_graphQLQuery.sh:
# video.sh: ""
# video_graphQLQuery.sh: ""
# Name of volume mount is used to mount scripts in the ConfigMap
scriptVolumeMountName:
videoVolumeMountName: videos
Expand All @@ -154,7 +154,7 @@ uploaderConfigMap:
extraScriptsDirectory: "/opt/bin"
# List of extra scripts to be mounted to the container. Format as `filename: content`
extraScripts:
upload.sh:
upload.sh: ""
# Extra files stored in Secret to be mounted to the container.
secretFiles:
upload.conf: "[sample]"
Expand Down
3 changes: 2 additions & 1 deletion tests/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ if [ "${CI:-false}" = "false" ]; then
fi

python -m pip install selenium==4.19.0 \
docker===6.1.3 \
docker===7.0.0 \
chardet \
| grep -v 'Requirement already satisfied'

if [ "${SELENIUM_GRID_PROTOCOL}" = "https" ]; then
Expand Down
7 changes: 5 additions & 2 deletions tests/charts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ python -m pip install pyyaml==6.0.1 \

cd ..

helm package charts/selenium-grid --version 1.0.0-SNAPSHOT -d tests/tests

RELEASE_NAME="selenium"

helm template ${RELEASE_NAME} --values tests/charts/templates/render/dummy.yaml \
--set-file 'nodeConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \
--set-file 'recorderConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \
--set-file 'uploaderConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \
charts/selenium-grid > ./tests/tests/dummy_template_manifests.yaml
tests/tests/selenium-grid-1.0.0-SNAPSHOT.tgz > ./tests/tests/dummy_template_manifests.yaml

python tests/charts/templates/test.py "./tests/tests/dummy_template_manifests.yaml" ${RELEASE_NAME}
if [ $? -ne 0 ]; then
Expand All @@ -30,14 +32,15 @@ fi
rm -rf tests/charts/umbrella-charts/Chart.lock tests/charts/umbrella-charts/charts
helm dependency update tests/charts/umbrella-charts
helm dependency build tests/charts/umbrella-charts
helm package tests/charts/umbrella-charts --version 1.0.0-SNAPSHOT -d tests/tests

RELEASE_NAME="test"

helm template ${RELEASE_NAME} --values tests/charts/templates/render/dummy_solution.yaml \
--set-file 'selenium-grid.nodeConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \
--set-file 'selenium-grid.recorderConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \
--set-file 'selenium-grid.uploaderConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \
tests/charts/umbrella-charts > ./tests/tests/dummy_solution_template_manifests.yaml
tests/tests/umbrella-charts-1.0.0-SNAPSHOT.tgz > ./tests/tests/dummy_solution_template_manifests.yaml

python tests/charts/templates/test.py "./tests/tests/dummy_solution_template_manifests.yaml" ${RELEASE_NAME}
if [ $? -ne 0 ]; then
Expand Down
1 change: 1 addition & 0 deletions tests/charts/ci/base-auth-ingress-values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
global:
seleniumGrid:
logLevel: INFO
stdoutProbeLog: true

ingress:
className: nginx
Expand Down
7 changes: 7 additions & 0 deletions tests/charts/make/chart_setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ if [ "$(uname -m)" = "x86_64" ]; then
sudo apt-get install -yq docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker version
echo "==============================="
echo "Installing Docker compose for AMD64 / x86_64"
DOCKER_COMPOSE_VERSION="v2.26.0"
curl -fsSL -o ./docker-compose "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-x86_64"
chmod +x ./docker-compose
sudo mv ./docker-compose /usr/libexec/docker/cli-plugins
docker compose version
echo "==============================="
if [ "${CLUSTER}" = "kind" ]; then
echo "Installing kind for AMD64 / x86_64"
curl -fsSL -o ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
Expand Down
8 changes: 4 additions & 4 deletions tests/charts/templates/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ def test_extra_script_import_to_node_configmap(self):
for doc in LIST_OF_DOCUMENTS:
if doc['metadata']['name'] in resources_name and doc['kind'] == 'ConfigMap':
logger.info(f"Assert default file is imported to Node ConfigMap")
self.assertTrue(doc['data']['nodeProbe.sh'] is not None)
self.assertTrue(doc['data']['nodePreStop.sh'] is not None)
self.assertTrue(doc['data']['nodeCustomTask.sh'] is not None)
self.assertTrue(doc['data']['setFromCommand.sh'] is not None)
self.assertTrue(doc['data']['nodeProbe.sh'] != "")
self.assertTrue(doc['data']['nodePreStop.sh'] != "")
self.assertTrue(doc['data']['nodeCustomTask.sh'] != "")
self.assertTrue(doc['data']['setFromCommand.sh'] != "")
count += 1
self.assertEqual(count, len(resources_name), "No node config resources found")

Expand Down
6 changes: 6 additions & 0 deletions tests/charts/umbrella-charts/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
global:
seleniumGrid:
imageRegistry: selenium

selenium-grid:
enabled: true
11 changes: 11 additions & 0 deletions tests/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[docker]

configs = [
"${NAMESPACE}/standalone-firefox:${TAG}", '{"browserName": "firefox", "platformName": "linux"}',
"${NAMESPACE}/standalone-chrome:${TAG}", '{"browserName": "chrome", "platformName": "linux"}',
"${NAMESPACE}/standalone-edge:${TAG}", '{"browserName": "MicrosoftEdge", "platformName": "linux"}'
]

url = "http://127.0.0.1:2375"

video-image = "${NAMESPACE}/video:${VIDEO_TAG}"
39 changes: 39 additions & 0 deletions tests/docker-compose-v3-test-node-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "3"
services:
node-docker:
image: ${NAMESPACE}/node-docker:${TAG}
volumes:
- ./videos:/opt/selenium/assets
- ./videos/config.toml:/opt/bin/config.toml
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_ENABLE_MANAGED_DOWNLOADS=true
- SE_LOG_LEVEL=FINE

selenium-hub:
image: ${NAMESPACE}/hub:${TAG}
container_name: selenium-hub
environment:
- SE_LOG_LEVEL=${LOG_LEVEL}
- SE_SESSION_REQUEST_TIMEOUT=${REQUEST_TIMEOUT}
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"

tests:
image: docker-selenium-tests:latest
build:
context: ./
dockerfile: ./Dockerfile
depends_on:
- selenium-hub
environment:
- RUN_IN_DOCKER_COMPOSE=true
- SELENIUM_GRID_HOST=selenium-hub
command: ["./bootstrap.sh", "${NODE}"]

0 comments on commit 496b79a

Please sign in to comment.