teemtee / tmt

Test Management Tool
MIT License
84 stars 125 forks source link

tmt does not like if entrypoint is not standard #1046

Open thrix opened 2 years ago

thrix commented 2 years ago

While working on our CLI tool, I found this annoyance, if I have ENTRYPOINT set, tmt starts the container with the command and just exits, subsequent commands file. The error is cryptic:

❯ tmt run -dddvvv
Using tree '/home/mvadkert/git/gitlab.com/testing-farm/cli'.
/var/tmp/tmt/run-007
tmt version: 1.9.0 (599b9a1)
Read file '/var/tmp/tmt/run-007/run.yaml'.
Run data not found.
Enabled steps: discover, report, finish, provision, execute and prepare
    Sync the worktree to '/var/tmp/tmt/run-007/plans/sanity/tree'.
    Run command 'rsync -ar --exclude .git /home/mvadkert/git/gitlab.com/testing-farm/cli/ /var/tmp/tmt/run-007/plans/sanity/tree'.
Found 1 plan.
Write file '/var/tmp/tmt/run-007/run.yaml'.

/plans/sanity
summary: Sanity test plan
info
    environment: {}
    context: {}
wake
    discover
        Read file '/var/tmp/tmt/run-007/plans/sanity/discover/step.yaml'.
        Step data not found.
        Read file '/var/tmp/tmt/run-007/plans/sanity/discover/tests.yaml'.
        Discovered tests not found.
        Using the 'DiscoverFmf' plugin for the 'fmf' method.
        status: todo
        Write file '/var/tmp/tmt/run-007/plans/sanity/discover/step.yaml'.
        Write file '/var/tmp/tmt/run-007/plans/sanity/discover/tests.yaml'.
    provision
        Read file '/var/tmp/tmt/run-007/plans/sanity/provision/step.yaml'.
        Step data not found.
        Read file '/var/tmp/tmt/run-007/plans/sanity/provision/guests.yaml'.
        Provisioned guests not found.
        Using the 'ProvisionPodman' plugin for the 'container' method.
        status: todo
        Write file '/var/tmp/tmt/run-007/plans/sanity/provision/step.yaml'.
        Write file '/var/tmp/tmt/run-007/plans/sanity/provision/guests.yaml'.
    prepare
        Read file '/var/tmp/tmt/run-007/plans/sanity/prepare/step.yaml'.
        Step data not found.
        Using the 'PrepareShell' plugin for the 'shell' method.
        status: todo
        Write file '/var/tmp/tmt/run-007/plans/sanity/prepare/step.yaml'.
    execute
        Read file '/var/tmp/tmt/run-007/plans/sanity/execute/step.yaml'.
        Step data not found.
        Read file '/var/tmp/tmt/run-007/plans/sanity/execute/results.yaml'.
        Test results not found.
        Using the 'ExecuteInternal' plugin for the 'tmt' method.
        status: todo
        Write file '/var/tmp/tmt/run-007/plans/sanity/execute/step.yaml'.
        Write file '/var/tmp/tmt/run-007/plans/sanity/execute/results.yaml'.
    report
        Read file '/var/tmp/tmt/run-007/plans/sanity/report/step.yaml'.
        Step data not found.
        Report step always force mode enabled.
        Clean up workdir '/var/tmp/tmt/run-007/plans/sanity/report'.
        status: todo
        Using the 'ReportDisplay' plugin for the 'display' method.
        Write file '/var/tmp/tmt/run-007/plans/sanity/report/step.yaml'.
    finish
        Read file '/var/tmp/tmt/run-007/plans/sanity/finish/step.yaml'.
        Step data not found.
        Using the 'FinishShell' plugin for the 'shell' method.
        status: todo
        Write file '/var/tmp/tmt/run-007/plans/sanity/finish/step.yaml'.
    action
