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

Make status test readable #2940

Merged
merged 7 commits into from
Sep 25, 2020

Conversation

youngnick
Copy link
Member

@youngnick youngnick commented Sep 24, 2020

This PR attempts to make the status tests more readable by putting the
fixtures next to the test cases they are used in as much as possible.

  • Extracted the common Service and Secret fixtures (and the certificates) to internal/fixtures.
  • Names are also changed. No more proxy47a!
  • I also found some duplicate tests (probably from when we converted IngressRoute tests to HTTPProxy ones).

Blocks #2495 until it's merged; I don't want to attempt refactoring all these tests until it's a bit
easier to see what everything's used for.

Signed-off-by: Nick Young ynick@vmware.com

@youngnick youngnick self-assigned this Sep 24, 2020
@youngnick youngnick force-pushed the make-status-test-readable branch 2 times, most recently from c6a5d36 to 5718a5b Compare September 24, 2020 06:30
@codecov
Copy link

codecov bot commented Sep 24, 2020

Codecov Report

Merging #2940 into main will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2940   +/-   ##
=======================================
  Coverage   74.91%   74.91%           
=======================================
  Files          87       87           
  Lines        5604     5604           
=======================================
  Hits         4198     4198           
  Misses       1315     1315           
  Partials       91       91           

Copy link
Contributor

@jpeach jpeach left a comment

Choose a reason for hiding this comment

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

The main things here are that we should establish a consistent naming convention for fixture globals, and use a local run helper in the status tests. I haven't reviewed the test coverage in detail; the coverage percentage is unchanged, which is great, but we may want to ensure that we didn't drop important test cases.

internal/fixture/service_fixtures.go Outdated Show resolved Hide resolved
internal/fixture/service_fixtures.go Outdated Show resolved Hide resolved
internal/fixture/service_fixtures.go Outdated Show resolved Hide resolved
internal/fixture/secret_fixtures.go Outdated Show resolved Hide resolved
internal/fixture/secret_fixtures.go Outdated Show resolved Hide resolved
internal/dag/status_test.go Outdated Show resolved Hide resolved
Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

couple nits so far; will look through status_test.go in some more detail.

internal/fixture/certificate_constants.go Show resolved Hide resolved
internal/fixture/secret_fixtures.go Show resolved Hide resolved
internal/fixture/service_fixtures.go Show resolved Hide resolved
Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

Other than the nits I'm happy with this, it's definitely an improvement in readability. I agree with James' comment that we may want to do a detailed tick and tie to ensure we didn't inadvertently drop any important test cases, but I haven't done that.

@youngnick
Copy link
Member Author

I only knowingly removed two test cases, that I checked carefully to ensure that were duplicates. I'll use the "show coverage" thing on main and here and check if I've dropped anything.

I'll also swap over to the run style rather than table style; that's not a huge change now the hard part (moving everything) is done.

Nick Young added 4 commits September 25, 2020 00:32
- Extract status Secret and Service fixtures out to `internal/fixture`, assuming they could be reused.

Signed-off-by: Nick Young <ynick@vmware.com>
Signed-off-by: Nick Young <ynick@vmware.com>
This commit attempts to make the status tests more readable by putting the
fixtures next to the test cases they are used in as much as possible.

Names are also changed. No more `proxy47a`!

I also found some duplicate tests (probably from when we converted
IngressRoute tests to HTTPProxy ones).

Signed-off-by: Nick Young <ynick@vmware.com>
Signed-off-by: Nick Young <ynick@vmware.com>
@youngnick
Copy link
Member Author

I've gone over all of the places in httpproxy_processor.go that are not covered in this branch and main, and confirmed that they match. I've also got a list which will be handy of what we're not covering.

Nick Young added 3 commits September 25, 2020 00:48
Signed-off-by: Nick Young <ynick@vmware.com>
Signed-off-by: Nick Young <ynick@vmware.com>
Signed-off-by: Nick Young <ynick@vmware.com>
@youngnick
Copy link
Member Author

Only test failure is the SNI flake, I'm going to go ahead and merge this so I can bring it in to the other status work.

@youngnick youngnick merged commit 02d77f0 into projectcontour:main Sep 25, 2020
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