mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-02 00:02:01 +00:00
tests: kata-deploy: Use helm_helper()
With this we switch to fully testing with helm, instead of testimg with the kustomizations (which will soon be removed). Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
This commit is contained in:
parent
f7976a40e4
commit
404e212102
@ -6,9 +6,10 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
load "${BATS_TEST_DIRNAME}/../../common.bash"
|
load "${BATS_TEST_DIRNAME}/../../common.bash"
|
||||||
|
repo_root_dir="${BATS_TEST_DIRNAME}/../../../"
|
||||||
|
load "${repo_root_dir}/tests/gha-run-k8s-common.sh"
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
repo_root_dir="${BATS_TEST_DIRNAME}/../../../"
|
|
||||||
ensure_yq
|
ensure_yq
|
||||||
|
|
||||||
pushd "${repo_root_dir}"
|
pushd "${repo_root_dir}"
|
||||||
@ -25,77 +26,35 @@ setup() {
|
|||||||
"kata-${KATA_HYPERVISOR}\s+kata-${KATA_HYPERVISOR}" \
|
"kata-${KATA_HYPERVISOR}\s+kata-${KATA_HYPERVISOR}" \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Set the latest image, the one generated as part of the PR, to be used as part of the tests
|
# Set the latest image, the one generated as part of the PR, to be used as part of the tests
|
||||||
sed -i -e "s|quay.io/kata-containers/kata-deploy:latest|${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}|g" "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
export HELM_IMAGE_REFERENCE="${DOCKER_REGISTRY}/${DOCKER_REPO}"
|
||||||
|
export HELM_IMAGE_TAG="${DOCKER_TAG}"
|
||||||
|
|
||||||
# Enable debug for Kata Containers
|
# Enable debug for Kata Containers
|
||||||
yq -i \
|
export HELM_DEBUG="true"
|
||||||
'.spec.template.spec.containers[0].env[1].value = "true"' \
|
|
||||||
"tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
|
||||||
# Create the runtime class only for the shim that's being tested
|
# Create the runtime class only for the shim that's being tested
|
||||||
yq -i \
|
export HELM_SHIMS="${KATA_HYPERVISOR}"
|
||||||
".spec.template.spec.containers[0].env[2].value = \"${KATA_HYPERVISOR}\"" \
|
|
||||||
"tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
|
||||||
# Set the tested hypervisor as the default `kata` shim
|
# Set the tested hypervisor as the default `kata` shim
|
||||||
yq -i \
|
export HELM_DEFAULT_SHIM="${KATA_HYPERVISOR}"
|
||||||
".spec.template.spec.containers[0].env[3].value = \"${KATA_HYPERVISOR}\"" \
|
|
||||||
"tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
|
||||||
# Let the `kata-deploy` script take care of the runtime class creation / removal
|
# Let the `kata-deploy` script take care of the runtime class creation / removal
|
||||||
yq -i \
|
export HELM_CREATE_RUNTIME_CLASSES="true"
|
||||||
'.spec.template.spec.containers[0].env[4].value = "true"' \
|
|
||||||
"tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
|
||||||
# Let the `kata-deploy` create the default `kata` runtime class
|
# Let the `kata-deploy` create the default `kata` runtime class
|
||||||
yq -i \
|
export HELM_CREATE_DEFAULT_RUNTIME_CLASS="true"
|
||||||
'.spec.template.spec.containers[0].env[5].value = "true"' \
|
|
||||||
"tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
|
||||||
|
|
||||||
if [ "${KATA_HOST_OS}" = "cbl-mariner" ]; then
|
HOST_OS=""
|
||||||
yq -i \
|
if [[ "${KATA_HOST_OS}" = "cbl-mariner" ]]; then
|
||||||
".spec.template.spec.containers[0].env += [{\"name\": \"HOST_OS\", \"value\": \"${KATA_HOST_OS}\"}]" \
|
HOST_OS="${KATA_HOST_OS}"
|
||||||
"tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
|
||||||
fi
|
fi
|
||||||
|
export HELM_HOST_OS="${HOST_OS}"
|
||||||
|
|
||||||
echo "::group::Final kata-deploy.yaml that is used in the test"
|
export HELM_K8S_DISTRIBUTION="${KUBERNETES}"
|
||||||
cat "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
|
||||||
grep "${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}" "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" || die "Failed to setup the tests image"
|
|
||||||
echo "::endgroup::"
|
|
||||||
|
|
||||||
echo "::group::Debug overlays directory content"
|
helm_helper
|
||||||
echo "Current working directory: $(pwd)"
|
|
||||||
ls -la tools/packaging/kata-deploy/kata-deploy/overlays/
|
|
||||||
echo "::endgroup::"
|
|
||||||
|
|
||||||
kubectl apply -f "tools/packaging/kata-deploy/kata-rbac/base/kata-rbac.yaml"
|
|
||||||
if [ "${KUBERNETES}" = "k0s" ]; then
|
|
||||||
kubectl apply -k "tools/packaging/kata-deploy/kata-deploy/overlays/k0s"
|
|
||||||
elif [ "${KUBERNETES}" = "k3s" ]; then
|
|
||||||
kubectl apply -k "tools/packaging/kata-deploy/kata-deploy/overlays/k3s"
|
|
||||||
elif [ "${KUBERNETES}" = "rke2" ]; then
|
|
||||||
kubectl apply -k "tools/packaging/kata-deploy/kata-deploy/overlays/rke2"
|
|
||||||
elif [ "${KUBERNETES}" = "microk8s" ]; then
|
|
||||||
kubectl apply -k "tools/packaging/kata-deploy/kata-deploy/overlays/microk8s"
|
|
||||||
else
|
|
||||||
kubectl apply -f "tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local cmd="kubectl -n kube-system get -l name=kata-deploy pod 2>/dev/null | grep '\<Running\>'"
|
|
||||||
|
|
||||||
if ! waitForProcess 240 10 "$cmd"; then
|
|
||||||
echo "Kata-deploy pod is not running. Printing pod details for debugging:"
|
|
||||||
kubectl -n kube-system get pods -o wide
|
|
||||||
kubectl -n kube-system get pods -l name=kata-deploy -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | while read -r pod; do
|
|
||||||
echo "Describing pod: $pod"
|
|
||||||
kubectl -n kube-system describe pod "$pod"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "ERROR: kata-deploy pod is not running, tests will not be execute."
|
|
||||||
echo "ERROR: setup() aborting tests..."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Give some time for the pod to finish what's doing and have the
|
|
||||||
# runtimeclasses properly created
|
|
||||||
sleep 30s
|
|
||||||
|
|
||||||
echo "::group::kata-deploy logs"
|
echo "::group::kata-deploy logs"
|
||||||
kubectl -n kube-system logs --tail=100 -l name=kata-deploy
|
kubectl -n kube-system logs --tail=100 -l name=kata-deploy
|
||||||
@ -135,52 +94,8 @@ setup() {
|
|||||||
teardown() {
|
teardown() {
|
||||||
pushd "${repo_root_dir}"
|
pushd "${repo_root_dir}"
|
||||||
|
|
||||||
if [ "${KUBERNETES}" = "k0s" ]; then
|
helm uninstall --namespace=kube-system kata-deploy --wait
|
||||||
deploy_spec="-k \"tools/packaging/kata-deploy/kata-deploy/overlays/k0s\""
|
|
||||||
cleanup_spec="-k \"tools/packaging/kata-deploy/kata-cleanup/overlays/k0s\""
|
|
||||||
elif [ "${KUBERNETES}" = "k3s" ]; then
|
|
||||||
deploy_spec="-k \"tools/packaging/kata-deploy/kata-deploy/overlays/k3s\""
|
|
||||||
cleanup_spec="-k \"tools/packaging/kata-deploy/kata-cleanup/overlays/k3s\""
|
|
||||||
elif [ "${KUBERNETES}" = "rke2" ]; then
|
|
||||||
deploy_spec="-k \"tools/packaging/kata-deploy/kata-deploy/overlays/rke2\""
|
|
||||||
cleanup_spec="-k \"tools/packaging/kata-deploy/kata-cleanup/overlays/rke2\""
|
|
||||||
elif [ "${KUBERNETES}" = "microk8s" ]; then
|
|
||||||
deploy_spec="-k \"tools/packaging/kata-deploy/kata-deploy/overlays/microk8s\""
|
|
||||||
cleanup_spec="-k \"tools/packaging/kata-deploy/kata-cleanup/overlays/microk8s\""
|
|
||||||
else
|
|
||||||
deploy_spec="-f \"tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml\""
|
|
||||||
cleanup_spec="-f \"tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
kubectl delete ${deploy_spec}
|
|
||||||
kubectl -n kube-system wait --timeout=10m --for=delete -l name=kata-deploy pod
|
kubectl -n kube-system wait --timeout=10m --for=delete -l name=kata-deploy pod
|
||||||
|
|
||||||
# Let the `kata-deploy` script take care of the runtime class creation / removal
|
|
||||||
yq -i \
|
|
||||||
'.spec.template.spec.containers[0].env[4].value = "true"' \
|
|
||||||
"tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml"
|
|
||||||
# Create the runtime class only for the shim that's being tested
|
|
||||||
yq -i \
|
|
||||||
".spec.template.spec.containers[0].env[2].value = \"${KATA_HYPERVISOR}\"" \
|
|
||||||
"tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml"
|
|
||||||
# Set the tested hypervisor as the default `kata` shim
|
|
||||||
yq -i \
|
|
||||||
".spec.template.spec.containers[0].env[3].value = \"${KATA_HYPERVISOR}\"" \
|
|
||||||
"tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml"
|
|
||||||
# Let the `kata-deploy` create the default `kata` runtime class
|
|
||||||
yq -i \
|
|
||||||
'.spec.template.spec.containers[0].env[5].value = "true"' \
|
|
||||||
"tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
|
||||||
|
|
||||||
sed -i -e "s|quay.io/kata-containers/kata-deploy:latest|${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}|g" "tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml"
|
|
||||||
cat "tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml"
|
|
||||||
grep "${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}" "tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml" || die "Failed to setup the tests image"
|
|
||||||
|
|
||||||
kubectl apply ${cleanup_spec}
|
|
||||||
sleep 30s
|
|
||||||
|
|
||||||
kubectl delete ${cleanup_spec}
|
|
||||||
kubectl delete -f "tools/packaging/kata-deploy/kata-rbac/base/kata-rbac.yaml"
|
|
||||||
|
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user