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
Fix test_ssh_kwargs to not access /etc/salt/pki #61178
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bdrung
force-pushed
the
fix-test_ssh_kwargs
branch
from
November 3, 2021 13:03
b38509a
to
ad6e83c
Compare
MKLeb
previously approved these changes
Nov 10, 2021
bdrung
force-pushed
the
fix-test_ssh_kwargs
branch
from
November 11, 2021 09:58
ad6e83c
to
091f892
Compare
Just rebased on master. |
Running the SSH unit tests without root permission fails: ``` $ python3 -m pytest tests/pytests/unit/client/ssh/test_ssh.py [...] Traceback (most recent call last): File "salt/client/ssh/__init__.py", line 264, in __init__ salt.client.ssh.shell.gen_key(priv) File "salt/client/ssh/shell.py", line 36, in gen_key os.makedirs(os.path.dirname(path)) File "/usr/lib/python3.9/os.py", line 215, in makedirs makedirs(head, exist_ok=exist_ok) File "/usr/lib/python3.9/os.py", line 215, in makedirs makedirs(head, exist_ok=exist_ok) File "/usr/lib/python3.9/os.py", line 225, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/etc/salt/pki' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "tests/pytests/unit/client/ssh/test_ssh.py", line 134, in test_ssh_kwargs ssh_obj = client._prep_ssh(**opts) File "salt/client/ssh/client.py", line 125, in _prep_ssh return salt.client.ssh.SSH(opts) File "salt/client/ssh/__init__.py", line 266, in __init__ raise salt.exceptions.SaltClientError( salt.exceptions.SaltClientError: salt-ssh could not be run because it could not generate keys. ``` Changing the accessed directories to temporary directories would be a solution: ```python client.opts["pki_dir"] = tmpdir.join("pki").strpath client.opts["cachedir"] = tmpdir.join("cache").strpath ``` But running the 38 tests takes 130 seconds on an Intel Core i7-8850H CPU @ 2.60GHz. So mock all functions and methods that try to write to the pki or cache directory. Then the tests will succeed in a few seconds. Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
bdrung
force-pushed
the
fix-test_ssh_kwargs
branch
from
December 11, 2021 14:35
091f892
to
250b53c
Compare
Rebased on master. |
Ch3LL
approved these changes
Dec 16, 2021
bdrung
added a commit
to bdrung/salt
that referenced
this pull request
Apr 15, 2022
Running the SSH unit tests without root permission fails: ``` $ python3 -m pytest tests/pytests/unit/client/ssh/test_ssh.py [...] Traceback (most recent call last): File "salt/client/ssh/__init__.py", line 264, in __init__ salt.client.ssh.shell.gen_key(priv) File "salt/client/ssh/shell.py", line 36, in gen_key os.makedirs(os.path.dirname(path)) File "/usr/lib/python3.9/os.py", line 215, in makedirs makedirs(head, exist_ok=exist_ok) File "/usr/lib/python3.9/os.py", line 215, in makedirs makedirs(head, exist_ok=exist_ok) File "/usr/lib/python3.9/os.py", line 225, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/etc/salt/pki' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "tests/pytests/unit/client/ssh/test_ssh.py", line 134, in test_ssh_kwargs ssh_obj = client._prep_ssh(**opts) File "salt/client/ssh/client.py", line 125, in _prep_ssh return salt.client.ssh.SSH(opts) File "salt/client/ssh/__init__.py", line 266, in __init__ raise salt.exceptions.SaltClientError( salt.exceptions.SaltClientError: salt-ssh could not be run because it could not generate keys. ``` Changing the accessed directories to temporary directories would be a solution: ```python client.opts["pki_dir"] = tmpdir.join("pki").strpath client.opts["cachedir"] = tmpdir.join("cache").strpath ``` But running the 38 tests takes 130 seconds on an Intel Core i7-8850H CPU @ 2.60GHz. So mock all functions and methods that try to write to the pki or cache directory. Then the tests will succeed in a few seconds. Forwarded: saltstack#61178 Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
bdrung
added a commit
to bdrung/salt
that referenced
this pull request
Apr 16, 2022
Running the SSH unit tests without root permission fails: ``` $ python3 -m pytest tests/pytests/unit/client/ssh/test_ssh.py [...] Traceback (most recent call last): File "salt/client/ssh/__init__.py", line 264, in __init__ salt.client.ssh.shell.gen_key(priv) File "salt/client/ssh/shell.py", line 36, in gen_key os.makedirs(os.path.dirname(path)) File "/usr/lib/python3.9/os.py", line 215, in makedirs makedirs(head, exist_ok=exist_ok) File "/usr/lib/python3.9/os.py", line 215, in makedirs makedirs(head, exist_ok=exist_ok) File "/usr/lib/python3.9/os.py", line 225, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/etc/salt/pki' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "tests/pytests/unit/client/ssh/test_ssh.py", line 134, in test_ssh_kwargs ssh_obj = client._prep_ssh(**opts) File "salt/client/ssh/client.py", line 125, in _prep_ssh return salt.client.ssh.SSH(opts) File "salt/client/ssh/__init__.py", line 266, in __init__ raise salt.exceptions.SaltClientError( salt.exceptions.SaltClientError: salt-ssh could not be run because it could not generate keys. ``` Changing the accessed directories to temporary directories would be a solution: ```python client.opts["pki_dir"] = tmpdir.join("pki").strpath client.opts["cachedir"] = tmpdir.join("cache").strpath ``` But running the 38 tests takes 130 seconds on an Intel Core i7-8850H CPU @ 2.60GHz. So mock all functions and methods that try to write to the pki or cache directory. Then the tests will succeed in a few seconds. Forwarded: saltstack#61178 Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Running the SSH unit tests without root permission fails:
Changing the accessed directories to temporary directories would be a solution:
But running the 38 tests takes 130 seconds on an Intel Core i7-8850H CPU @ 2.60GHz. So mock all functions and methods that try to write to the pki or cache directory. Then the tests will succeed in a few seconds.