Skip to content

Commit 359df2b

Browse files
committed
server: add tests for graphman config pools graphql api
1 parent 91432b9 commit 359df2b

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

server/graphman/tests/config_query.rs

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,109 @@ fn graphql_can_check_how_specific_subgraph_would_be_placed() {
175175
assert_eq!(resp_custom, expected_resp_custom);
176176
});
177177
}
178+
179+
#[test]
180+
fn graphql_can_fetch_info_about_size_of_database_pools() {
181+
run_test(|| async {
182+
let curr_dir = std::env::current_dir()
183+
.unwrap()
184+
.to_str()
185+
.unwrap()
186+
.to_string();
187+
let config_dir = format!("{}/tests/test_config.toml", curr_dir);
188+
std::env::set_var("GRAPH_NODE_CONFIG", config_dir);
189+
190+
let resp = send_graphql_request(
191+
json!({
192+
"query": r#"{
193+
config {
194+
pools(nodes: ["index_node_1_a", "index_node_2_a", "index_node_3_a"]) {
195+
pools {
196+
shards
197+
node
198+
}
199+
}
200+
}
201+
}"#
202+
}),
203+
VALID_TOKEN,
204+
)
205+
.await;
206+
207+
let expected_resp = json!({
208+
"data": {
209+
"config": {
210+
"pools": {
211+
"pools": [
212+
{
213+
"shards": {
214+
"primary": 2,
215+
"shard_a": 2
216+
},
217+
"node": "index_node_1_a"
218+
},
219+
{
220+
"shards": {
221+
"primary": 10,
222+
"shard_a": 10
223+
},
224+
"node": "index_node_2_a"
225+
},
226+
{
227+
"shards": {
228+
"primary": 10,
229+
"shard_a": 10
230+
},
231+
"node": "index_node_3_a"
232+
}
233+
]
234+
}
235+
}
236+
}
237+
});
238+
239+
assert_eq!(resp, expected_resp);
240+
});
241+
}
242+
243+
#[test]
244+
fn graphql_can_fetch_connections_by_shard() {
245+
run_test(|| async {
246+
let curr_dir = std::env::current_dir()
247+
.unwrap()
248+
.to_str()
249+
.unwrap()
250+
.to_string();
251+
let config_dir = format!("{}/tests/test_config.toml", curr_dir);
252+
std::env::set_var("GRAPH_NODE_CONFIG", config_dir);
253+
254+
let resp = send_graphql_request(
255+
json!({
256+
"query": r#"{
257+
config {
258+
pools(nodes: ["index_node_1_a", "index_node_2_a", "index_node_3_a"]) {
259+
shards
260+
}
261+
}
262+
}"#
263+
}),
264+
VALID_TOKEN,
265+
)
266+
.await;
267+
268+
let expected_resp = json!({
269+
"data": {
270+
"config": {
271+
"pools": {
272+
"shards": {
273+
"primary": 22,
274+
"shard_a": 22
275+
}
276+
}
277+
}
278+
}
279+
});
280+
281+
assert_eq!(resp, expected_resp);
282+
});
283+
}

0 commit comments

Comments
 (0)