-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sdk): wing test fails if unable to clean up files (#6320)
If a container mounts a volume to the state directory as described in #6295, it can sometimes result in permission errors when the CLI is cleaning up files after `wing test` because the mounted directory may have different permissions. ``` EACCES: permission denied, scandir 'target/test/mount.test.wsim/.state/c892787d9270cdccc06c34c95f7f9738be92b19134' ``` This error only seems to happen on CI for me. I'm not sure of the cause but I'm guessing that in CI, docker runs in a different (rootless maybe?) mode than on macOS. Unblocks winglang/winglibs#207 ## Checklist - [ ] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [ ] Description explains motivation and solution - [ ] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
- Loading branch information
Showing
5 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
bring sim; | ||
bring util; | ||
|
||
// This test was added to check that "wing test" still works when sim.Container is mounted to the state directory | ||
|
||
// only relevant in simulator | ||
if util.env("WING_TARGET") == "sim" { | ||
let container = new sim.Container( | ||
name: "postgres", | ||
image: "postgres:15", | ||
env: { | ||
POSTGRES_PASSWORD: "password" | ||
}, | ||
containerPort: 5432, | ||
volumes: ["$WING_STATE_DIR:/var/lib/postgresql/data"], | ||
); | ||
|
||
test "my test" { | ||
log("dummy test"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...ar/__snapshots__/test_corpus/sdk_tests/container/mount.test.w_compile_tf-aws.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# [mount.test.w](../../../../../../examples/tests/sdk_tests/container/mount.test.w) | compile | tf-aws | ||
|
||
## main.tf.json | ||
```json | ||
{ | ||
"//": { | ||
"metadata": { | ||
"backend": "local", | ||
"stackName": "root", | ||
"version": "0.20.3" | ||
}, | ||
"outputs": {} | ||
}, | ||
"provider": { | ||
"aws": [ | ||
{} | ||
] | ||
} | ||
} | ||
``` | ||
|
18 changes: 18 additions & 0 deletions
18
...s/hangar/__snapshots__/test_corpus/sdk_tests/container/mount.test.w_test_sim.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# [mount.test.w](../../../../../../examples/tests/sdk_tests/container/mount.test.w) | test | sim | ||
|
||
## stderr.log | ||
```log | ||
Warning: unable to clean up test directory: Error: EACCES: permission denied, scandir 'target/test/mount.test.wsim/.state/<STATE_FILE>' | ||
``` | ||
|
||
## stdout.log | ||
```log | ||
[INFO] my test | dummy test | ||
pass ─ mount.test.wsim » root/env0/test:my test | ||
Tests 1 passed (1) | ||
Snapshots 1 skipped | ||
Test Files 1 passed (1) | ||
Duration <DURATION> | ||
``` | ||
|