Commit f88ade56 authored by Ivan Mazhukin's avatar Ivan Mazhukin

less output when use --exec command

parent 5e065f15
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
- `--builder-path <path>`: явный builder64-путь вместо дефолта - `--builder-path <path>`: явный builder64-путь вместо дефолта
- `--preset <all|russian|main>`: добавить набор систем - `--preset <all|russian|main>`: добавить набор систем
- `--latest`: передать `--latest` в `epm play` (принудительно последняя версия) - `--latest`: передать `--latest` в `epm play` (принудительно последняя версия)
- `--exec <cmd>`: выполнить произвольную shell-команду вместо `epm play` (bootstrap системы выполняется как обычно) - `--exec <cmd>`: выполнить произвольную shell-команду вместо `epm play` без bootstrap системы
- `--parallel`: запустить все тесты параллельно - `--parallel`: запустить все тесты параллельно
- `-j <N>`: запустить не более N тестов одновременно - `-j <N>`: запустить не более N тестов одновременно
- `--log-root <path>`: каталог для логов - `--log-root <path>`: каталог для логов
...@@ -209,7 +209,7 @@ Runner: local docker (inside ssh session, user: builder-robot) ...@@ -209,7 +209,7 @@ Runner: local docker (inside ssh session, user: builder-robot)
## Что делает контейнер ## Что делает контейнер
Внутри контейнера скрипт: В режиме `play` внутри контейнера скрипт:
1. Определяет `os_id` из `/etc/os-release`. 1. Определяет `os_id` из `/etc/os-release`.
2. Проверяет наличие `bin/eepm` в примонтированной директории. 2. Проверяет наличие `bin/eepm` в примонтированной директории.
...@@ -220,7 +220,9 @@ Runner: local docker (inside ssh session, user: builder-robot) ...@@ -220,7 +220,9 @@ Runner: local docker (inside ssh session, user: builder-robot)
./bin/eepm play --auto <app> ./bin/eepm play --auto <app>
``` ```
Сейчас bootstrap завязан на семейство системы: В режиме `--exec` bootstrap пропускается: команда запускается через `sh -c` сразу после подготовки временного `HOME`. Если доступно дерево `eepm`, его `bin` добавляется в `PATH`.
Сейчас bootstrap для `play` завязан на семейство системы:
- `altlinux|alt`: `repo set etersoft`, `update`, затем установка `wget glibc-pthread file` - `altlinux|alt`: `repo set etersoft`, `update`, затем установка `wget glibc-pthread file`
- `debian|ubuntu`: `update`, затем установка `wget ca-certificates coreutils file` - `debian|ubuntu`: `update`, затем установка `wget ca-certificates coreutils file`
......
...@@ -30,6 +30,7 @@ SYSTEM_INPUTS=() ...@@ -30,6 +30,7 @@ SYSTEM_INPUTS=()
PRESET_NAMES=() PRESET_NAMES=()
TARGET_SYSTEMS=() TARGET_SYSTEMS=()
PARALLEL_JOBS=0 PARALLEL_JOBS=0
EFFECTIVE_RUN_MODE=""
SUMMARY_SYSTEMS=() SUMMARY_SYSTEMS=()
SUMMARY_RESULTS=() SUMMARY_RESULTS=()
SUMMARY_LOGS=() SUMMARY_LOGS=()
...@@ -294,6 +295,29 @@ resolve_source_path() { ...@@ -294,6 +295,29 @@ resolve_source_path() {
esac esac
} }
resolve_exec_source_path() {
local candidate
case "$SOURCE_KIND" in
local|explicit)
candidate="${SOURCE_PATH:-$(pwd -P)}"
;;
builder64)
candidate="${BUILDER_PATH:-$(default_builder_source_path)}"
;;
*)
fatal "Unsupported eepm source kind: $SOURCE_KIND"
;;
esac
[[ -n "$candidate" ]] || return 0
candidate="$(realpath "$candidate" 2>/dev/null || printf '%s\n' "$candidate")"
if [[ -d "$candidate" && -f "$candidate/bin/eepm" && -r "$candidate/bin/eepm" ]]; then
printf '%s\n' "$candidate"
fi
}
remote_target() { remote_target() {
[[ -n "$REMOTE_USER" ]] || fatal "Remote user is empty" [[ -n "$REMOTE_USER" ]] || fatal "Remote user is empty"
printf '%s@%s\n' "$REMOTE_USER" "$REMOTE_HOST" printf '%s@%s\n' "$REMOTE_USER" "$REMOTE_HOST"
...@@ -410,6 +434,7 @@ print_summary_table() { ...@@ -410,6 +434,7 @@ print_summary_table() {
local result_label local result_label
local result_output local result_output
[[ -z "$EXEC_COMMAND" ]] || return 0
((${#SUMMARY_SYSTEMS[@]} > 1)) || return 0 ((${#SUMMARY_SYSTEMS[@]} > 1)) || return 0
for i in "${!SUMMARY_SYSTEMS[@]}"; do for i in "${!SUMMARY_SYSTEMS[@]}"; do
...@@ -480,6 +505,7 @@ set -eu ...@@ -480,6 +505,7 @@ set -eu
TEST_COMMAND="$1" TEST_COMMAND="$1"
shift shift
SOURCE_DIR="/work/eepm" SOURCE_DIR="/work/eepm"
HAS_SOURCE=0
run_eepm() { run_eepm() {
bash ./bin/eepm "$@" bash ./bin/eepm "$@"
...@@ -491,18 +517,28 @@ if [ -r /etc/os-release ]; then ...@@ -491,18 +517,28 @@ if [ -r /etc/os-release ]; then
os_id="${ID:-unknown}" os_id="${ID:-unknown}"
fi fi
export HOME="/tmp/epm-home"
mkdir -p "$HOME"
if [ -f "$SOURCE_DIR/bin/eepm" ]; then
HAS_SOURCE=1
export PATH="$SOURCE_DIR/bin:$PATH"
cd "$SOURCE_DIR"
else
cd "$HOME"
fi
if [ "$TEST_COMMAND" = "exec" ]; then
exec sh -c "$1"
fi
printf '[container] bootstrap: os_id=%s\n' "$os_id" >&2 printf '[container] bootstrap: os_id=%s\n' "$os_id" >&2
if [ ! -f "$SOURCE_DIR/bin/eepm" ]; then if [ "$HAS_SOURCE" -ne 1 ]; then
printf '[container] eepm tree does not contain ./bin/eepm\n' >&2 printf '[container] eepm tree does not contain ./bin/eepm\n' >&2
exit 3 exit 3
fi fi
export HOME="/tmp/epm-home"
mkdir -p "$HOME"
export PATH="$SOURCE_DIR/bin:$PATH"
cd "$SOURCE_DIR"
case "$os_id" in case "$os_id" in
altlinux|alt) altlinux|alt)
run_eepm --auto repo set etersoft run_eepm --auto repo set etersoft
...@@ -537,9 +573,6 @@ case "$TEST_COMMAND" in ...@@ -537,9 +573,6 @@ case "$TEST_COMMAND" in
shift shift
exec bash ./bin/eepm play --auto "$@" "$APP_NAME" exec bash ./bin/eepm play --auto "$@" "$APP_NAME"
;; ;;
exec)
exec bash -c "$1"
;;
*) *)
printf '[container] unsupported test command: %s\n' "$TEST_COMMAND" >&2 printf '[container] unsupported test command: %s\n' "$TEST_COMMAND" >&2
exit 64 exit 64
...@@ -555,6 +588,7 @@ run_container_locally() { ...@@ -555,6 +588,7 @@ run_container_locally() {
local inner_script container_name local inner_script container_name
local current_user local current_user
local status local status
local -a docker_args
local -a inner_args local -a inner_args
require_command docker require_command docker
...@@ -570,23 +604,39 @@ run_container_locally() { ...@@ -570,23 +604,39 @@ run_container_locally() {
container_name="epm-test-$(sanitize_name "$APP_NAME")-$(sanitize_name "$SYSTEM_IMAGE")-$$" container_name="epm-test-$(sanitize_name "$APP_NAME")-$(sanitize_name "$SYSTEM_IMAGE")-$$"
fi fi
info "Using eepm tree: $resolved_source" if [[ -z "$EXEC_COMMAND" ]]; then
info "Target image: $SYSTEM_IMAGE" if [[ -n "$resolved_source" ]]; then
current_user="$(id -un)" info "Using eepm tree: $resolved_source"
if ((INTERNAL_LOCAL_RUN)); then fi
info "Runner: local docker (inside ssh session, user: $current_user)" info "Target image: $SYSTEM_IMAGE"
else current_user="$(id -un)"
info "Runner: local docker" if ((INTERNAL_LOCAL_RUN)); then
info "Runner: local docker (inside ssh session, user: $current_user)"
else
info "Runner: local docker"
fi
fi
docker_args=(
run --rm
--name "$container_name"
--hostname epm-docker-test
)
if [[ -n "$resolved_source" ]]; then
docker_args+=(
--workdir /work/eepm
--volume "$resolved_source:/work/eepm:ro"
)
fi fi
if docker run --rm \ docker_args+=(
--name "$container_name" \ --volume "$inner_script:/tmp/epm-docker-test-inner.sh:ro"
--hostname epm-docker-test \ "$SYSTEM_IMAGE"
--workdir /work/eepm \ sh /tmp/epm-docker-test-inner.sh "${inner_args[@]}"
--volume "$resolved_source:/work/eepm:ro" \ )
--volume "$inner_script:/tmp/epm-docker-test-inner.sh:ro" \
"$SYSTEM_IMAGE" \ if docker "${docker_args[@]}"; then
sh /tmp/epm-docker-test-inner.sh "${inner_args[@]}"; then
status=0 status=0
else else
status=$? status=$?
...@@ -605,6 +655,11 @@ build_remote_args() { ...@@ -605,6 +655,11 @@ build_remote_args() {
REMOTE_SYNC_DIR="" REMOTE_SYNC_DIR=""
target="$(remote_target)" target="$(remote_target)"
if [[ -n "$EXEC_COMMAND" ]]; then
REMOTE_ARGS+=(--exec "$EXEC_COMMAND" "$SYSTEM_IMAGE")
return 0
fi
if [[ "$SOURCE_KIND" == "local" || "$SOURCE_KIND" == "explicit" ]]; then if [[ "$SOURCE_KIND" == "local" || "$SOURCE_KIND" == "explicit" ]]; then
if remote_source="$(find_remote_builder_source_path "$target")"; then if remote_source="$(find_remote_builder_source_path "$target")"; then
info "Remote eepm tree found at: $remote_source" info "Remote eepm tree found at: $remote_source"
...@@ -640,7 +695,7 @@ run_container_via_ssh() { ...@@ -640,7 +695,7 @@ run_container_via_ssh() {
[[ -n "$REMOTE_USER" ]] || fatal "Remote user is empty" [[ -n "$REMOTE_USER" ]] || fatal "Remote user is empty"
target="${REMOTE_USER}@${REMOTE_HOST}" target="${REMOTE_USER}@${REMOTE_HOST}"
info "Runner: ssh -> $target" [[ -n "$EXEC_COMMAND" ]] || info "Runner: ssh -> $target"
build_remote_args build_remote_args
...@@ -674,11 +729,18 @@ run_container_via_ssh() { ...@@ -674,11 +729,18 @@ run_container_via_ssh() {
run_once() { run_once() {
local resolved_source local resolved_source
local run_mode
case "$RUN_MODE" in run_mode="${EFFECTIVE_RUN_MODE:-$RUN_MODE}"
case "$run_mode" in
auto) auto)
if can_use_local_docker; then if can_use_local_docker; then
resolved_source="$(resolve_source_path)" if [[ -n "$EXEC_COMMAND" ]]; then
resolved_source="$(resolve_exec_source_path)"
else
resolved_source="$(resolve_source_path)"
fi
run_container_locally "$resolved_source" run_container_locally "$resolved_source"
else else
warn "Local Docker is unavailable; falling back to ssh runner" warn "Local Docker is unavailable; falling back to ssh runner"
...@@ -686,7 +748,11 @@ run_once() { ...@@ -686,7 +748,11 @@ run_once() {
fi fi
;; ;;
local) local)
resolved_source="$(resolve_source_path)" if [[ -n "$EXEC_COMMAND" ]]; then
resolved_source="$(resolve_exec_source_path)"
else
resolved_source="$(resolve_source_path)"
fi
run_container_locally "$resolved_source" run_container_locally "$resolved_source"
;; ;;
remote) remote)
...@@ -706,6 +772,45 @@ test_description() { ...@@ -706,6 +772,45 @@ test_description() {
fi fi
} }
print_exec_header() {
local current_user
local desc
[[ -n "$EXEC_COMMAND" ]] || return 0
desc="$(test_description)"
info "Test command: $desc"
case "$RUN_MODE" in
auto)
if can_use_local_docker; then
EFFECTIVE_RUN_MODE="local"
info "Runner: local docker"
else
EFFECTIVE_RUN_MODE="remote"
warn "Local Docker is unavailable; falling back to ssh runner"
info "Runner: ssh -> $(remote_target)"
fi
;;
local)
EFFECTIVE_RUN_MODE="local"
if ((INTERNAL_LOCAL_RUN)); then
current_user="$(id -un)"
info "Runner: local docker (inside ssh session, user: $current_user)"
else
info "Runner: local docker"
fi
;;
remote)
EFFECTIVE_RUN_MODE="remote"
info "Runner: ssh -> $(remote_target)"
;;
*)
fatal "Unsupported run mode: $RUN_MODE"
;;
esac
}
run_for_system() { run_for_system() {
local system_image="$1" local system_image="$1"
local index="$2" local index="$2"
...@@ -720,15 +825,19 @@ run_for_system() { ...@@ -720,15 +825,19 @@ run_for_system() {
if ((total > 1)); then if ((total > 1)); then
info "Run [$index/$total]: $desc on $SYSTEM_IMAGE" info "Run [$index/$total]: $desc on $SYSTEM_IMAGE"
fi fi
info "Log file: $LOG_FILE" if [[ -z "$EXEC_COMMAND" ]]; then
info "Normalized system: $SYSTEM_IMAGE" info "Log file: $LOG_FILE"
info "Test command: $desc" info "Normalized system: $SYSTEM_IMAGE"
info "Test command: $desc"
fi
run_once 2>&1 | tee "$LOG_FILE" && status=0 || status=$? run_once 2>&1 | tee "$LOG_FILE" && status=0 || status=$?
if ((status == 0)); then if ((status == 0)); then
printf '\nTest passed: %s on %s\n' "$desc" "$SYSTEM_IMAGE" if [[ -z "$EXEC_COMMAND" ]]; then
printf 'Log: %s\n' "$LOG_FILE" printf '\nTest passed: %s on %s\n' "$desc" "$SYSTEM_IMAGE"
printf 'Log: %s\n' "$LOG_FILE"
fi
else else
printf '\nTest failed: %s on %s\n' "$desc" "$SYSTEM_IMAGE" >&2 printf '\nTest failed: %s on %s\n' "$desc" "$SYSTEM_IMAGE" >&2
printf 'Log: %s\n' "$LOG_FILE" >&2 printf 'Log: %s\n' "$LOG_FILE" >&2
...@@ -907,6 +1016,8 @@ main() { ...@@ -907,6 +1016,8 @@ main() {
build_target_systems build_target_systems
total="${#TARGET_SYSTEMS[@]}" total="${#TARGET_SYSTEMS[@]}"
print_exec_header
if ((PARALLEL_JOBS != 0 && total > 1)); then if ((PARALLEL_JOBS != 0 && total > 1)); then
local result_dir local result_dir
local i sys res log local i sys res log
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment