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

integ-runner: "Could not checkout snapshot directory" if HEAD branch does not contain snapshots #29278

Open
jvalore-medallia opened this issue Feb 27, 2024 · 5 comments
Labels
@aws-cdk/integ-runner bug This issue is a bug. cli Issues related to the CDK CLI p2

Comments

@jvalore-medallia
Copy link

Describe the bug

Running integ-runner results in a git failures:

Running test /Users/jvalore/Projects/mindful-composer2/test/integ.getConfiguration.ts in us-east-1
error: pathspec 'integ.getConfiguration.ts.snapshot' did not match any file(s) known to git
  SUCCESS    integ.getConfiguration-GetAppConfigurationLambda/DefaultTest 248.229s
       AssertionResultsLambdaInvoked2f382cf205e7f04c4f85bed1cc026bf - success
      AssertionResultsLambdaInvoke3c6d8322bda64b60f1d6ee49af533865 - success

Test Results:

Tests:    1 passed, 1 total
Could not checkout snapshot directory 'test/integ.getConfiguration.ts.snapshot'. Please verify the following command completes correctly:
git checkout $(git merge-base HEAD main) -- integ.getConfiguration.ts.snapshot
error: Error: Command exited with status 1
    at exec2 (/Users/jvalore/Projects/mindful-composer2/node_modules/@aws-cdk/integ-runner/lib/workers/extract/index.js:12932:11)
    at IntegTestRunner.checkoutSnapshot (/Users/jvalore/Projects/mindful-composer2/node_modules/@aws-cdk/integ-runner/lib/workers/extract/index.js:20124:13)
    at IntegTestRunner.deploy (/Users/jvalore/Projects/mindful-composer2/node_modules/@aws-cdk/integ-runner/lib/workers/extract/index.js:20420:18)
    at IntegTestRunner.runIntegTestCase (/Users/jvalore/Projects/mindful-composer2/node_modules/@aws-cdk/integ-runner/lib/workers/extract/index.js:20199:37)
    at Function.integTestWorker (/Users/jvalore/Projects/mindful-composer2/node_modules/@aws-cdk/integ-runner/lib/workers/extract/index.js:30637:34)
    at MessagePort.<anonymous> (/Users/jvalore/Projects/mindful-composer2/node_modules/@aws-cdk/integ-runner/lib/workers/extract/index.js:967:31)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:807:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)

The message:

Could not checkout snapshot directory 'test/integ.getConfiguration.ts.snapshot'. Please verify the following command completes correctly:
git checkout $(git merge-base HEAD main) -- integ.getConfiguration.ts.snapshot

Looks like it doesn't include the test/path in the git command.

Expected Behavior

Test should pass and update snapshot. (Ideally there shouldn't be git lock-in here either, but I guess that is a different discussion).

Current Behavior

(See error message above)

Reproduction Steps

Have an test in the default test/ directory. In my case test/integ.getConfiguration.ts

Run integ-runner --force once. The snapshot is created in

test/integ.getConfiguration.ts.snapshot

git add and git commit the snapshot, as is recommended in the integ-runner docs.

Run integ-runner --force again.
Results in the error message listed above.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.129.0 (build d5ab0df)

Framework Version

No response

Node.js Version

v20.9.0

OS

Mac

Language

TypeScript

Language Version

4.8.4

Other information

No response

@jvalore-medallia jvalore-medallia added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 27, 2024
@pahud
Copy link
Contributor

pahud commented Feb 27, 2024

Unfortunate I can't reproduce this.

When I run npx integ-runner --force for the 2nd time, it just deploys with test UNCHANGED.

image

@pahud pahud added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Feb 27, 2024
@pahud pahud changed the title @aws-cdk/integ-runner: "Could not checkout snapshot directory" seems to uses wrong path integ-runner: "Could not checkout snapshot directory" seems to uses wrong path Feb 27, 2024
@jvalore-medallia
Copy link
Author

@pahud thanks for attempting. I'll see if I can catch it happen again, and if it does I'll try to debug into cdk a bit...

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Feb 28, 2024
@jvalore-medallia
Copy link
Author

I haven't had this error happen again, so going to close this issue for now.

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@jvalore-medallia
Copy link
Author

jvalore-medallia commented Mar 1, 2024

@pahud I am reopening this issue since I got it to happen again.

I think this happens if you work on a branch, and your main branch doesn't have the snapshots yet.

This comment doesn't really make sens to me: https://github.com/aws/aws-cdk/blob/main/packages/@aws-cdk/integ-runner/lib/runner/integ-test-runner.ts#L94-L105

      /**
       * When running integration tests with the update path workflow
       * it is important that the snapshot that is deployed is the current snapshot
       * from the upstream branch. In order to guarantee that, first checkout the latest
       * (to the user) snapshot from upstream
       *
       * It is not straightforward to figure out what branch the current
       * working branch was created from. This is a best effort attempt to do so.
       * This assumes that there is an 'origin'. `git remote show origin` returns a list of
       * all branches and we then search for one that starts with `HEAD branch: `
       */

But that function tries to overwrite your current snapshot in your branch with whatever is in main. So in my case, my current branch has a new feature which makes a new snapshot, and main doesn't have that snapshot. So I get the originally noted git error.

So in my repro steps, that would mean doing a git checkout -b newfeature and making a new test/integ.newfeature.ts test in that branch. Then running integ-test will try to git checkout -- test/integ.newfeature.ts from the main branch, where it doesn't exist.


Is this checkout logic specific to how aws operates and uses this to test cdk itself? It doesn't seem valid for general/public use... what branch I'm currently working in has no relation to main. Why can't the current snapshot just be checked without trying to re-pull it from a completely different branch?


edit:

I was trying to think through some examples to support my statement of

It doesn't seem valid for general/public use

but maybe I'm just projecting my specific use case... at my employer specifically it doesn't work well because we have multiple logical 'head' branches, where we have some diverged code that supports different deployment environments (where aws deployed assets may be different). There is no single logical head in our case.

My initial thought was that if you were working on something like a release branch that is a maybe a month old, then pulling a snapshot from main wouldnt make sense since that branch has moved forward, but the merge-root should return a commit in the past as the common ancestor, so that case is probably fine.

Maybe a contrived example would be something like if you ran a git repo with major versions as branches, and they were unrelated in terms of code. Like v1 and v2 as branches where v2 is a major rewrite or a conversion from JS to TS or something like that, where there isn't really a common ancestor. v1 might be marked as the "head" in git just because there has to be one and only 1, but running integ in v2 has no relation to the snapshots in v1 branch.

@jvalore-medallia jvalore-medallia changed the title integ-runner: "Could not checkout snapshot directory" seems to uses wrong path integ-runner: "Could not checkout snapshot directory" if HEAD branch does not contain snapshots Mar 1, 2024
@pahud pahud added the cli Issues related to the CDK CLI label Apr 11, 2024
@pahud pahud removed the needs-reproduction This issue needs reproduction. label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/integ-runner bug This issue is a bug. cli Issues related to the CDK CLI p2
Projects
None yet
Development

No branches or pull requests

2 participants