Hi <#C9UTHV2AD|>, It seems that "branch" and "tag...
# pact-net
s
Hi #C9UTHV2AD, It seems that "branch" and "tags" does not get populated in Pactflow as configured in PactVerifier for my Provider Pact test. After test run, only "Provider Version" gets populated but not Branch and Tags. I'm using PactNet 4.3.0. Could anyone advice on how to fix this?
Copy code
[Fact]
        public async void Ensure_Api_Honours_PactWithConsumers()
        {
            var config = new PactVerifierConfig
            {
                Outputters = new List<IOutput>
                {
                    new XUnitOutput(_output),
                },
                LogLevel = PactNet.PactLogLevel.Trace
            };

            IPactVerifier pactVerifier = new PactVerifier(config);

            Assert.True(PactInvoker.IsRunning(out _));

            pactVerifier
                .ServiceProvider("DemoMicroservice", _serverUri)
                .WithPactBrokerSource(PactBrokerUrl,
                    (c) =>
                    {
                        c.TokenAuthentication(PactBrokerToken);
                        c.ConsumerTags(PactBrokerConsumerTags);
                        c.PublishResults(PactBrokerProviderVersion);
                        c.ProviderBranch(PactBrokerProviderBranch);
                        c.ProviderTags(PactBrokerProviderTags);
                    })
                .WithProviderStateUrl(new Uri(_serverUri, ProviderStatesEndpoint))
                .Verify();
        }
