Skip to content

Restore behaviour of not having test logs on stdout/stderr by default #329

@belimawr

Description

@belimawr

With the refactoring to use global loggers, logp has changed behaviour and now tests that use a testing logger, like logptest.NewTestingLogger. Making the output of go test -v pretty much unreadable, it is not possible to see the tests that are running and the time they took.

As an example, let's get Filebeat Filestream's tests, from Beats root:

cd filebeat/input/filestream
git checkout v9.0.0
go test -v -count=1

The output is a clear list of all the tests run and the time they took. It's 208 lines long.

output

% go test -v -count=1
=== RUN   TestConfigValidate
=== RUN   TestConfigValidate/paths_cannot_be_empty
--- PASS: TestConfigValidate (0.00s)
    --- PASS: TestConfigValidate/paths_cannot_be_empty (0.00s)
=== RUN   TestValidateInputIDs
=== RUN   TestValidateInputIDs/empty_config
=== RUN   TestValidateInputIDs/one_empty_ID_is_allowed
=== RUN   TestValidateInputIDs/duplicated_empty_ID
=== RUN   TestValidateInputIDs/duplicated_IDs
=== RUN   TestValidateInputIDs/duplicated_IDs_and_empty_ID
=== RUN   TestValidateInputIDs/only_unique_IDs
--- PASS: TestValidateInputIDs (0.00s)
    --- PASS: TestValidateInputIDs/empty_config (0.00s)
    --- PASS: TestValidateInputIDs/one_empty_ID_is_allowed (0.00s)
    --- PASS: TestValidateInputIDs/duplicated_empty_ID (0.00s)
    --- PASS: TestValidateInputIDs/duplicated_IDs (0.00s)
    --- PASS: TestValidateInputIDs/duplicated_IDs_and_empty_ID (0.00s)
    --- PASS: TestValidateInputIDs/only_unique_IDs (0.00s)
=== RUN   TestCopyTruncateProspector_Create
=== RUN   TestCopyTruncateProspector_Create/first_rotated_file,_when_rotated_file_not_exist
=== RUN   TestCopyTruncateProspector_Create/one_new_file,_then_rotated
=== RUN   TestCopyTruncateProspector_Create/one_new_file,_then_rotated_twice_in_order
=== RUN   TestCopyTruncateProspector_Create/one_new_file,_then_rotated_twice_with_renaming
--- PASS: TestCopyTruncateProspector_Create (0.00s)
    --- PASS: TestCopyTruncateProspector_Create/first_rotated_file,_when_rotated_file_not_exist (0.00s)
    --- PASS: TestCopyTruncateProspector_Create/one_new_file,_then_rotated (0.00s)
    --- PASS: TestCopyTruncateProspector_Create/one_new_file,_then_rotated_twice_in_order (0.00s)
    --- PASS: TestCopyTruncateProspector_Create/one_new_file,_then_rotated_twice_with_renaming (0.00s)
=== RUN   TestNumericSorter
=== RUN   TestNumericSorter/one_fileinfo
=== RUN   TestNumericSorter/ordered_fileinfos
=== RUN   TestNumericSorter/unordered_fileinfos
=== RUN   TestNumericSorter/unordered_fileinfos_with_numbers_in_filename
--- PASS: TestNumericSorter (0.00s)
    --- PASS: TestNumericSorter/one_fileinfo (0.00s)
    --- PASS: TestNumericSorter/ordered_fileinfos (0.00s)
    --- PASS: TestNumericSorter/unordered_fileinfos (0.00s)
    --- PASS: TestNumericSorter/unordered_fileinfos_with_numbers_in_filename (0.00s)
=== RUN   TestDateSorter
=== RUN   TestDateSorter/one_fileinfo
=== RUN   TestDateSorter/ordered_fileinfos
=== RUN   TestDateSorter/unordered_fileinfos
--- PASS: TestDateSorter (0.00s)
    --- PASS: TestDateSorter/one_fileinfo (0.00s)
    --- PASS: TestDateSorter/ordered_fileinfos (0.00s)
    --- PASS: TestDateSorter/unordered_fileinfos (0.00s)