go
    discover
        workdir: /var/tmp/tmt/run-007/plans/sanity/discover
        how: fmf
        order: 50
            Run command 'git rev-parse --show-toplevel'.
            out: /home/mvadkert/git/gitlab.com/testing-farm/cli
        directory: /home/mvadkert/git/gitlab.com/testing-farm/cli
            Copy '/home/mvadkert/git/gitlab.com/testing-farm/cli' to '/var/tmp/tmt/run-007/plans/sanity/discover/default/tests'.
            Run command 'git rev-parse --short HEAD'.
            out: 3111ba8
        hash: 3111ba8
            Check metadata tree in '/var/tmp/tmt/run-007/plans/sanity/discover/default/tests/'.
        summary: 2 tests selected
            /tests/commands/request
            /tests/commands/version
        status: done
        Write file '/var/tmp/tmt/run-007/plans/sanity/discover/step.yaml'.
        Write file '/var/tmp/tmt/run-007/plans/sanity/discover/tests.yaml'.
        Write file '/var/tmp/tmt/run-007/plans/sanity/discover/run.yaml'.
    provision
        workdir: /var/tmp/tmt/run-007/plans/sanity/provision
        how: container
        order: 50
        image: quay.io/testing-farm/cli:latest
            Check for container image 'quay.io/testing-farm/cli:latest'.
            out: 082f27d79382
        name: tmt-var-tmp-tmt-run-007-plans-sanity
            Start container 'quay.io/testing-farm/cli:latest'.
            Run command 'podman run --security-opt seccomp=unconfined --name tmt-var-tmp-tmt-run-007-plans-sanity -v /var/tmp/tmt/run-007/plans/sanity:/var/tmp/tmt/run-007/plans/sanity:Z -itd quay.io/testing-farm/cli:latest'.
            err: time="2022-02-09T20:46:01+01:00" level=warning msg="The input device is not a TTY. The --tty and --interactive flags might not work properly"
            out: 0de66e9ef36b875974b0b3e7a92e8f702af38b1c827438351643f9f352f651d9
            Run command 'podman exec tmt-var-tmp-tmt-run-007-plans-sanity sh -c cat /etc/os-release'.
            out: PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
            out: NAME="Debian GNU/Linux"
            out: VERSION_ID="11"
            out: VERSION="11 (bullseye)"
            out: VERSION_CODENAME=bullseye
            out: ID=debian
            out: HOME_URL="https://www.debian.org/"
            out: SUPPORT_URL="https://www.debian.org/support"
            out: BUG_REPORT_URL="https://bugs.debian.org/"
        distro: Debian GNU/Linux 11 (bullseye)
            Run command 'podman exec tmt-var-tmp-tmt-run-007-plans-sanity sh -c uname -r'.
            out: 5.15.16-100.fc34.x86_64
        kernel: 5.15.16-100.fc34.x86_64
        summary: 1 guest provisioned
        status: done
        Write file '/var/tmp/tmt/run-007/plans/sanity/provision/step.yaml'.
        Write file '/var/tmp/tmt/run-007/plans/sanity/provision/guests.yaml'.
    prepare
        workdir: /var/tmp/tmt/run-007/plans/sanity/prepare
        summary: 0 preparations applied
        status: done
        Write file '/var/tmp/tmt/run-007/plans/sanity/prepare/step.yaml'.
    execute
        workdir: /var/tmp/tmt/run-007/plans/sanity/execute
        how: tmt
        order: 50
        exit-first: False
            Write file '/var/tmp/tmt/run-007/plans/sanity/execute/data/tests/commands/request/metadata.yaml'.
            Write file '/var/tmp/tmt/run-007/plans/sanity/execute/data/tests/commands/version/metadata.yaml'.
        Write file '/var/tmp/tmt/run-007/plans/sanity/execute/tmt-file-submit'.
            Back up '/usr/bin/rstrnt-reboot' if present.
            Run command 'podman exec tmt-var-tmp-tmt-run-007-plans-sanity sh -c [ ! -e "/usr/bin/rstrnt-reboot" ]'.
            Run command 'podman exec tmt-var-tmp-tmt-run-007-plans-sanity sh -c cp "/var/tmp/tmt/run-007/plans/sanity/execute/default/reboot_template" "/usr/bin/rstrnt-reboot" && chmod +x "/usr/bin/rstrnt-reboot"'.
            err: Error: can only create exec sessions on running containers: container state improper
            Command returned '255'.
            Remove our reboot script implementations.
            Run command 'podman exec tmt-var-tmp-tmt-run-007-plans-sanity sh -c rm "/usr/bin/rstrnt-reboot"'.
            err: Error: can only create exec sessions on running containers: container state improper
            Command returned '255'.
    finish
        workdir: /var/tmp/tmt/run-007/plans/sanity/finish
            Run command 'podman container stop tmt-var-tmp-tmt-run-007-plans-sanity'.
            out: tmt-var-tmp-tmt-run-007-plans-sanity
        container: stopped
            Run command 'podman container rm -f tmt-var-tmp-tmt-run-007-plans-sanity'.
            out: 0de66e9ef36b875974b0b3e7a92e8f702af38b1c827438351643f9f352f651d9
        container: removed
        summary: 0 tasks completed
        status: done
        Write file '/var/tmp/tmt/run-007/plans/sanity/finish/step.yaml'.

stderr (1/1 lines)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: can only create exec sessions on running containers: container state improper

Failed to run command 'podman exec tmt-var-tmp-tmt-run-007-plans-sanity sh -c rm "/usr/bin/rstrnt-reboot"'. Reason: Command returned '255'.

I believe we should support setting entrypoint in these cases or maybe even force entrypoint to sh? WDYT @lukaszachy @psss ?

lukaszachy commented 2 years ago

I'd say tmt should set entrypoint to bash (as you pointed in #1047) but there should be way for user to keep entrypoint as is (if they know what they are doing) or to set it to their preferred value. TMT will just assume it behaves as if it was unset/set to bash

thrix commented 2 years ago

@lukaszachy agreed, seems like a good step forward. And document tmt right now requires bash in the container to work