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

A sample application using a mock server #116

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

alefranz
Copy link

Hi @sebastienros
I've created a sample application using wiremock as mock server.

Opening this mainly to discuss the approach and a few potential improvements I thought of with this experiment, before raising them as issues.

The idea of having a Wiremock job is that you can easily setup canned response in its json configuration, which is quite flexible. Not sure however if performance would be good enough (and how accurate is the applied delay).

Other comments in line

@@ -0,0 +1,2 @@
FROM rodolpheche/wiremock as mockserver
COPY config /home/wiremock
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice to add a 3rd way to add a docker job by specify the docker hub name, or did I miss it?

Copy link
Author

@alefranz alefranz Aug 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could add another property dockerSourceImage, and, when present, instead of doing a docker build, do a docker pull then tagging the image with the dockerImageName so that the rest of the logic stay the same.
What do you think @sebastienros ? would you accept a PR for that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the suggestion. Had the same issue myself which required me to create a dumb docker file. dockerImage ? Would allow for name and tag. And change how dockerImageName is constructed when not provided to be sure the tag part is not interfering with the syntax of the command line.

: $"run -d {environmentArguments} {job.Arguments} --label benchmarks --name {containerName} --network SELF --ip {hostname} {imageName} {source.DockerCommand}";
: string.Equals(hostname, "localhost", StringComparison.OrdinalIgnoreCase)
? $"run -d {environmentArguments} {job.Arguments} --label benchmarks --name {containerName} -p {job.Port}:{job.Port} {imageName} {source.DockerCommand}"
: $"run -d {environmentArguments} {job.Arguments} --label benchmarks --name {containerName} --network SELF --ip {hostname} {imageName} {source.DockerCommand}";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to run this to be able to run locally on windows without having to create a network and to be able to map the port.
Not sure however if that Port parameter is the correct parameter.

Maybe there should be a more generic argument to pass parameter to docker while I believe currently you can only specify arguemnts to the container

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just keep the port:port version on Windows. I used SELF because I was trying to create a faster network interface, but at least if port:port works it's better for now.

Base automatically changed from master to main March 4, 2021 23:34
Copy link
Member

@sebastienros sebastienros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know ...

: $"run -d {environmentArguments} {job.Arguments} --label benchmarks --name {containerName} --network SELF --ip {hostname} {imageName} {source.DockerCommand}";
: string.Equals(hostname, "localhost", StringComparison.OrdinalIgnoreCase)
? $"run -d {environmentArguments} {job.Arguments} --label benchmarks --name {containerName} -p {job.Port}:{job.Port} {imageName} {source.DockerCommand}"
: $"run -d {environmentArguments} {job.Arguments} --label benchmarks --name {containerName} --network SELF --ip {hostname} {imageName} {source.DockerCommand}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just keep the port:port version on Windows. I used SELF because I was trying to create a faster network interface, but at least if port:port works it's better for now.

@@ -0,0 +1,2 @@
FROM rodolpheche/wiremock as mockserver
COPY config /home/wiremock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the suggestion. Had the same issue myself which required me to create a dumb docker file. dockerImage ? Would allow for name and tag. And change how dockerImageName is constructed when not provided to be sure the tag part is not interfering with the syntax of the command line.

@@ -0,0 +1,57 @@
// Licensed to the .NET Foundation under one or more agreements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use the new WebApplicationBuilder model now

});
});

Console.WriteLine($"AspNetCore location: {typeof(IWebHostBuilder).GetTypeInfo().Assembly.Location}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary. Results show the version automatically.

@alefranz
Copy link
Author

alefranz commented Aug 1, 2023

Hi @sebastienros !

I know .... 😂

I've not being using Crank recently. I wonder if this could still be useful or is there already an implemented alternative?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants