Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Matt Fellows
    @mefellows
    @rollertone_twitter sorry I didn't get to finish what I started ­čść
    I'd be interested in seeing that line of thinking in a POC of sorts,. Another option would be a tool that bootstrapped the pact test code (e.g. templated/generated) so that or will allow
    ...See this is why I hate gitter. I'm on my mobile and hit enter whilst editing something, so it just cuts off the rest of the text...
    Anywho... So that it will allow you to maintain the pact tests properly once up and going (i.e. after you've recorded what's in use). I personally think there are use case for both
    Vito Andolini
    @rollertone_twitter
    @mefellows right, I agree. I certainly follow the purity of the "consumer first" principle. @uglyog brings up a good point that if you just record the service response as a start for creating your pact, it's possible that you're including things in the pact that the consumer does not actually need. This means that in the future, when the service wants to remove something from its API that the client doesn't actually need, the Pact tests fail and there's potential confusion between the teams about whether or not said "thing" can be removed.
    But I still find it rather tedious to manually write the code that the builder uses to generate Pact files if you have an existing app that makes many service calls.
    Perhaps there's a happy medium... that you can record response and generate the Pact files, but that the consumer team should do a review after generation. Does this save time? Might be debatable but I'm probably going to give it a shot.
    Matt Fellows
    @mefellows
    Yep. One of the reasons pact is used is to help deprecate/update APIs. So if you include everything then you don't know what is safe to change. You coild record from the comsumers side, if the consumers already have the teststho (still would suffer part of that problem. You'd know what APIs but not what fields are consumed)
    I'm keen to see this explored though. There's perhaps a middle ground we're not catering for but still adds some value
    On terms of the review process, that's something we're looking to add to our pact broker - ability to review a change before it becoming 'official'
    victor alemany
    @valemanym_twitter
    @uglyog Can you please provide an eta on pact-jvm-provider-spock ? , i know its hard to tell, just need a rough estimate. Given the situation with Grails killing support for Junit we are gonna have to kill all of our pacts and move back to integration testing :( , but im pushing to wait for spock support of course
    Siamak Khoubyari
    @khoubyari
    I am a new user and slightly confused and would appreciate some clarification. in all the consumer-side Pact java samples I've seen so far, they use the DSL in java unit tests to construct the request and verify the response, adding a JSON string, etc. This seems hard to create and maintain. Is there any way I (as a consumer) can just create a Pact file (in JSON or Yaml) and pass it to Pact library along with the host and post of the provider and have it validated? Basically declaring my expected request/response in a file instead of through writing verbose java code? Is there an example of this somewhere?
    the closest thing I've found is the Atlassian validator: https://bitbucket.org/atlassian/swagger-mock-validator
    Matt Fellows
    @mefellows
    @signed that would he missing the point. You might as well just create a swagger doc and get them to validate it. The point of pact is that your actual code is executed as part of the test, so it is guaranteed that you actual make the call and is therefore a true expectation in the provider. As time goes by and your code evolves, any new expectations or ones no longer required would be picked up this way. If we just created a doc they could easily drift - that's why pact was created in the first place (because that happens all of the time)
    Matt Fellows
    @mefellows
    @valemanym_twitter that seems quite drastic! Perhaps you could invest that time in writing the Spock pact implementation instead ­čść
    Ronald Holshausen
    @uglyog
    @valemanym_twitter I only get to work on Pact-JVM in my spare time, so it depends on how easy the implementation is and how much time I have. Unfortunately, Spock integration did not seem trivial the last time I looked at it.
    victor alemany
    @valemanym_twitter
    Oh i see. Sorry was not aware of that. Thanks much for your work and support @uglyog , really appreciate it and find it useful.
    @mefellows thats a fair statement , but i think migrating back to integration tests will take less time in this case since we had some of them before migrating to pact , will be a big refactor but still faster than diving into implement a full pact-jvm-provider-spock
    victor alemany
    @valemanym_twitter
    Just be aware whoever is using grails and Junit with pact provider and calling controllers directly will be blocked
    its just good info for the future. Thanks again all.
    pijushcse
    @pijushcse

    Hi all, I am pretty new to pact. I wrote a consumer test using pact jvm version. And when I run the test , I am getting following error:
    java.lang.NoSuchMethodError: scala.Predef$.$conforms()Lscala/Predef$$less$colon$less;

    I am using pact-jvm-consumer-junit_2.12: 3.5.15 dependency

    Here is the full trace of the error:

    Exception in thread "Thread-2" java.lang.NoSuchMethodError: scala.Predef$.$conforms()Lscala/Predef

    KaTeX parse error: Unexpected character: '$' at position 4: less╠▓$colon$less;
     : less$colon$less;
        at au.com.dius.pact.model.Matching$.javaMapToScalaMap3(Matching.scala:104)
        at au.com.dius.pact.model.Matching$.matchQuery(Matching.scala:178)
        at au.com.dius.pact.model.RequestMatching$.requestMismatches(RequestMatching.scala:52)
        at au.com.dius.pact.model.RequestMatching$.compareRequest(RequestMatching.scala:43)
        at au.com.dius.pact.model.RequestMatching.au$com$dius$pact$model$RequestMatching
    compareToActual$1(RequestMatching.scala:12)
    at au.com.dius.pact.model.RequestMatching
    KaTeX parse error: Unexpected character: '$' at position 7: anonfun╠▓$1.apply(Reque: anonfun$1.apply(RequestMatching.scala:13)
        at au.com.dius.pact.model.RequestMatching
    anonfun$1.apply(RequestMatching.scala:13)
    at scala.collection.TraversableLike
    KaTeX parse error: Unexpected character: '$' at position 7: anonfun╠▓$map$1.apply(T: anonfun$map$1.apply(TraversableLike.scala:244)
        at scala.collection.TraversableLike
    anonfun$map$1.apply(TraversableLike.scala:244)

    Any help will be appreciated. Thanks!
    Muru Muthusamy
    @Murumuthus_twitter
    I'm trying to use pact contract testing for our microservices. we are using client library as a provider which intern calls REST web services. But our consumer calls a method in client lib. Can we use pact for this scenario? how do we have contract with client-lib provider?
    Santosh Tripathi
    @santoshtrip_twitter
    Has anyone used the Swagger mock validator for pact verification?
    Matt Fellows
    @mefellows
    This message was deleted
    Hi @santoshtrip_twitter @Murumuthus_twitter @pijushcse FYI we are migrating to Slack as Gitter has a number of issues and is no longer supported. Join us at slack.pact.io
    Hanumanth Abhilash
    @abhi86tweet_twitter
    @ShettynSunil_twitter / @uglyog / @mefellows / @sivaganesh1988 / @gnewitt : Hi Sunil, can you please tell me how to write provider test for kafka message producer. Here is the question : https://stackoverflow.com/questions/50569251/pact-jvm-for-message-queues-can-someone-provide-sample-provider-test-for-kafka
    This message was deleted
    Hanumanth Abhilash
    @abhi86tweet_twitter
    Here is consumer Test code :
    package com.appd.contracts;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import org.junit.Assert;
    import org.junit.Rule;
    import org.junit.Test;
    
    import au.com.dius.pact.consumer.MessagePactBuilder;
    import au.com.dius.pact.consumer.MessagePactProviderRule;
    import au.com.dius.pact.consumer.Pact;
    import au.com.dius.pact.consumer.dsl.PactDslJsonBody;
    import au.com.dius.pact.consumer.PactVerification;
    import au.com.dius.pact.model.v3.messaging.MessagePact;
    
    
    public class ExampleMessageConsumerTest {
    
        @Rule
        public MessagePactProviderRule mockProvider = new MessagePactProviderRule(this);
        private byte[] currentMessage;
    
        @Pact(provider = "SimpleProvider", consumer = "SimpleConsumer")
        public MessagePact createPact(MessagePactBuilder builder) {
            PactDslJsonBody body = new PactDslJsonBody();
            body.stringValue("10", "100");
    
            Map<String, String> metadata = new HashMap<>();
            metadata.put("contentType", "application/json");
    
            return builder.given("SomeProviderState")
                    .expectsToReceive("a test message")
                    .withMetadata(metadata)
                    .withContent(body)
                    .toPact();
        }
    
        @Test
        @PactVerification({"test_provider", "SomeProviderState"})
        public void test() throws Exception {
            Assert.assertNotNull(new String(currentMessage));
        }
    
        public void setMessage(byte[] messageContents) {
            currentMessage = messageContents;
        }
    }
    Can someone tell me how to write provider test for above consumer test for kakfa queue ?
    Henrik Stene
    @steam0

    Good morning (In europe, hehe). I am having trouble using the gradle plugin to publish to a pact broker combined with the pact-jvm-junit5 package. I cannot seem to change the path of the pact from /targets/pact to /build/pacts. I have reported the issue on github because I think this might be a bug.
    DiUS/pact-jvm#690

    Anyone here that has any good ideas?

    Henrik Stene
    @steam0
    @uglyog ^
    Ronald Holshausen
    @uglyog
    @steam0 we are migrating to Slack as Gitter has a number of issues and is no longer supported. Join us at slack.pact.io
    But it does look like a defect, so raising an issue is the correct thing to do
    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