Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwanted login in finish step when login -t is used #1918

Open
lukaszachy opened this issue Mar 14, 2023 · 3 comments · May be fixed by #1933
Open

Unwanted login in finish step when login -t is used #1918

lukaszachy opened this issue Mar 14, 2023 · 3 comments · May be fixed by #1933
Assignees
Labels
command | login The login command used to access the guest

Comments

@lukaszachy
Copy link
Collaborator

The help says: -t. --test Log into the guest after each executed test in the execute phase.

I have plan with one test, run tmt run login -t however there is an additional login in the finish step.

@lukaszachy lukaszachy added the command | login The login command used to access the guest label Mar 14, 2023
@idorax idorax self-assigned this Mar 15, 2023
@idorax
Copy link
Contributor

idorax commented Mar 15, 2023

Hi @lukaszachy, would you please help to paste the fmf file and the CLI, I'd like to help to look into it, thanks!

@lukaszachy
Copy link
Collaborator Author

lukaszachy commented Mar 15, 2023

E.g.

$ cat  reproducer.fmf
/plan:
  execute:
    how: tmt
  provision:
    how: virtual
  discover:
    how: fmf


/test:
  test: echo

And when you do tmt run login -t you see that [root@default-0 tree]# is twice, the later login shouldn't happen IMO (with this commandline, there are options --when or --step which change the situation).

/var/tmp/tmt/run-103

/reproducer/plan
    discover
        how: fmf
        directory: /tmp/r_142617_Vj5
        summary: 1 test selected
    provision
        how: virtual
        user: root
        image: fedora
        memory: 2048 MB
        disk: 40 GB
        arch: x86_64
        progress: booting...
        distro: Fedora Linux 37 (Cloud Edition)
        summary: 1 guest provisioned
    prepare
        summary: 0 preparations applied
    execute
        how: tmt
        progress: /reproducer/test [1/1]        login: Starting interactive shell
[root@default-0 tests]# 
exit
Shared connection to 127.0.0.1 closed.
        login: Interactive shell finished
        summary: 1 test executed        
    report
        how: display
        summary: 1 test passed
    finish
        login: Starting interactive shell
[root@default-0 tree]# 
exit
Shared connection to 127.0.0.1 closed.
        login: Interactive shell finished
        guest: stopped
        guest: removed
        summary: 1 task completed

total: 1 test passed

@idorax
Copy link
Contributor

idorax commented Mar 21, 2023

There are two entrances that invoke Login._login(), one is Login.go(), the other is Login.after_test().

# https://github.com/teemtee/tmt/blob/main/tmt/steps/__init__.py#L1171
  1171	class Login(Action):
  1172	    """ Log into the guest """
  ....<snip>...
  1249	    def go(self) -> None:
  1250	        """ Login to the guest(s) """
  1251	
  1252	        if self._enabled_by_results(self.parent.plan.execute.results()):
  1253	            self._login()
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ....<snip>...
  1295	    def after_test(
  1296	            self,
  1297	            result: 'tmt.base.Result',
  1298	            cwd: Optional[Path] = None,
  1299	            env: Optional[tmt.utils.EnvironmentType] = None) -> None:
  1300	        """ Check and login after test execution """
  1301	        if self._enabled_by_results([result]):
  1302	            self._login(cwd, env)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To fix it,

  • if option -t is used(e.g. tmt run login -t), should cancel to call self._login in Login.go() in Finish step;
  • and if option -t is not used (e.g. tmt run login), should support to call self._login in Login.go() in Finish step.

@idorax idorax linked a pull request Mar 21, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command | login The login command used to access the guest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants