terraform-cdk icon indicating copy to clipboard operation
terraform-cdk copied to clipboard

Testcase fails if Docker is not running

Open ansgarm opened this issue 4 years ago • 2 comments
trafficstars

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

This testcase fails if Docker is not running: https://github.com/hashicorp/terraform-cdk/blob/a5d0380585abee49c9ffbaa7fa6454aa186d07f8/packages/cdktf/lib/testing/tests/matchers.test.ts#L246-L256

But as these logs are usually swallowed:

╷
│ Error: Error pinging Docker server: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
│ 
│   with provider["registry.terraform.io/terraform-providers/docker"],
│   on cdk.tf.json line 19, in provider.docker[0]:
│   19:       {}
│ 
╵

They are swallowed because stdio is ignored here: https://github.com/hashicorp/terraform-cdk/blob/a5d0380585abee49c9ffbaa7fa6454aa186d07f8/packages/cdktf/lib/testing/matchers.ts#L267-L267

The original failure message does not help much when trying to figure out why this is failing:

matchers › toPlanSuccessfully › succeeds if the terraform config passed is valid

    expect(received).toBeTruthy()

    Received: false

      255 |       
    > 256 |       expect(res.pass).toBeTruthy();
          |                        ^
      257 |       expect(res.message()).toMatchInlineSnapshot(
      258 |         `"Expected subject not to plan successfully"`
      259 |       );

      at Object.<anonymous> (lib/testing/__tests__/matchers.test.ts:256:24)

Setting CDKTF_LOG_LEVEL also does not work, as the stdio from Terraform is ignored.

Tasks

  • [ ] Use a different resource for the test case (e.g. local_file)

ansgarm avatar Sep 27 '21 10:09 ansgarm

This is pretty annoying for my local development. I'm running a local VS Code dev container via Docker Desktop and WSL2 on Windows.

jsteinich avatar Oct 05 '21 04:10 jsteinich

This is not only the case in the matcher tests, but also in the project conversion test in the hcl2cdk package

DanielMSchmidt avatar Oct 13 '21 10:10 DanielMSchmidt

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Feb 12 '24 01:02 github-actions[bot]