You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
String[] consumers() default "${pactbroker.consumers:}"; which is deprecated.
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:
tag = let's imagine develop
latest = let's imagine true
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:
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.
The text was updated successfully, but these errors were encountered:
danilchican
changed the title
Pact Broker issue with consumers filtering
Pact Broker issue with filtering by a consumers list
Sep 22, 2021
uglyog
added
the
bug
Indicates an unexpected problem or unintended behavior
label
Sep 24, 2021
@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
Pact Broker java version used:
au.com.dius.pact.provider:junit5:4.2.3
Verification tests looks like:
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:String[] consumers() default "${pactbroker.consumers:}";
which is deprecated.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 defaultVersionSelector
which constructs based on following properties:As a result of building consumer version selectors we have: one selector item (VersionSelector type) with the values:
develop
true
consumer=Consumer1,Consumer2
) instead of split items and two items ofVersionSelector
.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:
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.The text was updated successfully, but these errors were encountered: