|
575 | 575 | echo "$APP_IMAGE_ID" > "$id_file"
|
576 | 576 | }
|
577 | 577 |
|
578 |
| -# ct_check_exec_env_vars [env_filter] |
579 |
| -# -------------------- |
580 |
| -# Checks if all relevant environment variables from `docker run` |
581 |
| -# can be found in `docker exec` as well. |
582 |
| -# Argument: env_filter - optional string passed to grep used for |
583 |
| -# choosing which variables to check in the test case. |
584 |
| -# Defaults to X_SCLS and variables containing /opt/app-root, /opt/rh |
585 |
| -# Uses: $CID_FILE_DIR - path to directory containing cid_files |
586 |
| -# Uses: $IMAGE_NAME - name of the image being tested |
587 |
| -function ct_check_exec_env_vars() { |
588 |
| - local tmpdir exec_envs cid old_IFS env_filter |
589 |
| - local var_name stripped filtered_envs run_envs |
590 |
| - env_filter=${1:-"^X_SCLS=\|/opt/rh\|/opt/app-root"} |
591 |
| - tmpdir=$(mktemp -d) |
592 |
| - CID_FILE_DIR=${CID_FILE_DIR:-$(mktemp -d)} |
593 |
| - # Get environment variables from `docker run` |
594 |
| - run_envs=$(docker run --rm "$IMAGE_NAME" /bin/bash -c "env") |
595 |
| - # Get environment variables from `docker exec` |
596 |
| - ct_create_container "test_exec_envs" bash -c "sleep 1000" >/dev/null |
597 |
| - cid=$(ct_get_cid "test_exec_envs") |
598 |
| - exec_envs=$(docker exec "$cid" env) |
599 |
| - # Filter out variables we are not interested in |
600 |
| - # Always check X_SCLS, ignore PWD |
601 |
| - # Check variables from `docker run` that have alternative paths inside (/opt/rh, /opt/app-root) |
602 |
| - ct_check_envs_set "$env_filter" "$exec_envs" "$run_envs" "*VALUE*" || return 1 |
603 |
| - echo " All values present in \`docker exec\`" |
604 |
| - return 0 |
605 |
| -} |
606 |
| - |
607 |
| -# ct_check_scl_enable_vars [env_filter] |
608 |
| -# -------------------- |
609 |
| -# Checks if all relevant environment variables from `docker run` |
610 |
| -# are set twice after a second call of `scl enable $SCLS`. |
611 |
| -# Argument: env_filter - optional string passed to grep used for |
612 |
| -# choosing which variables to check in the test case. |
613 |
| -# Defaults to paths containing enabled SCLS in the image |
614 |
| -# Uses: $IMAGE_NAME - name of the image being tested |
615 |
| -function ct_check_scl_enable_vars() { |
616 |
| - local tmpdir exec_envs cid old_IFS env_filter enabled_scls |
617 |
| - local var_name stripped filtered_envs loop_envs |
618 |
| - env_filter=$1 |
619 |
| - tmpdir=$(mktemp -d) |
620 |
| - enabled_scls=$(docker run --rm "$IMAGE_NAME" /bin/bash -c "echo \$X_SCLS") |
621 |
| - if [ -z "$env_filter" ]; then |
622 |
| - for scl in $enabled_scls; do |
623 |
| - [ -z "$env_filter" ] && env_filter="/$scl" && continue |
624 |
| - # env_filter not empty, append to the existing list |
625 |
| - env_filter="$env_filter|/$scl" |
626 |
| - done |
627 |
| - fi |
628 |
| - # Get environment variables from `docker run` |
629 |
| - loop_envs=$(docker run --rm "$IMAGE_NAME" /bin/bash -c "env") |
630 |
| - run_envs=$(docker run --rm "$IMAGE_NAME" /bin/bash -c "X_SCLS= scl enable $enabled_scls env") |
631 |
| - # Check if the values are set twice in the second set of envs |
632 |
| - ct_check_envs_set "$env_filter" "$run_envs" "$loop_envs" "*VALUE*VALUE*" || return 1 |
633 |
| - echo " All scl_enable values present" |
634 |
| - return 0 |
635 |
| -} |
636 | 578 |
|
637 | 579 | # ct_path_append PATH_VARNAME DIRECTORY
|
638 | 580 | # -------------------------------------
|
|
0 commit comments