podman

Форк
0
/
850-compose.bats 
77 строк · 2.9 Кб
1
#!/usr/bin/env bats   -*- bats -*-
2
#
3
# Smoke tests for the podman-compose command.  test/compose takes care of functional tests.
4
#
5

6
load helpers
7

8
@test "podman compose - smoke tests" {
9
    fake_compose_bin="$PODMAN_TMPDIR/fake_compose"
10
    cat >$fake_compose_bin <<EOF
11
#!/bin/bash
12
if [[ "\$@" == "fail" ]]; then
13
    exit 42
14
fi
15
if [[ "\$@" == "env" ]]; then
16
    printenv DOCKER_HOST DOCKER_BUILDKIT DOCKER_CONFIG
17
    exit 0
18
fi
19
echo "arguments: \$@"
20
EOF
21

22
    compose_conf="$PODMAN_TMPDIR/compose.conf"
23
    cat >$compose_conf <<EOF
24
[engine]
25
compose_providers = ["$fake_compose_bin"]
26
compose_warning_logs = false
27
EOF
28

29
    random_data="--foo=bar --random=$(random_string 15) -f /path/to/file ignore me"
30

31
    # Make sure that the fake compose binary is used and that error reporting works
32
    PODMAN_COMPOSE_PROVIDER=$fake_compose_bin run_podman 125 compose --help
33
    is "$output" ".*executing $fake_compose_bin --help: .*: permission denied"
34

35
    # Make the fake one executable and check the --help output
36
    chmod +x $fake_compose_bin
37
    PODMAN_COMPOSE_PROVIDER=$fake_compose_bin run_podman compose --help
38
    is "$output" "Run compose workloads via an external provider .*arguments: --help"
39

40
    # No argument yields the help message as well
41
    PODMAN_COMPOSE_PROVIDER=$fake_compose_bin run_podman compose
42
    is "$output" "Run compose workloads via an external provider .*arguments: "
43

44
    # Make sure that the provider can be specified via containers.conf and that
45
    # the warning logs can be turned off
46
    CONTAINERS_CONF_OVERRIDE=$compose_conf run_podman compose --help
47
    is "$output" "Run compose workloads via an external provider .*arguments: --help"
48
    assert "$output" !~ ".*Executing external compose provider.*"
49

50
    # Run with bogus arguments and make sure they're being returned
51
    CONTAINERS_CONF_OVERRIDE=$compose_conf run_podman compose $random_data
52
    is "$output" "arguments: $random_data"
53

54
    # Make sure Podman returns the exit code of the compose provider
55
    CONTAINERS_CONF_OVERRIDE=$compose_conf run_podman 42 compose fail
56

57
    # Make sure the three env variables are set (and parsed)
58
    op='=~'
59
    url=".*/podman.sock"
60
    # if we run remote with --url check the url arg is honored
61
    if [[ "$PODMAN" =~ "--url" ]]; then
62
        # get the url from the podman string
63
        url="${PODMAN##*--url }"
64
        url="${url%% *}"
65
        op='='
66
    fi
67
    # podman-remote test might run with --url so unset this because the socket will be used otherwise
68
    CONTAINERS_CONF_OVERRIDE=$compose_conf run_podman compose env
69
    assert "${lines[0]}" $op "$url" "line 1 of 3 (DOCKER_HOST)"
70
    assert "${lines[1]}" = "0"      "line 2 of 3 (DOCKER_BUILDKIT)"
71
    assert "${lines[2]}" = ""       "line 3 of 3 (DOCKER_CONFIG)"
72

73
    DOCKER_HOST="$random_data" DOCKER_CONFIG="$random_data" CONTAINERS_CONF_OVERRIDE=$compose_conf run_podman compose env
74
    is "${lines[0]}" "$random_data"
75
    is "${lines[1]}" "0"
76
    is "${lines[2]}" "$random_data"
77
}
78

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.