Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Amitoj Duggal
    @amitojduggal

    Hello All , i have a basic question :)
    the cases where the microservice is a consumer and also a provider to some other service. I would like to have the configuration in maven, but when i do that, the pact broker have to be specified twice.

    example

    <plugin>
                <groupId>au.com.dius</groupId>
                <artifactId>pact-jvm-provider-maven_2.12</artifactId>
                <version>3.5.20</version>
                <configuration>
                    <pactDirectory>target/pacts</pactDirectory> 
                    <pactBrokerUrl>xxx</pactBrokerUrl>
                    <pactBrokerUsername>xxx</pactBrokerUsername>
                    <pactBrokerPassword>xxx</pactBrokerPassword>
                    <trimSnapshot>true</trimSnapshot> <!-- Defaults to false -->
                    <tags>
                        <tag>default</tag>
                    </tags>
                    <serviceProviders>
                        <serviceProvider>
                            <protocol>http</protocol>
                            <host>xxx</host>
                            <port>80</port>
                            <path>xxx</path>
                            <name>xxx</name>
                <pactBroker>
                                <url>xxx</url>
                                <authentication>
                                    <username>xxx</username>
                                    <password>xxx</password>
                                </authentication>
                                <tags>
                                    <tag>default</tag>
                                </tags>
                            </pactBroker>
                        </serviceProvider>
                    </serviceProviders>
                    <configuration>
                        <pact.showStacktrace>true</pact.showStacktrace>
                        <pact.verifier.publishResults>true</pact.verifier.publishResults>
                    </configuration>
                </configuration>
            </plugin>
        </plugins>
    </build>
    code
    can you suggest a better way to do this, as right now i have to duplicate the pact broker url,pass at 2 locations. ?
    Ronald Holshausen
    @uglyog
    @amitojduggal , can you raise an issue at the github project?
    Amitoj Duggal
    @amitojduggal
    @uglyog Sure. would do that. Thanks :)
    Amitoj Duggal
    @amitojduggal

    @uglyog Another query i have is
    when we see the results after the execution the log says

    Verifying a pact between A and B
    [from Pact Broker https://xyz.com.au/pacts/provider/A/consumer/B/version/0.0.33]

    Verifying a pact between A and B
    [from Pact Broker https://xyz.com.au/pacts/provider/A/consumer/B/version/0.0.33]

    it doesnt give us the tag url
    so if i ran the provider tests for 2 tags, develop and master, i dont come to know which of the tag is causing the failure. cause both look the same , the pact broker url should have /tag/version as i think?

    Ronald Holshausen
    @uglyog
    @amitojduggal we are migrating to Slack as Gitter has a number of issues and is no longer supported. Join us at slack.pact.io
    YLPeng
    @YLPeng
    Anyone know how to set provider version using pact-jvm-provider?
    Adrian Soria
    @adrianSoria
    using Pact-jvm in a national integration. Looks promising. :)
    Sandhyagabbi
    @Sandhyagabbi
    Hi, I am having trouble publishing a PACT file to broker. A 500 error is returned randomly. It works after a few retries though. Is there any reason why this is happening?
    deshdeep-airwallex
    @deshdeep-airwallex
    hi @here I am new to PACT testing can someone please point me to a simple example for gradle+kotlin? appreciate!!
    Matt Fellows
    @mefellows
    Hi @deshdeep-airwallex @Sandhyagabbi and team - we've migrated to Slack due to overwhelming community support there. Please join us at slack.pact.io
    @deshdeep-airwallex say hi to Craig Rees for us :)
    Gopinath Langote
    @gopinath-langote
    @deshdeep-airwallex This mighe help you https://github.com/gopinath-langote/CDC-Kotlin-Implementation
    Max WU
    @maxwu
    Hi All, I am checking if pact lamdaDsl supports to check whether a field shall be absent. But it seems nullValue is regarded different than a missing field.
    Juan Manuel Perez Toro
    @Juanma97
    Hello, I am implementing TargetRequestFilter
    @TargetRequestfilter
    public void setAuthorizationHeader(HttpRequest req) { }
    But I have the next error:should take only a single HttpRequest parameter
    I try with MockHttpServletRequestBuilder but nothing
    I have the 4.0.5 version pact
    Beth Skurrie
    @bethesque
    Hi @Juanma97. We have moved to slack.pact.io and this channel is no longer monitored. Please ask your question there in the #pact-jvm channel.
    tainguyenvn
    @tainguyenvn
    Hello all
    I would like to send a POST request, where the request body get value from provider state
    However I am facing the issue: The request body content is escaped after it is rebuilt by using value injected from provider state
    Does anyone help me to solve this problem?
    Phil
    @philip368320_twitter
    Hi, I'm writing a pact provider jvm and I want to know how can I verify a header exists?
    Srinivasan Sekar
    @SrinivasanTarget

    Hi Team, can someone help me fix below issue when validating messages at producer end of a spring boot kafka application?

    Verifying a pact between dateConsumerKafka and dateProviderKafka
      [from Pact Broker http://localhost:82/pacts/provider/dateProviderKafka/consumer/dateConsumerKafka/version/0.0.1-SNAPSHOT]
      valid date from kafka provider
          Verification Failed - No annotated methods were found for interaction 'valid date from kafka provider'. You need to provide a method annotated with @PactVerifyProvider("valid date from kafka provider") on the classpath that returns the message contents.
    java.lang.RuntimeException: No annotated methods were found for interaction 'valid date from kafka provider'. You need to provide a method annotated with @PactVerifyProvider("valid date from kafka provider") on the classpath that returns the message contents.
        at au.com.dius.pact.provider.ProviderVerifier.verifyResponseByInvokingProviderMethods(ProviderVerifier.kt:282)

    My provider test looks like below:

    @RunWith(SpringMessagePactRunner.class)
    @Provider("dateProviderKafka")
    @Consumer("dateConsumerKafka")
    @PactBroker(host = "localhost", port = "82")
    @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
    public class DateProducerTest {
    
        @TestTarget
        public final Target target = new SpringAwareAmqpTarget();
    
        @PactVerifyProvider("valid date from kafka provider")
        String verifyDateInformationMessage() {
            System.out.println("i m invoked");
            return "{\"isLeapYear\":true,\"localDate\":\"2000-01-31\"}";
        }
    }

    Maven config looks like below:

                <plugin>
                    <groupId>au.com.dius</groupId>
                    <artifactId>pact-jvm-provider-maven</artifactId>
                    <version>4.0.0</version>
                    <configuration>
                        <serviceProviders>
                            <serviceProvider>
                                <name>dateProviderKafka</name>
                                <verificationType>ANNOTATED_METHOD</verificationType>
                                <packagesToScan>
                                    <packageToScan>src.test.java.com.example.producer.pact</packageToScan>
                                </packagesToScan>
                                <pactBroker>
                                    <url>http://localhost:82/</url>
                                </pactBroker>
                            </serviceProvider>
                        </serviceProviders>
                        <configuration>
                            <pact.showStacktrace>true</pact.showStacktrace>
                            <pact.verifier.publishResults>true</pact.verifier.publishResults>
                        </configuration>
                        <pactBrokerUrl/>
                    </configuration>
                </plugin>

    Appreciate any help. Thanks in advance.

    Iñaki Plessmann
    @Plessmann_twitter

    Hi all,

    Im following https://github.com/DiUS/pact-jvm/blob/v4.x/consumer/pact-jvm-consumer-specs2/src/test/scala/au/com/dius/pact/consumer/specs2/ExamplePactSpec.scala to migrate from ScalaPact to PactJVM. Im having an issue when having 2 interactions like in the example, i get the following exception:

    [error]  java.lang.UnsupportedOperationException: null (MutableCollectionsJVM.kt:42)
    [error] kotlin.collections.CollectionsKt__MutableCollectionsJVMKt.sortWith(MutableCollectionsJVM.kt:42)
    [error] au.com.dius.pact.core.model.RequestResponsePact.sortInteractions(RequestResponsePact.kt:65)
    [error] au.com.dius.pact.core.model.DefaultPactWriter.writePact(PactWriter.kt:56)
    [error] au.com.dius.pact.core.model.DefaultPactWriter.writePact(PactWriter.kt:100)
    [error] au.com.dius.pact.consumer.BaseMockServer.verifyResultAndWritePact(MockHttpServer.kt:133)
    [error] au.com.dius.pact.consumer.BaseMockServer.runAndWritePact(MockHttpServer.kt:119)
    [error] au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest(ConsumerPactRunner.kt:13)
    [error] au.com.dius.pact.consumer.specs2.PactSpec$ReadyForTest.$anonfun$withConsumerTest$2(PactSpec.scala:54)
    [error] au.com.dius.pact.consumer.specs2.PactSpec$$anon$1.asResult(PactSpec.scala:33)

    I copied the example from the repo previously referenced and got the same error. So far i can infer an issue while sorting interactions but i have no clue what i am missing, can anyone point me in the correct path? Im using Java 11 but it also fails in Java 8.

    Matt Fellows
    @mefellows
    Hi all, please see above, we have moved to slack.pact.io and this channel is no longer monitored. Please ask your question there in the #pact-jvm-help channel.
    Matt Fellows
    @mefellows
    @Hoagiex ☝️
    1 reply
    paul-ovchinnikov
    @paul-ovchinnikov
    Hello! I have infinite loop with case of limit and offset parameters in consumer

    `public class ConsumerClientService {

    private final int limit = 100;
    private final ConsumerClient client = new ConsumerClient();

    public List<String> getAll() {
    final List<String> retrievedAll = new ArrayList<>();

    for (int i = 0, offset = 0; ; ++i, offset = i * limit) {
      final List<String> retrieved = client.getAll(limit, offset);
      if (retrieved.isEmpty()) {
        return retrievedAll;
      }
    
      retrievedAll.addAll(retrieved);
    }

    }
    }`

    There is exit condition on return statement depends on empty request
    How to test such cases?
    Sunny Goel
    @goel-sunny

    Hi, we are facing an issue while running pact test verification from spring boot provider app below is the code and error which we are facing :-

    package com.spike.pact;
    
    import au.com.dius.pact.provider.junit.Provider;
    import au.com.dius.pact.provider.junit.State;
    import au.com.dius.pact.provider.junit.loader.PactBroker;
    import au.com.dius.pact.provider.junit5.HttpTestTarget;
    import au.com.dius.pact.provider.junit5.PactVerificationContext;
    import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider;
    import org.junit.jupiter.api.BeforeEach;
    import org.junit.jupiter.api.TestTemplate;
    import org.junit.jupiter.api.extension.ExtendWith;
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.boot.web.server.LocalServerPort;
    import org.springframework.test.context.junit.jupiter.SpringExtension;
    
    @ExtendWith(SpringExtension.class)
    @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
    @Provider("platform")
    @PactBroker(host = "localhost", port = "9292", protocol = "http")
    public class PactApplicationTests {
    
      @LocalServerPort
      private int port;
    
    //  @BeforeEach
    //  void setupTestTarget(PactVerificationContext context) {
    //    context.setTarget(new HttpTestTarget("localhost", port, "/"));
    //  }
    
      @TestTemplate
      @ExtendWith(PactVerificationInvocationContextProvider.class)
      void pactVerificationTestTemplate(PactVerificationContext context) {
        context.verifyInteraction();
      }
    
      @State({"there are 4224 total assets"})
      public void totalAssetsState() {
        System.out.println("Executing asset count test");
      }
    }

    Given there are 4224 total assets
    WARNING: State Change ignored as there is no stateChange URL
    should accept a valid post request for fetching total asset count
    Request Failed - Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)

    Failures:

    0) Verifying a pact between asset-count and platform - should accept a valid post request for fetching total asset count Given there are 4224 total assets
    Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)

    Does anyone have idea, how to resolve this ?

    Matt Fellows
    @mefellows
    :point_up: please see above. We are no longer here
    Dattasaisukumar
    @Dattasaisukumar
    Hi
    can anyone please share the PACT POST Method GITHUB example please
    Francislainy Campos
    @francislainy
    I think you may want to ask your question here as they've said this channel is no longer maintained. https://app.slack.com/client/T5F60FXSQ/C9UN99H24/thread/C9UN99H24-1592926606.157200
    Uladzislau Danilchyk
    @danilchican
    Hi all!
    Is there any example how to write a contract for a negative scenario with 4xx errors? I faced the issue that HttpClientErrorException is thrown instead.
    haripriya517
    @haripriya517
    Hi all!Is there any solution to write Consumer side pact in Spring Context (@SpringbootTest).
    Le Dinh Cuong
    @cuongld2
    My service requires jwt token, so when running provider test it show unauthorized. How do I pass the token value to the header when running the test (Java) @uglyog ? Can you help?

    `@RunWith(SpringRestPactRunner.class)
    @Provider("user-service")
    @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
    //pact_broker is the service name in docker-compose
    @PactBroker(host = "localhost")
    public class ProviderTest {

    @TestTarget
    public final Target target = new SpringBootHttpTarget();
    
    
    private HttpHeaders createHeadersWithToken(String token) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("token", token);
        return headers;
    }
    
    @Test
    @PactVerifyProvider("user-service")
    public void toDefaultState(Map<String, Object> params) {
    
    
    
    }

    }`

    <build>
            <plugins>
                <plugin>
                    <groupId>au.com.dius.pact.provider</groupId>
                    <artifactId>maven</artifactId>
                    <version>4.1.0</version>
                    <configuration><!-- Defaults to ${project.build.directory}/pacts -->
                        <pactBrokerUrl>http://localhost</pactBrokerUrl>
                        <projectVersion>1.0.100</projectVersion> <!-- Defaults to ${project.version} -->
                        <trimSnapshot>true</trimSnapshot> <!-- Defaults to false -->
                        <skipPactPublish>false</skipPactPublish> <!-- Defaults to false -->
                        <serviceProviders>
                            <!-- You can define as many as you need, but each must have a unique name -->
                            <serviceProvider>
                                <name>user-service</name>
                                <!-- All the provider properties are optional, and have sensible defaults (shown below) -->
                                <protocol>http</protocol>
                                <host>localhost</host>
                                <port>8081</port>
                                <path>/</path>
                                <consumers>
                                    <!-- Again, you can define as many consumers for each provider as you need, but each must have a unique name -->
                                    <consumer>
                                        <name>blog_by_id</name>
                                        <!--  currently supports a file path using pactFile or a URL using pactUrl -->
                                        <pactUrl>http://localhost</pactUrl>
                                    </consumer>
                                </consumers>
                            </serviceProvider>
                        </serviceProviders>
                    </configuration>
                </plugin>
            </plugins>
        </build>
     1.1) StatusMismatch: expected status of 200 but was 401
    
        1.2) BodyMismatch: $ BodyMismatch: Expected id=1 but was missing
    
            {
            -  "id": 1,
            -  "title": "Testing",
            -  "content": "Testing"
            +  "timestamp": "2020-10-08T04:43:18.643+0000",
            +  "status": 401,
            +  "error": "Unauthorized",
            +  "message": "Unauthorized",
            +  "path": "/blog/1"
            }
    Le Dinh Cuong
    @cuongld2
    I'm not sure when I run mvn pact:verify it run provider test file, currently it seems it only runs from pom definition
    Matt Fellows
    @mefellows
    this room is no longer maintained, please see the message above