m
can you please share the logs (looks like you are at trace level) for this? (be sure to redact anything sensitive)
s
Here is the log from build agent. Only extracted the logs after test run completed.
Copy code
##[debug]   --environment
##[debug]   TestSettings__PactBroker__ProviderVersion=6f3ebdae855f18a6c057fc23cae55408e3015155
##[debug]   --environment
##[debug]   TestSettings__PactBroker__ProviderBranch=ITSO-275-FixProviderVerifyTagging
##[debug]   --environment
##[debug]   TestSettings__PactBroker__ProviderTags=ITSO-275-FixProviderVerifyTagging
--- truncated. Added above to show what's expected to be saved into PactFlow
##[debug]12 results
##[debug]found 12 paths
##[debug]applying include pattern
##[debug]adjustedPattern: '/buildagent/_work/_temp/**/*.trx'
##[debug]1 matches
##[debug]1 final results
##[debug]TestManagement.Server.UsePublishTestResultsLibInAgent is on
##[debug]Object of TestLogStore created.
Result Attachments will be stored in LogStore
##[debug]Object of TestResultsPublisher created.
##[debug]Object of TestLogStore created.
Run Attachments will be stored in LogStore
##[debug]Object of TestRunPublisher created.
##[debug]Object of TestLogStore created.
##[debug]TestManagement.PublishTestResultsTask.EnableXUnitHeirarchicalParsing is on
##[debug]Object of TrxResultParser created.
##[debug]Entering ParseTestResultFiles
##[debug]runContext.ReleaseURI is null
##[debug]runContext.ReleaseEnvironmentUri is null
##[debug]Reading test results from file '/buildagent/_work/_temp/_vm-nwbuildlc-02_2023-02-06_19_05_33.trx'.
##[debug]Setting run start and finish times.
##[debug]Attachment location: /buildagent/_work/_temp/_vm-nwbuildlc-02_2023-02-06_19_05_33/In.
##[debug]Total test results: 1.
##[debug]Leaving ParseTestResultFiles
##[debug]Processed: ##vso[results.publish type=VSTest;mergeResults=false;publishRunAttachments=true;resultFiles=/buildagent/_work/_temp/_vm-nwbuildlc-02_2023-02-06_19_05_33.trx;testRunSystem=VSTS - dotnet;]
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: <https://docs.microsoft.com/en-us/dotnet/core/tools/> and <https://docs.microsoft.com/en-us/dotnet/core/compatibility/> . To learn about more such changes and troubleshoot, refer here: <https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting>
##[debug]Uploading build level attachements individually
Async Command Start: Publish test results
##[debug]runContext.ReleaseURI is null
##[debug]runContext.ReleaseEnvironmentUri is null
##[debug]Entering PublishToNewTestRunPerTestResultFileAsync
##[debug]Entering CreateTestRunAsync
##[debug]Leaving CreateTestRunAsync
##[debug]Total build level attachments: 0.
##[debug]Entering AddTestResultsAsync
Publishing test results to test run '1070690'.
TestResults To Publish 1, Test run id:1070690
Test results publishing 1, remaining: 0. Test run id: 1070690
##[debug]Leaving AddTestResultsAsync
##[debug]Entering UpdateTestRunAsync
##[debug]Leaving UpdateTestRunAsync
##[debug]Entering CreateTestRunAttachmentsAsync
##[debug]Leaving CreateTestRunAttachmentsAsync
##[debug]Uploading test run attachements individually
##[debug]Entering UploadTestRunLogAsync
##[debug]Blob name: GeneralAttachment/_vm-nwbuildlc-02_2023-02-06_19_05_33.trx .
##[debug]File uploaded successsfully on LogStore _vm-nwbuildlc-02_2023-02-06_19_05_33.trx
Published Test Run : <https://AZDO/_TestManagement/Runs?runId=1070690&_a=runCharts>
##[debug]Leaving PublishToNewTestRunPerTestResultFileAsync
##[debug]TestManagement.PTR.CalculateTestRunSummary is on
##[debug]RESOURCE_URIS:
##[debug]Setting task variable METADATA_956bdb31-4403-47cc-af16-40dbcac4b587: {"name":"2a2e097c-18ec-47b6-a1d2-cb9471289385","resourceUris":[],"metadata":{"description":"","relatedUrls":[{"url":"<https://AZDO/_build/results?buildId=77995>","label":"pipeline-url"}],"humanReadableName":"Test Results from Publish Test Results utility","serializedPayload":"{\"testId\":\"PublishTestResults\",\"testTool\":\"VSTest\",\"testResultAttestation\":{\"total\":1,\"failed\":0,\"passed\":1,\"skipped\":0},\"testDurationSeconds\":0.0,\"testPassPercentage\":\"100\",\"relatedUrls\":[{\"url\":\"<https://AZDO/_build/results?buildId=77995>\",\"label\":\"pipeline-url\"}]}"}} 
##[debug]TestManagement.Agent.PTR.EnableFlakyCheck is on
##[debug]TestManagement.Server.TriggerCoverageMergeJob is on
Async Command End: Publish test results
m
hmmm these logs aren’t helpful, where are the Pact logs output to? These are just .NET logs or something else
s
Hi @Matt (pactflow.io / pact-js / pact-go), You're right. I rerun the tests locally and got the pact verifier output logs. For troubleshooting purposes, I have also attached the expected provider details per comments below
Copy code
pactVerifier
                .ServiceProvider("PriceMicroservice", _serverUri)
                .WithPactBrokerSource(PactBrokerUrl,
                    (c) =>
                    {
                        c.TokenAuthentication(PactBrokerToken);
                        c.ConsumerTags(PactBrokerConsumerTags); // master
                        c.PublishResults(PactBrokerProviderVersion); // timestamp. e.g. 20230207162248
                        c.ProviderBranch(PactBrokerProviderBranch); // local
                        c.ProviderTags(PactBrokerProviderTags); // local
                    })
                .WithProviderStateUrl(new Uri(_serverUri, ProviderStatesEndpoint))
                .Verify();
