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

Hashicorp Vaul tests ignore components initialization errors and test for uninitialized/undefined behaviour #2330

Closed
tmacam opened this issue Nov 30, 2022 · 0 comments · Fixed by #2331
Labels
kind/bug Something isn't working

Comments

@tmacam
Copy link
Contributor

tmacam commented Nov 30, 2022

Expected Behavior

Actual Behavior

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
in fact hiding errors in the test setup even in Unix systems:

--- FAIL: TestVaultTokenPrefix (0.01s)
    --- FAIL: TestVaultTokenPrefix/if_vaultKVUsePrefix_is_false_ignore_vaultKVPrefix (0.00s)
        vault_test.go:174: couldn't read vault token from mount path ./vault.txt err: open ./vault.txt: no such file or directory
--- FAIL: TestVaultTokenMountPathOrVaultTokenRequired (0.00s)
    --- FAIL: TestVaultTokenMountPathOrVaultTokenRequired/with_vaultTokenMount (0.00s)
        vault_test.go:245: couldn't read vault token from mount path ./vault.txt err: open ./vault.txt: no such file or directory
--- FAIL: TestDefaultVaultAddress (0.00s)
    --- FAIL: TestDefaultVaultAddress/with_blank_vaultAddr (0.00s)
        vault_test.go:320: couldn't read vault token from mount path ./vault.txt err: open ./vault.txt: no such file or directory

This is just a problem in test setup. I have not observed any impact on the component behavior impacted by this.

Steps to Reproduce the Problem

Replace _ = target.Init(m) with if err := target.Init(m); err != nil {t.Fatal(err) } and run tests in vault_test.go

Release Note

RELEASE NOTE: FIX Improve Hashicorp Vault test setup.

@tmacam tmacam added the kind/bug Something isn't working label Nov 30, 2022
tmacam added a commit to tmacam/dapr-components-contrib that referenced this issue Nov 30, 2022
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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant