Ignore Salt exit codes
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 48/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- python
調査の方向性
Start by reading testinfra/modules/salt.py around the Salt module call and host.py at the referenced check_output implementation. Check the existing run_expect documentation for related behavior, then determine how accepted exit codes should be represented so Salt results can be analyzed; done means the reported valid codes no longer abort the test and coverage verifies the behavior.
索引モデルが issue の本文から書いたものです。
説明
Hi,
I wrote a test like the following:
def test_salt_state_apply_test(host):
result = host.salt('state.apply', ['suse_ha', 'test=True'])
changed, changes = find_changes(result, True)
assert changed
The Salt command returns exit code 1 (or 2, with --retcode-passthrough) - this is expected by me, and I further analyze the validity of the result using my custom logic (find_changes, in this example).
However, Pytest does not execute my logic, as it immediately aborts the test after host.salt returns:
def test_salt_state_apply_test(host):
> result = host.salt('state.apply', ['suse_ha', 'test=True'])
suse_ha-formula/tests/test_00_salt.py:40:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.10/site-packages/testinfra/modules/salt.py:49: in __call__
return json.loads(self.check_output(cmd, *cmd_args))["local"]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'testinfra.modules.base.Salt'>, args = ('salt-call --out=json %s %s %s', 'state.apply', 'suse_ha', 'test=True'), kwargs = {}
@classmethod
def check_output(cls, *args, **kwargs):
> return cls._host.check_output(*args, **kwargs)
< lots of output from Salt >
FAILED suse_ha-formula/tests/test_00_salt.py::test_salt_state_apply_test[paramiko://test-ha-minion-01] - AssertionError: Unexpected exit code 1 for CommandResult(command=b"sudo /bin/sh -c 'salt-call --out=json state.apply suse_ha test=True'", exit_status=1, stdout=b'{\n "local"...
Is there a way to ignore or whitelist "bad" exit codes and to continue my test function?
I only found run_expect in the documentation, but would preferably continue using the Salt module.
It seems the issue is with check_output having 0 defined as its only acceptable return code:
- 主要言語
- Python
- スター
- 2.5k
- フォーク
- 360
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pytest-dev/pytest-testinfra のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 58/100
pytest-dev/pytest-testinfra#815 ·
-
service is_enabled does not work with exit code 4対応中かも @pfuntner が 553 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
pytest-dev/pytest-testinfra#801 · コメント 1 件 ·
-
Chroot backendオープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
pytest-dev/pytest-testinfra#789 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
pytest-dev/pytest-testinfra#788 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
pytest-dev/pytest-testinfra#786 ·
pytest-dev/pytest-testinfra の issue をすべて見る
似ている issue
-
bug ready for review
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
odysseus-dev/odysseus#6641 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
happypawspillaro/happypaws#78 ·
メンテナーはふだん 4 日以内に返信
-
pydanty:is-working
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
pydantic/pydantic-ai#10020 ·
メンテナーはふだん 1 日以内に返信
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ansible-collections/ibm_zos_core#2650 ·
-
hw: pvc tests: vllm vllm
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
intel/intel-xpu-backend-for-triton#8362 ·
メンテナーはふだん 1 日以内に返信