Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pact Broker issue with filtering by a consumers list #1447

Closed
danilchican opened this issue Sep 22, 2021 · 4 comments
Closed

Pact Broker issue with filtering by a consumers list #1447

danilchican opened this issue Sep 22, 2021 · 4 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@danilchican
Copy link

danilchican commented Sep 22, 2021

Pact Broker java version used: au.com.dius.pact.provider:junit5:4.2.3

Verification tests looks like:

@AllowOverridePactUrl
@IgnoreMissingStateChange
@Provider("My-Provider-Name")
@PactBroker
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class FacadeProviderVerificationTest {
...
}

I've faced with the issue related to filtering by consumers list. There is property pactbroker.consumers that should filter pacts by a consumers list (comma-separated), e.g. pactbroker.consumers=Consumer1,Consumer2,Consumer3.
This property is used in two places inside @PactBroker annotation:

  1. String[] consumers() default "${pactbroker.consumers:}"; which is deprecated.
  2. VersionSelector[] consumerVersionSelectors() which is replacement for the previous approach.

But in case I pass this property with the list of consumers, I cannot get proper result ("no pacts to verify are found" error).
After some debugging, I've found the supposed root cause. The reason is that consumerVersionSelectors() has default VersionSelector which constructs based on following properties:

VersionSelector[] consumerVersionSelectors() default @VersionSelector(
    tag = "${pactbroker.consumerversionselectors.tags:}",
    latest = "${pactbroker.consumerversionselectors.latest:}",
    consumer = "${pactbroker.consumers:}"  <---- look at this
  );

As a result of building consumer version selectors we have: one selector item (VersionSelector type) with the values:

  1. tag = let's imagine develop
  2. latest = let's imagine true
  3. and consumer = here you have whole list (consumer=Consumer1,Consumer2) instead of split items and two items of VersionSelector.

And that selector (one selector) is used to fetch pacts. But consumer with name Consumer1,Consumer2 does not exist. This string is not splitting out.
But (it's important!) this string is used in additional step with filtering already fetched pacts from Pact Broker and in this step string was split to an array of consumers. Why? For what? Why do we filtering pacts while fetching and additionally after fetch?

So there is no filtering by multiple consumer names at all... And I cannot get proper results.

I think it's a bug.

There is, let's say, an "alternative" like consumerVersionSelectors. But this does not change that there is a filtering bug.
Alternative is used to construct these selectors in verification test and it will look like:

@PactBroker(
        consumerVersionSelectors={
                @VersionSelector(tag = "develop", consumer = "Consumer1"),
                @VersionSelector(tag = "develop", consumer = "Consumer2"),
        }
)

But again. It's fine that this approach exists, but it's not a replacement. It would be good to do not lose controlling consumers, tags and so on from CI. Using the last approach it's not possible to control these items from CI cause for every case (consumers combination) we should have separate verification test cause the VersionSelector cannot be added dynamically by using property data. It's quite big costs to move to this solution.

@danilchican danilchican changed the title Pact Broker issue with consumers filtering Pact Broker issue with filtering by a consumers list Sep 22, 2021
@uglyog uglyog added the bug Indicates an unexpected problem or unintended behavior label Sep 24, 2021
@danilchican
Copy link
Author

@uglyog , how soon it will be released? thank you in advance for the quick reply/help.

@uglyog
Copy link
Member

uglyog commented Sep 27, 2021

4.2.13 is released

@danilchican
Copy link
Author

@uglyog , hi! Thank you! Now it's working. But I found another small issue with the consumers filtering along with WIP enabled. Will describe it in separate issue

@danilchican
Copy link
Author

Described here #1449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants