AssertionError message to nagios output

Đang mở
#588 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
devops, testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Python
Star
2.5k
Fork
358
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pytest-dev/pytest-testinfra

Tất cả issue của pytest-dev/pytest-testinfra

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.