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

chore(tmc): use real terraform in e2e tests #1177

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

i4ki
Copy link
Contributor

@i4ki i4ki commented Oct 12, 2023

Reasons for this change

Before we used a fake terraform binary that mimicked some Terraform behavior and it supported fully customization of the program's output.
The problem is that the fake terraform misses a lot of important details:

  • terraform show gives different error messages depending on different requirements not met.
  • terraform show requires an initialized terraform module and then mimicking this behavior is hard.
  • terraform show checks the lock files
  • etc

if we ignore those details, we miss the opportunity to test those cases and improve Terramate error messages for such errors.
The error message improvements are not addressed in this PR.

Changes

  • Now during the e2e test setup, the Terraform is installed in a temp directory using the hashicorp official hc-install library.
  • Tests were updated to use a real project.
  • Sandbox library updated to support copy and run commands.

@netlify
Copy link

netlify bot commented Oct 12, 2023

Deploy Preview for terramate-io-docs canceled.

Name Link
🔨 Latest commit 3668835
🔍 Latest deploy log https://app.netlify.com/sites/terramate-io-docs/deploys/65301e965163a40008ce8950

@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (b0b6318) 62.76% compared to head (1b89f94) 62.82%.
Report is 3 commits behind head on main.

❗ Current head 1b89f94 differs from pull request most recent head 3668835. Consider uploading reports for the commit 3668835 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1177      +/-   ##
==========================================
+ Coverage   62.76%   62.82%   +0.06%     
==========================================
  Files         102      102              
  Lines       16395    16431      +36     
