github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/kubernetes/k8s-oom.bats (about) 1 #!/usr/bin/env bats 2 # 3 # Copyright (c) 2020 Ant Group 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 8 load "${BATS_TEST_DIRNAME}/../../.ci/lib.sh" 9 load "${BATS_TEST_DIRNAME}/tests_common.sh" 10 11 setup() { 12 export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}" 13 pod_name="pod-oom" 14 get_pod_config_dir 15 } 16 17 @test "Test OOM events for pods" { 18 19 # Create pod 20 kubectl create -f "${pod_config_dir}/pod-oom.yaml" 21 22 # Check pod creation 23 kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name" 24 25 # Check if OOMKilled 26 cmd="kubectl get pods "$pod_name" -o yaml | yq r - 'status.containerStatuses[0].state.terminated.reason' | grep OOMKilled" 27 28 waitForProcess "$wait_time" "$sleep_time" "$cmd" 29 } 30 31 teardown() { 32 # Debugging information 33 kubectl describe "pod/$pod_name" 34 kubectl get "pod/$pod_name" -o yaml 35 36 kubectl delete pod "$pod_name" 37 }