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

stestr run doesn't work from the shell #145

Open
mtreinish opened this issue Feb 23, 2018 · 20 comments
Open

stestr run doesn't work from the shell #145

mtreinish opened this issue Feb 23, 2018 · 20 comments
Labels

Comments

@mtreinish
Copy link
Owner

When trying to us the run command from inside the stestr shell you're not able to. This is due to cmd2 (which is what cliff uses for the interactive shell) having a builtin command run defined. This conflicts with the run command stestr defines, and the cmd2 builtin takes precedence. We'll have to find some way to override that cmd2 builtin to make this work.

@mtreinish mtreinish added the bug label Feb 23, 2018
@masayukig
Copy link
Collaborator

In my local environment, the run command works from the stestr shell(interactive mode) like below.

(stestr) run stestr.tests.test_utils.TestUtils.test_cleanup_test_name_strip_scenario_and_attrs
{0} stestr.tests.test_utils.TestUtils.test_cleanup_test_name_strip_scenario_and_attrs [0.000470s] ... ok

But yeah, I think that conflict should be happened.

@mtreinish
Copy link
Owner Author

Hmm, I only tried running 'run' by itself, without any arguments and I definitely got an error with that.

@masayukig
Copy link
Collaborator

so, I also did it, and it works.. I don't know why.. But I think there is something wrong with the shell mode, anyway.

$ stestr
(stestr) run
{0} stestr.tests.repository.test_file.TestFileRepository.test_initialise [0.002374s] ... ok
<SNIP>
======
Totals
======
Ran: 108 tests in 28.9085 sec.
 - Passed: 106
 - Skipped: 2
 - Expected Fail: 0
 - Unexpected Success: 0
 - Failed: 0
Sum of execute time for each test: 104.9565 sec.

==============
Worker Balance
==============
 - Worker 0 (32 tests) => 0:00:25.821829
 - Worker 1 (32 tests) => 0:00:27.695498
 - Worker 2 (34 tests) => 0:00:24.687430
 - Worker 3 (10 tests) => 0:00:26.987423
(stestr) 

@mtreinish
Copy link
Owner Author

hmm, now it's working for me too. I could have sworn it was failing on me before. I do get an error running help bare now (which definitely wasn't the case before because that's how I fond the conflict):

(stestr) help
ERROR: Invalid syntax: list.remove(x): x not in list

@masayukig
Copy link
Collaborator

heh, same here :-p
It's might depend on libraries version??

@masayukig
Copy link
Collaborator

masayukig commented Feb 26, 2018

It seems something has been changed in cmd2 0.8.0. When I install cmd2 0.7.9, this bug is showed up. And when I use 0.8.0, the behavior is like the above..

<cmd2: 0.8.0>
(stestr) run
help

Shell commands (type help <topic>):
===================================
cmdenvironment  exit  history  py        quit  save  shell      show
edit            help  load     pyscript  run   set   shortcuts

Application commands (type help <topic>):
=========================================
complete  failing  help  init  last  list  load  run  slowest

(stestr) 

@masayukig
Copy link
Collaborator

Oh, run command has been removed in 0.8.0 :)

https://github.com/python-cmd2/cmd2/blob/master/CHANGELOG.md#080-february-1-2018

Commands Removed

    The cmdenvironment has been removed and its functionality incorporated into the -a/--all argument to set
    The show command has been removed. Its functionality has always existing within set and continues to do so
    The save command has been removed. The capability to save commands is now part of the history command.
    The run command has been removed. The capability to run prior commands is now part of the history command.

But load is still an issue..

(stestr) load
NoneType: None
ERROR: load command requires a file path:

@masayukig
Copy link
Collaborator

OK, I'll push a patch for bumping up the cmd2 version to keep the consistent behavior.

@masayukig
Copy link
Collaborator

I pushed the patch for the requirements project https://review.openstack.org/548209
requirements -> cliff -> stestr

@masayukig
Copy link
Collaborator

The patch was merged already. run command should work now. load doesn't yet though.

@mtreinish
Copy link
Owner Author

@masayukig do we need to bump the cliff minimum version or anything to ensure this is in a good state?

@masayukig
Copy link
Collaborator

@mtreinish yeah, I think so. But we can't do it yet because the cmd2>=0.8.0 patch wasn't in the latest cliff release. So, for now, users need to update cmd2 to the latest if the installed version is lower than 0.8.0.

@mtreinish
Copy link
Owner Author

@masayukig is there any update on this. I'm planning to push a 2.4.0 release soon and getting a fix in for this before that would be great.

@masayukig
Copy link
Collaborator

masayukig commented May 21, 2019

In my stestr env, the cmd2 version is already >=0.8.0 which doesn't have run command itself. So, it looks there's no problem in py27.

$ source .tox/py27/bin/activate
(py27) 
$ pip freeze| grep -e cmd2 -e cliff
cliff==2.14.1
cmd2==0.8.9

$ stestr
(stestr) help

Shell commands (type help <topic>):
===================================
alias  exit  history  py        quit  shell      unalias
edit   help  load     pyscript  set   shortcuts