=== RUN   TestLogFileTimedClosing
=== RUN   TestLogFileTimedClosing/read_from_file_and_close_on_EOF
=== RUN   TestLogFileTimedClosing/read_from_file_and_close_inactive
=== RUN   TestLogFileTimedClosing/read_from_file_and_close_after_interval
--- PASS: TestLogFileTimedClosing (5.04s)
    --- PASS: TestLogFileTimedClosing/read_from_file_and_close_on_EOF (0.00s)
    --- PASS: TestLogFileTimedClosing/read_from_file_and_close_inactive (2.00s)
    --- PASS: TestLogFileTimedClosing/read_from_file_and_close_after_interval (3.04s)
=== RUN   TestLogFileTruncated
--- PASS: TestLogFileTruncated (0.00s)
=== RUN   TestFileWatcher
=== RUN   TestFileWatcher/detects_a_new_file
=== RUN   TestFileWatcher/detects_a_file_write
=== RUN   TestFileWatcher/detects_a_file_rename
=== RUN   TestFileWatcher/detects_a_file_truncate
=== RUN   TestFileWatcher/emits_truncate_on_touch_when_resend_on_touch_is_enabled
=== RUN   TestFileWatcher/detects_a_file_remove
=== RUN   TestFileWatcher/propagates_a_fingerprints_for_a_new_file
=== RUN   TestFileWatcher/does_not_emit_events_if_a_file_is_touched_and_resend_on_touch_is_disabled
=== RUN   TestFileWatcher/does_not_emit_events_for_empty_files
=== RUN   TestFileWatcher/does_not_emit_events_for_empty_files/issues_a_debug_message_in_logs
=== RUN   TestFileWatcher/does_not_emit_events_for_empty_files/emits_a_create_event_once_something_is_written_to_the_empty_file
=== RUN   TestFileWatcher/does_not_emit_an_event_for_a_fingerprint_collision
=== RUN   TestFileWatcher/does_not_log_warnings_on_duplicate_globs_and_filters_out_duplicates
--- PASS: TestFileWatcher (1.65s)
    --- PASS: TestFileWatcher/detects_a_new_file (0.00s)
    --- PASS: TestFileWatcher/detects_a_file_write (0.10s)
    --- PASS: TestFileWatcher/detects_a_file_rename (0.10s)
    --- PASS: TestFileWatcher/detects_a_file_truncate (0.10s)
    --- PASS: TestFileWatcher/emits_truncate_on_touch_when_resend_on_touch_is_enabled (0.10s)
    --- PASS: TestFileWatcher/detects_a_file_remove (0.10s)
    --- PASS: TestFileWatcher/propagates_a_fingerprints_for_a_new_file (0.00s)
    --- PASS: TestFileWatcher/does_not_emit_events_if_a_file_is_touched_and_resend_on_touch_is_disabled (1.00s)
    --- PASS: TestFileWatcher/does_not_emit_events_for_empty_files (0.05s)
        --- PASS: TestFileWatcher/does_not_emit_events_for_empty_files/issues_a_debug_message_in_logs (0.01s)
        --- PASS: TestFileWatcher/does_not_emit_events_for_empty_files/emits_a_create_event_once_something_is_written_to_the_empty_file (0.04s)
    --- PASS: TestFileWatcher/does_not_emit_an_event_for_a_fingerprint_collision (0.10s)
    --- PASS: TestFileWatcher/does_not_log_warnings_on_duplicate_globs_and_filters_out_duplicates (0.00s)
