Merge pull request #12779 from rophy/fix/strip-cr-from-tty-exec

tests: strip \r from kubectl exec output for TTY containers
This commit is contained in:
Aurélien Bombo
2026-04-07 10:19:21 -05:00
committed by GitHub
2 changed files with 5 additions and 4 deletions

View File

@@ -69,11 +69,11 @@ EOF"
## Cases for target container
### First container
container_name=$(kubectl exec $pod_name -c $first_container_name -- $env_command | grep CONTAINER_NAME)
container_name=$(kubectl exec $pod_name -c $first_container_name -- $env_command | grep CONTAINER_NAME | tr -d '\r')
[ "$container_name" == "CONTAINER_NAME=$first_container_name" ]
### Second container
container_name=$(kubectl exec $pod_name -c $second_container_name -- $env_command | grep CONTAINER_NAME)
container_name=$(kubectl exec $pod_name -c $second_container_name -- $env_command | grep CONTAINER_NAME | tr -d '\r')
[ "$container_name" == "CONTAINER_NAME=$second_container_name" ]
}

View File

@@ -35,15 +35,16 @@ setup() {
kubectl wait --for=condition=Ready --timeout=$timeout pod $pod_name
# Check PID from first container
# Strip \r — containers with tty: true return \r\n line endings
first_pid_container=$(kubectl exec $pod_name -c $first_container_name \
-- $ps_command | grep "/pause")
-- $ps_command | grep "/pause" | tr -d '\r')
# Verify that is not empty
check_first_pid=$(echo $first_pid_container | wc -l)
[ "$check_first_pid" == "1" ]
# Check PID from second container
second_pid_container=$(kubectl exec $pod_name -c $second_container_name \
-- $ps_command | grep "/pause")
-- $ps_command | grep "/pause" | tr -d '\r')
# Verify that is not empty
check_second_pid=$(echo $second_pid_container | wc -l)
[ "$check_second_pid" == "1" ]