Skip to content

Commit

Permalink
Support environment variables as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolovison committed Sep 19, 2024
1 parent a9974ff commit 3650d1e
Showing 1 changed file with 55 additions and 15 deletions.
70 changes: 55 additions & 15 deletions .github/scripts/tests/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ if [ "$GIT_WORKSPACE" = "" ]; then
echo "GIT_WORKSPACE variable not defined. Should be the root of the source code. Example GIT_WORKSPACE=/home/dev/git/data-science-pipelines-operator" && exit 1
fi

K8SAPISERVERHOST=""
DSPA_NAMESPACE="test-dspa"
DSPA_EXTERNAL_NAMESPACE="dspa-ext"
MINIO_NAMESPACE="test-minio"
MARIADB_NAMESPACE="test-mariadb"
PYPISERVER_NAMESPACE="test-pypiserver"
DSPA_NAME="test-dspa"
DSPA_EXTERNAL_NAME="dspa-ext"
DSPA_DEPLOY_WAIT_TIMEOUT="300"
INTEGRATION_TESTS_DIR="${GIT_WORKSPACE}/tests"
DSPA_PATH="${GIT_WORKSPACE}/tests/resources/dspa-lite.yaml"
Expand Down Expand Up @@ -163,14 +162,14 @@ run_tests() {
echo "---------------------------------"
echo "Run tests"
echo "---------------------------------"
( cd $GIT_WORKSPACE && make integrationtest K8SAPISERVERHOST=$(kubectl whoami --show-server) DSPANAMESPACE=${DSPA_NAMESPACE} DSPAPATH=${DSPA_PATH} )
( cd $GIT_WORKSPACE && make integrationtest K8SAPISERVERHOST=${K8SAPISERVERHOST} DSPANAMESPACE=${DSPA_NAMESPACE} DSPAPATH=${DSPA_PATH} )
}

run_tests_dspa_external_connections() {
echo "---------------------------------"
echo "Run tests for DSPA with External Connections"
echo "---------------------------------"
( cd $GIT_WORKSPACE && make integrationtest K8SAPISERVERHOST=$(kubectl whoami --show-server) DSPANAMESPACE=${DSPA_EXTERNAL_NAMESPACE} DSPAPATH=${DSPA_EXTERNAL_PATH} )
( cd $GIT_WORKSPACE && make integrationtest K8SAPISERVERHOST=${K8SAPISERVERHOST} DSPANAMESPACE=${DSPA_EXTERNAL_NAMESPACE} DSPAPATH=${DSPA_EXTERNAL_PATH} )
}

undeploy_kind_resources() {
Expand All @@ -189,7 +188,7 @@ remove_namespace_created_for_rhoai() {
kubectl delete projects $PYPISERVER_NAMESPACE --now || true
}

run_kind_tests() {
setup_kind_requirements() {
apply_crd
build_image
create_opendatahub_namespace
Expand All @@ -205,13 +204,9 @@ run_kind_tests() {
create_namespace_dspa_external_connections
apply_mariadb_minio_secrets_configmaps_external_namespace
apply_pip_server_configmap
run_tests
run_tests_dspa_external_connections
undeploy_kind_resources
}

run_rhoai_tests() {
remove_namespace_created_for_rhoai
setup_rhoai_requirements() {
deploy_minio
deploy_mariadb
deploy_pypi_server
Expand All @@ -221,20 +216,65 @@ run_rhoai_tests() {
create_namespace_dspa_external_connections
apply_mariadb_minio_secrets_configmaps_external_namespace
apply_pip_server_configmap
run_tests
run_tests_dspa_external_connections
}

# Run
case "$1" in
--kind)
run_kind_tests
TARGET="kind"
shift
;;
--rhoai)
run_rhoai_tests
TARGET="rhoai"
shift
;;
--k8s-api-server-host)
shift
K8SAPISERVERHOST=$1
shift
;;
--dspa-namespace)
shift
DSPANAMESPACE=$1
shift
;;
--dspa-external-namespace)
shift
DSPA_EXTERNAL_NAMESPACE=$1
shift
;;
--dspa-path)
shift
DSPAPATH=$1
shift
;;
--kube-config)
shift
KUBECONFIGPATH=$1
shift
;;
*)
echo "Usage: $0 [--kind]"
echo "Unknown command line switch: $1"
exit 1
;;
esac

if [ "$K8SAPISERVERHOST" = "" ]; then
echo "If K8SAPISERVERHOST is empty. It will use suite_test.go::Defaultk8sApiServerHost"
echo "If the TARGET is OpenShift or RHOAI. You can use: oc whoami --show-server"
fi

if [ "$TARGET" = "kind" ]; then
setup_kind_requirements
elif [ "$TARGET" == "rhoai" ]; then
setup_rhoai_requirements
fi

run_tests
run_tests_dspa_external_connections

if [ "$TARGET" = "kind" ]; then
undeploy_kind_resources
elif [ "$TARGET" == "rhoai" ]; then
remove_namespace_created_for_rhoai
fi

0 comments on commit 3650d1e

Please sign in to comment.