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

tests: Improve variable definition in tests/e2e scripts #346

Merged
merged 1 commit into from
Feb 21, 2024
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
6 changes: 3 additions & 3 deletions tests/e2e/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ wait_pods() {
# Note: copied from kata-containers/tests/lib/common.bash
#
wait_for_process() {
wait_time="$1"
sleep_time="$2"
cmd="$3"
local wait_time="$1"
local sleep_time="$2"
local cmd="$3"
while [ "$wait_time" -gt 0 ]; do
if eval "$cmd"; then
return 0
Expand Down
10 changes: 5 additions & 5 deletions tests/e2e/operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ install_ccruntime() {

# Check if the runtime is up.
# There could be a case where it is not even if the pods above are running.
cmd="kubectl get runtimeclass | grep -q ${runtimeclass}"
local cmd="kubectl get runtimeclass | grep -q ${runtimeclass}"
if ! wait_for_process 300 30 "$cmd"; then
echo "::error:: runtimeclass ${runtimeclass} is not up"
return 1
Expand Down Expand Up @@ -260,11 +260,11 @@ uninstall_operator() {
#
wait_for_stabilization() {
declare -A restart_counts
iteration=0
count=0
local iteration=0
local count=0
while true; do
change=0
pod_info=$(kubectl get pods -n "$op_ns" -o=jsonpath='{range .items[*]}{.metadata.name}{" "}{range .status.containerStatuses[*]}{.name}{" "}{.restartCount}{"\n"}{end}{end}')
local change=0
local pod_info=$(kubectl get pods -n "$op_ns" -o=jsonpath='{range .items[*]}{.metadata.name}{" "}{range .status.containerStatuses[*]}{.name}{" "}{.restartCount}{"\n"}{end}{end}')

while read -r pod container restart_count; do
if [ "${restart_counts[$pod-$container]--1}" != "$restart_count" ]; then
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/run-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ main() {
run 20m sudo -E PATH="$PATH" bash -c './operator.sh'

echo "::info:: Run tests"
cmd="run 20m sudo -E PATH=\"$PATH\" bash -c "
local cmd="run 20m sudo -E PATH=\"$PATH\" bash -c "
if [ -z "$runtimeclass" ]; then
cmd+="'./tests_runner.sh'"
else
Expand Down
Loading