spanner: Unflake TestTakeFromWriteQueue

TestTakeFromWriteQueue inspected the internal data structure of
the session pool without locking the mutex that protects it.
This caused a data race if the health checker or maintainer also
tried to alter the state of the internal data structure at the
same time.

Fixes #1283.

Change-Id: Ib0e6d2d4807cb52fb2bfeed76d7bda57c7f63c04
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/45710
Reviewed-by: Jean de Klerk <deklerk@google.com>
diff --git a/spanner/session_test.go b/spanner/session_test.go
index 7e03925..449ab5b 100644
--- a/spanner/session_test.go
+++ b/spanner/session_test.go
@@ -769,12 +769,14 @@
 	<-time.After(time.Second)
 
 	// The session should now be in write queue but take should also return it.
+	sp.mu.Lock()
 	if sp.idleWriteList.Len() == 0 {
 		t.Fatalf("write queue unexpectedly empty")
 	}
 	if sp.idleList.Len() != 0 {
 		t.Fatalf("read queue not empty")
 	}
+	sp.mu.Unlock()
 	sh, err = sp.take(ctx)
 	if err != nil {
 		t.Fatalf("cannot get session from session pool: %v", err)