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

Example test case to showcase using Patch Resources and field ownership conflicts #2625

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rquitales
Copy link
Contributor

@rquitales rquitales commented Oct 24, 2023

TestIgnoreChangesPatchResources tests that we can successfully ignore changes to a Patch Resource without SSA conflicts, and accidentally unsetting a field of interest when the Patch resource is declared as the field manager. This allows a user to use a SSA Patch resource like a strategic merge patch resource.
This test uses 2 stacks:

  1. The "deployment stack" creates a Deployment object on cluster.
  2. The "patch stack" uses a DeploymentPatch resource to patch the Deployment object on cluster.

Steps:

  1. Create the deployment stack and let it run in the background with a goroutine.
  2. Wait for the deployment stack to finish creating the deployment object.
  3. Create the patch stack and patch the deployment object to scale to 2 replicas and have shared field
    owner ship of the .metadata.labels.app field.
  4. Validate that the deployment was scaled to 2 replica.
  5. Unblock the last step of the deploymnet step to run, and block the second step of the patch stack from running.
  6. Run the second and final step of the deployment stack to relinquish field ownership of the .metadata.labels.app field
    to the patch stack.
  7. Unblock the second step of the patch stack to run.
  8. Run the second step of the patch stack, which we expect to fail.
  9. Add the .metadata.labels.app field to the ignoreChanges list of the DeploymentPatch resource in step 3 of the patch stack.
  10. Run the third step of the patch stack which we expect to succeed.

@github-actions
Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@codecov-commenter
Copy link

Codecov Report

Merging #2625 (5e4247e) into master (523ff36) will increase coverage by 0.20%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #2625      +/-   ##
==========================================
+ Coverage   18.39%   18.59%   +0.20%     
==========================================
  Files          47       47              
  Lines        9667     9668       +1     
==========================================
+ Hits         1778     1798      +20     
+ Misses       7785     7761      -24     
- Partials      104      109       +5     
Files Coverage Δ
provider/pkg/provider/provider.go 7.24% <0.00%> (-0.01%) ⬇️

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

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.

None yet

2 participants