AssertionError message to nagios output

Abierto
#588 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
devops, testing

Línea de trabajo

Start with the pytest command using the --nagios option and compare its output with the same command without --nagios, using the shown AssertionError case. Trace how the assertion message is handled for the Nagios result and verify that the failing test's message appears in the final Nagios output while the pass/fail summary remains intact.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Hello I have a simple test where I print the filename if the file exists.

/home/nagios/monitoring-env/bin/pytest -v -s -qq --nagios --tb long --inputfile=test.txt /usr/local/ncpa/plugins/test_myinfra.py

input file: test.txt
File Found: '/usr/local/ncpa/plugins/test.txt'
TESTINFRA OK - 1 passed, 0 failed, 0 skipped in 0.06 seconds

In nagios I do see the print statement: File Found: '/usr/local/ncpa/plugins/test.txt'

I have a simple assert in my code;
assert len(list_match)==1 , " File NOT Found:" + str(list_match).strip('[]')

If i run the test without nagios I do see the AssertionError

/home/nagios/monitoring-env/bin/pytest -v -s --inputfile=test.txt /usr/local/ncpa/plugins/test_myinfra.py

E       AssertionError: File NOT Found: '/usr/local/ncpa/plugins/test.txt'

TESTINFRA CRITICAL - 0 passed, 1 failed, 0 skipped in 0.10 seconds

How can I have the AssertionError message displayed in Nagios when running the command below?

/home/nagios/monitoring-env/bin/pytest -v -s -qq --nagios --tb long --inputfile=test.txt /usr/local/ncpa/plugins/test_myinfra.py
TESTINFRA CRITICAL - 0 passed, 1 failed, 0 skipped in 0.06 seconds
Lenguaje dominante
Python
Estrellas
2.5k
Forks
359
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pytest-dev/pytest-testinfra

Todos los issues de pytest-dev/pytest-testinfra

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.