mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-05-11 06:05:04 +00:00
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:
@@ -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" ]
|
||||
|
||||
}
|
||||
|
||||
@@ -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" ]
|
||||
|
||||
Reference in New Issue
Block a user