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

Backport of Support namespaces in test helpers into release/1.13.x #20077

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions helper/testhelpers/testhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func GenerateRootWithError(t testing.T, cluster *vault.TestCluster, kind Generat
keys = cluster.BarrierKeys
}
client := cluster.Cores[0].Client
oldNS := client.Namespace()
defer client.SetNamespace(oldNS)
client.ClearNamespace()

var err error
var status *api.GenerateRootStatusResponse
Expand Down Expand Up @@ -174,6 +177,10 @@ func AttemptUnsealCore(c *vault.TestCluster, core *vault.TestClusterCore) error
}

client := core.Client
oldNS := client.Namespace()
defer client.SetNamespace(oldNS)
client.ClearNamespace()

client.Sys().ResetUnsealProcess()
for j := 0; j < len(c.BarrierKeys); j++ {
statusResp, err := client.Sys().Unseal(base64.StdEncoding.EncodeToString(c.BarrierKeys[j]))
Expand Down Expand Up @@ -242,7 +249,10 @@ func DeriveActiveCore(t testing.T, cluster *vault.TestCluster) *vault.TestCluste
t.Helper()
for i := 0; i < 60; i++ {
for _, core := range cluster.Cores {
oldNS := core.Client.Namespace()
core.Client.ClearNamespace()
leaderResp, err := core.Client.Sys().Leader()
core.Client.SetNamespace(oldNS)
if err != nil {
t.Fatal(err)
}
Expand All @@ -260,7 +270,10 @@ func DeriveStandbyCores(t testing.T, cluster *vault.TestCluster) []*vault.TestCl
t.Helper()
cores := make([]*vault.TestClusterCore, 0, 2)
for _, core := range cluster.Cores {
oldNS := core.Client.Namespace()
core.Client.ClearNamespace()
leaderResp, err := core.Client.Sys().Leader()
core.Client.SetNamespace(oldNS)
if err != nil {
t.Fatal(err)
}
Expand Down