diff --git a/Distributor/start-selenium-grid-distributor.sh b/Distributor/start-selenium-grid-distributor.sh index b51340c91..b0782c3c3 100755 --- a/Distributor/start-selenium-grid-distributor.sh +++ b/Distributor/start-selenium-grid-distributor.sh @@ -54,6 +54,11 @@ if [ ! -z "$SE_DISTRIBUTOR_PORT" ]; then PORT_CONFIG="--port ${SE_DISTRIBUTOR_PORT}" fi +if [ ! -z "$SE_LOG_LEVEL" ]; then + echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}" + SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}" +fi + EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then diff --git a/EventBus/start-selenium-grid-eventbus.sh b/EventBus/start-selenium-grid-eventbus.sh index d3413a968..a8af2c040 100755 --- a/EventBus/start-selenium-grid-eventbus.sh +++ b/EventBus/start-selenium-grid-eventbus.sh @@ -19,6 +19,11 @@ if [ ! -z "$SE_OPTS" ]; then echo "Appending Selenium options: ${SE_OPTS}" fi +if [ ! -z "$SE_LOG_LEVEL" ]; then + echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}" + SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}" +fi + EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then diff --git a/Hub/start-selenium-grid-hub.sh b/Hub/start-selenium-grid-hub.sh index 98b9758f7..e25fe16d4 100755 --- a/Hub/start-selenium-grid-hub.sh +++ b/Hub/start-selenium-grid-hub.sh @@ -22,6 +22,11 @@ if [ ! -z "$SE_SUB_PATH" ]; then SUB_PATH_CONFIG="--sub-path ${SE_SUB_PATH}" fi +if [ ! -z "$SE_LOG_LEVEL" ]; then + echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}" + SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}" +fi + EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then diff --git a/NodeBase/start-selenium-node.sh b/NodeBase/start-selenium-node.sh index 4b069c7dd..21cd7b946 100755 --- a/NodeBase/start-selenium-node.sh +++ b/NodeBase/start-selenium-node.sh @@ -36,6 +36,11 @@ if [ ! -z "$SE_NODE_SESSION_TIMEOUT" ]; then echo "Appending Selenium node session timeout via SE_OPTS: ${SE_OPTS}" fi +if [ ! -z "$SE_LOG_LEVEL" ]; then + echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}" + SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}" +fi + if [ "$GENERATE_CONFIG" = true ]; then echo "Generating Selenium Config" /opt/bin/generate_config diff --git a/NodeDocker/start-selenium-grid-docker.sh b/NodeDocker/start-selenium-grid-docker.sh index 0220a1ec9..a811780e7 100755 --- a/NodeDocker/start-selenium-grid-docker.sh +++ b/NodeDocker/start-selenium-grid-docker.sh @@ -29,6 +29,11 @@ if [ ! -z "$SE_NODE_GRID_URL" ]; then SE_GRID_URL="--grid-url ${SE_NODE_GRID_URL}" fi +if [ ! -z "$SE_LOG_LEVEL" ]; then + echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}" + SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}" +fi + EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then diff --git a/Router/start-selenium-grid-router.sh b/Router/start-selenium-grid-router.sh index 1c3103dfc..bb848a1c7 100755 --- a/Router/start-selenium-grid-router.sh +++ b/Router/start-selenium-grid-router.sh @@ -54,6 +54,11 @@ if [ ! -z "$SE_ROUTER_PORT" ]; then PORT_CONFIG="--port ${SE_ROUTER_PORT}" fi +if [ ! -z "$SE_LOG_LEVEL" ]; then + echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}" + SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}" +fi + EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then diff --git a/SessionQueue/start-selenium-grid-session-queue.sh b/SessionQueue/start-selenium-grid-session-queue.sh index b92c116bd..11074afb9 100755 --- a/SessionQueue/start-selenium-grid-session-queue.sh +++ b/SessionQueue/start-selenium-grid-session-queue.sh @@ -19,6 +19,11 @@ if [ ! -z "$SE_SESSION_QUEUE_PORT" ]; then PORT_CONFIG="--port ${SE_SESSION_QUEUE_PORT}" fi +if [ ! -z "$SE_LOG_LEVEL" ]; then + echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}" + SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}" +fi + EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then diff --git a/Sessions/start-selenium-grid-sessions.sh b/Sessions/start-selenium-grid-sessions.sh index 8dd9db195..4d34a1a5b 100755 --- a/Sessions/start-selenium-grid-sessions.sh +++ b/Sessions/start-selenium-grid-sessions.sh @@ -34,6 +34,11 @@ if [ ! -z "$SE_SESSIONS_PORT" ]; then PORT_CONFIG="--port ${SE_SESSIONS_PORT}" fi +if [ ! -z "$SE_LOG_LEVEL" ]; then + echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}" + SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}" +fi + EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then diff --git a/Standalone/start-selenium-standalone.sh b/Standalone/start-selenium-standalone.sh index cfde62d8e..955cb15f4 100755 --- a/Standalone/start-selenium-standalone.sh +++ b/Standalone/start-selenium-standalone.sh @@ -11,6 +11,11 @@ if [ ! -z "$SE_OPTS" ]; then echo "Appending Selenium options: ${SE_OPTS}" fi +if [ ! -z "$SE_LOG_LEVEL" ]; then + echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}" + SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}" +fi + /opt/bin/generate_config echo "Selenium Grid Standalone configuration: " diff --git a/StandaloneDocker/start-selenium-grid-docker.sh b/StandaloneDocker/start-selenium-grid-docker.sh index 2f4ad1e13..8571abc7a 100755 --- a/StandaloneDocker/start-selenium-grid-docker.sh +++ b/StandaloneDocker/start-selenium-grid-docker.sh @@ -14,6 +14,11 @@ if [ ! -z "$SE_NODE_GRID_URL" ]; then SE_GRID_URL="--grid-url ${SE_NODE_GRID_URL}" fi +if [ ! -z "$SE_LOG_LEVEL" ]; then + echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}" + SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}" +fi + EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then diff --git a/charts/selenium-grid/Chart.yaml b/charts/selenium-grid/Chart.yaml index 5f8594060..6a0dbfdb6 100644 --- a/charts/selenium-grid/Chart.yaml +++ b/charts/selenium-grid/Chart.yaml @@ -7,7 +7,7 @@ appVersion: 4.16.1-20231212 icon: https://github.com/SeleniumHQ/docker-selenium/raw/trunk/logo.png dependencies: - repository: https://kedacore.github.io/charts - version: 2.12.0 + version: 2.12.1 name: keda condition: autoscaling.enabled maintainers: diff --git a/charts/selenium-grid/README.md b/charts/selenium-grid/README.md index 524b497b5..8681ed5e0 100644 --- a/charts/selenium-grid/README.md +++ b/charts/selenium-grid/README.md @@ -140,6 +140,7 @@ For now, global configuration supported is: | `global.seleniumGrid.imagePullSecret` | `""` | Pull secret to be used for all images | | `global.seleniumGrid.imagePullSecret` | `""` | Pull secret to be used for all images | | `global.seleniumGrid.affinity` | `{}` | Affinity assigned globally | +| `global.seleniumGrid.logLevel` | `INFO` | Set log level for all components | This table contains the configuration parameters of the chart and their default values: diff --git a/charts/selenium-grid/templates/_helpers.tpl b/charts/selenium-grid/templates/_helpers.tpl index 48c18bb95..12342ad9b 100644 --- a/charts/selenium-grid/templates/_helpers.tpl +++ b/charts/selenium-grid/templates/_helpers.tpl @@ -207,6 +207,8 @@ template: name: {{ .Values.busConfigMap.name }} - configMapRef: name: {{ .Values.nodeConfigMap.name }} + - configMapRef: + name: {{ .Values.loggingConfigMap.name }} {{- with .node.extraEnvFrom }} {{- tpl (toYaml .) $ | nindent 10 }} {{- end }} diff --git a/charts/selenium-grid/templates/distributor-deployment.yaml b/charts/selenium-grid/templates/distributor-deployment.yaml index 07462f15e..990e519fb 100644 --- a/charts/selenium-grid/templates/distributor-deployment.yaml +++ b/charts/selenium-grid/templates/distributor-deployment.yaml @@ -47,6 +47,8 @@ spec: envFrom: - configMapRef: name: {{ .Values.busConfigMap.name }} + - configMapRef: + name: {{ .Values.loggingConfigMap.name }} {{- with .Values.components.extraEnvFrom }} {{- toYaml . | nindent 12 }} {{- end }} diff --git a/charts/selenium-grid/templates/event-bus-deployment.yaml b/charts/selenium-grid/templates/event-bus-deployment.yaml index 8d894790b..498570c9b 100644 --- a/charts/selenium-grid/templates/event-bus-deployment.yaml +++ b/charts/selenium-grid/templates/event-bus-deployment.yaml @@ -42,10 +42,12 @@ spec: {{- with .Values.components.extraEnvironmentVariables }} env: {{- tpl (toYaml .) $ | nindent 12 }} {{- end }} - {{- with .Values.components.extraEnvFrom }} envFrom: + - configMapRef: + name: {{ .Values.loggingConfigMap.name }} + {{- with .Values.components.extraEnvFrom }} {{- toYaml . | nindent 12 }} - {{- end }} + {{- end }} {{- with .Values.components.eventBus.resources }} resources: {{- toYaml . | nindent 12 }} {{- end }} diff --git a/charts/selenium-grid/templates/hub-deployment.yaml b/charts/selenium-grid/templates/hub-deployment.yaml index 8b322ecd5..14345e6c8 100644 --- a/charts/selenium-grid/templates/hub-deployment.yaml +++ b/charts/selenium-grid/templates/hub-deployment.yaml @@ -76,10 +76,12 @@ spec: {{- with .Values.hub.extraEnvironmentVariables }} {{- tpl (toYaml .) $ | nindent 12 }} {{- end }} - {{- with .Values.hub.extraEnvFrom }} envFrom: + - configMapRef: + name: {{ .Values.loggingConfigMap.name }} + {{- with .Values.hub.extraEnvFrom }} {{- toYaml . | nindent 12 }} - {{- end }} + {{- end }} {{- with .Values.hub.extraVolumeMounts }} volumeMounts: {{- tpl (toYaml .) $ | nindent 12 }} diff --git a/charts/selenium-grid/templates/logging-configmap.yaml b/charts/selenium-grid/templates/logging-configmap.yaml new file mode 100644 index 000000000..36acc3bde --- /dev/null +++ b/charts/selenium-grid/templates/logging-configmap.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.loggingConfigMap.name }} + namespace: {{ .Release.Namespace }} +{{- with .Values.loggingConfigMap.annotations }} + annotations: {{- toYaml . | nindent 4 }} +{{- end }} + labels: + {{- include "seleniumGrid.commonLabels" . | nindent 4 }} + {{- with .Values.customLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} +data: + SE_LOG_LEVEL: "{{ default "INFO" .Values.global.seleniumGrid.logLevel }}" diff --git a/charts/selenium-grid/templates/router-deployment.yaml b/charts/selenium-grid/templates/router-deployment.yaml index 33d98c65a..70ebe9bc3 100644 --- a/charts/selenium-grid/templates/router-deployment.yaml +++ b/charts/selenium-grid/templates/router-deployment.yaml @@ -56,10 +56,12 @@ spec: {{- with .Values.components.extraEnvironmentVariables }} {{- tpl (toYaml .) $ | nindent 12 }} {{- end }} - {{- with .Values.components.extraEnvFrom }} envFrom: + - configMapRef: + name: {{ .Values.loggingConfigMap.name }} + {{- with .Values.components.extraEnvFrom }} {{- toYaml . | nindent 12 }} - {{- end }} + {{- end }} ports: - containerPort: {{ .Values.components.router.port }} protocol: TCP diff --git a/charts/selenium-grid/templates/session-map-deployment.yaml b/charts/selenium-grid/templates/session-map-deployment.yaml index 8aebdefb2..2edd701e2 100644 --- a/charts/selenium-grid/templates/session-map-deployment.yaml +++ b/charts/selenium-grid/templates/session-map-deployment.yaml @@ -36,6 +36,8 @@ spec: env: {{- tpl (toYaml .) $ | nindent 12 }} {{- end }} envFrom: + - configMapRef: + name: {{ .Values.loggingConfigMap.name }} - configMapRef: name: {{ .Values.busConfigMap.name }} {{- with .Values.components.extraEnvFrom }} diff --git a/charts/selenium-grid/templates/session-queuer-deployment.yaml b/charts/selenium-grid/templates/session-queuer-deployment.yaml index 557d6774e..379285038 100644 --- a/charts/selenium-grid/templates/session-queuer-deployment.yaml +++ b/charts/selenium-grid/templates/session-queuer-deployment.yaml @@ -35,10 +35,12 @@ spec: {{- with .Values.components.extraEnvironmentVariables }} env: {{- tpl (toYaml .) $ | nindent 12 }} {{- end }} - {{- with .Values.components.extraEnvFrom }} envFrom: + - configMapRef: + name: {{ .Values.loggingConfigMap.name }} + {{- with .Values.components.extraEnvFrom }} {{- toYaml . | nindent 12 }} - {{- end }} + {{- end }} ports: - containerPort: {{ .Values.components.sessionQueue.port }} protocol: TCP diff --git a/charts/selenium-grid/values.yaml b/charts/selenium-grid/values.yaml index 5a82d207d..f6be10a83 100644 --- a/charts/selenium-grid/values.yaml +++ b/charts/selenium-grid/values.yaml @@ -10,6 +10,8 @@ global: videoImageTag: ffmpeg-6.1-20231212 # Pull secret for all components, can be overridden individually imagePullSecret: "" + # Log level for all components. Possible values describe here: https://www.selenium.dev/documentation/grid/configuration/cli_options/#logging + logLevel: INFO # Basic auth settings for Selenium Grid basicAuth: @@ -68,6 +70,12 @@ nodeConfigMap: # Custom annotations for configmap annotations: {} +# ConfigMap that contains common environment variables for Logging (https://www.selenium.dev/documentation/grid/configuration/cli_options/#logging) +loggingConfigMap: + name: selenium-logging-config + # Custom annotations for configmap + annotations: {} + # Configuration for isolated components (applied only if `isolateComponents: true`) components: diff --git a/tests/charts/templates/render/dummy.yaml b/tests/charts/templates/render/dummy.yaml index 52d672a8a..fbb746166 100644 --- a/tests/charts/templates/render/dummy.yaml +++ b/tests/charts/templates/render/dummy.yaml @@ -1,6 +1,7 @@ # This is dummy values file for chart template testing global: seleniumGrid: + logLevel: FINE affinity: &affinity podAffinity: requiredDuringSchedulingIgnoredDuringExecution: diff --git a/tests/charts/templates/test.py b/tests/charts/templates/test.py index f05c7629d..2f0c2f412 100644 --- a/tests/charts/templates/test.py +++ b/tests/charts/templates/test.py @@ -67,6 +67,29 @@ def test_sub_path_set_to_grid_env_var(self): is_present = True self.assertTrue(is_present, "ENV variable SE_SUB_PATH is not populated") + def test_log_level_set_to_logging_config_map(self): + resources_name = ['selenium-chrome-node', 'selenium-distributor', 'selenium-edge-node', 'selenium-firefox-node', + 'selenium-event-bus', 'selenium-router', 'selenium-session-map', 'selenium-session-queue'] + logger.info(f"Assert log level value is set to logging ConfigMap") + count_config = 0 + for doc in LIST_OF_DOCUMENTS: + if doc['metadata']['name'] == 'selenium-logging-config' and doc['kind'] == 'ConfigMap': + self.assertTrue(doc['data']['SE_LOG_LEVEL'] == 'FINE') + count_config += 1 + self.assertEqual(count_config, 1, "No logging ConfigMap found") + count = 0 + for doc in LIST_OF_DOCUMENTS: + if doc['metadata']['name'] in resources_name and doc['kind'] == 'Deployment': + is_present = False + logger.info(f"Assert logging ConfigMap is set to envFrom in resource {doc['metadata']['name']}") + list_env_from = doc['spec']['template']['spec']['containers'][0]['envFrom'] + for env in list_env_from: + if env['configMapRef']['name'] == 'selenium-logging-config': + is_present = True + self.assertTrue(is_present, "envFrom doesn't contain logging ConfigMap") + count += 1 + self.assertEqual(count, len(resources_name), "Logging ConfigMap is not present in expected resources") + if __name__ == '__main__': failed = False try: