close
Skip to content

Unified logging approach for api and ingestion server#2380

Merged
stacimc merged 14 commits intoWordPress:mainfrom
ashiramin:unified-logging-approach-api-and-ingestion-server
Jun 27, 2023
Merged

Unified logging approach for api and ingestion server#2380
stacimc merged 14 commits intoWordPress:mainfrom
ashiramin:unified-logging-approach-api-and-ingestion-server

Conversation

@ashiramin
Copy link
Contributor

@ashiramin ashiramin commented Jun 11, 2023

Fixes

Fixes #2031 by @dhruvkb

Description

Unified logging approach between api and ingestion server by logging container logs in ci/cd instead of inside python code. Now both test-api and test-ing follow a similar pattern of storing test logs.

  1. .github/workflows/ci_cd.yml:

    • Added a step to store the ingestion-server test logs an
  2. ingestion_server/justfile:

    • Added a new command to display integration test logs.
  3. ingestion_server/test/integration_test.py:

    • Docker compose stack is only removed when running tests locally. CI does this separately after storing logs
    • Test logs are no longer saved when running locally.

Testing Instructions

  • Since most of the changes are made in the CI, testing it locally is hard. Running tests locally removes the docker compose stack so newly added test-logs command won't return anything since test containers are destroyed
  • To verify this in the CI. Go to the latest summary page for this PR where artifacts are listed and make sure ing_logs exists and has ingestion server test logs. This can be verified by downloading ing_logs.zip file

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate 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.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (if applicable).

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.

@openverse-bot openverse-bot added 🟩 priority: low Low priority and doesn't need to be rushed ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository 🧱 stack: api Related to the Django API 🧱 stack: ingestion server Related to the ingestion/data refresh server labels Jun 11, 2023
@ashiramin ashiramin marked this pull request as ready for review June 11, 2023 23:40
@ashiramin ashiramin requested review from a team as code owners June 11, 2023 23:41
@ashiramin ashiramin requested review from krysal and stacimc June 11, 2023 23:41
@ashiramin ashiramin changed the title Unified logging approach api and ingestion server Unified logging approach for api and ingestion server Jun 11, 2023
@sarayourfriend
Copy link
Collaborator

@ashiramin Can you add testing instructions for this change? It makes it much easier for maintainers to review the changes leading to reviews coming in sooner 🙂

@ashiramin
Copy link
Contributor Author

@ashiramin Can you add testing instructions for this change? It makes it much easier for maintainers to review the changes leading to reviews coming in sooner 🙂

@sarayourfriend Thank you for letting me know. I updated the testing instruction section in the PR description :)

@stacimc stacimc requested a review from dhruvkb June 20, 2023 18:35
Copy link
Collaborator

@sarayourfriend sarayourfriend 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 to me! I'll be happy to approve once @dhruvkb confirms whether the if condition is needed on "Cleanup ingestion-server test".

ashiramin and others added 2 commits June 21, 2023 19:53
Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com>
Copy link
Collaborator

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

Apologies for not noticing this before, but I'd like to request that this change does not affect the local development experience by making the logs inaccessible locally. Before this change the logs would output to a file before the stack is torn down. I believe the easiest way to preserve this is to remove tearing down the stack from the Python script entirely. Instead, we can add test-logs test-clean-dc to test-local.

It would look something like this:

test-local:
    pipenv run pytest {{ args }}
    if [ -z "$CI" ]; then just test-logs && just test-clean-dc; fi

Please also update the test-clean-dc doc-comment as it'll now be regularly used.

@openverse-bot
Copy link
Collaborator

Based on the low urgency of this PR, the following reviewers are being gently reminded to review this PR:

@krysal
@dhruvkb
@stacimc
This reminder is being automatically generated due to the urgency configuration.

Excluding weekend1 days, this PR was ready for review 9 day(s) ago. PRs labelled with low urgency are expected to be reviewed within 5 weekday(s)2.

@ashiramin, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings.

Footnotes

  1. Specifically, Saturday and Sunday.

  2. For the purpose of these reminders we treat Monday - Friday as weekdays. Please note that the operation that generates these reminders runs at midnight UTC on Monday - Friday. This means that depending on your timezone, you may be pinged outside of the expected range.

@krysal krysal marked this pull request as draft June 24, 2023 03:47
@ashiramin ashiramin marked this pull request as ready for review June 25, 2023 01:38
@ashiramin
Copy link
Contributor Author

ashiramin commented Jun 25, 2023

Apologies for not noticing this before, but I'd like to request that this change does not affect the local development experience by making the logs inaccessible locally. Before this change the logs would output to a file before the stack is torn down. I believe the easiest way to preserve this is to remove tearing down the stack from the Python script entirely. Instead, we can add test-logs test-clean-dc to test-local.

It would look something like this:

test-local:
    pipenv run pytest {{ args }}
    if [ -z "$CI" ]; then just test-logs && just test-clean-dc; fi

Please also update the test-clean-dc doc-comment as it'll now be regularly used.

@sarayourfriend made the change :) sorry it took me a bit longer. Please take a look

Copy link
Collaborator

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

Fantastic, thanks very much for your patience in the review process. I've tested this locally by running just ingestion_server/test-local with and without CI=1 and the behaviour is exactly as expected.

Thanks again very much for your contribution @ashiramin 🙏

Copy link
Collaborator

@stacimc stacimc left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution and especially for your patience @ashiramin :)

Pinging @dhruvkb again for awareness, but I was able to test this locally and this looks good to me.

@stacimc stacimc merged commit 1d6404b into WordPress:main Jun 27, 2023
@ashiramin ashiramin deleted the unified-logging-approach-api-and-ingestion-server branch August 6, 2023 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: api Related to the Django API 🧱 stack: ingestion server Related to the ingestion/data refresh server

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Unify logging approach between API tests and ingestion server tests

4 participants