Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: graph-node-status-endpoint for DeploymentDetail status_url #91

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 74 additions & 52 deletions common/src/subgraph_client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ pub struct DeploymentDetails {

impl DeploymentDetails {
pub fn for_graph_node(
graph_node_status_url: &str,
graph_node_base_url: &str,
deployment: DeploymentId,
) -> Result<Self, anyhow::Error> {
Ok(Self {
deployment: Some(deployment),
status_url: Some(Url::parse(&format!("{graph_node_base_url}/status"))?),
status_url: Some(Url::parse(graph_node_status_url)?),
query_url: Url::parse(&format!("{graph_node_base_url}/subgraphs/id/{deployment}"))?,
})
}
Expand Down Expand Up @@ -206,23 +207,23 @@ mod test {
let deployment =
DeploymentId::from_str("QmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA").unwrap();

let mock_server_local = MockServer::start().await;
mock_server_local
.register(
Mock::given(method("POST"))
.and(path("/status"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"data": {
"indexingStatuses": [
{
"synced": true,
"health": "healthy"
}
]
}
}))),
)
let mock_server_status = MockServer::start().await;
mock_server_status
.register(Mock::given(method("POST")).respond_with(
ResponseTemplate::new(200).set_body_json(json!({
"data": {
"indexingStatuses": [
{
"synced": true,
"health": "healthy"
}
]
}
})),
))
.await;

let mock_server_local = MockServer::start().await;
mock_server_local
.register(
Mock::given(method("POST"))
Expand Down Expand Up @@ -255,7 +256,14 @@ mod test {
// Create the subgraph client
let client = SubgraphClient::new(
reqwest::Client::new(),
Some(DeploymentDetails::for_graph_node(&mock_server_local.uri(), deployment).unwrap()),
Some(
DeploymentDetails::for_graph_node(
&mock_server_status.uri(),
&mock_server_local.uri(),
deployment,
)
.unwrap(),
),
DeploymentDetails::for_query_url(&format!(
"{}/subgraphs/id/{}",
mock_server_remote.uri(),
Expand All @@ -278,23 +286,23 @@ mod test {
let deployment =
DeploymentId::from_str("QmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA").unwrap();

let mock_server_local = MockServer::start().await;
mock_server_local
.register(
Mock::given(method("POST"))
.and(path("/status"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"data": {
"indexingStatuses": [
{
"synced": true,
"health": "unhealthy"
}
]
}
}))),
)
let mock_server_status = MockServer::start().await;
mock_server_status
.register(Mock::given(method("POST")).respond_with(
ResponseTemplate::new(200).set_body_json(json!({
"data": {
"indexingStatuses": [
{
"synced": true,
"health": "unhealthy"
}
]
}
})),
))
.await;

let mock_server_local = MockServer::start().await;
mock_server_local
.register(
Mock::given(method("POST"))
Expand Down Expand Up @@ -327,7 +335,14 @@ mod test {
// Create the subgraph client
let client = SubgraphClient::new(
reqwest::Client::new(),
Some(DeploymentDetails::for_graph_node(&mock_server_local.uri(), deployment).unwrap()),
Some(
DeploymentDetails::for_graph_node(
&mock_server_status.uri(),
&mock_server_local.uri(),
deployment,
)
.unwrap(),
),
DeploymentDetails::for_query_url(&format!(
"{}/subgraphs/id/{}",
mock_server_remote.uri(),
Expand All @@ -350,23 +365,23 @@ mod test {
let deployment =
DeploymentId::from_str("QmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA").unwrap();

let mock_server_local = MockServer::start().await;
mock_server_local
.register(
Mock::given(method("POST"))
.and(path("/status"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"data": {
"indexingStatuses": [
{
"synced": false,
"health": "healthy"
}
]
}
}))),
)
let mock_server_status = MockServer::start().await;
mock_server_status
.register(Mock::given(method("POST")).respond_with(
ResponseTemplate::new(200).set_body_json(json!({
"data": {
"indexingStatuses": [
{
"synced": false,
"health": "healthy"
}
]
}
})),
))
.await;

let mock_server_local = MockServer::start().await;
mock_server_local
.register(
Mock::given(method("POST"))
Expand Down Expand Up @@ -399,7 +414,14 @@ mod test {
// Create the subgraph client
let client = SubgraphClient::new(
reqwest::Client::new(),
Some(DeploymentDetails::for_graph_node(&mock_server_local.uri(), deployment).unwrap()),
Some(
DeploymentDetails::for_graph_node(
&mock_server_status.uri(),
&mock_server_local.uri(),
deployment,
)
.unwrap(),
),
DeploymentDetails::for_query_url(&format!(
"{}/subgraphs/id/{}",
mock_server_remote.uri(),
Expand Down
2 changes: 2 additions & 0 deletions service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ async fn main() -> Result<(), std::io::Error> {
.network_subgraph_deployment
.map(|deployment| {
DeploymentDetails::for_graph_node(
&config.indexer_infrastructure.graph_node_status_endpoint,
&config.indexer_infrastructure.graph_node_query_endpoint,
deployment,
)
Expand Down Expand Up @@ -128,6 +129,7 @@ async fn main() -> Result<(), std::io::Error> {
.escrow_subgraph_deployment
.map(|deployment| {
DeploymentDetails::for_graph_node(
&config.indexer_infrastructure.graph_node_status_endpoint,
&config.indexer_infrastructure.graph_node_query_endpoint,
deployment,
)
Expand Down