Application commands (type help <topic>):
=========================================
complete  failing  help  init  last  list  load  run  slowest

However, in my py37 env, there's an issue like this..

$ source .tox/py37/bin/activate
(py37) 
$ pip freeze| grep -e cmd2 -e cliff
cliff==2.14.1
cmd2==0.9.12

$ stestr
(stestr) set debug true
debug - was: False
now: True
(stestr) help
Traceback (most recent call last):
  File "/home/masayuki/git/stestr/.tox/py37/lib/python3.7/site-packages/cmd2/cmd2.py", line 1739, in onecmd_plus_hooks
    statement = self.precmd(statement)
  File "/home/masayuki/git/stestr/.tox/py37/lib/python3.7/site-packages/cliff/interactive.py", line 172, in precmd
    statement.command = cmd_name
  File "/home/masayuki/git/stestr/.tox/py37/lib/python3.7/site-packages/attr/_make.py", line 428, in _frozen_setattrs
    raise FrozenInstanceError()
attr.exceptions.FrozenInstanceError
EXCEPTION of type 'FrozenInstanceError' occurred with message: ''
(stestr) 

I changed the cmd2 version to 0.8.9, then there's no problem of 'stestr help` like this. So, I think there is something between 0.8.9 and 0.9.12.

(py37) 
$ pip install cmd2==0.8.9
$ stestr
(stestr) help

Shell commands (type help <topic>):
===================================
alias  exit  history  py        quit  shell      unalias
edit   help  load     pyscript  set   shortcuts

Application commands (type help <topic>):
=========================================
complete  failing  help  init  last  list  load  run  slowest

@mtreinish
Copy link
Owner Author

Should we bump the minimum cliff version to make sure we pull in a new enough cmd2 version?

@masayukig
Copy link
Collaborator

I don't think we should do it because the shell mode doesn't work completely at the latest cliff(cmd2) version now.. :(

Does it work in your environment?

@masayukig
Copy link
Collaborator

So, I think we probably should cap the version like as openstack for now..
https://bugs.launchpad.net/python-cliff/+bug/1810213
https://review.opendev.org/#/c/629269/

@masayukig
Copy link
Collaborator

masayukig commented May 21, 2019

I can't cap the cmd2 version by tox. I actually have no idea for this behavior..

$ git diff
diff --git a/tox.ini b/tox.ini
index 3af11ee..4259004 100644
--- a/tox.ini
+++ b/tox.ini
@@ -8,7 +8,8 @@ usedevelop = True
 install_command = pip install -U --force-reinstall {opts} {packages}
 setenv = VIRTUAL_ENV={envdir}
 whitelist_externals = find
-deps = -r{toxinidir}/requirements.txt
+deps = -c{toxinidir}/upper-constraints.txt
+       -r{toxinidir}/requirements.txt
        -r{toxinidir}/test-requirements.txt
 commands =
     python tools/find_and_rm.py

$ \cat upper-constraints.txt
cmd2===0.8.9
$ tox -e py37 -r
py37 recreate: /home/masayuki/git/stestr/.tox/py37
py37 installdeps: -c/home/masayuki/git/stestr/upper-constraints.txt, -r/home/masayuki/git/stestr/requirements.txt, -r/home/masayuki/git/stestr/test-requirements.txt
py37 develop-inst: /home/masayuki/git/stestr
py37 installed: alabaster==0.7.12,alembic==1.0.10,attrs==19.1.0,Babel==2.6.0,certifi==2019.3.9,chardet==3.0.4,cliff==2.14.1,cmd2==0.9.12,
<SNIP> ..

$ source .tox/py37/bin/activate
(py37) 
$ pip freeze| grep -e cmd2 -e cliff
cliff==2.14.1
cmd2==0.9.12

@mtreinish
Copy link
Owner Author

I think it's because you're using python3. Looking at the requirements for cliff, it only caps <0.9.0 on python2:
https://github.com/openstack/cliff/blob/master/requirements.txt#L5-L6

As for why your constraints file didn't work it looks like you have a typo there, it should be cmd2==0.8.9 not cmd2===0.8.9

@masayukig
Copy link
Collaborator

masayukig commented May 22, 2019

tl;dr
I couldn't find a way to cap the cmd2 version in Python3 so far..


I think it's because you're using python3. Looking at the requirements for cliff, it only caps <0.9.0 on python2:
https://github.com/openstack/cliff/blob/master/requirements.txt#L5-L6

yeah, I see. So, I tried to use -c option with my upper-constraints.txt.

As for why your constraints file didn't work it looks like you have a typo there, it should be cmd2==0.8.9 not cmd2===0.8.9

Oh, really? I copied and pasted the openstack's one.
https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt

cmd2===0.8.9

And it works with the command line like following but not with tox like the above..

$ pip install -U --force-reinstall -c upper-constraints.txt -r requirements.txt -r test-requirements.txt
<SNIP>
$ pip freeze | grep -e cmd2 -e cliff
cliff==2.14.1
cmd2==0.8.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants