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

Mini http server to serve static files in the context of unit tests #388

Closed
wants to merge 3 commits into from

Conversation

lquerel
Copy link
Contributor

@lquerel lquerel commented Sep 24, 2024

This PR implements a simple HTTP server to serve static files, so tests no longer depend on remote files.

Example:

#[test]
fn test_semconv_spec_from_url() {
    let server = ServeStaticFiles::from("tests/test_data").unwrap();
    let semconv_url = server.relative_path_to_url("url/common.yaml");
    let result =
        SemConvRegistry::semconv_spec_from_url(&semconv_url).into_result_failing_non_fatal();
    assert!(result.is_ok());
}

In this example, the mini HTTP server returns the file located at tests/test_data/url/common.yaml. The URL returned by server.relative_path_to_url is something like http://127.0.0.1:<dyn_port>/url/common.yaml.

Closes: #267

@lquerel lquerel requested a review from a team as a code owner September 24, 2024 00:40
@lquerel lquerel self-assigned this Sep 24, 2024
@lquerel lquerel added the enhancement New feature or request label Sep 24, 2024
@jsuereth
Copy link
Contributor

I think the windows failure here is legit, and looks like it might be a leaky thread of sorts.

jsuereth added a commit that referenced this pull request Oct 25, 2024
* chore(test): Create a mini http server to serve static files in the context of unit tests

* chore(test): Fix cargo fmt issue

* Attempt to debug stalled tests

Add some explicit joins, repeated attempts to kill threads and debug logging

* clean up style

---------

Co-authored-by: Laurent Querel <[email protected]>
@jsuereth
Copy link
Contributor

Closing this as replaced by #429

@jsuereth jsuereth closed this Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Remove all remote dependencies on the semconv repo (i.e. Git URL or Git Archive URL) for stability purposes.
2 participants