Skip to content

Commit

Permalink
fix issues with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Haaroon committed Jun 3, 2024
1 parent cd5444d commit aff0c1c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions python/src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,13 @@ impl PyRaphtoryServer {
///
/// Arguments:
/// * `port`: the port to use (defaults to 1736).
#[pyo3(signature = (port = 1736, log_level="INFO".to_string(),enable_tracing=false))]
#[pyo3(signature = (port = 1736, log_level="INFO".to_string(),enable_tracing=false,enable_auth=false))]
pub fn start(
slf: PyRefMut<Self>,
port: u16,
log_level: String,
enable_tracing: bool,
enable_auth: bool,
) -> PyResult<PyRunningRaphtoryServer> {
let (sender, receiver) = crossbeam_channel::bounded::<BridgeCommand>(1);
let server = take_server_ownership(slf)?;
Expand All @@ -361,8 +362,10 @@ impl PyRaphtoryServer {
.build()
.unwrap()
.block_on(async move {
let handler = server.start_with_port(port, &log_level, enable_tracing);
let tokio_sender = handler._get_sender().clone();
let handler =
server.start_with_port(port, &log_level, enable_tracing, enable_auth);
let running_server = handler.await;
let tokio_sender = running_server._get_sender().clone();
tokio::task::spawn_blocking(move || {
match receiver.recv().expect("Failed to wait for cancellation") {
BridgeCommand::StopServer => tokio_sender
Expand All @@ -371,7 +374,7 @@ impl PyRaphtoryServer {
BridgeCommand::StopListening => (),
}
});
let result = handler.wait().await;
let result = running_server.wait().await;
_ = cloned_sender.send(BridgeCommand::StopListening);
result
})
Expand All @@ -384,15 +387,17 @@ impl PyRaphtoryServer {
///
/// Arguments:
/// * `port`: the port to use (defaults to 1736).
#[pyo3(signature = (port = 1736, log_level="INFO".to_string(),enable_tracing=false))]
#[pyo3(signature = (port = 1736, log_level="INFO".to_string(),enable_tracing=false,enable_auth=false))]
pub fn run(
slf: PyRefMut<Self>,
py: Python,
port: u16,
log_level: String,
enable_tracing: bool,
enable_auth: bool,
) -> PyResult<()> {
let mut server = Self::start(slf, port, log_level, enable_tracing)?.server_handler;
let mut server =
Self::start(slf, port, log_level, enable_tracing, enable_auth)?.server_handler;
py.allow_threads(|| wait_server(&mut server))
}
}
Expand Down
7 changes: 1 addition & 6 deletions raphtory-graphql/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,6 @@ impl RaphtoryServer {
.data(app_state.clone())
.with(token_middleware.clone()),
)
// .at(
// "/secure_endpoint",
// secure_endpoint.with(token_middleware.clone()),
// )
.at("/logout", logout.with(token_middleware.clone()))
.with(CookieJarManager::new())
.with(Cors::new());
Expand Down Expand Up @@ -487,7 +483,6 @@ mod server_tests {
let handler = server.start_with_port(0, "info", false, false);
sleep(Duration::from_secs(1)).await;
println!("Calling stop at time {}", Local::now());
handler.await.stop().await;
handler.await.wait().await.unwrap()
handler.await.stop().await
}
}

0 comments on commit aff0c1c

Please sign in to comment.