Skip to content

go test fails on offline system #8928

Description

@pdostal

Describe the bug

when running the tests offline there are errors recently introduced by #8698.

Steps to reproduce the behavior

  1. Build hg from this repository
  2. Run make test
  3. See error

Expected vs actual behavior

All the other tests are successfully passing; however, there are a few specific tests that are failing. A potential workaround involves using the command -skip="TestRunInspect|TestJSONOutput|TestNewSigstoreVerifier|TestRunVerify|TestTUFRootVerify", though this approach lacks elegance.

To address this issue more gracefully, one of two strategies could be employed: either emulate the remote call with a local one or categorize these tests as online tests so they can be selectively skipped. This could streamline the testing process while maintaining the integrity of the test suite.

Activity

  1. williammartin commented on Apr 5, 2024

    @williammartin
    Member

    @pdostal thanks for the detailed report. This is definitely not a desirable state. Aside from what you've mentioned it's also introducing a source of flakiness.

  2. added
    tech-debtA chore that addresses technical debt
    coreThis issue is not accepting PRs from outside contributors
    and removed
    bugSomething isn't working
    on Apr 5, 2024
  3. williammartin commented on Apr 5, 2024

    @williammartin
    Member

    @malancas can you take a look at this please?

    What is the testing seam here? Is it acceptable to stub the SigStoreVerifier altogether and assume it is tested correctly elsewhere? Should we be stubbing the http responses? Let me know your thoughts.

  4. malancas commented on Apr 5, 2024

    @malancas
    Contributor

    @williammartin Taking a look now. I'm going to read through the code and figure out the best place to either stub the code out.

  5. malancas commented on Apr 5, 2024

    @malancas
    Contributor

    @williammartin I think stubbing out the SigstoreVerifier in the verify package unit tests makes the most sense here. I'll work on a PR for that.

  6. self-assigned this
    on Apr 11, 2024
  7. malancas commented on Apr 12, 2024

    @malancas
    Contributor

    @pdostal this should now be fix in the trunk branch, but please let me know if you are still encountering the issue. Thanks!

  8. pdostal commented on Apr 17, 2024

    @pdostal
    ContributorAuthor

    Hello @malancas, thank you for your fix.

    I think that the number of failures decreesed, but there are still two present, please see gist.

  9. malancas commented on Apr 18, 2024

    @malancas
    Contributor

    Hello @malancas, thank you for your fix.

    I think that the number of failures decreesed, but there are still two present, please see gist.

    Thanks for the update. I've found the code and a new pull request to fix this should be ready soon.

  10. pdostal commented on May 1, 2024

    @pdostal
    ContributorAuthor

    Hello @malancas, it's progressing but I have some more. Please see gist.

  11. malancas commented on May 3, 2024

    @malancas
    Contributor

    Hello @malancas, it's progressing but I have some more. Please see gist.

    @pdostal I've merged a fix that should address the test failures in your gist. Let me know if this change resolves your issue.

  12. pdostal commented on May 10, 2024

    @pdostal
    ContributorAuthor

    All looks fine now. Thank you!

  13. williammartin commented on May 10, 2024

    @williammartin
    Member

    Great! Sorry for the friction and thank you for your help. Please let us know if we mess this up again in the future.

  14. pdostal commented on Jul 18, 2024

    @pdostal
    ContributorAuthor

    Hello, I have another test failing when building offline. It is TestGetTrustedRoot/successfully_verifies_TUF_root and you can see the log here.

    Can you please look at it? 🙏

  15. williammartin commented on Jul 18, 2024

    @williammartin
    Member

    @steiza @malancas I'd like us to get a handle on tests that really have to reach out to external resources or not. Can you have a think about how the attestation commands tests could be restructured, lints we could write, or any other approach to prevent this happening. It seems like a very easy thing to do, without much visibility with the nature of the tuf client.

    Happy to get together and pair on this with you.

  16. steiza commented on Jul 18, 2024

    @steiza
    Contributor

    Ah, sorry, I didn't realize that the tests were intended to work offline!

    #9340 should be a quick fix. If we wanted to re-enable happy-path testing we could mock out a client, but I think we'd need some small support changes in sigstore-go.

    In terms of how to ensure tests work offline in the future, ideally CI would run tests in a restricted network, maybe by using Azure private networking? Now that I know we want tests to run offline, I can be aware of that in future changes.

    A linter detection for this specific issue would be pretty difficult. tuf.New does use the network in the happy path, but it doesn't in the fails because the root cannot be found test case that remains. And of course, this wouldn't detect other functions potentially included in future tests that would make network calls.

  17. pdostal commented on Jul 19, 2024

    @pdostal
    ContributorAuthor

    Hello,

    I package gh for openSUSE, where the entire pipeline operates completely offline. This design choice ensures build reproducibility and guarantees that the package is not externally influenced.

    When a test fails due to the absence of a network connection, I can disable it, but I appreciate having the package thoroughly tested.

    While you can flag each test that requires a network connection, I believe it's beneficial to maintain the test suite as self-sufficient as possible.

    Thank you very much for your work and support for the offline scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreThis issue is not accepting PRs from outside contributorstech-debtA chore that addresses technical debt

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions