diff --git a/tests/common/server_fixture.rs b/tests/common/server_fixture.rs index be0f675305..0a46b94411 100644 --- a/tests/common/server_fixture.rs +++ b/tests/common/server_fixture.rs @@ -68,7 +68,7 @@ use tokio::sync::Mutex; /// testing. pub struct ServerFixture { server: Arc, - grpc_channel: std::sync::RwLock, + grpc_channel: tonic::transport::Channel, } /// Specifieds should we configure a server initially @@ -133,12 +133,10 @@ impl ServerFixture { } async fn create_common(server: Arc) -> Self { - let grpc_channel = std::sync::RwLock::new( - server - .grpc_channel() - .await - .expect("The server should have been up"), - ); + let grpc_channel = server + .grpc_channel() + .await + .expect("The server should have been up"); ServerFixture { server, @@ -149,8 +147,7 @@ impl ServerFixture { /// Return a channel connected to the gRPC API. Panics if the /// server is not yet up pub fn grpc_channel(&self) -> tonic::transport::Channel { - let guard = self.grpc_channel.read().expect("getting gRPC channel lock"); - guard.clone() + self.grpc_channel.clone() } /// Return the url base of the grpc management API @@ -201,19 +198,21 @@ impl ServerFixture { /// Restart test server. /// /// This will break all currently connected clients! - pub async fn restart_server(&self) { + pub async fn restart_server(self) -> Self { self.server.restart().await; self.server .wait_until_ready(InitialConfig::SetWriterId) .await; - - let new_channel = self + let grpc_channel = self .server .grpc_channel() .await .expect("The server should have been up"); - let mut guard = self.grpc_channel.write().expect("lock poisened"); - *guard = new_channel; + + Self { + server: self.server, + grpc_channel, + } } } diff --git a/tests/end_to_end_cases/preservation.rs b/tests/end_to_end_cases/preservation.rs index a6a8a233fb..7b4c166143 100644 --- a/tests/end_to_end_cases/preservation.rs +++ b/tests/end_to_end_cases/preservation.rs @@ -45,7 +45,7 @@ async fn test_query_chunk_after_restart() { assert_chunk_query_works(&fixture, &db_name).await; // restart server - fixture.restart_server().await; + let fixture = fixture.restart_server().await; // need to re-register the database create_readable_database(&db_name, fixture.grpc_channel()).await;