fix(spanner): fix flaky TestCustomerManagedEncryptionKeys test
* Increased timeout for TestCustomerManagedEncryptionKeys to 1.5 hours from 1 hour
* Added logs to debug time taken in create DB, create backup and restoreDB operation with encryption keys.
Fixes
@@ -428,13 +428,12 @@ func TestCreateDatabaseWithRetentionPeriodSample(t *testing.T) {
}
func TestCustomerManagedEncryptionKeys(t *testing.T) {
- t.Skip("https://github.com/GoogleCloudPlatform/golang-samples/issues/2230")
if os.Getenv("GOLANG_SAMPLES_E2E_TEST") == "" {
t.Skip("GOLANG_SAMPLES_E2E_TEST not set")
}
tc := testutil.SystemTest(t)
t.Parallel()
-
+ startTime := time.Now()
instName, dbName, cleanup := initTest(t, randomID())
defer cleanup()
@@ -456,7 +455,7 @@ func TestCustomerManagedEncryptionKeys(t *testing.T) {
keyId,
)
- ctx, cancel := context.WithTimeout(context.Background(), time.Hour)
+ ctx, cancel := context.WithTimeout(context.Background(), 90*time.Minute)
defer cancel()
// Create an encrypted database. The database is automatically deleted by the cleanup function.
@@ -465,6 +464,7 @@ func TestCustomerManagedEncryptionKeys(t *testing.T) {
}
out := b.String()
assertContains(t, out, fmt.Sprintf("Created database [%s] using encryption key %q", dbName, kmsKeyName))
+ t.Logf("create database operation took: %v\n", time.Since(startTime))
// Try to create a backup of the encrypted database and delete it after the test.
backupId := fmt.Sprintf("enc-backup-%s", randomID())
@@ -475,6 +475,7 @@ func TestCustomerManagedEncryptionKeys(t *testing.T) {
out = b.String()
assertContains(t, out, fmt.Sprintf("backups/%s", backupId))
assertContains(t, out, fmt.Sprintf("using encryption key %s", kmsKeyName))
+ t.Logf("create backup operation took: %v\n", time.Since(startTime))
// Try to restore the encrypted database and delete the restored database after the test.
restoredName := fmt.Sprintf("%s/databases/rest-enc-%s", instName, randomID())
@@ -484,6 +485,7 @@ func TestCustomerManagedEncryptionKeys(t *testing.T) {
out = runBackupSampleWithRetry(ctx, t, restoreFunc, restoredName, backupId, "failed to restore database with customer managed encryption key", 10)
assertContains(t, out, fmt.Sprintf("Database %s restored", dbName))
assertContains(t, out, fmt.Sprintf("using encryption key %s", kmsKeyName))
+ t.Logf("restore backup operation took: %v\n", time.Since(startTime))
}
func TestCreateDatabaseWithDefaultLeaderSample(t *testing.T) {
