Mike Lovely
07/17/2023, 12:36 PMPhpPact\Standalone\Exception\HealthCheckFailedException: Failed to make connection to Mock Server in 100 attempts
Here is my test setup:
private \PhpPact\Standalone\MockService\MockServer $mockServer;
private \PhpPact\Standalone\MockService\MockServerEnvConfig $config;
public function setUp(): void
{
$this->config = new \PhpPact\Standalone\MockService\MockServerEnvConfig();
$this->config->setCors(true);
$this->config->setLog('file.log');
$this->mockServer = new \PhpPact\Standalone\MockService\MockServer($this->config);
$this->mockServer->start();
}
public function tearDown(): void
{
// Stop the Pact Mock Server
$this->mockServer->stop();
}
I would paste the whole test but this fails during the set-up even before I get to the test. Not sure what to try. This is running locally on PHP 8.2 but also fails when running on PHP 8.1 via a docker container. Is there something obvious (probably) I am missing here?
Here is my phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>" xsi:noNamespaceSchemaLocation="<https://schema.phpunit.de/10.1/phpunit.xsd>" bootstrap="tests/bootstrap.php" executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" failOnRisky="true" failOnWarning="true">
<testsuites>
<testsuite name="Contract">
<directory>./tests/contract/</directory>
</testsuite>
</testsuites>
<php>
<env name="PACT_MOCK_SERVER_HOST" value="localhost"/>
<env name="PACT_MOCK_SERVER_PORT" value="7200"/>
<env name="PACT_CONSUMER_NAME" value="ExampleOne"/>
<env name="PACT_PROVIDER_NAME" value="ExampleAPI"/>
</php>
<coverage>
<report>
<clover outputFile="clover.xml"/>
</report>
</coverage>
</phpunit>
Yousaf Nabi (pactflow.io)
composer install
/ composer test
does that run for you?Mike Lovely
07/17/2023, 2:33 PM> phpunit --debug -c example/phpunit.all.xml
PHPUnit 9.6.10 by Sebastian Bergmann and contributors.
Test 'PhpPactTest\Broker\Service\BrokerHttpClientTest::testAllConsumerUrlsAreExtractedCorrectly' started
Test 'PhpPactTest\Broker\Service\BrokerHttpClientTest::testAllConsumerUrlsAreExtractedCorrectly' ended
Test 'PhpPactTest\Consumer\InteractionBuilderTest::testSimpleGet' started
[2023-07-17T14:25:49.583843+00:00] server.debug: start background command: /app/src/PhpPact/Standalone/Installer/Model/../../../../../bin/pact-ruby-standalone/bin/pact-mock-service service --consumer='someConsumer' --provider='someProvider' --pact-dir='./example/output//' --pact-file-write-mode=overwrite --host=localhost --port=7200 --cors=true --pact-specification-version=2.0.0 [] []
[2023-07-17T14:25:49.776588+00:00] server.debug: started process pid=35 [] []
Test 'PhpPactTest\Consumer\InteractionBuilderTest::testSimpleGet' ended
Stopping Process Id: 35
Test 'PhpPactTest\Consumer\InteractionBuilderTest::testPostWithBody' started
[2023-07-17T14:29:12.398424+00:00] server.debug: start background command: /app/src/PhpPact/Standalone/Installer/Model/../../../../../bin/pact-ruby-standalone/bin/pact-mock-service service --consumer='someConsumer' --provider='someProvider' --pact-dir='./example/output//' --pact-file-write-mode=overwrite --host=localhost --port=7200 --cors=true --pact-specification-version=2.0.0 [] []
[2023-07-17T14:29:12.409379+00:00] server.debug: started process pid=46 [] []
The following exception is caused by a process timeout
Check <https://getcomposer.org/doc/06-config.md#process-timeout> for details
In Process.php line 1204:
The process "phpunit --debug -c example/phpunit.all.xml" exceeded the timeout of 300 seconds.
test [--dev] [--no-dev] [--] [<args>...]
Mike Lovely
07/17/2023, 2:35 PMdocker run --rm --interactive --tty --volume $PWD:/app composer test
Yousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Mike Lovely
07/17/2023, 4:15 PMYousaf Nabi (pactflow.io)
Mike Lovely
07/19/2023, 7:51 AMYousaf Nabi (pactflow.io)
Mike Lovely
07/19/2023, 1:02 PM<extension class="PhpPact\Consumer\Listener\PactTestListener">
in my phpunit.xml but that doesn't seem to work with my version of phpunit (9.5.28).
At the end of each test should I be calling $builder->writePact() or finalize() or neither?
I'm not using pact-broker just yet. I am building up to that. I'm still just trying to get a poc working here.Mike Lovely
07/19/2023, 1:13 PMYousaf Nabi (pactflow.io)