spanner: Unflake TestMinOpenedSessions

TestMinOpenedSessions did not wait until the maintainer
had had a chance to run, causing the test to sometimes
fail if the check for MinOpened was executed after the
last session was deleted, but before the maintainer had
run.

Fixes #1639.

Change-Id: I8dc0a4114834878302278a214d9f235ea8a14e78
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/47490
Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Dietz <ndietz@google.com>
diff --git a/spanner/session_test.go b/spanner/session_test.go
index 0007eb4..2837db5 100644
--- a/spanner/session_test.go
+++ b/spanner/session_test.go
@@ -446,7 +446,8 @@
 	_, client, teardown := setupMockedTestServerWithConfig(t,
 		ClientConfig{
 			SessionPoolConfig: SessionPoolConfig{
-				MinOpened: 1,
+				MinOpened:                 1,
+				healthCheckSampleInterval: time.Millisecond,
 			},
 		})
 	defer teardown()
@@ -473,6 +474,16 @@
 		s.destroy(true)
 	}
 
+	// Wait until the maintainer has had a chance to replenish the pool.
+	for i := 0; i < 10; i++ {
+		sp.mu.Lock()
+		if sp.numOpened > 0 {
+			sp.mu.Unlock()
+			break
+		}
+		sp.mu.Unlock()
+		<-time.After(sp.healthCheckSampleInterval)
+	}
 	sp.mu.Lock()
 	defer sp.mu.Unlock()
 	// There should be still one session left in either the idle list or in one