=== RUN   TestFileScanner
=== RUN   TestFileScanner/returns_all_files_when_no_limits,_not_including_the_repeated_symlink
=== RUN   TestFileScanner/returns_filtered_files,_excluding_symlinks
=== RUN   TestFileScanner/returns_files_according_to_excluded_list
=== RUN   TestFileScanner/returns_no_symlink_if_the_original_file_is_excluded
=== RUN   TestFileScanner/returns_files_according_to_included_list
=== RUN   TestFileScanner/returns_no_included_symlink_if_the_original_file_is_not_included
=== RUN   TestFileScanner/returns_an_included_symlink_if_the_original_file_is_included
=== RUN   TestFileScanner/returns_all_files_except_too_small_to_fingerprint
=== RUN   TestFileScanner/returns_all_files_that_match_a_non-standard_fingerprint_window
=== RUN   TestFileScanner/does_not_issue_warnings_when_file_is_too_small
=== RUN   TestFileScanner/returns_error_when_creating_scanner_with_a_fingerprint_too_small
--- PASS: TestFileScanner (0.00s)
    --- PASS: TestFileScanner/returns_all_files_when_no_limits,_not_including_the_repeated_symlink (0.00s)
    --- PASS: TestFileScanner/returns_filtered_files,_excluding_symlinks (0.00s)
    --- PASS: TestFileScanner/returns_files_according_to_excluded_list (0.00s)
    --- PASS: TestFileScanner/returns_no_symlink_if_the_original_file_is_excluded (0.00s)
    --- PASS: TestFileScanner/returns_files_according_to_included_list (0.00s)
    --- PASS: TestFileScanner/returns_no_included_symlink_if_the_original_file_is_not_included (0.00s)
    --- PASS: TestFileScanner/returns_an_included_symlink_if_the_original_file_is_included (0.00s)
    --- PASS: TestFileScanner/returns_all_files_except_too_small_to_fingerprint (0.00s)
    --- PASS: TestFileScanner/returns_all_files_that_match_a_non-standard_fingerprint_window (0.00s)
    --- PASS: TestFileScanner/does_not_issue_warnings_when_file_is_too_small (0.00s)
    --- PASS: TestFileScanner/returns_error_when_creating_scanner_with_a_fingerprint_too_small (0.00s)
=== RUN   TestFileIdentifier
=== RUN   TestFileIdentifier/native_file_identifier
=== RUN   TestFileIdentifier/native_file_identifier_with_suffix
=== RUN   TestFileIdentifier/path_identifier
=== RUN   TestFileIdentifier/fingerprint_identifier
--- PASS: TestFileIdentifier (0.00s)
    --- PASS: TestFileIdentifier/native_file_identifier (0.00s)
    --- PASS: TestFileIdentifier/native_file_identifier_with_suffix (0.00s)
    --- PASS: TestFileIdentifier/path_identifier (0.00s)
    --- PASS: TestFileIdentifier/fingerprint_identifier (0.00s)
=== RUN   TestTakeOverTags
=== RUN   TestTakeOverTags/test-take_over-true
=== RUN   TestTakeOverTags/test-take_over-false
--- PASS: TestTakeOverTags (0.00s)
    --- PASS: TestTakeOverTags/test-take_over-true (0.00s)
    --- PASS: TestTakeOverTags/test-take_over-false (0.00s)
