Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.15](backport #5346) Improve testing logger #5447

Merged
merged 7 commits into from
Sep 10, 2024
Merged

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Sep 6, 2024

What does this PR do?

Adds a PrettyPrintf method to ObservedLogs to logger.NewTesting

Why is it important?

The testing logger is helpful, however on every failed test it's necessary to manually format the logs before printing. That leads to several tests just printing the logs as they are which isn't the best for reading them and investigating why the test failed.

The new PrettyPrintf method provides an easy way to pretty print the logs

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • [ ] I have added an entry in ./changelog/fragments using the changelog tool
  • [ ] I have added an integration test or an E2E test

Disruptive User Impact

None

How to test this PR locally

run the test TestObservedLogs_PrettyPrintf

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

This is an automatic backport of pull request #5346 done by [Mergify](https://mergify.com).

* add loggertesting package

move logger.NewTesting to loggertesting.New
add loggertesting.PrintObservedLogs to pretty print logs from a observer.ObservedLogs

(cherry picked from commit 0126540)

# Conflicts:
#	internal/pkg/agent/application/upgrade/watcher_test.go
#	pkg/component/runtime/manager_fake_input_test.go
@mergify mergify bot requested a review from a team as a code owner September 6, 2024 06:27
@mergify mergify bot added backport conflicts There is a conflict in the backported pull request labels Sep 6, 2024
@mergify mergify bot requested review from andrzej-stencel and swiatekm and removed request for a team September 6, 2024 06:27
Copy link
Contributor Author

mergify bot commented Sep 6, 2024

Cherry-pick of 0126540 has failed:

On branch mergify/bp/8.15/pr-5346
Your branch is up to date with 'origin/8.15'.

You are currently cherry-picking commit 0126540de0.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   internal/pkg/agent/application/actions/handlers/handler_action_diagnostics_test.go
	modified:   internal/pkg/agent/application/actions/handlers/handler_action_policy_change_test.go
	modified:   internal/pkg/agent/application/actions/handlers/handler_action_settings_test.go
	modified:   internal/pkg/agent/application/apm_config_modifier_test.go
	modified:   internal/pkg/agent/application/application_test.go
	modified:   internal/pkg/agent/application/coordinator/coordinator_unit_test.go
	modified:   internal/pkg/agent/application/dispatcher/dispatcher_test.go
	modified:   internal/pkg/agent/application/gateway/fleet/fleet_gateway_test.go
	modified:   internal/pkg/agent/application/monitoring/reload/reload_test.go
	modified:   internal/pkg/agent/application/upgrade/artifact/config_test.go
	modified:   internal/pkg/agent/application/upgrade/artifact/download/fs/verifier_test.go
	modified:   internal/pkg/agent/application/upgrade/artifact/download/http/downloader_test.go
	modified:   internal/pkg/agent/application/upgrade/artifact/download/snapshot/downloader_test.go
	modified:   internal/pkg/agent/application/upgrade/artifact/download/verifier_test.go
	modified:   internal/pkg/agent/application/upgrade/marker_watcher_test.go
	modified:   internal/pkg/agent/application/upgrade/rollback_test.go
	modified:   internal/pkg/agent/application/upgrade/step_download_test.go
	modified:   internal/pkg/agent/application/upgrade/step_unpack_test.go
	modified:   internal/pkg/agent/application/upgrade/upgrade_test.go
	modified:   internal/pkg/agent/cmd/enroll_cmd_test.go
	modified:   internal/pkg/agent/cmd/watch_test.go
	modified:   internal/pkg/agent/storage/store/migrations_test.go
	modified:   internal/pkg/fleetapi/client/client_test.go
	new file:   pkg/core/logger/loggertest/logger.go
	new file:   pkg/core/logger/loggertest/logger_test.go
	deleted:    pkg/core/logger/testing.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   internal/pkg/agent/application/upgrade/watcher_test.go
	both modified:   pkg/component/runtime/manager_fake_input_test.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Copy link
Contributor Author

mergify bot commented Sep 9, 2024

This pull request has not been merged yet. Could you please review and merge it @AndersonQ? 🙏

Copy link
Contributor Author

mergify bot commented Sep 9, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b mergify/bp/8.15/pr-5346 upstream/mergify/bp/8.15/pr-5346
git merge upstream/8.15
git push upstream mergify/bp/8.15/pr-5346

@AndersonQ AndersonQ removed the conflicts There is a conflict in the backported pull request label Sep 9, 2024
@AndersonQ AndersonQ enabled auto-merge (squash) September 9, 2024 15:52
@AndersonQ AndersonQ requested review from AndersonQ and removed request for andrzej-stencel and swiatekm September 10, 2024 07:03
@AndersonQ AndersonQ merged commit e2e901a into 8.15 Sep 10, 2024
13 checks passed
@AndersonQ AndersonQ deleted the mergify/bp/8.15/pr-5346 branch September 10, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant