Skip to content

Commit

Permalink
update database restore test
Browse files Browse the repository at this point in the history
  • Loading branch information
NikTJ777 committed Nov 6, 2020
1 parent 0689fb6 commit 50d4d65
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ github.com/gruntwork-io/gruntwork-cli v0.6.1 h1:sPeSdsn3TU1PJMPUHJRFfrxTBHNF0Y0O
github.com/gruntwork-io/gruntwork-cli v0.6.1/go.mod h1:jp6Z7NcLF2avpY8v71fBx6hds9eOFPELSuD/VPv7w00=
github.com/gruntwork-io/terratest v0.28.10 h1:4K3idJK5atavZ7iwY+L+RPCA7lFwPu87dVnoFOaoPzI=
github.com/gruntwork-io/terratest v0.28.10/go.mod h1:PkVylPuUNmItkfOTwSiFreYA4FkanK8AluBuNeGxQOw=
github.com/gruntwork-io/terratest v0.30.17 h1:4gTq6rihN5lVkSlHQRYu7Hser7KMT8Ke4Wr90C2520M=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
Expand Down
4 changes: 4 additions & 0 deletions test/minikube/minikube_base_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ func restoreDatabase(t *testing.T, namespaceName string, podName string, databas
defer k8s.RunKubectl(t, kubectlOptions, "delete", "job", "restore-demo")

testlib.AwaitPodPhase(t, namespaceName, "restore-demo-", corev1.PodSucceeded, 120*time.Second)
podName := testlib.GetPodName(t, namespaceName, "restore-demo-")
if restoreLog, err := k8s.RunKubectlAndGetOutputE(t, kubectlOptions, "logs", podName); err != nil {
t.Log(restoreLog)
}
}

testlib.AwaitDatabaseRestart(t, namespaceName, podName, "demo", databaseOptions, restore)
Expand Down
10 changes: 4 additions & 6 deletions test/testlib/minikube_utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,9 @@ func AwaitDatabaseRestart(t *testing.T, namespace string, podName string, databa
restart()

Await(t, func() bool {
return GetDatabaseIncarnation(t, namespace, podName, databaseName).Major > incarnation.Major
newIncarnation := GetDatabaseIncarnation(t, namespace, podName, databaseName)
t.Log("incarnation ->", newIncarnation)

This comment has been minimized.

Copy link
@mkysel

mkysel Nov 6, 2020

Contributor

this log is not necessary, you can see the incarnation from the previous line

TestKubernetesRestoreDatabase 2020-11-06T06:32:38Z logger.go:66: Running command kubectl with args [--namespace testkubernetesrestoredatabase-nrbqi3 exec admin-nrbqi3-nuodb-cluster0-0 -- nuocmd --show-json get databases]
TestKubernetesRestoreDatabase 2020-11-06T06:32:41Z logger.go:66: {
TestKubernetesRestoreDatabase 2020-11-06T06:32:41Z logger.go:66:   "incarnation": {
TestKubernetesRestoreDatabase 2020-11-06T06:32:41Z logger.go:66:     "major": 2, 
TestKubernetesRestoreDatabase 2020-11-06T06:32:41Z logger.go:66:     "minor": 0
TestKubernetesRestoreDatabase 2020-11-06T06:32:41Z logger.go:66:   }, 
TestKubernetesRestoreDatabase 2020-11-06T06:32:41Z logger.go:66:   "name": "demo", 
TestKubernetesRestoreDatabase 2020-11-06T06:32:41Z logger.go:66:   "state": "AWAITING_ARCHIVE_HISTORIES_MSG", 
TestKubernetesRestoreDatabase 2020-11-06T06:32:41Z logger.go:66:   "uri": "https://localhost:8888/api/1/databases/demo"
TestKubernetesRestoreDatabase 2020-11-06T06:32:41Z logger.go:66: }
    minikube_utilities.go:566: incarnation -> &{2 0}
return newIncarnation.Major > incarnation.Major
}, 300*time.Second)

opts := GetExtractedOptions(databaseOptions)
Expand Down Expand Up @@ -860,15 +862,11 @@ func RunSQL(t *testing.T, namespace string, podName string, databaseName string,

// secrets := getSecret(t, namespace, databaseName)

result, err = k8s.RunKubectlAndGetOutputE(t, options,
return k8s.RunKubectlAndGetOutputE(t, options,

This comment has been minimized.

Copy link
@mkysel

mkysel Nov 6, 2020

Contributor

good catch!

"exec", podName, "--",
"bash", "-c",
fmt.Sprintf("echo \"%s;\" | /opt/nuodb/bin/nuosql --user dba --password secret %s", sql, databaseName),
)

require.NoError(t, err, "runSQL: error trying to run ", sql)

return result, err
}

func GetNuoDBK8sConfigDump(t *testing.T, namespace string, podName string) NuoDBKubeConfig {
Expand Down

0 comments on commit 50d4d65

Please sign in to comment.