=== RUN   TestCreateProspector
=== RUN   TestCreateProspector/SetIgnoreInactiveSince
=== RUN   TestCreateProspector/SetIgnoreInactiveSince/ignore_inactive_since_set_to_since_last_start
=== RUN   TestCreateProspector/SetIgnoreInactiveSince/ignore_inactive_since_set_to_since_first_start
=== RUN   TestCreateProspector/SetIgnoreInactiveSince/ignore_inactive_since_not_set
=== RUN   TestCreateProspector/file_watcher_and_file_identity_compatibility
=== RUN   TestCreateProspector/file_watcher_and_file_identity_compatibility/returns_no_error_for_a_fully_default_config
=== RUN   TestCreateProspector/file_watcher_and_file_identity_compatibility/returns_no_error_when_fingerprint_and_identity_is_configured
=== RUN   TestCreateProspector/file_watcher_and_file_identity_compatibility/returns_no_error_when_fingerprint_and_other_identity_is_configured
=== RUN   TestCreateProspector/file_watcher_and_file_identity_compatibility/returns_error_when_fingerprint_is_disabled_but_fingerprint_identity_is_configured
--- PASS: TestCreateProspector (0.00s)
    --- PASS: TestCreateProspector/SetIgnoreInactiveSince (0.00s)
        --- PASS: TestCreateProspector/SetIgnoreInactiveSince/ignore_inactive_since_set_to_since_last_start (0.00s)
        --- PASS: TestCreateProspector/SetIgnoreInactiveSince/ignore_inactive_since_set_to_since_first_start (0.00s)
        --- PASS: TestCreateProspector/SetIgnoreInactiveSince/ignore_inactive_since_not_set (0.00s)
    --- PASS: TestCreateProspector/file_watcher_and_file_identity_compatibility (0.00s)
        --- PASS: TestCreateProspector/file_watcher_and_file_identity_compatibility/returns_no_error_for_a_fully_default_config (0.00s)
        --- PASS: TestCreateProspector/file_watcher_and_file_identity_compatibility/returns_no_error_when_fingerprint_and_identity_is_configured (0.00s)
        --- PASS: TestCreateProspector/file_watcher_and_file_identity_compatibility/returns_no_error_when_fingerprint_and_other_identity_is_configured (0.00s)
        --- PASS: TestCreateProspector/file_watcher_and_file_identity_compatibility/returns_error_when_fingerprint_is_disabled_but_fingerprint_identity_is_configured (0.00s)
=== RUN   TestProspector_InitCleanIfRemoved
=== RUN   TestProspector_InitCleanIfRemoved/prospector_init_with_clean_removed_enabled_with_no_entries
=== RUN   TestProspector_InitCleanIfRemoved/prospector_init_with_clean_removed_disabled_with_entries
=== RUN   TestProspector_InitCleanIfRemoved/prospector_init_with_clean_removed_enabled_with_entries
--- PASS: TestProspector_InitCleanIfRemoved (0.00s)
    --- PASS: TestProspector_InitCleanIfRemoved/prospector_init_with_clean_removed_enabled_with_no_entries (0.00s)
    --- PASS: TestProspector_InitCleanIfRemoved/prospector_init_with_clean_removed_disabled_with_entries (0.00s)
    --- PASS: TestProspector_InitCleanIfRemoved/prospector_init_with_clean_removed_enabled_with_entries (0.00s)
=== RUN   TestProspector_InitUpdateIdentifiers
=== RUN   TestProspector_InitUpdateIdentifiers/prospector_init_does_not_update_keys_if_there_are_no_entries
=== RUN   TestProspector_InitUpdateIdentifiers/prospector_init_does_not_update_keys_of_not_existing_files
=== RUN   TestProspector_InitUpdateIdentifiers/prospector_init_does_not_update_keys_if_new_file_identity_is_not_fingerprint
--- PASS: TestProspector_InitUpdateIdentifiers (0.00s)
    --- PASS: TestProspector_InitUpdateIdentifiers/prospector_init_does_not_update_keys_if_there_are_no_entries (0.00s)
    --- PASS: TestProspector_InitUpdateIdentifiers/prospector_init_does_not_update_keys_of_not_existing_files (0.00s)
    --- PASS: TestProspector_InitUpdateIdentifiers/prospector_init_does_not_update_keys_if_new_file_identity_is_not_fingerprint (0.00s)
=== RUN   TestMigrateRegistryToFingerprint
=== RUN   TestMigrateRegistryToFingerprint/fingerprint_to_native_fails
=== RUN   TestMigrateRegistryToFingerprint/path_to_native_fails
=== RUN   TestMigrateRegistryToFingerprint/inode_to_fingerprint_succeeds
=== RUN   TestMigrateRegistryToFingerprint/path_to_fingerprint_succeeds
=== RUN   TestMigrateRegistryToFingerprint/fingerprint_to_fingerprint_fails
--- PASS: TestMigrateRegistryToFingerprint (0.00s)
    --- PASS: TestMigrateRegistryToFingerprint/fingerprint_to_native_fails (0.00s)
    --- PASS: TestMigrateRegistryToFingerprint/path_to_native_fails (0.00s)
    --- PASS: TestMigrateRegistryToFingerprint/inode_to_fingerprint_succeeds (0.00s)
    --- PASS: TestMigrateRegistryToFingerprint/path_to_fingerprint_succeeds (0.00s)
    --- PASS: TestMigrateRegistryToFingerprint/fingerprint_to_fingerprint_fails (0.00s)
