Skip to content

Commit

Permalink
Allow DSPO test suite be running with RHOAI
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolovison committed Sep 18, 2024
1 parent b616f69 commit f3871a3
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 32 deletions.
87 changes: 55 additions & 32 deletions .github/scripts/tests/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ set -e

# ------------------------------------
# Env vars
echo "GIT_WORKSPACE=$GIT_WORKSPACE"
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
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

if [ "$REGISTRY_ADDRESS" = "" ]; then
echo "REGISTRY_ADDRESS variable not defined." && exit
fi

IMAGE_REPO_DSPO="data-science-pipelines-operator"
DSPA_NAMESPACE="test-dspa"
DSPA_EXTERNAL_NAMESPACE="dspa-ext"
MINIO_NAMESPACE="test-minio"
Expand All @@ -30,13 +26,19 @@ DSPA_PATH="${GIT_WORKSPACE}/tests/resources/dspa-lite.yaml"
DSPA_EXTERNAL_PATH="${GIT_WORKSPACE}/tests/resources/dspa-external-lite.yaml"
CONFIG_DIR="${GIT_WORKSPACE}/config"
RESOURCES_DIR_CRD="${GIT_WORKSPACE}/.github/resources"
DSPO_IMAGE="${REGISTRY_ADDRESS}/data-science-pipelines-operator"
OPENDATAHUB_NAMESPACE="opendatahub"
RESOURCES_DIR_PYPI="${GIT_WORKSPACE}/.github/resources/pypiserver/base"
# ------------------------------------

# ------------------------------------
# Functions
get_dspo_image() {
if [ "$REGISTRY_ADDRESS" = "" ]; then
echo "REGISTRY_ADDRESS variable not defined." && exit 1
fi
echo "${REGISTRY_ADDRESS}/data-science-pipelines-operator"
}

