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

Enforce error checking for Vault component initialization on tests. #2331

Merged
merged 1 commit into from
Nov 30, 2022

Conversation

tmacam
Copy link
Contributor

@tmacam tmacam commented Nov 30, 2022

Description

Tests in vault_test.go had the following:

    // This call will throw an error on Windows systems because of the of
    // the call x509.SystemCertPool() because system root pool is not
    // available on Windows so ignore the error for when the tests are run
    // on the Windows platform during CI
    _ = target.Init(m)

As of Go 1.18 this is not the case for Windows anymore and
we can instead enforce error checking. References:

Given Dapr depends on Go 1.19, we can enforce tests on Init result
and remove this comment.

While enforcing error checking we notice that the code above was
actually hiding errors in the test setup. Component initialization was
ending prematurely due to those errors and the test code was wrongfully
testing for the behavior of a component that has not been successfully
initialized. This is also addressed in this PR.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #2330

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation / Created issue in the https://github.com/dapr/docs/ repo: dapr/docs#[issue number]

Tests in vault_test.go had the following :

```go
    // This call will throw an error on Windows systems because of the of
    // the call x509.SystemCertPool() because system root pool is not
    // available on Windows so ignore the error for when the tests are run
    // on the Windows platform during CI
    _ = target.Init(m)
```

As of Go 1.18 this is not the case for Windows anymore and
we can instead enforce error checking. References:

* golang/go#16736
* golang/go#18609
* rancher/system-agent#84
* jaegertracing/jaeger#2756

Given Dapr depends on Go 1.19, we can enforce tests on `Init` result
and remove this comment.

While enforcing error checking we notice that the code above was
actually hiding errors in the test setup. Component initialization was
ending prematurely due to those errors and the test code was wrongfully
testing for the behavior of a component that has not been successfully
initialized. This is also addressed in this PR.

Closes dapr#2330.

Signed-off-by: Tiago Alves Macambira <tmacam@burocrata.org>
@tmacam tmacam marked this pull request as ready for review November 30, 2022 01:22
@tmacam tmacam requested review from a team as code owners November 30, 2022 01:22
@tmacam
Copy link
Contributor Author

tmacam commented Nov 30, 2022

FYI: this has been tested on Windows (native, not WSL) ;)

@codecov
Copy link

codecov bot commented Nov 30, 2022

Codecov Report

Merging #2331 (b4c65ed) into master (47b0d73) will decrease coverage by 0.13%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2331      +/-   ##
==========================================
- Coverage   38.22%   38.09%   -0.14%     
==========================================
  Files         202      202              
  Lines       25496    25496              
==========================================
- Hits         9747     9713      -34     
- Misses      14985    15025      +40     
+ Partials      764      758       -6     
Impacted Files Coverage Δ
configuration/azure/appconfig/appconfig.go 61.13% <0.00%> (-12.56%) ⬇️
state/in-memory/in_memory.go 38.28% <0.00%> (-2.98%) ⬇️
secretstores/hashicorp/vault/vault.go 36.63% <0.00%> (+1.98%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@berndverst berndverst merged commit 6f13681 into dapr:master Nov 30, 2022
@tmacam tmacam deleted the SystemCertPoolWorksInWindows branch November 30, 2022 19:34
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.

Hashicorp Vaul tests ignore components initialization errors and test for uninitialized/undefined behaviour
3 participants