=== RUN   TestProspectorNewAndUpdatedFiles
=== RUN   TestProspectorNewAndUpdatedFiles/two_new_files
=== RUN   TestProspectorNewAndUpdatedFiles/one_updated_file
=== RUN   TestProspectorNewAndUpdatedFiles/one_updated_then_truncated_file
=== RUN   TestProspectorNewAndUpdatedFiles/old_files_with_ignore_older_configured
=== RUN   TestProspectorNewAndUpdatedFiles/newer_files_with_ignore_older
--- PASS: TestProspectorNewAndUpdatedFiles (0.00s)
    --- PASS: TestProspectorNewAndUpdatedFiles/two_new_files (0.00s)
    --- PASS: TestProspectorNewAndUpdatedFiles/one_updated_file (0.00s)
    --- PASS: TestProspectorNewAndUpdatedFiles/one_updated_then_truncated_file (0.00s)
    --- PASS: TestProspectorNewAndUpdatedFiles/old_files_with_ignore_older_configured (0.00s)
    --- PASS: TestProspectorNewAndUpdatedFiles/newer_files_with_ignore_older (0.00s)
=== RUN   TestProspectorHarvesterUpdateIgnoredFiles
--- PASS: TestProspectorHarvesterUpdateIgnoredFiles (0.02s)
=== RUN   TestProspectorDeletedFile
=== RUN   TestProspectorDeletedFile/one_deleted_file_without_clean_removed
=== RUN   TestProspectorDeletedFile/one_deleted_file_with_clean_removed
--- PASS: TestProspectorDeletedFile (0.00s)
    --- PASS: TestProspectorDeletedFile/one_deleted_file_without_clean_removed (0.00s)
    --- PASS: TestProspectorDeletedFile/one_deleted_file_with_clean_removed (0.00s)
=== RUN   TestProspectorRenamedFile
=== RUN   TestProspectorRenamedFile/one_renamed_file_without_rename_tracker
=== RUN   TestProspectorRenamedFile/one_renamed_file_with_rename_tracker
=== RUN   TestProspectorRenamedFile/one_renamed_file_with_rename_tracker_with_close_renamed
--- PASS: TestProspectorRenamedFile (0.00s)
    --- PASS: TestProspectorRenamedFile/one_renamed_file_without_rename_tracker (0.00s)
    --- PASS: TestProspectorRenamedFile/one_renamed_file_with_rename_tracker (0.00s)
    --- PASS: TestProspectorRenamedFile/one_renamed_file_with_rename_tracker_with_close_renamed (0.00s)
=== RUN   TestOnRenameFileIdentity
=== RUN   TestOnRenameFileIdentity/identifier_name_from_meta_is_kept
=== RUN   TestOnRenameFileIdentity/identifier_from_prospector_is_used
--- PASS: TestOnRenameFileIdentity (0.00s)
    --- PASS: TestOnRenameFileIdentity/identifier_name_from_meta_is_kept (0.00s)
    --- PASS: TestOnRenameFileIdentity/identifier_from_prospector_is_used (0.00s)
PASS
ok      github.com/elastic/beats/v7/filebeat/input/filestream   6.756s

However the same thing ran on main outputs 837 119 lines, that's 125Mb.

git checkout main
go test -v -count=1

This output is just too large to be of any use and it is impossible to see which tests were run.

Another problem of the new behaviour is printing the stack trace at error level by default, this makes the output look like a panic, which can be very confusing.

Proposal

Revert to the previous behaviour (like from v0.18.9) of not having development/test loggers logging to stdout/err and do not print the stack trace at level error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions