[🚀 Feature]: Automatic creation of new jobs with browsers
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- bash, docker, kubernetes
- Ambito
- devops, distributed-systems, infrastructure
Direzione di ricerca
Non viene indicato alcun file del repository, test o punto di ingresso; inizia confrontando il ciclo Bash proposto con la configurazione Kubernetes/Helm Selenium Grid esistente. Definisci prima il rilevamento dei browser/versioni supportati e il ciclo di vita di ScaledJob, quindi verifica che le richieste accodate creino i job previsti e che le versioni non supportate vengano gestite.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Feature and motivation
In my installation, I added another component for the automatic generation of jobs with browsers. And since you’ve already started building multiple browser images versions with the new Selenium, I’d like to share my implementation. It would be awesome if we could add similar logic to Selenium Grid.
#!/bin/bash
PVC_NAME=$(kubectl get pvc -n $SE_NAMESPACE -o jsonpath='{.items[0].metadata.name}')
function deployment_exists(){
kubectl get scaledjob selenium-grid-selenium-${1,,}-node-v${2%.*} --namespace $SE_NAMESPACE > /dev/null 2>&1
}
while true
do
readarray requests <<< "$(curl -X POST -H "Content-Type: application/json" --data '{"query":"{ sessionsInfo { sessionQueueRequests } }"}' -sfk $SE_NODE_GRID_GRAPHQL_URL | jq .data.sessionsInfo.sessionQueueRequests)"
unset "requests[0]"
if [[ ${#requests[*]} -gt 0 ]]; then
unset "requests[-1]"
fi
for i in "${!requests[@]}"
do
name=$(echo -e ${requests[$i]} | grep browserName | awk -F'[:,]' '{for(i=1;i<=NF;i++){if($i~/browserName/){print $(i+1)}}}' | tr -d '[:space:]' | tr -d '\\"')
version=$(echo -e ${requests[$i]} | grep browserVersion | awk -F'[:,]' '{for(i=1;i<=NF;i++){if($i~/browserVersion/){print $(i+1)}}}' | tr -d '[:space:]' | tr -d '\\"')
platform=$(echo -e ${requests[$i]} | grep platformName | awk -F'[:,]' '{for(i=1;i<=NF;i++){if($i~/platformName/){print $(i+1)}}}' | tr -d '[:space:]' | tr -d '\\"')
name=${name,,}
platform=${platform,,}
if ! [[ -z "$name" ]] && ! [[ -z "$version" ]] && [[ "$platform" == "linux" ]]; then
pattern="\b[1-9][0-9][0-9]\.[0]\b"
if [[ $version =~ $pattern ]]; then
case $name in
microsoftedge)
if (( $(echo "$version < 120.0" |bc -l) )); then
echo "This version of $name is no longer supported by our Grid. Version=$version"
else
deployments[$i]=edge:$version
fi
;;
chrome)
if (( $(echo "$version < 120.0" |bc -l) )); then
echo "This version of $name is no longer supported by our Grid. Version=$version"
else
deployments[$i]=chrome:$version
fi
;;
firefox)
if (( $(echo "$version < 122.0" |bc -l) )); then
echo "This version of $name is no longer supported by our Grid. Version=$version"
else
deployments[$i]=firefox:$version
fi
;;
esac
else
echo "Version of $name is incorrect, version=$version"
fi
fi
done
uniqs_deployments=($(for d in "${deployments[@]}"; do echo "${d}"; done | sort -u))
for i in "${!uniqs_deployments[@]}"
do
name=$(echo ${uniqs_deployments[$i]} | cut -d ':' -f 1 )
version=$(echo ${uniqs_deployments[$i]} | cut -d ':' -f 2 )
if [ $name == "edge" ]; then kedabrowsername=MicrosoftEdge; sessionBrowserName=msedge; else kedabrowsername=$name; sessionBrowserName=$name; fi
if [ $name == "firefox" ]; then disable_dshm=""; else disable_dshm="--disable-dev-shm-usage"; fi
if [ $SE_NAMESPACE == "selenium-test" ]; then testTag="-test"; else testTag=""; fi
if ! deployment_exists $name $version; then
tags=$(curl -s -X GET https://registry.host/v2/$name/tags/list | jq -r '.tags[]')
filtered_tags=$(echo "$tags" | grep "^$version")
if [ "$filtered_tags" ]; then
if [ -n "$testTag" ]; then
filtered_tags=$(echo "$filtered_tags" | grep "\-test")
else
filtered_tags=$(echo "$filtered_tags" | grep -v "\-test")
fi
latest_tag=$(echo "$filtered_tags" | sort -V | tail -n 1)
kubectl apply -f - <<EOF
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
annotations:
helm.sh/hook: post-install,post-upgrade,post-rollback
helm.sh/hook-weight: "1"
autoscaling.keda.sh/paused: "false"
finalizers:
- finalizer.keda.sh
generation: 2
labels:
app: selenium-grid-selenium-$name-node-v${version%.*}
app.kubernetes.io/instance: selenium-grid
app.kubernetes.io/name: selenium-grid-selenium-$name-node-v${version%.*}
name: selenium-grid-selenium-$name-node-v${version%.*}
namespace: $SE_NAMESPACE
spec:
failedJobsHistoryLimit: 10
jobTargetRef:
activeDeadlineSeconds: 3600
backoffLimit: 0
completions: 1
parallelism: 1
template:
metadata:
labels:
app: selenium-grid-selenium-$name-node-v${version%.*}
app.kubernetes.io/name: selenium-grid-selenium-$name-node-v${version%.*}
app.kubernetes.io/instance: selenium-grid
spec:
containers:
- env:
- name: KUBERNETES_NODE_HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: SE_NODE_MAX_SESSIONS
value: "1"
- name: SE_DRAIN_AFTER_SESSION_COUNT
value: "1"
- name: SE_NODE_BROWSER_VERSION
value: "$version"
- name: SE_NODE_PLATFORM_NAME
value: linux
- name: SE_NODE_STEREOTYPE_EXTRA
- name: SE_NODE_CONTAINER_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: SE_BROWSER_ARGS_DISABLE_DSHM
value: $disable_dshm
- name: SE_OTEL_SERVICE_NAME
value: selenium-node-$(echo "$SE_SUB_PATH" | cut -c 2-).$name:$version
- name: SE_ENABLE_TRACING
value: "true"
- name: SE_NODE_HOST
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: SE_NODE_PORT
value: "5555"
- name: SE_NODE_REGISTER_PERIOD
value: "120"
- name: SE_NODE_REGISTER_CYCLE
value: "5"
- name: SE_SESSION_REQUEST_TIMEOUT
value: "3600"
- name: SE_VNC_NO_PASSWORD
value: "1"
- name: SE_VNC_VIEW_ONLY
value: "1"
- name: SE_OPTS
value: "--enable-managed-downloads true"
envFrom:
- configMapRef:
name: selenium-grid-selenium-event-bus-config
- configMapRef:
name: selenium-grid-selenium-node-config
- configMapRef:
name: selenium-grid-selenium-logging-config
- configMapRef:
name: selenium-grid-selenium-server-config
- secretRef:
name: selenium-grid-selenium-secrets
- secretRef:
name: selenium-grid-selenium-basic-auth-secrets
image: registry.host/$name:$latest_tag
imagePullPolicy: IfNotPresent
lifecycle:
preStop:
exec:
command:
- bash
- -c
- /opt/bin/nodePreStop.sh >> /proc/1/fd/1
name: selenium-grid-selenium-$name-node-v${version%.*}
ports:
- containerPort: 5555
protocol: TCP
resources:
limits:
cpu: "4"
memory: 2Gi
ephemeral-storage: 1Gi
requests:
cpu: "1"
memory: 1Gi
ephemeral-storage: 256Mi
startupProbe:
failureThreshold: 12
httpGet:
path: /status
port: 5555
scheme: ${SE_SERVER_PROTOCOL^^}
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 60
volumeMounts:
- name: dshm
mountPath: /dev/shm
- name: artifacts
mountPath: /artifacts
- mountPath: /opt/bin/nodeGridUrl.sh
name: selenium-grid-selenium-node-config
subPath: nodeGridUrl.sh
- mountPath: /opt/bin/nodePreStop.sh
name: selenium-grid-selenium-node-config
subPath: nodePreStop.sh
- mountPath: /opt/bin/nodeProbe.sh
name: selenium-grid-selenium-node-config
subPath: nodeProbe.sh
- mountPath: /opt/selenium/secrets
name: selenium-grid-selenium-tls-secret
readOnly: true
- env:
- name: SE_NODE_MAX_SESSIONS
value: "1"
- name: SE_DRAIN_AFTER_SESSION_COUNT
value: "1"
- name: SE_NODE_PORT
value: "5555"
- name: DISPLAY_CONTAINER_NAME
valueFrom:
fieldRef:
fieldPath: status.podIP
envFrom:
- configMapRef:
name: selenium-grid-selenium-event-bus-config
- configMapRef:
name: selenium-grid-selenium-node-config
- configMapRef:
name: selenium-grid-selenium-recorder-config
- configMapRef:
name: selenium-grid-selenium-server-config
- secretRef:
name: selenium-grid-selenium-basic-auth-secrets
- secretRef:
name: selenium-grid-selenium-secrets
image: docker-proxy.host/selenium/video:$SE_FF_MPEG_IMAGE
imagePullPolicy: IfNotPresent
name: video
ports:
- containerPort: 9000
protocol: TCP
resources:
limits:
cpu: "1"
memory: 1Gi
ephemeral-storage: 300Mi
requests:
cpu: 100m
memory: 128Mi
ephemeral-storage: 128Mi
volumeMounts:
- name: dshm
mountPath: /dev/shm
- mountPath: /opt/selenium/upload.conf
name: selenium-grid-selenium-secrets
subPath: upload.conf
- mountPath: /videos
name: videos
initContainers:
- command:
- bash
- -c
- '''true'''
image: registry.host/$name:$latest_tag
imagePullPolicy: IfNotPresent
name: pre-puller-selenium-grid-selenium-node
resources:
limits:
cpu: "4"
memory: 2Gi
ephemeral-storage: 1Gi
requests:
cpu: "1"
memory: 1Gi
ephemeral-storage: 10Mi
- command:
- bash
- -c
- '''true'''
image: docker-proxy.host/selenium/video:$SE_FF_MPEG_IMAGE
imagePullPolicy: IfNotPresent
name: pre-puller-video
resources:
limits:
cpu: "1"
memory: 1Gi
ephemeral-storage: 300Mi
requests:
cpu: 100m
memory: 128Mi
ephemeral-storage: 128Mi
restartPolicy: Never
serviceAccount: $SE_NAMESPACE-sa
serviceAccountName: $SE_NAMESPACE-sa
shareProcessNamespace: false
terminationGracePeriodSeconds: 3600
volumes:
- configMap:
defaultMode: 493
name: selenium-grid-selenium-node-config
name: selenium-grid-selenium-node-config
- name: dshm
emptyDir:
medium: Memory
sizeLimit: 1Gi
- name: selenium-grid-selenium-tls-secret
secret:
secretName: selenium-grid-selenium-tls-secret
- name: artifacts
persistentVolumeClaim:
claimName: $PVC_NAME
- emptyDir: {}
name: videos
- configMap:
defaultMode: 493
name: selenium-grid-selenium-recorder-config
name: selenium-grid-selenium-recorder-config
- configMap:
defaultMode: 493
name: selenium-grid-selenium-uploader-config
name: selenium-grid-selenium-uploader-config
- name: selenium-grid-selenium-secrets
secret:
secretName: selenium-grid-selenium-secrets
maxReplicaCount: 220
minReplicaCount: 0
pollingInterval: 20
rollout:
strategy: gradual
scalingStrategy:
strategy: default
successfulJobsHistoryLimit: 0
triggers:
- authenticationRef:
name: selenium-grid-selenium-scaler-trigger-auth
metadata:
browserName: $kedabrowsername
browserVersion: "$version"
capabilities: ""
nodeMaxSessions: "1"
platformName: linux
sessionBrowserName: $sessionBrowserName
unsafeSsl: "true"
type: selenium-grid
EOF
else
echo "This $name version is not available on registry, version=$version"
fi
fi
done
unset name
unset version
unset uniqs_deployments
unset deployments
unset requests
unset kedabrowsername
unset tracesexporter
sleep 5
done
Usage example
If we add this logic to Selenium Grid, then we’ll be able to support all existing browser versions, as well as those that will be released later.
- Lingua principale
- Go
- Stelle
- 8.7k
- Fork
- 2.5k
- Merge medio
- 1g 15h
- PR unite (30g)
- 37
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di SeleniumHQ/docker-selenium
-
Nightly build is failingAperta
Difficoltà 4/5 1-2 giorni Idoneità per principianti 25/100
SeleniumHQ/docker-selenium#3338 ·
I maintainer di solito rispondono entro 1 giorno
-
[🐛 Bug]: hub & node-chromium - cURL 8.22.0 & guava 33.6.0-android pulled in, needs security fixesApertaneeds-triaging
Difficoltà 3/5 1-2 giorni Idoneità per principianti 54/100
SeleniumHQ/docker-selenium#3332 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
needs-triaging
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
SeleniumHQ/docker-selenium#3299 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
needs-triaging
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
SeleniumHQ/docker-selenium#3298 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
needs-triaging
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
SeleniumHQ/docker-selenium#3279 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di SeleniumHQ/docker-selenium
Issue simili
-
bug effort:s impact:med raised-by:desk risk:low
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
medici-finance/assay#8342 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug sweep
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
bketelsen/truenas-mcp#120 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nwverse/persona#22164 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
sresarehumantoo/cc-artex#559 ·