Skip to content

Commit

Permalink
test: Update test using ClientConfig
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Nov 5, 2024
1 parent 0666391 commit d2c56dd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -918,15 +918,15 @@ 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

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
Expand All @@ -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" \
Expand Down
10 changes: 6 additions & 4 deletions tests/SeleniumTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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':
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 0 additions & 4 deletions tests/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=$?

Expand Down
22 changes: 11 additions & 11 deletions tests/charts/make/chart_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d2c56dd

Please sign in to comment.