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
feat: Remote mock server service for consumer tests #277
Conversation
Add UseRemoteMockService property to IMockProviderService/Mockprovider class
Add header as optional parameter in SendAdminHttpRequest
Modify MockService to support Remote host by not starting rubyhost and calling a remote mockservice URL instead
SendAdminHttpRequest need to call optional parameter to pass Pact URL to save Pact file
Build_WhenCalledWithTheMockProviderServiceInitialised_CallsSendAdminHttpRequestOnTheMockProviderService
Fix all units test. When UseRemoteMockService mode is ON then host could be null and admin interactions should be sent to remote mock server.
I can't comment on the code changes, but the concept is 👍🏽 |
What Beth says - cool! |
I would love to see this in master soon ! |
This addition would be very useful! Changes look legit to me. |
I think Neil is a bit busy to review/release right now. Is there anyone else who can do it? |
Hi, I have some thoughts related to code changes can comment on it later on, but that is probably all. It doesn't look like I can merge this to master. JM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I have promised I have left few comments/suggestions. Sorry that it took me a while.
Please let me know if something will not be clear.
Thanks for the collaboration on this folks 👏 Are either of you keen to help be a co-maintainer of the project? Let us know, we'd love to support you! |
In Remote Mode, return the pact to be saved from the remote server to the client. Then save it localy to the specified path
Hi @mefellows, it will be my great honor to join you as co-maintainer as soon as this PR is merged, Thank you! 😃 |
Hi @mefellows I am also honored with your offer to become co-maintainer. I do not always have so much time I wish to have, but I am keen to help . Thanks JM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall code looks good to me, just one more small suggestion.
{ | ||
return string.Empty; | ||
} | ||
return !string.IsNullOrEmpty(responseContent) ? responseContent : Empty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you have used using static System.String;
, you may also consider using it in terms of IsNullOrEmpty
@HugoDoyon look good to me - really small suggestion from my point of view it can be merged. |
While investigating why an update to 2.6.2 via dependabot has broken a project of mine, reviewing the diff between 2.6.1 and 2.6.2 shows that this PR introduced binary and source-breaking compatibility issues by adding new members to the public This change should have ideally been released as a v3.0.0 to comply with SemVer, been done in a way that didn't cause binary breaking compatibility, or at least have been released as a minor version bump to 2.7 if the major version number is being kept in sync with Pact itself. I'm still trying to work out what change has actually broken my CI - will open an issue if I get to the bottom if it. |
Thanks Martin, appreciate you picking this up, apologies for any issue. I think the best course of action is to disable new installs of the new package (via Nuget), and re-release as a @HugoDoyon @jacekmlynek - thoughts? FWIW: Most of the other Pact projects use conventional commits and automated changelogs - something I'd like to do on this now that I'm helping out with the release. |
@mefellows It is new feature so at least it should be released with minor version bump by default. Now, I can agree that changes in this PR could break someone else code if he is implementing one of mention interfaces, which make it a good reason to bum major version (I think we must catch this earlier - maybe using gitversion will help). However this looks for me like static source incompatibility change. Less important, but maybe worth to touch a bit is mentioned by @martincostello breaking binary compatibility. I just would like to understand how in your case it breaks binary compatibility? Do you not compile your code before publishing it? Furthermore I am not sure if there is anything about binary compatibility in semver. I think semantic versioning leave wiggle-room in this case. Saying that I am aware that there were some discussion about additional indicator, but I am not sure how it is ended. Nerveless, it will be good to understand your problem a bit more for the future releases. |
It breaks binary compatibility by amending the public interfaces. Any libraries that maybe extend or consume Pact in some way and are distributed further would be broken due to the interfaces being changed. Adding optional parameters is a binary-breaking change as the method signature changes from a runtime perspective, even if it isn't neccessarily a source-breaking change. Adding the additional property to In my case it didn't break the source as I don't do that in my projects, but from a C#/.NET perspective, these changes are breaking to anyone who may have done that with Pact. |
Thanks folks. So to remediate this and prevent further frustrations for others, shall I re-release under |
Regarding this, I'm experiencing timeouts in some tests I have where the test process seems to be deadlocking. From viewing the diff further, I think the problem has been introduced by the change at the bottom of this file: https://github.com/pact-foundation/pact-net/compare/2.6.1..2.6.2#diff-8ea699804b2cb88e7361e4f10ad670345b83a1d891e980848c80994d6c535104
pact-net/PactNet/PactBuilder.cs Line 128 in ffa6ab8
Should the call be wrapped in
I think the most likely culprit is
|
@martincostello as far as I understood binary incompatibility was not your case, you just share some generic thought. Is this right? @mefellows that sound right to me, but I think it is far to wait for @HugoDoyon as well. |
Yep that's right, my issue is a deadlock. I was just mentioning it from a general principal standpoint. It was investigating what might be causing the deadlock that lead me to spot the changes to the interfaces. |
NP. I've just unlisted the package until we sort this out to err on the side of caution. I'll be offline probably (getting late here) so will pick any actions up in the morning. |
I am not a big expert of async Task in c#, but I took a quick look on the code and unfortunately it looks like a classic example of possible deadlock:
In short term I think we could add to public static TResult RunSync<TResult>(Func<Task<TResult>> task)
=> _taskFactory
.StartNew(task)
.Unwrap()
.GetAwaiter()
.GetResult(); And used this instead of Result In long term we should redesign contract behind SendAdminHttpRequest IMHO it should not expose asyn methods, unless we will not want to expose public async method too. Hope it is clear. I am just not sure how can reproduce @martincostello problem and test purpose fix. @HugoDoyon sorry that I didn't catch that in code review. |
Thanks for digging in Jacek. I'm out of my depth here (no C#/.NET knowledge) so will provide a supporting role. It would be great to be able to repro, but also, it sounds like the async call is mishandled anyway. @martincostello if the patch described above was added to this PR, could you test if the deadlock occurs? |
I'll try and repro and then check for a fix with a patch some time today. |
|
Fix deadlock caused by use of .Result. Addresses pact-foundation/pact-net#277 (comment).
Add the possibility to use a remote mock server service for the consumer tests.
For instance a remote mock server could be call to a pact-cli docker container.
To run your consumer tests against a remote server, in PactBuilder class, set the "useRemoteMockService" parameter to true.
See readme.md for more details
Fix the following issues: