Skip to content

tests: json-to-hcl.test can fail when app.test is running at the same time #77

@jsteinich

Description

@jsteinich

Expected Behavior

The two tests can run correctly in parallel.

Actual Behavior

json-to-hcl.test will occasionally fail with:

 FAIL  test/json-to-hcl.test.ts (5.73 s)
  ● pass variables
    ENOENT: no such file or directory, lstat 'terraform.OriginStack.tfstate'

      135 |  */
      136 | function copySync(from: string, to: string) {
    > 137 |   if (fs.lstatSync(from).isDirectory()) {
          |          ^
      138 |     fs.mkdirSync(to, { recursive: true });
      139 |     for (const file of fs.readdirSync(from)) {
      140 |       copySync(path.join(from, file), path.join(to, file));

      at lstatSync (lib/terraform-module-asset.ts:137:10)
      at copySync (lib/terraform-module-asset.ts:140:7)
      at new copySync (lib/terraform-module-asset.ts:65:7)
      at Function.of (lib/terraform-module-asset.ts:81:15)
      at new of (lib/terraform-module.ts:59:44)
      at new TerraformHclModule (lib/terraform-hcl-module.ts:16:5)
      at Object.<anonymous> (test/json-to-hcl.test.ts:973:3)

Steps to Reproduce

  1. Run lerna run --scope 'cdktn' test:ci
  2. Every so often that will fail

Possible Solutions

Make sure different directories are used during the two tests to isolate effects.

Anything Else?

I believe this is caused by a race condition where the json-to-hcl test can detect the outputs of the running app.test when it is initially determining assets, but then those assets are removed when copying the assets.

References

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions