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

fix: optimise WIP pacts by using branch/tag heads #668

Merged

Conversation

bethesque
Copy link
Member

PACT-1845

@bethesque
Copy link
Member Author

A consumer version may have tags associated with it. Tags were what we used before we had branches and environments. Many customers still use tags to represent their branches. For these customers the "latest pact for a tag" generally equates to "the latest pact for a branch".

When calculating the set of pacts that should be returned for verification, there are two subsets.

  1. Those specified by the consumer version selectors eg. { branch: "main", latest: true}, { tag: "prod", latest: true} and
  2. the "work in progress pacts", where we attempt to return what we think are the pacts that are currently being worked on.

For both subsets of pacts, for customers who use tags, we identify the latest pact for each consumer version tag.

The exact logic for "latest pact for a tag" though, has some subtleties around it, and has changed over time. This is because we discovered problems with the original implementation.

Imagine "Some Consumer" which has published pacts for 3 application versions, which it has tagged with the branch name "main". For the first version, it publishes pacts with Providers 1 and 2. By the time it publishes v2, things have changed, and it no longer requires the integration with Provider 2, so it only publishes the pact for Provider 1.

image

Imagine we are fetching the pacts for verification. The original Pact Broker logic used to return the pact for Provider 2, even though that integration was no longer necessary. This was discovered to cause problems when verifying pacts, because that old pact would stick around in the verifications, even though the consumer didn't need that provider any more, and if the provider changed its behaviour in a way that caused that old pact to fail, it was unnecessarily blocking that provider from changing.

The new logic only returns pacts that belong to the latest version for each tag, so if a pact for an integration stops being published, it will stop being verified.

This new logic had been applied to subset 1 of the 'pacts for verification' response - the pacts specified by the consumer version selectors. It hadn't been applied to subset 2 of the pacts - the WIP pacts.

This PR updates the WIP pacts logic to use the "new" approach for finding the "latest pact for each tag". The upside of making this change is that as well as correcting the logic, it is a much more efficient query, and should help fix some performance issues we've been having.

@bethesque bethesque merged commit 871209e into master Feb 29, 2024
16 of 17 checks passed
@bethesque bethesque deleted the feat/use-branch-and-tag-heads-for-pacts-for-verification branch February 29, 2024 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants