From d2c56dd334129b02db13d1fff1d5dde37b03d931 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Sun, 3 Nov 2024 16:59:30 +0700 Subject: [PATCH] test: Update test using ClientConfig Signed-off-by: Viet Nguyen Duc --- Makefile | 6 +++--- tests/SeleniumTests/__init__.py | 10 ++++++---- tests/bootstrap.sh | 4 ---- tests/charts/make/chart_test.sh | 22 +++++++++++----------- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 080ff9928..3fbd02302 100644 --- a/Makefile +++ b/Makefile @@ -918,7 +918,7 @@ chart_test_autoscaling_disabled: chart_test_autoscaling_deployment_https: PLATFORMS=$(PLATFORMS) CHART_FULL_DISTRIBUTED_MODE=true CHART_ENABLE_BASIC_AUTH=true \ SECURE_INGRESS_ONLY_DEFAULT=true INGRESS_DISABLE_USE_HTTP2=true SELENIUM_GRID_PROTOCOL=https CHART_ENABLE_INGRESS_HOSTNAME=true SELENIUM_GRID_PORT=443 \ - SELENIUM_GRID_AUTOSCALING_MIN_REPLICA=1 MAX_SESSIONS_FIREFOX=3 MAX_SESSIONS_EDGE=2 MAX_SESSIONS_CHROME=1 TEST_NAME_OVERRIDE=true \ + SELENIUM_GRID_AUTOSCALING_MIN_REPLICA=0 MAX_SESSIONS_FIREFOX=3 MAX_SESSIONS_EDGE=2 MAX_SESSIONS_CHROME=1 TEST_NAME_OVERRIDE=true \ VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) KEDA_BASED_NAME=$(KEDA_BASED_NAME) KEDA_BASED_TAG=$(KEDA_BASED_TAG) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) BASE_VERSION=$(BASE_VERSION) \ TEMPLATE_OUTPUT_FILENAME="k8s_fullDistributed_basicAuth_secureIngress_defaultCerts_ingressHostName_disableHttp2_autoScaling_patchKEDA_scaledObject_subPath.yaml" \ ./tests/charts/make/chart_test.sh DeploymentAutoscaling @@ -926,7 +926,7 @@ chart_test_autoscaling_deployment_https: chart_test_autoscaling_deployment: PLATFORMS=$(PLATFORMS) TEST_EXISTING_KEDA=true RELEASE_NAME=selenium CHART_ENABLE_TRACING=true TEST_PATCHED_KEDA=false \ SECURE_CONNECTION_SERVER=true SECURE_USE_EXTERNAL_CERT=true SERVICE_TYPE_NODEPORT=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_HOST=$$(hostname -i) SELENIUM_GRID_PORT=31444 \ - SELENIUM_GRID_AUTOSCALING_MIN_REPLICA=0 SET_MAX_REPLICAS=3 TEST_DELAY_AFTER_TEST=2 SELENIUM_GRID_MONITORING=false \ + SELENIUM_GRID_AUTOSCALING_MIN_REPLICA=1 SET_MAX_REPLICAS=3 TEST_DELAY_AFTER_TEST=2 SELENIUM_GRID_MONITORING=false \ VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) KEDA_BASED_NAME=$(KEDA_BASED_NAME) KEDA_BASED_TAG=$(KEDA_BASED_TAG) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) BASE_VERSION=$(BASE_VERSION) \ TEMPLATE_OUTPUT_FILENAME="k8s_prefixSelenium_enableTracing_secureServer_externalCerts_nodePort_autoScaling_scaledObject_existingKEDA_subPath.yaml" \ ./tests/charts/make/chart_test.sh DeploymentAutoscaling @@ -947,7 +947,7 @@ chart_test_autoscaling_job_hostname: ./tests/charts/make/chart_test.sh JobAutoscaling chart_test_autoscaling_job: - PLATFORMS=$(PLATFORMS) TEST_EXISTING_KEDA=true TEST_CHROMIUM=true RELEASE_NAME=selenium CHART_ENABLE_TRACING=true CHART_FULL_DISTRIBUTED_MODE=true SELENIUM_GRID_MONITORING=false SCALING_STRATEGY=accurate \ + PLATFORMS=$(PLATFORMS) TEST_EXISTING_KEDA=true TEST_CHROMIUM=true RELEASE_NAME=selenium CHART_ENABLE_TRACING=true CHART_FULL_DISTRIBUTED_MODE=true SELENIUM_GRID_MONITORING=false \ SECURE_INGRESS_ONLY_CONFIG_INLINE=true SECURE_USE_EXTERNAL_CERT=true CHART_ENABLE_INGRESS_HOSTNAME=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_HOST=selenium-grid.prod SUB_PATH=/ SELENIUM_GRID_PORT=443 \ VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) KEDA_BASED_NAME=$(KEDA_BASED_NAME) KEDA_BASED_TAG=$(KEDA_BASED_TAG) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) BASE_VERSION=$(BASE_VERSION) \ TEMPLATE_OUTPUT_FILENAME="k8s_fullDistributed_secureIngress_externalCerts_ingressHostName_ingressTLSInline_autoScaling_scaledJob_existingKEDA_prefixSelenium_nodeChromium_enableTracing.yaml" \ diff --git a/tests/SeleniumTests/__init__.py b/tests/SeleniumTests/__init__.py index bb8a8ffcf..c037bfb1e 100644 --- a/tests/SeleniumTests/__init__.py +++ b/tests/SeleniumTests/__init__.py @@ -18,6 +18,7 @@ SELENIUM_GRID_PORT = os.environ.get('SELENIUM_GRID_PORT', '4444') SELENIUM_GRID_USERNAME = os.environ.get('SELENIUM_GRID_USERNAME', None) SELENIUM_GRID_PASSWORD = os.environ.get('SELENIUM_GRID_PASSWORD', None) +CHART_CERT_PATH = os.environ.get('CHART_CERT_PATH', None) SELENIUM_GRID_TEST_HEADLESS = os.environ.get('SELENIUM_GRID_TEST_HEADLESS', 'false').lower() == 'true' SELENIUM_ENABLE_MANAGED_DOWNLOADS = os.environ.get('SELENIUM_ENABLE_MANAGED_DOWNLOADS', 'true').lower() == 'true' WEB_DRIVER_WAIT_TIMEOUT = int(os.environ.get('WEB_DRIVER_WAIT_TIMEOUT', 60)) @@ -37,7 +38,8 @@ keep_alive=True, timeout=3600, username=SELENIUM_GRID_USERNAME, - password=SELENIUM_GRID_PASSWORD + password=SELENIUM_GRID_PASSWORD, + ca_certs=CHART_CERT_PATH, ) if TEST_NODE_RELAY == 'Android': @@ -167,7 +169,7 @@ def setUp(self): start_time = time.time() self.driver = webdriver.Remote( options=options, - command_executor="%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT), + command_executor=SELENIUM_GRID_URL, client_config=CLIENT_CONFIG ) end_time = time.time() @@ -196,7 +198,7 @@ def setUp(self): start_time = time.time() self.driver = webdriver.Remote( options=options, - command_executor="%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT), + command_executor=SELENIUM_GRID_URL, client_config=CLIENT_CONFIG ) end_time = time.time() @@ -230,7 +232,7 @@ def setUp(self): start_time = time.time() self.driver = webdriver.Remote( options=options, - command_executor="%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT), + command_executor=SELENIUM_GRID_URL, client_config=CLIENT_CONFIG ) end_time = time.time() diff --git a/tests/bootstrap.sh b/tests/bootstrap.sh index b5a36549e..9d216aef6 100755 --- a/tests/bootstrap.sh +++ b/tests/bootstrap.sh @@ -16,10 +16,6 @@ fi python3 -m pip install docker requests chardet | grep -v 'Requirement already satisfied' -if [ "${SELENIUM_GRID_PROTOCOL}" = "https" ]; then - export REQUESTS_CA_BUNDLE="${CHART_CERT_PATH}" -fi - python3 test.py $1 ret_code=$? diff --git a/tests/charts/make/chart_test.sh b/tests/charts/make/chart_test.sh index d7573ae6c..825b55519 100755 --- a/tests/charts/make/chart_test.sh +++ b/tests/charts/make/chart_test.sh @@ -3,6 +3,7 @@ mkdir -p tests/tests set -o xtrace echo "Set ENV variables" +RESOURCE_ID=$(openssl rand -hex 4) CLUSTER_NAME=${CLUSTER_NAME:-"chart-testing"} RELEASE_NAME=${RELEASE_NAME:-"test"} SELENIUM_NAMESPACE=${SELENIUM_NAMESPACE:-"selenium"} @@ -48,7 +49,7 @@ if [ "${RELEASE_NAME}" = "selenium" ]; then else SELENIUM_TLS_SECRET_NAME="${RELEASE_NAME}-selenium-tls-secret" fi -EXTERNAL_TLS_SECRET_NAME=${EXTERNAL_TLS_SECRET_NAME:-"external-tls-secret"} +EXTERNAL_TLS_SECRET_NAME=${EXTERNAL_TLS_SECRET_NAME:-"external-tls-secret-${RESOURCE_ID}"} SELENIUM_ENABLE_MANAGED_DOWNLOADS=${SELENIUM_ENABLE_MANAGED_DOWNLOADS:-"true"} MAX_SESSIONS_CHROME=${MAX_SESSIONS_CHROME:-"1"} MAX_SESSIONS_FIREFOX=${MAX_SESSIONS_FIREFOX:-"1"} @@ -251,8 +252,6 @@ if [ "${SECURE_INGRESS_ONLY_GENERATE}" = "true" ] && [ "${RENDER_HELM_TEMPLATE_O --set tls.ingress.defaultSANList[0]=${SELENIUM_GRID_HOST} \ --set tls.ingress.defaultIPList[0]=$(hostname -I | awk '{print $1}') \ " - kubectl get secret ${SELENIUM_TLS_SECRET_NAME} -n ${SELENIUM_NAMESPACE} -o jsonpath="{.data.tls\.crt}" | base64 -d > ./tests/tests/tls.crt - CHART_CERT_PATH="./tests/tests/tls.crt" fi if [ "${SECURE_INGRESS_ONLY_DEFAULT}" = "true" ]; then @@ -280,13 +279,14 @@ if [ "${SECURE_USE_EXTERNAL_CERT}" = "true" ] && [ "${RENDER_HELM_TEMPLATE_ONLY} --set ingress.nginx.sslSecret="${SELENIUM_NAMESPACE}/${EXTERNAL_TLS_SECRET_NAME}" \ " cert_dir="./tests/tests" - ADD_IP_ADDRESS=hostname ./${CHART_PATH}/certs/gen-cert-helper.sh -d ${cert_dir} - kubectl delete secret -n ${SELENIUM_NAMESPACE} ${EXTERNAL_TLS_SECRET_NAME} --ignore-not-found=true - kubectl create secret generic -n ${SELENIUM_NAMESPACE} ${EXTERNAL_TLS_SECRET_NAME} \ - --from-file=tls.crt=${cert_dir}/tls.crt \ - --from-file=tls.key=${cert_dir}/tls.key \ - --from-file=server.jks=${cert_dir}/server.jks \ - --from-file=server.pass=${cert_dir}/server.pass + if [ ! -f "./tests/tests/tls.crt" ]; then + ADD_IP_ADDRESS=hostname ./${CHART_PATH}/certs/gen-cert-helper.sh -d ${cert_dir} + kubectl create secret generic -n ${SELENIUM_NAMESPACE} ${EXTERNAL_TLS_SECRET_NAME} \ + --from-file=tls.crt=${cert_dir}/tls.crt \ + --from-file=tls.key=${cert_dir}/tls.key \ + --from-file=server.jks=${cert_dir}/server.jks \ + --from-file=server.pass=${cert_dir}/server.pass + fi CHART_CERT_PATH="./tests/tests/tls.crt" fi @@ -408,7 +408,7 @@ if [ "${TEST_UPGRADE_CHART}" = "true" ]; then exit 0 fi -if [ "${SECURE_INGRESS_ONLY_GENERATE}" = "true" ]; then +if [ "${SECURE_INGRESS_ONLY_GENERATE}" = "true" ] && [ "${RENDER_HELM_TEMPLATE_ONLY}" != "true" ]; then kubectl get secret ${SELENIUM_TLS_SECRET_NAME} -n ${SELENIUM_NAMESPACE} -o jsonpath="{.data.tls\.crt}" | base64 -d > ./tests/tests/tls.crt CHART_CERT_PATH="./tests/tests/tls.crt" fi