public void BoundUnbindInvalidAffinityKey() { GetSessionRequest getSessionRequest = new GetSessionRequest { Name = "random_name" }; Assert.ThrowsException <RpcException>(() => client.GetSession(getSessionRequest)); DeleteSessionRequest deleteSessionRequest = new DeleteSessionRequest { Name = "random_name" }; Assert.ThrowsException <RpcException>(() => client.DeleteSession(deleteSessionRequest)); }
/* * Probes to test session related grpc call from Spanner stub. * * Includes tests against CreateSession, GetSession, ListSessions, and * DeleteSession of Spanner stub. * * Args: * stub: An object of SpannerStub. * metrics: A list of metrics. * */ public static void sessionManagement(Spanner.SpannerClient client, ref Dictionary <string, long> metrics) { long latency; CreateSessionRequest createSessionRequest = new CreateSessionRequest(); createSessionRequest.Database = _DATABASE; //Create Session test //Create stopwatch.Start(); Session session = client.CreateSession(createSessionRequest); stopwatch.Stop(); latency = stopwatch.ElapsedMilliseconds; metrics.Add("create_session_latency_ms", latency); //Get Session GetSessionRequest getSessionRequest = new GetSessionRequest(); getSessionRequest.Name = session.Name; stopwatch.Start(); client.GetSession(getSessionRequest); stopwatch.Stop(); latency = stopwatch.ElapsedMilliseconds; metrics.Add("get_session_latency_ms", latency); //List Session ListSessionsRequest listSessionsRequest = new ListSessionsRequest(); listSessionsRequest.Database = _DATABASE; stopwatch.Start(); client.ListSessions(listSessionsRequest); stopwatch.Stop(); latency = stopwatch.ElapsedMilliseconds; metrics.Add("list_sessions_latency_ms", latency); //Delete Session DeleteSessionRequest deleteSessionRequest = new DeleteSessionRequest(); deleteSessionRequest.Name = session.Name; stopwatch.Start(); client.DeleteSession(deleteSessionRequest); stopwatch.Stop(); latency = stopwatch.ElapsedMilliseconds; metrics.Add("delete_session_latency_ms", latency); }