Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Stop destroying test output with automatic logging #569

Merged
merged 16 commits into from
Apr 11, 2022

Conversation

sarayourfriend
Copy link
Contributor

Fixes

Fixes #520 by @sarayourfriend

Description

Stops the destructive logging we were doing but maintains helpful-for-debugging logs in CI.

Testing Instructions

Run just api-testlocal with some tests that will fail (assert True is False) and confirm that it does not log away the test output locally.

I'll push a commit with a failing test to confirm that it does still log in CI

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • [N/A] I added or updated tests for the changes I made (if applicable).
  • [N/A] I added or updated documentation (if applicable).
  • [x[ I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@dhruvkb dhruvkb added ✨ goal: improvement Improvement to an existing user-facing feature 🟩 priority: low Low priority and doesn't need to be rushed 🤖 aspect: dx Concerns developers' experience with the codebase labels Mar 15, 2022
Copy link
Contributor

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one note on the GHA flow


- name: Print API test failure logs
if: {{ failure() }}
run: just logs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this stop as well, since the previous step failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to try debugging whether you have to explicitly exit 1 or something or if the if: {{ failure() }} runs just the "failure" jobs and ignores the rest.

@@ -18,8 +18,7 @@ succeeded=$?
if [[ $succeeded -eq 0 ]]; then
printf "${green}:-) All tests passed${endcol}\n"
else
printf "Full system logs:\n"
docker-compose logs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So apparently this has never worked for just api-test because docker-compose isn't available within the container 🙃

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, I use api-testlocal because it's easier to interface with pdb than having to docker attach openverse-web-1 or whatever.

@sarayourfriend sarayourfriend marked this pull request as ready for review March 16, 2022 12:12
@sarayourfriend sarayourfriend requested a review from a team as a code owner March 16, 2022 12:12
@sarayourfriend
Copy link
Contributor Author

Just marking ready for review to test CI but it's still not confirmed to be working.

@sarayourfriend sarayourfriend changed the title Stop destroying test output with automatic logging [WIP] Stop destroying test output with automatic logging Mar 16, 2022
@sarayourfriend
Copy link
Contributor Author

Apparently printing the API test logs times out the GitHub actions 💀

I think it'd be best to pipe them to a file and then upload them as an artifact.

@sarayourfriend
Copy link
Contributor Author

Nope, I was wrong. The logs are automatically followed by the justfile. Removing the -f default.

justfile Outdated
@@ -44,7 +44,7 @@ recreate:
@just up "--force-recreate --build"

# Show logs of all, or named, Docker services
logs services="" args="-f":
logs services="" args="":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this change, as it'll mean having to specify -f every time I run this locally 😕

Could we perhaps have this function similar to the IS_PROD flag, maybe with IS_CI, and that automatically removes the -f?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that'd be good! We could use the same IS_CI flag to automatically add -T to the other docker-compose commands as well to avoid having to remember that when adding new actions 🎉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great point!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarayourfriend if you're okay with it, I can work on adding IS_CI to this branch 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's up now, thanks though.

@zackkrida
Copy link
Member

@obulat could you look at this PR this week?

@sarayourfriend sarayourfriend force-pushed the remove/local-logging-test-failure branch from 9fb2bcf to 39cad50 Compare April 4, 2022 05:34
@sarayourfriend
Copy link
Contributor Author

Rebasing this so the actions actually run and we can verify they work 👍

@sarayourfriend sarayourfriend force-pushed the remove/local-logging-test-failure branch from cc4c242 to de045ca Compare April 5, 2022 06:05
@sarayourfriend sarayourfriend mentioned this pull request Apr 5, 2022
7 tasks
Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also export the logs as an artifact? Having the logs locally to scan through would be massively helpful because the GitHub Actions UI is not that good imo.

Also the PR says "[WIP]" in the title, confirming if that is still the case.

@sarayourfriend sarayourfriend force-pushed the remove/local-logging-test-failure branch from de045ca to 1594292 Compare April 6, 2022 04:45
@sarayourfriend
Copy link
Contributor Author

@dhruvkb Sure, I actually did at one point upload them as an artifact. I've put it back now. Will remove the WIP once the actions are passing as expected.

@dhruvkb
Copy link
Member

dhruvkb commented Apr 6, 2022

Feel free to use any code regarding logs from 0283304 (now removed from the other PR).

@sarayourfriend
Copy link
Contributor Author

@dhruvkb TIL you can download the raw output of actions:

image

Uploading the logs as an artifact still makes sense though because the raw output includes control characters for color output and makes it very annoying to read 😒

@sarayourfriend sarayourfriend changed the title [WIP] Stop destroying test output with automatic logging Stop destroying test output with automatic logging Apr 6, 2022
@sarayourfriend
Copy link
Contributor Author

This is ready for review now @AetherUnbound @dhruvkb @obulat

@@ -44,7 +46,7 @@ recreate:
@just up "--force-recreate --build"

# Show logs of all, or named, Docker services
logs services="" args="-f":
logs services="" args=(if IS_CI != "" { "" } else { "-f" }):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woah, TIL! Very cool

@@ -1,5 +1,7 @@
set dotenv-load := false

IS_CI := env_var_or_default("CI", "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL here as well! This is great

@@ -1,5 +1,7 @@
set dotenv-load := false

IS_CI := env_var_or_default("CI", "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL here as well! This is great

Copy link
Contributor

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it! ✨ 🚀
Small nit: for the API, the steps are print -> upload, but for the ingestion server they're upload -> print. It might be good for consistency to have these both be either one or the other.

@sarayourfriend sarayourfriend enabled auto-merge (squash) April 7, 2022 08:27
Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few suggestions:

.github/workflows/ci_cd.yml Show resolved Hide resolved
api/test/run_test.sh Show resolved Hide resolved
api/test/run_test.sh Outdated Show resolved Hide resolved
@sarayourfriend sarayourfriend requested a review from dhruvkb April 11, 2022 06:52
@sarayourfriend sarayourfriend merged commit d2bc44c into main Apr 11, 2022
@sarayourfriend sarayourfriend deleted the remove/local-logging-test-failure branch April 11, 2022 09:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤖 aspect: dx Concerns developers' experience with the codebase ✨ goal: improvement Improvement to an existing user-facing feature 🟩 priority: low Low priority and doesn't need to be rushed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve ingestion server test output
4 participants