diff --git a/Base/Dockerfile b/Base/Dockerfile index 8a7145772..8cbd0e9d1 100644 --- a/Base/Dockerfile +++ b/Base/Dockerfile @@ -63,7 +63,7 @@ RUN if [ "$(dpkg --print-architecture)" = "amd64" ]; then \ supervisor \ gnupg2 \ libnss3-tools \ - openjdk-${JRE_VERSION}-jre-headless \ + openjdk-${JRE_VERSION}-jdk-headless \ && rm -rf /var/lib/apt/lists/* /var/cache/apt/* RUN --mount=type=secret,id=SEL_PASSWD \ @@ -96,7 +96,7 @@ RUN --mount=type=secret,id=SEL_PASSWD \ #========== # Selenium & relaxing permissions for OpenShift and other non-sudo environments #========== - && mkdir -p /opt/selenium /opt/selenium/assets /opt/selenium/secrets /var/run/supervisor /var/log/supervisor ${SEL_DOWNLOAD_DIR} \ + && mkdir -p /opt/selenium /opt/selenium/assets /opt/selenium/secrets /opt/selenium/logs /var/run/supervisor /var/log/supervisor ${SEL_DOWNLOAD_DIR} \ ${HOME}/.mozilla ${HOME}/.vnc ${HOME}/.pki/nssdb ${VIDEO_FOLDER} \ # NSSDB initialization with an empty password && certutil -d sql:${HOME}/.pki/nssdb -N --empty-password \ @@ -142,8 +142,9 @@ RUN --mount=type=secret,id=SEL_PASSWD \ #====================================== # Add Grid check script #====================================== -COPY --chown="${SEL_UID}:${SEL_GID}" check-grid.sh entry_point.sh configs/node/nodeGridUrl.sh configs/node/nodePreStop.sh /opt/bin/ +COPY --chown="${SEL_UID}:${SEL_GID}" check-grid.sh entry_point.sh configs/node/nodeGridUrl.sh configs/node/nodePreStop.sh handle_heap_dump.sh /opt/bin/ COPY --chown="${SEL_UID}:${SEL_GID}" mask /usr/local/bin/ +RUN chmod +x /opt/bin/*.sh /usr/local/bin/mask #====================================== # Add Supervisor configuration file @@ -187,6 +188,8 @@ ENV SE_BIND_HOST=false \ SE_STRUCTURED_LOGS=false \ SE_ENABLE_TRACING=true \ SE_ENABLE_TLS=false \ + SE_JAVA_OPTS_DEFAULT="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/selenium/logs" \ + SE_JAVA_HEAP_DUMP="false" \ SE_JAVA_HTTPCLIENT_VERSION="HTTP_1_1" \ SE_JAVA_SSL_TRUST_STORE="/opt/selenium/secrets/server.jks" \ SE_JAVA_SSL_TRUST_STORE_PASSWORD="/opt/selenium/secrets/server.pass" \ diff --git a/Base/handle_heap_dump.sh b/Base/handle_heap_dump.sh new file mode 100644 index 000000000..cc7b922cd --- /dev/null +++ b/Base/handle_heap_dump.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +SELENIUM_SERVER_PID=$1 +LOG_DIR=$2 +TIMESTAMP=$(date +%s) + +filename="$LOG_DIR/dump_pid${SELENIUM_SERVER_PID}_${TIMESTAMP}.hprof" +if ps -p "${SELENIUM_SERVER_PID}" >/dev/null; then + echo "Server process is still running. Create heap dump by using jmap" + jmap -dump:live,format=b,file="${filename}" "${SELENIUM_SERVER_PID}" +else + filename_source="$LOG_DIR/java_pid${SELENIUM_SERVER_PID}.hprof" + if [ -f "$filename_source" ]; then + echo "Server is not running. Check HeapDumpOnOutOfMemoryError created" + mv "$filename_source" "$filename" + else + echo "Server is not running. No heap dump is created" + fi +fi diff --git a/Distributor/start-selenium-grid-distributor.sh b/Distributor/start-selenium-grid-distributor.sh index d4ff1660e..463acd538 100755 --- a/Distributor/start-selenium-grid-distributor.sh +++ b/Distributor/start-selenium-grid-distributor.sh @@ -183,9 +183,26 @@ if [ -n "${SE_JAVA_HTTPCLIENT_VERSION}" ]; then SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.httpclient.version=${SE_JAVA_HTTPCLIENT_VERSION}" fi +if [ -n "${SE_JAVA_OPTS_DEFAULT}" ]; then + SE_JAVA_OPTS="${SE_JAVA_OPTS_DEFAULT} $SE_JAVA_OPTS" +fi + +function handle_heap_dump() { + /opt/bin/handle_heap_dump.sh $SELENIUM_SERVER_PID /opt/selenium/logs +} +if [ "${SE_JAVA_HEAP_DUMP}" = "true" ]; then + trap handle_heap_dump ERR SIGTERM SIGINT +else + trap handle_heap_dump ERR +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} \ distributor \ --bind-bus false \ - ${SE_OPTS} + ${SE_OPTS} & + +SELENIUM_SERVER_PID=$! + +wait $SELENIUM_SERVER_PID diff --git a/EventBus/start-selenium-grid-eventbus.sh b/EventBus/start-selenium-grid-eventbus.sh index 55b1bec5c..981aeb77a 100755 --- a/EventBus/start-selenium-grid-eventbus.sh +++ b/EventBus/start-selenium-grid-eventbus.sh @@ -113,10 +113,27 @@ if [ -n "${SE_JAVA_HTTPCLIENT_VERSION}" ]; then SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.httpclient.version=${SE_JAVA_HTTPCLIENT_VERSION}" fi +if [ -n "${SE_JAVA_OPTS_DEFAULT}" ]; then + SE_JAVA_OPTS="${SE_JAVA_OPTS_DEFAULT} $SE_JAVA_OPTS" +fi + +function handle_heap_dump() { + /opt/bin/handle_heap_dump.sh $SELENIUM_SERVER_PID /opt/selenium/logs +} +if [ "${SE_JAVA_HEAP_DUMP}" = "true" ]; then + trap handle_heap_dump ERR SIGTERM SIGINT +else + trap handle_heap_dump ERR +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} event-bus \ --bind-host ${SE_BIND_HOST} \ ${HOST_CONFIG} \ ${PORT_CONFIG} \ - ${SE_OPTS} + ${SE_OPTS} & + +SELENIUM_SERVER_PID=$! + +wait $SELENIUM_SERVER_PID diff --git a/Hub/start-selenium-grid-hub.sh b/Hub/start-selenium-grid-hub.sh index d1cb15ca3..709c5a31d 100755 --- a/Hub/start-selenium-grid-hub.sh +++ b/Hub/start-selenium-grid-hub.sh @@ -163,8 +163,25 @@ if [ -n "${SE_JAVA_HTTPCLIENT_VERSION}" ]; then SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.httpclient.version=${SE_JAVA_HTTPCLIENT_VERSION}" fi +if [ -n "${SE_JAVA_OPTS_DEFAULT}" ]; then + SE_JAVA_OPTS="${SE_JAVA_OPTS_DEFAULT} $SE_JAVA_OPTS" +fi + +function handle_heap_dump() { + /opt/bin/handle_heap_dump.sh $SELENIUM_SERVER_PID /opt/selenium/logs +} +if [ "${SE_JAVA_HEAP_DUMP}" = "true" ]; then + trap handle_heap_dump ERR SIGTERM SIGINT +else + trap handle_heap_dump ERR +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} \ hub \ - ${SE_OPTS} + ${SE_OPTS} & + +SELENIUM_SERVER_PID=$! + +wait $SELENIUM_SERVER_PID diff --git a/NodeBase/start-selenium-node.sh b/NodeBase/start-selenium-node.sh index 9eb277bf9..958c76ebf 100755 --- a/NodeBase/start-selenium-node.sh +++ b/NodeBase/start-selenium-node.sh @@ -12,6 +12,9 @@ pacmd set-default-source v1.monitor rm -f /tmp/.X*lock +# set -e: exit asap if a command exits with a non-zero status +set -e + function append_se_opts() { local option="${1}" local value="${2:-""}" @@ -175,6 +178,19 @@ if [ -n "${SE_JAVA_HTTPCLIENT_VERSION}" ]; then SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.httpclient.version=${SE_JAVA_HTTPCLIENT_VERSION}" fi +if [ -n "${SE_JAVA_OPTS_DEFAULT}" ]; then + SE_JAVA_OPTS="${SE_JAVA_OPTS_DEFAULT} $SE_JAVA_OPTS" +fi + +function handle_heap_dump() { + /opt/bin/handle_heap_dump.sh $SELENIUM_SERVER_PID /opt/selenium/logs +} +if [ "${SE_JAVA_HEAP_DUMP}" = "true" ]; then + trap handle_heap_dump ERR SIGTERM SIGINT +else + trap handle_heap_dump ERR +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ ${CHROME_DRIVER_PATH_PROPERTY} \ ${EDGE_DRIVER_PATH_PROPERTY} \ @@ -182,4 +198,8 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} \ node \ - ${SE_OPTS} + ${SE_OPTS} & + +SELENIUM_SERVER_PID=$! + +wait $SELENIUM_SERVER_PID diff --git a/NodeDocker/start-selenium-grid-docker.sh b/NodeDocker/start-selenium-grid-docker.sh index b3caab114..90dcca3f8 100755 --- a/NodeDocker/start-selenium-grid-docker.sh +++ b/NodeDocker/start-selenium-grid-docker.sh @@ -123,6 +123,19 @@ if [ -n "${SE_JAVA_HTTPCLIENT_VERSION}" ]; then SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.httpclient.version=${SE_JAVA_HTTPCLIENT_VERSION}" fi +if [ -n "${SE_JAVA_OPTS_DEFAULT}" ]; then + SE_JAVA_OPTS="${SE_JAVA_OPTS_DEFAULT} $SE_JAVA_OPTS" +fi + +function handle_heap_dump() { + /opt/bin/handle_heap_dump.sh $SELENIUM_SERVER_PID /opt/selenium/logs +} +if [ "${SE_JAVA_HEAP_DUMP}" = "true" ]; then + trap handle_heap_dump ERR SIGTERM SIGINT +else + trap handle_heap_dump ERR +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} node \ @@ -131,4 +144,8 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ --bind-host ${SE_BIND_HOST} \ --detect-drivers false \ --config /opt/selenium/${SE_NODE_DOCKER_CONFIG_FILENAME:-"config.toml"} \ - ${SE_GRID_URL} ${SE_OPTS} + ${SE_GRID_URL} ${SE_OPTS} & + +SELENIUM_SERVER_PID=$! + +wait $SELENIUM_SERVER_PID diff --git a/Router/start-selenium-grid-router.sh b/Router/start-selenium-grid-router.sh index e37a63d79..14269d66c 100755 --- a/Router/start-selenium-grid-router.sh +++ b/Router/start-selenium-grid-router.sh @@ -164,6 +164,19 @@ if [ -n "${SE_JAVA_HTTPCLIENT_VERSION}" ]; then SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.httpclient.version=${SE_JAVA_HTTPCLIENT_VERSION}" fi +if [ -n "${SE_JAVA_OPTS_DEFAULT}" ]; then + SE_JAVA_OPTS="${SE_JAVA_OPTS_DEFAULT} $SE_JAVA_OPTS" +fi + +function handle_heap_dump() { + /opt/bin/handle_heap_dump.sh $SELENIUM_SERVER_PID /opt/selenium/logs +} +if [ "${SE_JAVA_HEAP_DUMP}" = "true" ]; then + trap handle_heap_dump ERR SIGTERM SIGINT +else + trap handle_heap_dump ERR +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} router \ @@ -177,4 +190,8 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ ${HOST_CONFIG} \ ${PORT_CONFIG} \ ${SUB_PATH_CONFIG} \ - ${SE_OPTS} + ${SE_OPTS} & + +SELENIUM_SERVER_PID=$! + +wait $SELENIUM_SERVER_PID diff --git a/SessionQueue/start-selenium-grid-session-queue.sh b/SessionQueue/start-selenium-grid-session-queue.sh index 6494ded62..6af6c05c9 100755 --- a/SessionQueue/start-selenium-grid-session-queue.sh +++ b/SessionQueue/start-selenium-grid-session-queue.sh @@ -117,6 +117,19 @@ if [ -n "${SE_JAVA_HTTPCLIENT_VERSION}" ]; then SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.httpclient.version=${SE_JAVA_HTTPCLIENT_VERSION}" fi +if [ -n "${SE_JAVA_OPTS_DEFAULT}" ]; then + SE_JAVA_OPTS="${SE_JAVA_OPTS_DEFAULT} $SE_JAVA_OPTS" +fi + +function handle_heap_dump() { + /opt/bin/handle_heap_dump.sh $SELENIUM_SERVER_PID /opt/selenium/logs +} +if [ "${SE_JAVA_HEAP_DUMP}" = "true" ]; then + trap handle_heap_dump ERR SIGTERM SIGINT +else + trap handle_heap_dump ERR +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} sessionqueue \ @@ -125,4 +138,8 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ --bind-host ${SE_BIND_HOST} \ ${HOST_CONFIG} \ ${PORT_CONFIG} \ - ${SE_OPTS} + ${SE_OPTS} & + +SELENIUM_SERVER_PID=$! + +wait $SELENIUM_SERVER_PID diff --git a/Sessions/start-selenium-grid-sessions.sh b/Sessions/start-selenium-grid-sessions.sh index 795f76306..6ce13b456 100755 --- a/Sessions/start-selenium-grid-sessions.sh +++ b/Sessions/start-selenium-grid-sessions.sh @@ -152,6 +152,19 @@ if [ -n "${SE_JAVA_HTTPCLIENT_VERSION}" ]; then SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.httpclient.version=${SE_JAVA_HTTPCLIENT_VERSION}" fi +if [ -n "${SE_JAVA_OPTS_DEFAULT}" ]; then + SE_JAVA_OPTS="${SE_JAVA_OPTS_DEFAULT} $SE_JAVA_OPTS" +fi + +function handle_heap_dump() { + /opt/bin/handle_heap_dump.sh $SELENIUM_SERVER_PID /opt/selenium/logs +} +if [ "${SE_JAVA_HEAP_DUMP}" = "true" ]; then + trap handle_heap_dump ERR SIGTERM SIGINT +else + trap handle_heap_dump ERR +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} sessions \ @@ -160,4 +173,8 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ --bind-host ${SE_BIND_HOST} \ ${HOST_CONFIG} \ ${PORT_CONFIG} \ - ${SE_OPTS} + ${SE_OPTS} & + +SELENIUM_SERVER_PID=$! + +wait $SELENIUM_SERVER_PID diff --git a/Standalone/start-selenium-standalone.sh b/Standalone/start-selenium-standalone.sh index 5348fa809..f3f23090d 100755 --- a/Standalone/start-selenium-standalone.sh +++ b/Standalone/start-selenium-standalone.sh @@ -166,6 +166,19 @@ if [ -n "${SE_JAVA_HTTPCLIENT_VERSION}" ]; then SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.httpclient.version=${SE_JAVA_HTTPCLIENT_VERSION}" fi +if [ -n "${SE_JAVA_OPTS_DEFAULT}" ]; then + SE_JAVA_OPTS="${SE_JAVA_OPTS_DEFAULT} $SE_JAVA_OPTS" +fi + +function handle_heap_dump() { + /opt/bin/handle_heap_dump.sh $SELENIUM_SERVER_PID /opt/selenium/logs +} +if [ "${SE_JAVA_HEAP_DUMP}" = "true" ]; then + trap handle_heap_dump ERR SIGTERM SIGINT +else + trap handle_heap_dump ERR +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ ${CHROME_DRIVER_PATH_PROPERTY} \ ${EDGE_DRIVER_PATH_PROPERTY} \ @@ -180,4 +193,8 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ --bind-host ${SE_BIND_HOST} \ --config /opt/selenium/config.toml \ ${SUB_PATH_CONFIG} \ - ${SE_OPTS} + ${SE_OPTS} & + +SELENIUM_SERVER_PID=$! + +wait $SELENIUM_SERVER_PID diff --git a/StandaloneDocker/start-selenium-grid-docker.sh b/StandaloneDocker/start-selenium-grid-docker.sh index af01e9f55..cb8bc1dcb 100755 --- a/StandaloneDocker/start-selenium-grid-docker.sh +++ b/StandaloneDocker/start-selenium-grid-docker.sh @@ -128,6 +128,19 @@ if [ -n "${SE_JAVA_HTTPCLIENT_VERSION}" ]; then SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.httpclient.version=${SE_JAVA_HTTPCLIENT_VERSION}" fi +if [ -n "${SE_JAVA_OPTS_DEFAULT}" ]; then + SE_JAVA_OPTS="${SE_JAVA_OPTS_DEFAULT} $SE_JAVA_OPTS" +fi + +function handle_heap_dump() { + /opt/bin/handle_heap_dump.sh $SELENIUM_SERVER_PID /opt/selenium/logs +} +if [ "${SE_JAVA_HEAP_DUMP}" = "true" ]; then + trap handle_heap_dump ERR SIGTERM SIGINT +else + trap handle_heap_dump ERR +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} standalone \ @@ -137,4 +150,8 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ --detect-drivers false \ --bind-host ${SE_BIND_HOST} \ --config /opt/selenium/config.toml \ - ${SE_GRID_URL} ${SE_OPTS} + ${SE_GRID_URL} ${SE_OPTS} & + +SELENIUM_SERVER_PID=$! + +wait $SELENIUM_SERVER_PID diff --git a/charts/selenium-grid/CONFIGURATION.md b/charts/selenium-grid/CONFIGURATION.md index ee338780e..22e6609d0 100644 --- a/charts/selenium-grid/CONFIGURATION.md +++ b/charts/selenium-grid/CONFIGURATION.md @@ -289,6 +289,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | components.sessionQueue.priorityClassName | string | `""` | Priority class name for Session Queue pods | | components.extraEnvironmentVariables | list | `[]` | Custom environment variables for all components | | components.extraEnvFrom | list | `[]` | Custom environment variables by sourcing entire configMap, Secret, etc. for all components | +| components.extraVolumeMounts | list | `[]` | Extra volume mounts for component container | +| components.extraVolumes | list | `[]` | Extra volumes for component pod | | hub.imageRegistry | string | `nil` | Registry to pull the image (this overwrites global.seleniumGrid.imageRegistry parameter) | | hub.imageName | string | `"hub"` | Selenium Hub image name | | hub.imageTag | string | `nil` | Selenium Hub image tag (this overwrites global.seleniumGrid.imageTag parameter) | @@ -312,8 +314,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | hub.subPath | string | `""` | Custom sub path for the hub deployment | | hub.extraEnvironmentVariables | list | `[]` | Custom environment variables for selenium-hub | | hub.extraEnvFrom | list | `[]` | Custom environment variables by sourcing entire configMap, Secret, etc. for selenium-hub | -| hub.extraVolumeMounts | list | `[]` | Extra volume mounts for selenium-hub container | -| hub.extraVolumes | list | `[]` | Extra volumes for selenium-hub pod | +| hub.extraVolumeMounts | list | `[]` | Extra volume mounts for Hub container | +| hub.extraVolumes | list | `[]` | Extra volumes for Hub pod | | hub.resources | object | `{}` | Resources for selenium-hub container | | hub.securityContext | object | `{}` | SecurityContext for selenium-hub container | | hub.serviceType | string | `"ClusterIP"` | Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) | diff --git a/charts/selenium-grid/values.yaml b/charts/selenium-grid/values.yaml index 63e6a68c6..f9a9cc17b 100644 --- a/charts/selenium-grid/values.yaml +++ b/charts/selenium-grid/values.yaml @@ -714,6 +714,17 @@ components: # - secretRef: # name: mysecret + # -- Extra volume mounts for component container + extraVolumeMounts: [] + # - name: logs-volume + # mountPath: /opt/selenium/logs + + # -- Extra volumes for component pod + extraVolumes: [] + # - name: logs-volume + # persistentVolumeClaim: + # claimName: external-logs-pvc + # Configuration for selenium hub deployment (applied only if `isolateComponents: false`) hub: # -- Registry to pull the image (this overwrites global.seleniumGrid.imageRegistry parameter) @@ -795,18 +806,15 @@ hub: # name: proxy-settings # - secretRef: # name: mysecret - # -- Extra volume mounts for selenium-hub container + # -- Extra volume mounts for Hub container extraVolumeMounts: [] - # - name: my-extra-volume - # mountPath: /home/seluser/Downloads - - # -- Extra volumes for selenium-hub pod + # - name: logs-volume + # mountPath: /opt/selenium/logs + # -- Extra volumes for Hub pod extraVolumes: [] - # - name: my-extra-volume - # emptyDir: {} - # - name: my-extra-volume-from-pvc + # - name: logs-volume # persistentVolumeClaim: - # claimName: my-pv-claim + # claimName: external-logs-pvc # -- Resources for selenium-hub container resources: {} # -- SecurityContext for selenium-hub container diff --git a/tests/charts/ci/DeploymentAutoscaling-values.yaml b/tests/charts/ci/DeploymentAutoscaling-values.yaml index 5d4d1e26d..a7c4beb9f 100644 --- a/tests/charts/ci/DeploymentAutoscaling-values.yaml +++ b/tests/charts/ci/DeploymentAutoscaling-values.yaml @@ -49,10 +49,20 @@ chromeNode: value: "Asia/Saigon" - name: SE_NODE_SESSION_TIMEOUT value: "3600" + - name: SE_JAVA_HEAP_DUMP + value: "true" readinessProbe: enabled: &readinessProbe true livenessProbe: enabled: &livenessProbe true + extraVolumeMounts: &extraVolumeMounts + - name: logs + mountPath: /opt/selenium/logs + subPath: logs + extraVolumes: &extraVolumes + - name: logs + persistentVolumeClaim: + claimName: selenium-grid-pvc-local # Configuration for edge nodes edgeNode: @@ -75,6 +85,8 @@ edgeNode: enabled: *readinessProbe livenessProbe: enabled: *livenessProbe + extraVolumeMounts: *extraVolumeMounts + extraVolumes: *extraVolumes # Configuration for firefox nodes firefoxNode: @@ -84,3 +96,5 @@ firefoxNode: enabled: *readinessProbe livenessProbe: enabled: *livenessProbe + extraVolumeMounts: *extraVolumeMounts + extraVolumes: *extraVolumes diff --git a/tests/charts/ci/JobAutoscaling-values.yaml b/tests/charts/ci/JobAutoscaling-values.yaml index e0e02a8cd..cb5e97eb0 100644 --- a/tests/charts/ci/JobAutoscaling-values.yaml +++ b/tests/charts/ci/JobAutoscaling-values.yaml @@ -24,6 +24,8 @@ chromeNode: value: "Asia/Saigon" - name: SE_NODE_SESSION_TIMEOUT value: "3600" + - name: SE_JAVA_HEAP_DUMP + value: "true" readinessProbe: enabled: &readinessProbe false livenessProbe: diff --git a/tests/charts/ci/NoAutoscaling-values.yaml b/tests/charts/ci/NoAutoscaling-values.yaml index 29e9f20de..de18ec39e 100644 --- a/tests/charts/ci/NoAutoscaling-values.yaml +++ b/tests/charts/ci/NoAutoscaling-values.yaml @@ -13,10 +13,20 @@ chromeNode: value: "1080" - name: TZ value: "Asia/Saigon" + - name: SE_JAVA_HEAP_DUMP + value: "true" readinessProbe: enabled: &readinessProbe false livenessProbe: enabled: &livenessProbe true + extraVolumeMounts: &extraVolumeMounts + - name: logs + mountPath: /opt/selenium/logs + subPath: logs + extraVolumes: &extraVolumes + - name: logs + persistentVolumeClaim: + claimName: selenium-grid-pvc-local # Configuration for edge nodes edgeNode: port: 8888 @@ -25,6 +35,8 @@ edgeNode: enabled: *readinessProbe livenessProbe: enabled: *livenessProbe + extraVolumeMounts: *extraVolumeMounts + extraVolumes: *extraVolumes # Configuration for firefox nodes firefoxNode: port: 7777 @@ -33,3 +45,5 @@ firefoxNode: enabled: *readinessProbe livenessProbe: enabled: *livenessProbe + extraVolumeMounts: *extraVolumeMounts + extraVolumes: *extraVolumes diff --git a/tests/charts/ci/base-auth-ingress-values.yaml b/tests/charts/ci/base-auth-ingress-values.yaml index 2e1c64344..e208797a2 100644 --- a/tests/charts/ci/base-auth-ingress-values.yaml +++ b/tests/charts/ci/base-auth-ingress-values.yaml @@ -29,9 +29,21 @@ hub: value: "false" - name: SE_LOG_LISTEN_GRAPHQL value: "true" + - name: SE_JAVA_HEAP_DUMP + value: "true" + extraVolumeMounts: &extraVolumeMounts + - name: logs + mountPath: /opt/selenium/logs + subPath: logs + extraVolumes: &extraVolumes + - name: logs + persistentVolumeClaim: + claimName: selenium-grid-pvc-local components: extraEnvironmentVariables: *extraEnvironmentVariables + extraVolumeMounts: *extraVolumeMounts + extraVolumes: *extraVolumes keda: webhooks: diff --git a/tests/charts/make/chart_test.sh b/tests/charts/make/chart_test.sh index 5535610be..5879fe02c 100755 --- a/tests/charts/make/chart_test.sh +++ b/tests/charts/make/chart_test.sh @@ -73,13 +73,11 @@ cleanup() { # Iterate over the pods and print their logs for pod in $pods; do echo "Logs for pod $pod" - kubectl logs -n ${SELENIUM_NAMESPACE} $pod --all-containers > tests/tests/pod_logs_${pod}.txt + kubectl logs -n ${SELENIUM_NAMESPACE} $pod --all-containers --tail=10000 > tests/tests/pod_logs_${pod}.txt done - if [ "${SKIP_CLEANUP}" = "false" ]; then + if [ "${SKIP_CLEANUP}" = "false" ] || [ "${CI:-false}" != "false" ]; then echo "Clean up chart release and namespace" helm delete ${RELEASE_NAME} --namespace ${SELENIUM_NAMESPACE} --wait - kubectl patch ns ${SELENIUM_NAMESPACE} -p '{"metadata":{"finalizers":null}}' - kubectl delete namespace ${SELENIUM_NAMESPACE} --wait=false fi } @@ -97,6 +95,7 @@ on_failure() { kubectl describe pod -n ${SELENIUM_NAMESPACE} >> tests/tests/describe_all_resources_${MATRIX_BROWSER}.txt echo "There is step failed with exit status $exit_status" cleanup + sudo chmod -R 777 ${HOST_PATH}/logs exit $exit_status } @@ -137,7 +136,7 @@ if [ "${TEST_UPGRADE_CHART}" != "true" ] && [ "${RENDER_HELM_TEMPLATE_ONLY}" != envsubst < ${LOCAL_PVC_YAML} > ./tests/tests/local-pvc.yaml LOCAL_PVC_YAML=./tests/tests/local-pvc.yaml kubectl delete -n ${SELENIUM_NAMESPACE} -f ${LOCAL_PVC_YAML} --ignore-not-found=true - sudo rm -rf ${HOST_PATH}; sudo mkdir -p ${HOST_PATH} + sudo rm -rf ${HOST_PATH}; sudo mkdir -p ${HOST_PATH}/logs sudo chmod -R 777 ${HOST_PATH} kubectl create ns ${SELENIUM_NAMESPACE} || true kubectl apply -n ${SELENIUM_NAMESPACE} -f ${LOCAL_PVC_YAML}