podman

Форк
0
/
setup_suite.bash 
63 строки · 2.1 Кб
1
# -*- bash -*-
2

3
bats_require_minimum_version 1.8.0
4

5
load helpers
6
load ../system/helpers
7
load ../system/helpers.registry
8
load ../system/helpers.network
9

10
function setup_suite(){
11
    if [[ -z "$ROOTLESS_USER" ]]; then
12
        if ! is_rootless; then
13
            die "Cannot run as root with no \$ROOTLESS_USER defined"
14
        fi
15
        export ROOTLESS_USER=$(id -un)
16
    fi
17

18
    sshdir=/home/$ROOTLESS_USER/.ssh
19
    sshkey=$sshdir/id_rsa
20
    if [[ ! -e $sshkey ]]; then
21
        ssh-keygen -t rsa -N "" -f $sshkey
22
        cat ${sshkey}.pub >> $sshdir/authorized_keys
23

24
        # Confirm that ssh localhost works. Since this is probably
25
        # the first time that we ssh, bypass the host key verification.
26
        ssh -T -o 'BatchMode yes' -o 'StrictHostKeyChecking no' localhost true
27
    fi
28

29
    # Sigh..... "system connection add" fails if podman is not in $PATH.
30
    # There does not seem to be any way to tell it to use an explicit path.
31
    type -P podman || die "No 'podman' in \$PATH"
32

33
    export FARMNAME="test-farm-$(random_string 5)"
34

35
    # only set up the podman farm before the first test
36
    run_podman system connection add --identity $sshkey test-node $ROOTLESS_USER@localhost
37
    run_podman farm create $FARMNAME test-node
38

39
    export PODMAN_LOGIN_WORKDIR=$(mktemp -d --tmpdir=${BATS_TMPDIR:-${TMPDIR:-/tmp}} podman-bats-registry.XXXXXX)
40

41
    export PODMAN_LOGIN_USER="user$(random_string 4)"
42
    export PODMAN_LOGIN_PASS="pw$(random_string 15)"
43

44
    # FIXME: racy! It could be many minutes between now and when we start it.
45
    # To mitigate, we use a range not used anywhere else in system tests.
46
    export PODMAN_LOGIN_REGISTRY_PORT=$(random_free_port 42000-42999)
47

48
    # create a local registry to push images to
49
    export REGISTRY=localhost:${PODMAN_LOGIN_REGISTRY_PORT}
50
    export AUTHFILE=$FARM_TMPDIR/authfile.json
51
    start_registry
52
    run_podman login --authfile=$AUTHFILE \
53
        --tls-verify=false \
54
        --username ${PODMAN_LOGIN_USER} \
55
        --password ${PODMAN_LOGIN_PASS} \
56
        $REGISTRY
57
}
58

59
function teardown_suite(){
60
    # clear out the farms after the last farm test
61
    run_podman farm rm --all
62
    stop_registry
63
}
64

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

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

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

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