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

Proof of Concept: Testing for docs.python.org redirects #499

Closed
wants to merge 4 commits into from

Conversation

ewdurbin
Copy link
Member

@ewdurbin ewdurbin commented Sep 26, 2024

Description

Right now we have lots of docs redirects and they are pretty complex and difficult to scrute.

This is a proof of concept for extracting those redirects to a separate file so we can stand it up in a bare-bone nginx docker container to run automated tests against.

This should be helpful for people developing redirects and let PSF Infra more readily merge changes like #498

Requires docker and hurl to be installed locally.

chungus:psf-salt ee$ bash tests/docs/redirects/run.sh 
Error response from daemon: No such container: docs-redirects-nginx
a52b5f7a1a22f1458c3d358224c2fd6e0e3dbb25f8cc57cfc957588283d9b9a1
/Users/ee/src/psf-salt/tests/docs/redirects/tests.hurl: Success (1 request(s) in 1 ms)
--------------------------------------------------------------------------------
Executed files:    1
Executed requests: 1 (1000.0/s)
Succeeded files:   1 (100.0%)
Failed files:      0 (0.0%)
Duration:          1 ms

docs-redirects-nginx

@ewdurbin
Copy link
Member Author

Interested in @AA-Turner and @JacobCoffee's thoughts here.

@ewdurbin ewdurbin force-pushed the test_docs_redirects branch 3 times, most recently from ab57468 to 730e716 Compare September 26, 2024 20:26
Copy link
Member

@JacobCoffee JacobCoffee left a comment

Choose a reason for hiding this comment

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

this looks good, but this just means docs contributors will need to write there tests as well as the redirect changes?

If so, rebasing #498 onto this and adding those tests would be nice!

Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

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

also cc @JulienPalard

Could we add some notes or a brief guide on how we should run this locally? I see it runs in CI, but I'd like to try and avoid pushing many commits to test something.

How extensive should the tests be? What should we be testing for? What do good hurl tests look like?

A

Comment on lines +3 to +7
on:
push:
branches: [main]
pull_request:
branches: [main]
Copy link
Member

Choose a reason for hiding this comment

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

Restricting branches is unhelpful for testing against CI when needed:

Suggested change
on:
push:
branches: [main]
pull_request:
branches: [main]
on:
push:
paths:
- "salt/docs/**"
- "test/docs/redirects/**"
pull_request:
paths:
- "salt/docs/**"
- "test/docs/redirects/**"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true


steps:
- name: Checkout repository
uses: actions/checkout@v3
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
uses: actions/checkout@v3
uses: actions/checkout@v4

Comment on lines +13 to +14
permissions:
contents: read
Copy link
Member

Choose a reason for hiding this comment

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

Set permissions at the workflow level

Suggested change
permissions:
contents: read

@ewdurbin
Copy link
Member Author

ewdurbin commented Sep 26, 2024

Most of the specifics are up for debate. Probably the main thing to consider if the test specifications in the hurl file are acceptable.

hurl is pretty extensible for testing, but for our concern here of making sure new redirects act as expected and are well defined the status code and resulting Location are probably sufficient.

Backfilling tests for old redirects will be a chore, but probably worth doing. Big advantage would be ensuring that our existing redirects aren't broken or interfered with by new ones.

If there's value seen here, it's probably worth wrapping as much of this up into containers as possible, putting behind a make target, and documenting.

Probably more usefully, I found it much more ergonomic and faster feedback for playing with the redirect from your other outstanding PR (a few seconds per run vs running a full salt hullabaloo).

@AA-Turner
Copy link
Member

My local state got so messy that I reset the entire thing and opened three stacked PRs (#504, #505, #506) that implement this proof-of-concept. Notably, I have generated tests for as many of the redirect rules as I could backward-induct from the regular expressions, leading to 9,406 test cases.

A

@ewdurbin
Copy link
Member Author

ewdurbin commented Oct 1, 2024

oh snap. incredible @AA-Turner! I'll review them serially.

@ewdurbin ewdurbin closed this Oct 1, 2024
@ewdurbin ewdurbin deleted the test_docs_redirects branch October 1, 2024 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants