-
-
Notifications
You must be signed in to change notification settings - Fork 350
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
Consumer tests failing on MAC OS Catalina #383
Comments
It looks like that error would happen if the mock service didn’t initialise. Is there anything in the pact log file (or test output) about errors during initialisation? Also, have your network settings changed after upgrading the OS? |
Unfortunately I don't get any logs anymore since this issue. Only during the very first run I got logs in the console, where it said that the init of the pact server failed, due to a "no such file or directory" error. I haven't been able to reproduce it, so I don't have the exact logs anymore...
No. |
Thanks @aTastyT0ast. Can you please share the output of our debugging tips? |
@mefellows Here you go. For better reproducibility, we used the jest example from this repo and set the same dependencies we use in our project, which have the same errors:
And the only thing we changed from the jest example were the logLevel to DEBUG (which apparently didn't provide any more logs as you can see in the logs above) and the package.json:
Also after testing it out on another machine and in docker containers, we noticed that it's not related to the OS at all. So now we are not sure what exactly causes the tests to fail. |
Thanks @aTastyT0ast (also love your computer name!). Mmm I can't see why that would be. The fact that the binaries are executing, and that our CI builds for linux/MacOSX aren't failing is a positive, and leads me to think that something is going on in your environment. Can you literally clone this repository and run the examples as we do in our CI build? |
@mefellows Thanks, here you go:
We made sure, that there was no pact-mock-service running beforehand, so I don't really understand the error message "connect ECONNREFUSED 127.0.0.1:8991". |
Thanks for the detailed repro. I can reproduce this with docker (and MacOS Mojave), so I suspect it is something to do with the container. I'll do a bit of investigating. |
Aha! This is happening because Jasmine (which is used by Jest) isn't waiting long enough for the pact server to start up, and for some reason Jasmine doesn't report the timeout failure in
To There are a few places where we could improve this example (eg #385), too. You might also be interested in https://github.com/YOU54F/jest-pact , which aims to make using Jest and Pact together less fiddly. I'll update the example to set the timeout. |
I've committed a change to the examples that I think fixes this. Let me know how you go, and please re-open if I am mistaken. |
FWIW - I'm seeing exactly the same issue. Only happened recently too. Windows dev box is fine, only occurs on CI. $ cross-env && jest --testRegex "./tests/pact/.*/*(.test.pact.js)" --runInBand
[�[37m2019-11-01T16:30:40.361Z�[39m] �[36m INFO�[39m: pact-node@10.0.1/594 on ip-10-64-22-233.eu-west-1.compute.internal:
�[90m �[36mCreating Pact Server with options:
{"consumer":"fe-fragment-user-insight","cors":false,"dir":"/home/jenkins/workspace/0-add-pact-tests-to-user-insight/pacts","host":"127.0.0.1","log":"/home/jenkins/workspace/0-add-pact-tests-to-user-insight/logs/mockserver-integration.log","pactFileWriteMode":"update","port":8991,"provider":"user-insight","spec":2,"ssl":false}�[39m
�[39mFAIL tests/pact/user-insights/mandatory-fields.test.pact.js
● Test suite failed to run
TypeError: Cannot read property 'writePact' of undefined
9 |
10 | afterAll(done => {
> 11 | return provider.finalize().then(() => done())
| ^
12 | })
13 |
at Pact.Object.<anonymous>.Pact.finalize (node_modules/@pact-foundation/src/httpPact.ts:148:8)
at Object.finalize (tests/pact/pactTestWrapper.js:11:19)
[�[37m2019-11-01T16:31:41.022Z�[39m] �[36m INFO�[39m: pact-node@10.0.1/594 on ip-10-64-22-233.eu-west-1.compute.internal:
�[90m �[36mCreating Pact Server with options:
{"consumer":"fe-fragment-user-insight","cors":false,"dir":"/home/jenkins/workspace/0-add-pact-tests-to-user-insight/pacts","host":"127.0.0.1","log":"/home/jenkins/workspace/0-add-pact-tests-to-user-insight/logs/mockserver-integration.log","pactFileWriteMode":"update","port":8991,"provider":"user-insight","spec":2,"ssl":false}�[39m
�[39mFAIL tests/pact/user-insights/jsonapi-confirmity.test.pact.js
● Test suite failed to run
TypeError: Cannot read property 'writePact' of undefined
9 |
10 | afterAll(done => {
> 11 | return provider.finalize().then(() => done())
| ^
12 | })
13 |
at Pact.Object.<anonymous>.Pact.finalize (node_modules/@pact-foundation/src/httpPact.ts:148:8)
at Object.finalize (tests/pact/pactTestWrapper.js:11:19)
Test Suites: 2 failed, 2 total
Tests: 0 total
Snapshots: 0 total
Time: 92.25s
Ran all test suites.
error Command failed with exit code 1. This includes the timeout option set as per the example jest repo. |
@jameshd Then I checked the proxy environment variables passed into the container, and I found that the mock server started on localhost was proxy to another URL. That's why pact tests can't connect to localhost mock server and make tests timeout. So pls check the proxy of the container, and make the mock server start in the container. |
Thanks @sunshy360. Are you asking us to change Pact or are these intended for James? If it's for us, could you please create a separate issue explaining the problem and expected behaviour? By the way, the host/address the server starts on is configurable, it need not be localhost. I believe any proxy environment vars should be respected but may be mistaken there. |
I too had the same problem while running in my machine. I took me a while to realise that the process is not exiting because of which when we run it next time, it's not getting the server instance and hence failing. Ideally there should be a clean way to kill the process once the tests are run. |
The consumer tests should be closing the process down when finalise is called- can you share a bit more about your test setup? |
Please make sure you call |
Thanks for the quick response.
and I have another file called jest-wrapper.js where I have defined the beforeAll and afterAll as below:
and i have defined a script in package.json file to run the tests as below:
Looks like there is some conflict with the port or the mock service instance is not getting started/closed. Any idea? |
Can some one plz help on my above request. My pacts are failing in docker while they work fine in local. |
If you could please raise a separate issue using the issue template, providing log files, reproducable examples etc., rather than piling onto an existing issue that would help. |
I think I found the root cause. so all good now. Thanks. I added a timeout to my script and that made it work. |
Software versions
Actual behaviour
Consumer tests were working fine on MAC OSX 10.14.5, but since we updated to 10.15 the tests are failing now.
Steps to reproduce
Run any consumer test on MAC OSX Catalina..
Relevant log files
The text was updated successfully, but these errors were encountered: