Skip to content

How to run unitest when using opendal services-oss/s3 with mock server #4897

Answered by Xuanwo
Lzzzzzt asked this question in Q&A
Discussion options

You must be logged in to vote

since oss use the virtual host style, if the mock server is listening on 127.0.0.1:8080, then bucket is 127, endpoint is http://0.0.1:8080, is that right?

Hi, this approach doesn't work. 127.0.0.1 itself is an IP address, we can't split it in this way. So we can't use virtual host style with an IP address; it must be a hostname. Neither <bucket>.127.0.0.1 nor 0.0.1 are valid URLs.

To mock the OSS service, we need to modify /etc/hosts or use reqwest::ClientBuilder::resolve_to_addrs in the HTTP client to map domains <bucket>.<hostname> to 127.0.0.1.

After those setup, we can set oss config endpoint to http://<hostname>:port. OpenDAL will send requests to http://<bucket>.<hostname>:port.

I…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Lzzzzzt
Comment options

@Xuanwo
Comment options

Xuanwo Jul 14, 2024
Collaborator

Answer selected by Lzzzzzt
@Lzzzzzt
Comment options

@Lzzzzzt
Comment options

@Lzzzzzt
Comment options

@Xuanwo
Comment options

Xuanwo Jul 15, 2024
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants