pact-foundation / pact-php

PHP version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project
Apache License 2.0
273 stars 92 forks source link

bin.real/ruby: No such file or directory #199

Closed guiyomh closed 3 years ago

guiyomh commented 3 years ago

Hi all,

I have created a test to verify my provider. Something like that:

<?php

declare(strict_types=1);

namespace App\Tests\Contracts;

use GuzzleHttp\Psr7\Uri;
use PHPUnit\Framework\TestCase;
use PhpPact\Standalone\ProviderVerifier\Verifier;
use PhpPact\Standalone\ProviderVerifier\Model\VerifierConfig;

class ProviderTest extends TestCase
{
    public function testPactVerifyAll(): void
    {
        $config = new VerifierConfig();
        $config
            ->setProviderName('my-api') // Providers name to fetch.
            ->setProviderBaseUrl(new Uri('http://nginx:80')) // URL of the Provider.
            ->setBrokerUri(new Uri('http://my-broker/')) // URL of the Pact Broker to publish results.
            ->setPublishResults(false) // Flag the verifier service to publish the results to the Pact Broker.
            ->setEnablePending(false); // Flag to enable pending pacts feature (check pact docs for further info)

        // Verify that the files in the array are valid.
        $verifier = new Verifier($config);
        $verifier->verifyAll();

        // This will not be reached if the PACT verifier throws an error, otherwise it was successful.
        $this->assertTrue(true, 'Pact Verification has failed.');
    }
}

When I execute my test, I have an error:

PHPUnit 9.5.4 by Sebastian Bergmann and contributors.

Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing
[2021-06-02T10:29:26.724644+02:00] console.info: Verifying PACT with script:
/app/vendor/pact-foundation/pact-php/src/PhpPact/Standalone/Installer/../../../../pact/bin/pact-provider-verifier http://my-broker/pacts/provider/my-api/consumer/my-cli/version/7903cfc3e --provider-base-url=http://nginx

 [] []
[2021-06-02T10:29:26.728580+02:00] console.debug: Process command: /app/vendor/pact-foundation/pact-php/src/PhpPact/Standalone/Installer/../../../../pact/bin/pact-provider-verifier http://my-broker/pacts/provider/my-api/consumer/my-cli/version/7903cfc3e --provider-base-url=http://nginx [] []
[2021-06-02T10:29:26.752357+02:00] console.debug: Exit code: 127 [] []
[2021-06-02T10:29:26.753556+02:00] console.info: out >  [] []
[2021-06-02T10:29:26.753670+02:00] console.error: err > /app/vendor/pact-foundation/pact-php/pact/lib/ruby/bin/ruby: line 6: /app/vendor/pact-foundation/pact-php/pact/lib/ruby/bin.real/ruby: No such file or directory
 [] []
E                                                                   1 / 1 (100%)

Time: 00:00.359, Memory: 22.00 MB

There was 1 error:

1) App\Tests\Contracts\ProviderTest::testPactVerifyAll
Exception: PactPHP Process returned non-zero exit code: 127

/app/vendor/pact-foundation/pact-php/src/PhpPact/Standalone/Runner/ProcessRunner.php:132
/app/vendor/amphp/amp/lib/Coroutine.php:118
/app/vendor/amphp/amp/lib/Internal/Placeholder.php:149
/app/vendor/amphp/amp/lib/Coroutine.php:123
/app/vendor/amphp/amp/lib/Internal/Placeholder.php:149
/app/vendor/amphp/amp/lib/Deferred.php:52
/app/vendor/amphp/byte-stream/lib/ResourceInputStream.php:109
/app/vendor/amphp/amp/lib/Loop/Driver.php:119
/app/vendor/amphp/amp/lib/Loop/Driver.php:72
/app/vendor/amphp/amp/lib/Loop.php:95
/app/vendor/pact-foundation/pact-php/src/PhpPact/Standalone/Runner/ProcessRunner.php:138
/app/vendor/pact-foundation/pact-php/src/PhpPact/Standalone/ProviderVerifier/VerifierProcess.php:77
/app/vendor/pact-foundation/pact-php/src/PhpPact/Standalone/ProviderVerifier/Verifier.php:244
/app/vendor/pact-foundation/pact-php/src/PhpPact/Standalone/ProviderVerifier/Verifier.php:195
/app/tests/Contracts/ProviderTest.php:26

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

What did I do wrong?

mefellows commented 3 years ago

Are you running on docker/alpine?

mefellows commented 3 years ago

I see you closed the issue, can you please share the problem/solution for others in the future?

guiyomh commented 3 years ago

@mefellows, yes I have close the issue because github has create a duplicate issue with https://github.com/pact-foundation/pact-php/issues/198

stoutput commented 2 years ago

For future reference – if on alpine, you must install glibc as follows (not gcompat – gives missing libcrypt error):

RUN apk --no-cache add bash ca-certificates wget
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \
    && wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk \
    && apk --no-cache add glibc-2.28-r0.apk
mefellows commented 2 years ago

See also https://docs.pact.io/docker.