mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-20 10:20:39 +00:00
Merge pull request #7238 from fidencio/topic/gha-run-tests-on-specific-namespace
gha: k8s: Ensure tests are running on a specific namespace
This commit is contained in:
commit
152e2509ca
@ -58,6 +58,12 @@ function get_cluster_credentials() {
|
|||||||
function run_tests() {
|
function run_tests() {
|
||||||
platform="${1}"
|
platform="${1}"
|
||||||
|
|
||||||
|
# Emsure we're in the default namespace
|
||||||
|
kubectl config set-context --current --namespace=default
|
||||||
|
|
||||||
|
# Delete any spurious tests namespace that was left behind
|
||||||
|
kubectl delete namespace kata-containers-k8s-tests &> /dev/null || true
|
||||||
|
|
||||||
sed -i -e "s|quay.io/kata-containers/kata-deploy:latest|${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}|g" "${tools_dir}/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_dir}/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
||||||
cat "${tools_dir}/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
cat "${tools_dir}/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml"
|
||||||
cat "${tools_dir}/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" | grep "${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}" || die "Failed to setup the tests image"
|
cat "${tools_dir}/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml" | grep "${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}" || die "Failed to setup the tests image"
|
||||||
@ -80,6 +86,10 @@ function run_tests() {
|
|||||||
sleep 60s
|
sleep 60s
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Create a new namespace for the tests and switch to it
|
||||||
|
kubectl apply -f ${integration_dir}/kubernetes/runtimeclass_workloads/tests-namespace.yaml
|
||||||
|
kubectl config set-context --current --namespace=kata-containers-k8s-tests
|
||||||
|
|
||||||
pushd "${integration_dir}/kubernetes"
|
pushd "${integration_dir}/kubernetes"
|
||||||
bash setup.sh
|
bash setup.sh
|
||||||
bash run_kubernetes_tests.sh
|
bash run_kubernetes_tests.sh
|
||||||
@ -89,6 +99,10 @@ function run_tests() {
|
|||||||
function cleanup() {
|
function cleanup() {
|
||||||
platform="${1}"
|
platform="${1}"
|
||||||
|
|
||||||
|
# Switch back to the default namespace and delete the tests one
|
||||||
|
kubectl config set-context --current --namespace=default
|
||||||
|
kubectl delete namespace kata-containers-k8s-tests
|
||||||
|
|
||||||
if [ "${platform}" = "tdx" ]; then
|
if [ "${platform}" = "tdx" ]; then
|
||||||
deploy_spec="-k "${tools_dir}/packaging/kata-deploy/kata-deploy/overlays/k3s""
|
deploy_spec="-k "${tools_dir}/packaging/kata-deploy/kata-deploy/overlays/k3s""
|
||||||
cleanup_spec="-k "${tools_dir}/packaging/kata-deploy/kata-cleanup/overlays/k3s""
|
cleanup_spec="-k "${tools_dir}/packaging/kata-deploy/kata-cleanup/overlays/k3s""
|
||||||
|
@ -14,13 +14,12 @@ setup() {
|
|||||||
@test "Pod quota" {
|
@test "Pod quota" {
|
||||||
resource_name="pod-quota"
|
resource_name="pod-quota"
|
||||||
deployment_name="deploymenttest"
|
deployment_name="deploymenttest"
|
||||||
namespace="test-quota-ns"
|
|
||||||
|
|
||||||
# Create the resourcequota
|
# Create the resourcequota
|
||||||
kubectl create -f "${pod_config_dir}/resource-quota.yaml"
|
kubectl create -f "${pod_config_dir}/resource-quota.yaml"
|
||||||
|
|
||||||
# View information about resourcequota
|
# View information about resourcequota
|
||||||
kubectl get -n "$namespace" resourcequota "$resource_name" \
|
kubectl get resourcequota "$resource_name" \
|
||||||
--output=yaml | grep 'pods: "2"'
|
--output=yaml | grep 'pods: "2"'
|
||||||
|
|
||||||
# Create deployment
|
# Create deployment
|
||||||
@ -28,10 +27,9 @@ setup() {
|
|||||||
|
|
||||||
# View deployment
|
# View deployment
|
||||||
kubectl wait --for=condition=Available --timeout=$timeout \
|
kubectl wait --for=condition=Available --timeout=$timeout \
|
||||||
-n "$namespace" deployment/${deployment_name}
|
deployment/${deployment_name}
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
kubectl delete -n "$namespace" deployment "$deployment_name"
|
|
||||||
kubectl delete -f "${pod_config_dir}/resource-quota.yaml"
|
kubectl delete -f "${pod_config_dir}/resource-quota.yaml"
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Pod
|
kind: Pod
|
||||||
metadata:
|
metadata:
|
||||||
namespace: default
|
|
||||||
name: custom-dns-test
|
name: custom-dns-test
|
||||||
spec:
|
spec:
|
||||||
terminationGracePeriodSeconds: 0
|
terminationGracePeriodSeconds: 0
|
||||||
|
@ -8,7 +8,6 @@ apiVersion: v1
|
|||||||
kind: Pod
|
kind: Pod
|
||||||
metadata:
|
metadata:
|
||||||
name: pod-oom
|
name: pod-oom
|
||||||
namespace: default
|
|
||||||
spec:
|
spec:
|
||||||
runtimeClassName: kata
|
runtimeClassName: kata
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
|
@ -7,7 +7,6 @@ apiVersion: apps/v1
|
|||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: deploymenttest
|
name: deploymenttest
|
||||||
namespace: test-quota-ns
|
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
|
@ -14,7 +14,6 @@ items:
|
|||||||
kind: ResourceQuota
|
kind: ResourceQuota
|
||||||
metadata:
|
metadata:
|
||||||
name: pod-quota
|
name: pod-quota
|
||||||
namespace: test-quota-ns
|
|
||||||
spec:
|
spec:
|
||||||
hard:
|
hard:
|
||||||
pods: "2"
|
pods: "2"
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: kata-containers-k8s-tests
|
Loading…
Reference in New Issue
Block a user