apply_crd() {
echo "---------------------------------"
echo "# Apply OCP CRDs"
Expand All @@ -49,7 +51,8 @@ build_image() {
echo "---------------------------------"
echo "Build image"
echo "---------------------------------"
( cd $GIT_WORKSPACE && make podman-build -e IMG="${DSPO_IMAGE}" )
IMG=$(get_dspo_image)
( cd $GIT_WORKSPACE && make podman-build -e IMG="$IMG" )
}

create_opendatahub_namespace() {
Expand All @@ -70,57 +73,55 @@ deploy_dspo() {
echo "---------------------------------"
echo "Deploy DSPO"
echo "---------------------------------"
( cd $GIT_WORKSPACE && make podman-push -e IMG="${DSPO_IMAGE}" )
( cd $GIT_WORKSPACE && make deploy-kind -e IMG="${DSPO_IMAGE}" )
IMG=$(get_dspo_image)
( cd $GIT_WORKSPACE && make podman-push -e IMG="$IMG" )
( cd $GIT_WORKSPACE && make deploy-kind -e IMG="$IMG" )
}

create_minio_namespace() {
deploy_minio() {
echo "---------------------------------"
echo "Create Minio Namespace"
echo "---------------------------------"
kubectl create namespace $MINIO_NAMESPACE
}

deploy_minio() {
echo "---------------------------------"
echo "Deploy Minio"
echo "---------------------------------"
( cd "${GIT_WORKSPACE}/.github/resources/minio" && kustomize build . | kubectl -n $MINIO_NAMESPACE apply -f - )
}

create_mariadb_namespace() {
deploy_mariadb() {
echo "---------------------------------"
echo "Create MariaDB Namespace"
echo "---------------------------------"
kubectl create namespace $MARIADB_NAMESPACE
}

deploy_mariadb() {
echo "---------------------------------"
echo "Deploy MariaDB"
echo "---------------------------------"
( cd "${GIT_WORKSPACE}/.github/resources/mariadb" && kustomize build . | kubectl -n $MARIADB_NAMESPACE apply -f - )
}

create_pypiserver_namespace() {
deploy_pypi_server() {
echo "---------------------------------"
echo "Create Pypiserver Namespace"
echo "---------------------------------"
kubectl create namespace $PYPISERVER_NAMESPACE
}

deploy_pypi_server() {
echo "---------------------------------"
echo "Deploy pypi-server"
echo "---------------------------------"
( cd "${GIT_WORKSPACE}/.github/resources/pypiserver/base" && kustomize build . | kubectl -n $PYPISERVER_NAMESPACE apply -f - )
}

wait_for_dependencies() {
wait_for_dspo_dependencies() {
echo "---------------------------------"
echo "Wait for Dependencies (DSPO, Minio, Mariadb, Pypi server)"
echo "Wait for DSPO Dependencies"
echo "---------------------------------"
kubectl wait -n $OPENDATAHUB_NAMESPACE --timeout=60s --for=condition=Available=true deployment data-science-pipelines-operator-controller-manager
}

wait_for_dependencies() {
echo "---------------------------------"
echo "Wait for Dependencies (Minio, Mariadb, Pypi server)"
echo "---------------------------------"
kubectl wait -n $MARIADB_NAMESPACE --timeout=60s --for=condition=Available=true deployment mariadb
kubectl wait -n $MINIO_NAMESPACE --timeout=60s --for=condition=Available=true deployment minio
kubectl wait -n $PYPISERVER_NAMESPACE --timeout=60s --for=condition=Available=true deployment pypi-server
Expand Down Expand Up @@ -151,7 +152,7 @@ apply_mariadb_minio_secrets_configmaps_external_namespace() {
echo "---------------------------------"
echo "Apply MariaDB and Minio Secrets and Configmaps in the External Namespace"
echo "---------------------------------"
( cd "${GIT_WORKSPACE}/.github/resources/external-pre-reqs" && kustomize build . | oc -n $DSPA_EXTERNAL_NAMESPACE apply -f - )
( cd "${GIT_WORKSPACE}/.github/resources/external-pre-reqs" && kustomize build . | kubectl -n $DSPA_EXTERNAL_NAMESPACE apply -f - )
}

apply_pip_server_configmap() {
Expand All @@ -165,34 +166,54 @@ run_tests() {
echo "---------------------------------"
echo "Run tests"
echo "---------------------------------"
( cd $GIT_WORKSPACE && make integrationtest K8SAPISERVERHOST=$(oc whoami --show-server) DSPANAMESPACE=${DSPA_NAMESPACE} DSPAPATH=${DSPA_PATH} )
( cd $GIT_WORKSPACE && make integrationtest K8SAPISERVERHOST=$(kubectl whoami --show-server) 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=$(oc whoami --show-server) DSPANAMESPACE=${DSPA_EXTERNAL_NAMESPACE} DSPAPATH=${DSPA_EXTERNAL_PATH} )
( cd $GIT_WORKSPACE && make integrationtest K8SAPISERVERHOST=$(kubectl whoami --show-server) DSPANAMESPACE=${DSPA_EXTERNAL_NAMESPACE} DSPAPATH=${DSPA_EXTERNAL_PATH} )
}

clean_up() {
undeploy_kind_resources() {
echo "---------------------------------"
echo "Clean up"
echo "---------------------------------"
( cd $GIT_WORKSPACE && make undeploy-kind )
}

remove_namespace_created_for_rhoai() {
kubectl delete projects $MINIO_NAMESPACE --now || true
kubectl delete projects $MARIADB_NAMESPACE --now || true
kubectl delete projects $PYPISERVER_NAMESPACE --now || true
}

run_kind_tests() {
apply_crd
build_image
create_opendatahub_namespace
deploy_argo_lite
deploy_dspo
create_minio_namespace
deploy_minio
create_mariadb_namespace
deploy_mariadb
create_pypiserver_namespace
deploy_pypi_server
wait_for_dspo_dependencies
wait_for_dependencies
upload_python_packages_to_pypi_server
create_dspa_namespace
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
deploy_minio
deploy_mariadb
deploy_pypi_server
wait_for_dependencies
upload_python_packages_to_pypi_server
Expand All @@ -202,7 +223,6 @@ run_kind_tests() {
apply_pip_server_configmap
run_tests
run_tests_dspa_external_connections
clean_up
}
# ------------------------------------

Expand All @@ -212,6 +232,9 @@ case "$1" in
--kind)
run_kind_tests
;;
--rhoai)
run_rhoai_tests
;;
*)
echo "Usage: $0 [--kind]"
exit 1
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kind-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- tests/**
- .github/resources/**
- '.github/workflows/kind-integration.yml'
- '.github/scripts/tests/tests.sh'
- Makefile
types:
- opened
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ Dockerfile.cross
__pycache__/
*.py[cod]
*$py.class
.github/scripts/python_package_upload/

0 comments on commit f3871a3

Please sign in to comment.