Ignore Salt exit codes
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- devops, infrastructure, testing-qa
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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:
- Lenguaje dominante
- Python
- Estrellas
- 2.5k
- Forks
- 360
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pytest-dev/pytest-testinfra
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 58/100
pytest-dev/pytest-testinfra#815 ·
-
service is_enabled does not work with exit code 4Posiblemente ocupada @pfuntner la tomó hace 553 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 45/100
pytest-dev/pytest-testinfra#801 · 1 comentario ·
-
Chroot backendAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
pytest-dev/pytest-testinfra#789 · 1 comentario ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
pytest-dev/pytest-testinfra#788 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
pytest-dev/pytest-testinfra#786 ·
Todos los issues de pytest-dev/pytest-testinfra
Issues similares
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
epam/ai-dial-quickapps-backend#628 ·
Los mantenedores suelen responder en 2 días
-
0xlau.dev 已失效,切换成 timlau.meAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 69/100
timqian/chinese-independent-blogs#2235 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
eclipse-score/coverage_tool#27 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
bojieli/ai-agent-book#1174 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
RedHatQE/mtv-api-tests#721 ·
Los mantenedores suelen responder en 1 día