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

LogEntries not being recorded on subsequent tests #132

Closed
tomwadley opened this issue May 10, 2018 · 6 comments
Closed

LogEntries not being recorded on subsequent tests #132

tomwadley opened this issue May 10, 2018 · 6 comments

Comments

@tomwadley
Copy link

tomwadley commented May 10, 2018

Starting WireMock subsequent times on the same port with the same stubs appears to work, but the LogEntries are not recorded meaning you can't verify what was sent to the server.

    class Program
    {
        static async Task Main(string[] args)
        {
            await RunTest(); // prints "1"
            await RunTest(); // prints "0" for some reason
        }

        private static async Task RunTest()
        {
            var server = FluentMockServer.Start(9988);
            
            server.Given(Request.Create().WithPath("/").UsingGet())
                .RespondWith(Response.Create().WithStatusCode(200).WithBody("Hello"));
            
            Thread.Sleep(1000);

            var response = await new HttpClient().GetAsync("http:https://localhost:9988/");
            response.EnsureSuccessStatusCode();
            
            Console.WriteLine(server.LogEntries.Count());

            server.Stop();
        }
    }

I first noticed this using xunit in a Dotnet Core Web API project. The above is a simple reproduction using a console app.

EDIT: This is WireMock.Net 1.0.3.16 running on netcoreapp2.0

@StefH
Copy link
Collaborator

StefH commented May 19, 2018

Running on same port will indeed behave wrong, I think that the server is not really shutdown or that the OS does not yet release the port connection from client to server.

I've added a test with different ports, and that one is ok.
da46d30

So for now I would suggest not to use the same port, but always random.

@StefH StefH closed this as completed May 19, 2018
@paulapaulTW
Copy link

Recently merged pull request addresses this in .NET core; it was not an issue in full framework - 297743a

@cezarypiatekGC
Copy link

cezarypiatekGC commented Jan 4, 2021

Hi,

I'm still experiencing a similar problem. When I access the LogEntries collection the first time I'm getting no results. It looks like the LogEntries collection is not updated immediately because after adding await Task.Delay(3000); before, the problem disappears.

@Zakashi92
Copy link

I'm having the same issue where log entries are coming back as empty, I'm running it on Linux version 4.15.0-202-generic.
Functional Test. Though it seems to be passing on Windows !

@Zakashi92
Copy link

I'm having the same issue where log entries are coming back as empty, I'm running it on Linux version 4.15.0-202-generic. Functional Test. Though it seems to be passing on Windows !

I have also tried removing random porting & I have tried with random porting both fail.

@StefH
Copy link
Collaborator

StefH commented Mar 29, 2023

@Zakashi92
What version of .NET do you use?

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

No branches or pull requests

5 participants