-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
How to use WiremockContainerBuilder for grpc using http2 #1239
Comments
@GomesNayagam : for better readability, you can use markdown syntax highlighting. json
And C#
|
To answer your question: See this page on how to use it: |
Hi @StefH I tried with new image and container able to up and running but when i query for mapping http://127.0.0.1:49160/app/__admin/mappings it is throwing. "No matching mapping found"
{"Status":"No matching mapping found"} var container = new WireMockContainerBuilder()
.WithAutoRemove(true)
.WithCleanUp(true)
.WithMappings(TestHelper.GetAbsolutePath(@"mocks\greet\mappings"))
.Build();
await container.StartAsync().ConfigureAwait(false); |
1] I think the URL you need to use is 2] var container = new WireMockContainerBuilder()
.WithAutoRemove(true)
.WithCleanUp(true)
.WithMappings(TestHelper.GetAbsolutePath(@"mocks\greet\mappings"))
.WithCommand("--Urls http://x.x.x.x:8080 grpc://x.x.x.x:9090").
.Build(); Where |
@StefH I tried the above with this code coz i dont want to use any static ip not sure how that works, i am okey to have localhost.
POST: grpc://127.0.0.1:53296/grpc Expected: work similar like this article says https://mstack.nl/blogs/wiremock-net-grpc/ var container = new WireMockContainerBuilder()
.WithAutoRemove(true)
.WithCleanUp(true)
.WithMappings(TestHelper.GetAbsolutePath(@"mocks\greet\mappings"))
.WithCommand("--Urls http://*:80/ grpc://*:9093/")
.Build(); Note i tried this preview as well 1.6.12-ci-19580, looks grpc server is not running in this container? correct me if i am wrong. |
@GomesNayagam |
Can you try this: var container = new WireMockContainerBuilder()
.WithCommand("--UseHttp2 true")
.WithEntrypoint("./wiremock-net", "--Urls", "http://*:80", "grpc://*:9090")
.WithPortBinding(9090, true) This will make sure that WireMock.Net inside the container will internally listen to 80 and 9090 and externally will use random ports. You get get the random ports using: var httpPort = wireMockContainer.GetMappedPublicPort(80);
var grpcPort = wireMockContainer.GetMappedPublicPort(9090); Getting the mappings on the httpPort should work. And calling GRPC method on the grpcPort should also work. |
@StefH below error var wireMockContainer = new WireMockContainerBuilder()
.WithAutoRemove(true)
.WithCleanUp(true)
.WithMappings(TestHelper.GetAbsolutePath(@"mocks\greet\mappings"))
.WithCommand("--UseHttp2 true")
.WithEntrypoint("./wiremock-net", "--Urls", "http://*:80", "grpc://*:9090")
.Build();
await wireMockContainer.StartAsync();
var httpPort = wireMockContainer.GetMappedPublicPort(80);
var grpcPort = wireMockContainer.GetMappedPublicPort(9090); Error outpu:
|
And this? var wireMockContainer = new WireMockContainerBuilder()
.WithAutoRemove(true)
.WithCleanUp(true)
.WithAdminUserNameAndPassword(adminUsername, adminPassword)
.WithCommand("--UseHttp2 true")
.WithCommand("--Urls", "http://*:80 grpc://*:9090")
.WithPortBinding(9090, true)
.Build(); |
Or try preview NuGet version 1.7.1-ci-19645 Which can be used like this: var wireMockContainer = new WireMockContainerBuilder()
.WithAutoRemove(true)
.WithCleanUp(true)
.WithAdminUserNameAndPassword(adminUsername, adminPassword)
.AddUrl("http://*:8080")
.AddUrl("grpc://*:9090")
.AddUrl("grpc://*:9091")
.Build(); |
@StefH port were running but grpc is not working. files were in ..\mocks\greet\hellorequest.json
code
error log:
|
It should be fixed. |
@StefH this works, also luv to see the container works like static server, to add protodefinition and refer it from mappings. like
Another request, can you remove this file and related code base as i provided this for e.g and i don't want to be in trouble from my company or atleast remove the line# 27 to 37 and update with some dummy value. |
|
container should spin up and ready for testing.
timeout exception
The text was updated successfully, but these errors were encountered: