mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-13 21:09:31 +00:00
Merge pull request #10346 from BbolroC/minor-improvement-k8s-tests
tests: Minor improvement k8s tests
This commit is contained in:
@@ -90,11 +90,5 @@ teardown() {
|
|||||||
skip "Test skipped as KBS not setup"
|
skip "Test skipped as KBS not setup"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -n "${pod_name:-}" ] && kubectl describe "pod/${pod_name}" || true
|
teardown_common "${node}" "${node_start_time:-}"
|
||||||
[ -n "${pod_config_dir:-}" ] && kubectl delete -f "${K8S_TEST_YAML}" || true
|
|
||||||
|
|
||||||
if [[ -n "${node_start_time:-}" && -z "$BATS_TEST_COMPLETED" ]]; then
|
|
||||||
echo "DEBUG: system logs of node '$node' since test start time ($node_start_time)"
|
|
||||||
exec_host "${node}" journalctl -x -t "kata" --since '"'$node_start_time'"' || true
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
@@ -110,13 +110,6 @@ teardown() {
|
|||||||
|
|
||||||
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
|
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
|
||||||
|
|
||||||
|
teardown_common "${node}" "${node_start_time:-}"
|
||||||
kubectl delete secret cococred --ignore-not-found
|
kubectl delete secret cococred --ignore-not-found
|
||||||
|
|
||||||
kubectl describe pods
|
|
||||||
k8s_delete_all_pods_if_any_exists || true
|
|
||||||
|
|
||||||
if [[ -n "${node_start_time:-}" && -z "$BATS_TEST_COMPLETED" ]]; then
|
|
||||||
echo "DEBUG: system logs of node '$node' since test start time ($node_start_time)"
|
|
||||||
exec_host "${node}" journalctl -x -t "kata" --since '"'$node_start_time'"' || true
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
@@ -95,11 +95,5 @@ teardown() {
|
|||||||
|
|
||||||
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
|
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
|
||||||
|
|
||||||
kubectl describe pods
|
teardown_common "${node}" "${node_start_time:-}"
|
||||||
k8s_delete_all_pods_if_any_exists || true
|
|
||||||
|
|
||||||
if [[ -n "${node_start_time:-}" && -z "$BATS_TEST_COMPLETED" ]]; then
|
|
||||||
echo "DEBUG: system logs of node '$node' since test start time ($node_start_time)"
|
|
||||||
exec_host "${node}" journalctl -x -t "kata" --since '"'$node_start_time'"' || true
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
@@ -146,11 +146,5 @@ teardown() {
|
|||||||
|
|
||||||
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
|
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
|
||||||
|
|
||||||
kubectl describe pods
|
teardown_common "${node}" "${node_start_time:-}"
|
||||||
k8s_delete_all_pods_if_any_exists || true
|
|
||||||
|
|
||||||
if [[ -n "${node_start_time:-}" && -z "$BATS_TEST_COMPLETED" ]]; then
|
|
||||||
echo "DEBUG: system logs of node '$node' since test start time ($node_start_time)"
|
|
||||||
exec_host "${node}" journalctl -x -t "kata" --since '"'$node_start_time'"' || true
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
@@ -230,8 +230,7 @@ teardown() {
|
|||||||
|
|
||||||
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
|
[ "${SNAPSHOTTER:-}" = "nydus" ] || skip "None snapshotter was found but this test requires one"
|
||||||
|
|
||||||
kubectl describe pods
|
teardown_common "${node}" "${node_start_time:-}"
|
||||||
k8s_delete_all_pods_if_any_exists || true
|
|
||||||
kubectl delete --ignore-not-found pvc trusted-pvc
|
kubectl delete --ignore-not-found pvc trusted-pvc
|
||||||
kubectl delete --ignore-not-found pv trusted-block-pv
|
kubectl delete --ignore-not-found pv trusted-block-pv
|
||||||
kubectl delete --ignore-not-found storageclass local-storage
|
kubectl delete --ignore-not-found storageclass local-storage
|
||||||
|
@@ -93,14 +93,7 @@ setup() {
|
|||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
# Debugging information
|
# Debugging information
|
||||||
kubectl describe "pod/$pod_name"
|
|
||||||
|
|
||||||
kubectl delete pod "$pod_name"
|
|
||||||
|
|
||||||
rm -f "${yaml_file}"
|
rm -f "${yaml_file}"
|
||||||
|
|
||||||
if [[ -n "${node_start_time:-}" && -z "$BATS_TEST_COMPLETED" ]]; then
|
teardown_common "${node}" "${node_start_time:-}"
|
||||||
echo "DEBUG: system logs of node '$node' since test start time ($node_start_time)"
|
|
||||||
exec_host "${node}" journalctl -x -t "kata" --since '"'$node_start_time'"' || true
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
@@ -22,13 +22,6 @@ setup() {
|
|||||||
setup_common
|
setup_common
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown() {
|
|
||||||
check_and_skip
|
|
||||||
|
|
||||||
kubectl describe -f "${pod_config}" || true
|
|
||||||
kubectl delete -f "${pod_config}" || true
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "Test cannnot launch pod with measured boot enabled and incorrect hash" {
|
@test "Test cannnot launch pod with measured boot enabled and incorrect hash" {
|
||||||
pod_config="$(new_pod_config nginx "kata-${KATA_HYPERVISOR}")"
|
pod_config="$(new_pod_config nginx "kata-${KATA_HYPERVISOR}")"
|
||||||
|
|
||||||
@@ -57,3 +50,9 @@ teardown() {
|
|||||||
assert_logs_contain "$node" kata "$node_start_time" \
|
assert_logs_contain "$node" kata "$node_start_time" \
|
||||||
'verity: .* metadata block .* is corrupted'
|
'verity: .* metadata block .* is corrupted'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
check_and_skip
|
||||||
|
|
||||||
|
teardown_common "${node}" "${node_start_time:-}"
|
||||||
|
}
|
||||||
|
@@ -107,14 +107,7 @@ teardown() {
|
|||||||
skip "Test skipped as KBS not setup"
|
skip "Test skipped as KBS not setup"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -n "${pod_name:-}" ] && kubectl describe "pod/${pod_name}" || true
|
teardown_common "${node}" "${node_start_time:-}"
|
||||||
[ -n "${pod_config_dir:-}" ] && kubectl delete -f "${K8S_TEST_YAML}" || true
|
|
||||||
|
|
||||||
kubectl delete secret sealed-secret --ignore-not-found
|
kubectl delete secret sealed-secret --ignore-not-found
|
||||||
kubectl delete secret not-sealed-secret --ignore-not-found
|
kubectl delete secret not-sealed-secret --ignore-not-found
|
||||||
|
|
||||||
if [[ -n "${node_start_time:-}" && -z "$BATS_TEST_COMPLETED" ]]; then
|
|
||||||
echo "DEBUG: system logs of node '$node' since test start time ($node_start_time)"
|
|
||||||
exec_host "${node}" journalctl -x -t "kata" --since '"'$node_start_time'"' || true
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
@@ -71,6 +71,10 @@ k8s_create_pod() {
|
|||||||
#
|
#
|
||||||
exec_host() {
|
exec_host() {
|
||||||
local node="$1"
|
local node="$1"
|
||||||
|
# Validate the node
|
||||||
|
if ! kubectl get node "${node}" > /dev/null 2>&1; then
|
||||||
|
die "A given node ${node} is not valid"
|
||||||
|
fi
|
||||||
# `kubectl debug` always returns 0, so we hack it to return the right exit code.
|
# `kubectl debug` always returns 0, so we hack it to return the right exit code.
|
||||||
local command="${@:2}"
|
local command="${@:2}"
|
||||||
# Make 7 character hash from the node name
|
# Make 7 character hash from the node name
|
||||||
|
@@ -359,3 +359,23 @@ pod_exec_blocked_command() {
|
|||||||
|
|
||||||
(echo "${exec_output}" | grep "ExecProcessRequest is blocked by policy" > /dev/null) || die "exec was not blocked by policy!"
|
(echo "${exec_output}" | grep "ExecProcessRequest is blocked by policy" > /dev/null) || die "exec was not blocked by policy!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Common teardown for tests.
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
# $1 - node name where kata is installed
|
||||||
|
# $2 - start time at the node for the sake of fetching logs
|
||||||
|
#
|
||||||
|
teardown_common() {
|
||||||
|
local node="$1"
|
||||||
|
local node_start_time="$2"
|
||||||
|
|
||||||
|
kubectl describe pods
|
||||||
|
k8s_delete_all_pods_if_any_exists || true
|
||||||
|
|
||||||
|
# Print the node journal since the test start time if a bats test is not completed
|
||||||
|
if [[ -n "${node_start_time}" && -z "$BATS_TEST_COMPLETED" ]]; then
|
||||||
|
echo "DEBUG: system logs of node '$node' since test start time ($node_start_time)"
|
||||||
|
exec_host "${node}" journalctl -x -t "kata" --since '"'$node_start_time'"' || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user