==========================================
+ Hits        10290    10323      +33     
- Misses       5681     5683       +2     
- Partials      424      425       +1     
Flag Coverage Δ
tests 62.82% <94.91%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
fs/copy.go 56.45% <100.00%> (+3.00%) ⬆️
test/sandbox/sandbox.go 86.22% <100.00%> (+0.67%) ⬆️
test/os.go 80.90% <80.00%> (-0.15%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@i4ki i4ki force-pushed the i4k-add-real-terraform-testcases branch from 58823c3 to 313ec9c Compare October 12, 2023 14:31
@i4ki i4ki changed the title chore(tmc): use real terraform in e2etests chore(tmc): use real terraform in e2e tests Oct 12, 2023
@i4ki i4ki force-pushed the i4k-add-real-terraform-testcases branch from 313ec9c to 135085a Compare October 12, 2023 14:33
@github-actions
Copy link

github-actions bot commented Oct 12, 2023

metric: time/op
ListFiles-2: old 179µs ± 4%: new 178µs ± 4%: delta: 0.00%
Generate-2: old 4.48s ± 4%: new 4.42s ± 2%: delta: 0.00%
GenerateRegex-2: old 2.88s ± 2%: new 2.86s ± 3%: delta: 0.00%
TokensForExpressionComplex-2: old 2.21ms ± 3%: new 2.22ms ± 3%: delta: 0.00%
TokensForExpressionPlainStringNoNewline-2: old 1.65µs ± 1%: new 1.66µs ± 3%: delta: 0.00%
TokensForExpressionStringWith100Newlines-2: old 53.5µs ± 1%: new 53.9µs ± 2%: delta: 0.69%
TokensForExpressionObjectWith100KeysWithNumberValues-2: old 2.55ms ± 2%: new 2.58ms ± 3%: delta: 1.11%
TokensForExpression-2: old 2.20ms ± 2%: new 2.23ms ± 3%: delta: 1.49%
PartialEvalComplex-2: old 719µs ± 3%: new 717µs ± 3%: delta: 0.00%
PartialEvalSmallString-2: old 6.26µs ± 2%: new 6.33µs ± 3%: delta: 1.17%
PartialEvalHugeString-2: old 3.13ms ± 2%: new 3.07ms ± 2%: delta: -2.01%
PartialEvalHugeInterpolatedString-2: old 8.38ms ± 4%: new 8.44ms ± 4%: delta: 0.00%
PartialEvalObject-2: old 36.1µs ± 3%: new 36.9µs ± 4%: delta: 2.25%
metric: alloc/op
ListFiles-2: old 99.4kB ± 0%: new 99.4kB ± 0%: delta: 0.00%
Generate-2: old 2.34GB ± 0%: new 2.34GB ± 0%: delta: 0.00%
GenerateRegex-2: old 952MB ± 0%: new 953MB ± 0%: delta: 0.02%
TokensForExpressionComplex-2: old 412kB ± 0%: new 412kB ± 0%: delta: 0.00%
TokensForExpressionPlainStringNoNewline-2: old 592B ± 0%: new 592B ± 0%: delta: 0.00%
TokensForExpressionStringWith100Newlines-2: old 14.0kB ± 0%: new 14.0kB ± 0%: delta: 0.00%
TokensForExpressionObjectWith100KeysWithNumberValues-2: old 402kB ± 0%: new 402kB ± 0%: delta: 0.00%
TokensForExpression-2: old 412kB ± 0%: new 412kB ± 0%: delta: 0.00%
PartialEvalComplex-2: old 353kB ± 0%: new 353kB ± 0%: delta: 0.00%
PartialEvalSmallString-2: old 1.74kB ± 0%: new 1.74kB ± 0%: delta: 0.00%
PartialEvalHugeString-2: old 166kB ± 0%: new 166kB ± 0%: delta: 0.00%
PartialEvalHugeInterpolatedString-2: old 4.38MB ± 0%: new 4.38MB ± 0%: delta: 0.00%
PartialEvalObject-2: old 20.4kB ± 0%: new 20.4kB ± 0%: delta: 0.00%
metric: allocs/op
ListFiles-2: old 474 ± 0%: new 474 ± 0%: delta: 0.00%
Generate-2: old 25.9M ± 0%: new 25.9M ± 0%: delta: 0.00%
GenerateRegex-2: old 18.3M ± 0%: new 18.3M ± 0%: delta: 0.00%
TokensForExpressionComplex-2: old 4.93k ± 0%: new 4.93k ± 0%: delta: 0.00%
TokensForExpressionPlainStringNoNewline-2: old 21.0 ± 0%: new 21.0 ± 0%: delta: 0.00%
TokensForExpressionStringWith100Newlines-2: old 328 ± 0%: new 328 ± 0%: delta: 0.00%
TokensForExpressionObjectWith100KeysWithNumberValues-2: old 3.29k ± 0%: new 3.29k ± 0%: delta: 0.00%
TokensForExpression-2: old 4.93k ± 0%: new 4.93k ± 0%: delta: 0.00%
PartialEvalComplex-2: old 2.83k ± 0%: new 2.83k ± 0%: delta: 0.00%
PartialEvalSmallString-2: old 23.0 ± 0%: new 23.0 ± 0%: delta: 0.00%
PartialEvalHugeString-2: old 35.0 ± 0%: new 35.0 ± 0%: delta: 0.00%
PartialEvalHugeInterpolatedString-2: old 23.1k ± 0%: new 23.1k ± 0%: delta: 0.00%
PartialEvalObject-2: old 125 ± 0%: new 125 ± 0%: delta: 0.00%

@i4ki i4ki force-pushed the i4k-add-real-terraform-testcases branch 5 times, most recently from 5cd7968 to 6b9afc7 Compare October 12, 2023 15:04
@i4ki i4ki marked this pull request as ready for review October 12, 2023 15:05
@i4ki i4ki requested a review from a team as a code owner October 12, 2023 15:05
@i4ki i4ki force-pushed the i4k-add-real-terraform-testcases branch from 6b9afc7 to d11e31b Compare October 12, 2023 20:11
snakster
snakster previously approved these changes Oct 16, 2023
test/sandbox/sandbox.go Outdated Show resolved Hide resolved
## Reasons for this change

Before we used a fake terraform binary that mimicked some Terraform behavior and it supported fully customization of the program's output.
The problem is that the fake terraform misses a lot of important details:
- `terraform show` gives different error messages depending on different requirements not met.
- `terraform show` requires an initialized terraform module and then mimicking this behavior is hard.
- `terraform show` checks the lock files
- etc

if we ignore those details, we miss the opportunity to test those cases and improve Terramate error messages for such errors.
_The error message improvements are not addressed in this PR_.

## Changes

- Now during the e2e test setup, the Terraform is installed in a temp directory using the hashicorp official `hc-install` library.
- Tests were updated to use a real project.
- Sandbox library updated to support `copy` and `run` commands.
@i4ki i4ki added this pull request to the merge queue Oct 19, 2023
Merged via the queue into main with commit 26e1cc1 Oct 19, 2023
13 checks passed
@i4ki i4ki deleted the i4k-add-real-terraform-testcases branch October 19, 2023 09:36
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