Refactor test to use hcvault NewTestCluster#658
Refactor test to use hcvault NewTestCluster#658somtochiama wants to merge 1 commit intofluxcd:mainfrom
Conversation
| resource, err := pool.Run("vault", testVaultVersion, []string{"VAULT_DEV_ROOT_TOKEN_ID=" + testVaultToken}) | ||
| if err != nil { | ||
| logger.Fatalf("could not start resource: %s", err) | ||
| cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{ |
There was a problem hiding this comment.
I'm not sure if this is a problem or not but IIUC we're re-using the cluster created here with the "artificial" testing.T context in tests with a different testing.T. Would this pose any problem w.r.t. log output or anything else?
There was a problem hiding this comment.
It seems to be a problem if there's an error in NewTestCluster and t.Fatal is called there. Specifically the tests hangs
I considered copying the whole file or creating a new test cluster for each test, but both seem overkill. Trying to see if there's a different way to structure the tests.
| github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= | ||
| github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= | ||
| github.com/ory/dockertest/v3 v3.8.0 h1:i5b0cJCd801qw0cVQUOH6dSpI9fT3j5tdWu0jKu90ks= |
There was a problem hiding this comment.
why do we still have dockertest in the deps?
There was a problem hiding this comment.
It is also used here. I will replace/remove it accordingly
There was a problem hiding this comment.
dockertest is used in the awskms test here.
I am not sure how we can rewrite this test to not use docker. @aryan9600 any ideas?
| cfg := api.DefaultConfig() | ||
| cfg.Address = testVaultAddress | ||
| cli, err := api.NewClient(cfg) | ||
| cli.SetToken(testClient.Token()) |
There was a problem hiding this comment.
| cli.SetToken(testClient.Token()) | |
| cli.SetToken(testVaultToken) |
| if err := func() error { | ||
| cfg := api.DefaultConfig() | ||
| cfg.Address = testVaultAddress | ||
| cli, err := api.NewClient(cfg) |
There was a problem hiding this comment.
we should check the error before setting the token.
dfce9d9 to
22cb2b8
Compare
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
591af28 to
da796be
Compare
Fixes: #648
Signed-off-by: Somtochi Onyekwere somtochionyekwere@gmail.com