log (partial)
Copy code
Standard Output: 
    Starting verification...
    Pact verification successful
    
    Verifier Output
    ---------------
    The pact at <https://demo.pactflow.io/pacts/provider/ProviderMS/consumer/ConsumerMS/pact-version/ad2ae57bcb321110989410bc60c2a454ae8b194c> is being verified because the pact content belongs to the consumer version matching the following criterion:
        * latest version tagged 'master' (4bc7861c4b622a26673d614adddbed7fd7bc5c2d)
    
    Verifying a pact between ConsumerMS and ProviderMS
    
      A GET request to retrieve health check
        returns a response which
          has status code 200 (OK)
          has a matching body (OK)
    
      A GET request to retrieve the Price
         Given There is a asset with code 'DemoCode'
        returns a response which
          has status code 200 (OK)
          includes headers
            "Content-Type" with value "application/json; charset=utf-8" (OK)
          has a matching body (OK)
    
    
    Verifier Logs
    -------------
    2023-02-07T05:22:56.840073Z  INFO ThreadId(01) pact_verifier::pact_broker: Fetching path '/' from pact broker
    2023-02-07T05:22:56.840237Z DEBUG ThreadId(01) reqwest::connect: starting new connection: <https://demo.pactflow.io/>    
    2023-02-07T05:22:56.909897Z DEBUG ThreadId(01) hyper::client::connect::http: connecting to 11.22.33.444:443
    2023-02-07T05:22:56.934381Z DEBUG ThreadId(01) hyper::client::connect::http: connected to 11.22.33.444:443
    2023-02-07T05:22:56.934438Z DEBUG ThreadId(01) rustls::client::hs: No cached session for DnsName(DnsName(DnsName("<http://demo.pactflow.io|demo.pactflow.io>")))    
    2023-02-07T05:22:56.934615Z DEBUG ThreadId(01) rustls::client::hs: Not resuming any session    
    2023-02-07T05:22:56.993404Z DEBUG ThreadId(01) rustls::client::hs: ALPN protocol is Some(b"h2")    
    2023-02-07T05:22:56.993419Z DEBUG ThreadId(01) rustls::client::hs: Using ciphersuite TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256    
    2023-02-07T05:22:56.993433Z DEBUG ThreadId(01) rustls::client::tls12::server_hello: Server supports tickets    
    2023-02-07T05:22:57.032276Z DEBUG ThreadId(01) rustls::client::tls12: ECDHE curve is ECParameters { curve_type: NamedCurve, named_group: secp256r1 }    
    2023-02-07T05:22:57.032292Z DEBUG ThreadId(01) rustls::client::tls12: Server DNS name is DnsName(DnsName(DnsName("<http://demo.pactflow.io|demo.pactflow.io>")))    
    2023-02-07T05:22:57.076876Z DEBUG ThreadId(01) rustls::client::tls12: Session saved    
    2023-02-07T05:22:57.076934Z DEBUG ThreadId(01) h2::client: binding client connection
    2023-02-07T05:22:57.076968Z DEBUG ThreadId(01) h2::client: client connection bound
    2023-02-07T05:22:57.076987Z DEBUG ThreadId(01) h2::codec::framed_write: send frame=Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384 }
    2023-02-07T05:22:57.077169Z DEBUG ThreadId(01) hyper::client::pool: pooling idle connection for ("https", <http://demo.pactflow.io|demo.pactflow.io>)
    2023-02-07T05:22:57.320051Z DEBUG ThreadId(01) reqwest::async_impl::client: response '200 OK' for <https://demo.pactflow.io/>    
    2023-02-07T05:22:57.320730Z DEBUG ThreadId(01) pact_verifier::pact_broker: Link URL is templated
    2023-02-07T05:22:57.320878Z DEBUG ThreadId(01) pact_verifier::pact_broker: templated URL = <https://demo.pactflow.io/pacts/provider/{provider}/for-verification>
    2023-02-07T05:22:57.323853Z DEBUG ThreadId(01) pact_verifier::pact_broker: final URL = <https://demo.pactflow.io/pacts/provider/ProviderMS/for-verification>
    2023-02-07T05:22:57.324027Z  INFO ThreadId(01) pact_verifier::pact_broker: Fetching path '/pacts/provider/ProviderMS/for-verification' from pact broker
    2023-02-07T05:22:57.324118Z DEBUG ThreadId(01) hyper::client::pool: reuse idle connection for ("https", <http://demo.pactflow.io|demo.pactflow.io>)
    2023-02-07T05:22:57.492096Z DEBUG ThreadId(01) reqwest::async_impl::client: response '200 OK' for <https://demo.pactflow.io/pacts/provider/ProviderMS/for-verification>    
    2023-02-07T05:22:57.492762Z DEBUG ThreadId(01) pact_verifier::pact_broker: templated URL = <https://demo.pactflow.io/pacts/provider/ProviderMS/for-verification>
    2023-02-07T05:22:57.494093Z DEBUG ThreadId(01) pact_verifier::pact_broker: final URL = <https://demo.pactflow.io/pacts/provider/ProviderMS/for-verification>
    2023-02-07T05:22:57.494138Z DEBUG ThreadId(01) pact_verifier::pact_broker: Sending JSON to <https://demo.pactflow.io/pacts/provider/ProviderMS/for-verification> using POST: {"providerVersionTags":["local"],"includePendingStatus":false,"consumerVersionSelectors":[{"tag":"master","latest":true}],"providerVersionBranch":"local"}
    2023-02-07T05:22:57.494234Z DEBUG ThreadId(01) hyper::client::pool: reuse idle connection for ("https", <http://demo.pactflow.io|demo.pactflow.io>)
    2023-02-07T05:22:57.636555Z DEBUG ThreadId(01) reqwest::async_impl::client: response '200 OK' for <https://demo.pactflow.io/pacts/provider/ProviderMS/for-verification> 

(truncated)
Please refer to the complete log in testlog file here.
What caught my attention this log below,
Copy code
2023-02-07T05:22:57.494138Z DEBUG ThreadId(01) pact_verifier::pact_broker: Sending JSON to <https://demo.pactflow.io/pacts/provider/ProviderMS/for-verification> using POST: {"providerVersionTags":["local"],"includePendingStatus":false,"consumerVersionSelectors":[{"tag":"master","latest":true}],"providerVersionBranch":"local"}
In the request payload, it appears that both "providerVersionTags" and "providerVersionBranch" got assigned the correct value from PactBrokerProviderTags and PactBrokerProviderBranch correctly, from the code snippet above. However these values didn't get updated in Pactflow. Only the Provider Version did with timestamp as expected.
m
That’s the verification step, not the publishing bit
This is the publishing bit:
Copy code
2023-02-07T05:22:58.316533Z  INFO ThreadId(01) pact_verifier: Publishing verification results back to the Pact Broker
2023-02-07T05:22:58.316536Z DEBUG ThreadId(01) pact_verifier: Publishing a successful result to PactBroker(<https://demo.pactflow.io/>, provider_name='ProviderMS')
2023-02-07T05:22:58.318699Z DEBUG ThreadId(01) pact_verifier::pact_broker: Sending JSON to <https://demo.pactflow.io/pacts/provider/ProviderMS/consumer/ConsumerMS/pact-version/ad2ae57bcb321110989410bc60c2a454ae8b194c/metadata/c1tdW3RdPW1hc3RlciZzW11bbF09dHJ1ZSZzW11bY3ZdPTExNg/verification-results> using POST: {"providerApplicationVersion":"20230207162248","success":true,"testResults":[{"interactionId":"2da03f3edcdbdf18a1c7ccfb6ef3dbf6258db005","success":true},{"interactionId":"8f59d27ead87c2f9110c12f71b97703408bcbf15","success":true}],"verifiedBy":{"implementation":"Pact-Rust","version":"0.4.5"}}
It looks to be missing the branch info. Not sure where the bug is for that bit, but worth raising it on the Pact .NET repo if you could please for looking into
Actually after a quick perusal of the Ruby code base. I’m not 100% sure where that data is sent for storage. @Beth (pactflow.io/Pact Broker/pact-ruby) or @uglyog do you know which API call sends the branch/tag information alongside the verification results?
s
@Matt (pactflow.io / pact-js / pact-go), while waiting for further responses, would you still like me to raise a bug?
u
I think there is a separate API call that is meant to happen before the main publish. Here is the code in Pact-JVM: https://github.com/pact-foundation/pact-jvm/blob/master/provider/src/main/kotlin/au/com/dius/pact/provider/VerificationReporter.kt#L106
👍 1
That uses the
pb:branch-version
link
s
Thanks for looking into this issues. Is this a regression bug? What would be the ETA having it fixed? Meanwhile, is there any workarounds? if it's a regression issue, is there an older version of PactNet I could use?
m
I can’t say for sure Steven, but the first step would be to raise a bug so we can get it on the radar and probably reviewed. Could you please raise on on the Pact .NET repo?
s