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

Pull out the HTTP mock server as cargo-dev-registry #14834

Open
Rustin170506 opened this issue Nov 18, 2024 · 3 comments
Open

Pull out the HTTP mock server as cargo-dev-registry #14834

Rustin170506 opened this issue Nov 18, 2024 · 3 comments
Labels
A-cargo-api Area: cargo-the-library API and internal code issues C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@Rustin170506
Copy link
Member

Rustin170506 commented Nov 18, 2024

Problem

In Cargo's unit tests, we used a mock HTTP server as our test infrastructure. But it is not a fully implemented registry. Some unit tests are just using custom handler to mock some registry API.

So as I discussed with @weihanglo and @epage, we both agree that having full featured dev registry in cargo would help the testing a lot. And maybe help us to catch some bugs that can only be caught in a real cargo registry.

At the same time, if we can have a standalone dev registry, it would help us a lot when testing or debugging the cargo itself. At the moment, it is difficult to test the real publish function, because setting up a real registry from scratch is difficult.

Furthermore, if we try to implement this dev registry, we can give other people a reference about how to implement the basic API for a cargo registry. We can also extend the common library for building a cargo registry. We believe this would not only help the cargo itself, but also help the community to implement a registry more easily.

Proposed Solution

As discussed with @epage, he suggested that we can do the following things to pull out the mock HTTP server as our cargo-dev-registry.

  • switch cargo's summary generation to use a normalized manifest, rather than a Package
  • pull registry types like IndexSummary out into cargo-util-schemas
  • pull out index/manifest/publish conversions into a cargo-util-registry
  • switch our dev registry to using the above rather than reimplement
  • pull our dev registry out into cargo-dev-registry with an optional cli for spinning it up

Notes

No response

@Rustin170506 Rustin170506 added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Nov 18, 2024
@Rustin170506
Copy link
Member Author

@arlosi If I remember correctly, I think we mentioned in one of our weekly meetings that we wanted a full-featured registry to test the Cargo, but I don't remember the context. Maybe it was related to authentication. Do you remember that requirement or use case?

@epage epage added the A-cargo-api Area: cargo-the-library API and internal code issues label Nov 18, 2024
@epage
Copy link
Contributor

epage commented Nov 18, 2024

For past references, see

CC @shepmaster, @Turbo87 as this involves trying to share more code between Cargo and registries

As discussed with @epage, he suggested that we can do the following things to pull out the mock HTTP server as our cargo-dev-regsitry.

To clarify, I expect cargo-dev-regsitry to be a first-party crate, not a built-in command.

pull out index/manifest/publish conversions into a cargo-util-registry

Do we want to start with cargo-util-registry and cargo-dev-registry being experimental, internal, or intentional artifacts? See the policy and our charter which makes it only an FCP and not an RFC.

@epage epage added S-needs-team-input Status: Needs input from team on whether/how to proceed. and removed S-triage Status: This issue is waiting on initial triage. labels Nov 18, 2024
@joshtriplett joshtriplett changed the title Pull out the HTTP mock server as cargo-dev-regsitry Pull out the HTTP mock server as cargo-dev-registry Nov 19, 2024
@ehuss ehuss added S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review and removed S-needs-team-input Status: Needs input from team on whether/how to proceed. labels Nov 19, 2024
@epage
Copy link
Contributor

epage commented Nov 21, 2024

In addition to accepting this, some thoughts when we discussed this as a team

  • Having cargo-dev-registry serve both to show how a registry works and as a dev-registry might come into conflict with each other because we might want test-specific features, like failure injections. We'll initially prioritize it as a dev-registry and then see if it can also serve as an example
  • As such, we might mark cargo-dev-registry as experimental. However, we didn't see a reason to do the same for cargo-util-registry
  • We considered having crates-io own the cargo-util-registry logic but crates-io is mostly client focused and putting server oriented logic in it might make it not serve its purpose as well for both, particularly in the server getting large client dependencies (and the name is specific to one registry)
  • While cargo-util-registry may have logic to help with registries, not all may find it useful
  • If we're able to create conformance tests or have this operate as a test double, that could also be usefl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo-api Area: cargo-the-library API and internal code issues C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
Development

No branches or pull requests

3 participants