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 #198

Closed guiyomh closed 2 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?

guiyomh commented 3 years ago

@mefellows to answers your question in the https://github.com/pact-foundation/pact-php/issues/199. yes I use docker/alpine

mefellows commented 3 years ago

Have you seen https://docs.pact.io/docker/?

guiyomh commented 3 years ago

no, but ok I'm going to follow the instruction for alpine and if that works, I will close this issue

mefellows commented 3 years ago

Should add a note to the homepage here also I reckon!

guiyomh commented 3 years ago

I have made this:

apk --no-cache add ca-certificates wget bash \
  && 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.29-r0/glibc-2.29-r0.apk \
  && apk add glibc-2.29-r0.apk

and now I have an error about ld.so:

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-07T18:13:37.772808+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 --broker-username=foo --broker-password=bar --enable-pending

 [] []
[2021-06-07T18:13:37.782398+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 --broker-username=foo --broker-password=bar --enable-pending [] []
[2021-06-07T18:13:37.840709+02:00] console.debug: Exit code: 127 [] []
[2021-06-07T18:13:37.843880+02:00] console.info: out >  [] []
[2021-06-07T18:13:37.844009+02:00] console.error: err > ERROR: ld.so: object 'php' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
/app/vendor/pact-foundation/pact-php/pact/lib/ruby/bin.real/ruby: error while loading shared libraries: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory
 [] []
E                                                                   1 / 1 (100%)

Time: 00:00.592, 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:239
/app/vendor/pact-foundation/pact-php/src/PhpPact/Standalone/ProviderVerifier/Verifier.php:190
/app/tests/Contracts/ProviderTest.php:30
mefellows commented 3 years ago

Looks like you forgot to also add RUN apk add --no-cache --virtual build-dependencies build-base

mefellows commented 2 years ago

Closing due to inactivity.

ravindradhaka commented 2 years ago

/dapi/pact/lib/ruby/bin/ruby: line 6: /builds/panamera/fcg/service/dapi/pact/lib/ruby/bin.real/ruby: No such file or director

in pact-go @mefellows

mefellows commented 2 years ago

@ravindradhaka Please stop finding other issues that look like yours in other languages and tagging me. It's not helpful for the previous issue (all watchers are now notified also), it's not helpful to solve your own problem and it's also not polite to summon somebody to an issue.

If you have an issue with pact go, raise the issue at Pact Go and a maintainer (probably me) will review it and respond accordingly. You must share what you've tried to do to resolve it, and provide a way to reproduce the problem, as you can see, the solution to what appears to be the same problem to you, has been identified and documented.