Skip to content

Commit 260b8f3

Browse files
committed
tests: Use TOML config file for integration tests
Switch from --postgres-url CLI args to --config with a generated TOML file, so the [log_store] section is available for the logs-query test.
1 parent fee13b2 commit 260b8f3

1 file changed

Lines changed: 48 additions & 8 deletions

File tree

tests/src/config.rs

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,61 @@ impl Config {
198198
) -> anyhow::Result<Child> {
199199
let ports = &self.graph_node.ports;
200200

201+
// Generate a TOML config file so we can include [log_store]
202+
let log_dir = "/tmp/integration-test-logs";
203+
std::fs::create_dir_all(log_dir).ok();
204+
let config_content = format!(
205+
r#"
206+
[store]
207+
[store.primary]
208+
connection = "{db_url}"
209+
pool_size = 10
210+
211+
[deployment]
212+
[[deployment.rule]]
213+
store = "primary"
214+
indexers = ["default"]
215+
216+
[chains]
217+
ingestor = "default"
218+
219+
[chains.test]
220+
shard = "primary"
221+
provider = [
222+
{{ label = "test", url = "{eth_url}", features = [] }}
223+
]
224+
225+
[log_store]
226+
backend = "file"
227+
directory = "{log_dir}"
228+
retention_hours = 0
229+
"#,
230+
db_url = self.db.url(),
231+
eth_url = self.eth.url(),
232+
log_dir = log_dir,
233+
);
234+
let config_path = std::env::temp_dir().join("graph-node-integration-test.toml");
235+
std::fs::write(&config_path, &config_content)?;
236+
237+
let config_path_str = config_path.to_string_lossy().to_string();
238+
let http_port = ports.http.to_string();
239+
let index_port = ports.index.to_string();
240+
let admin_port = ports.admin.to_string();
241+
let metrics_port = ports.metrics.to_string();
242+
201243
let args = [
202-
"--postgres-url",
203-
&self.db.url(),
204-
"--ethereum-rpc",
205-
&self.eth.network_url(),
244+
"--config",
245+
&config_path_str,
206246
"--ipfs",
207247
&self.graph_node.ipfs_uri,
208248
"--http-port",
209-
&ports.http.to_string(),
249+
&http_port,
210250
"--index-node-port",
211-
&ports.index.to_string(),
251+
&index_port,
212252
"--admin-port",
213-
&ports.admin.to_string(),
253+
&admin_port,
214254
"--metrics-port",
215-
&ports.metrics.to_string(),
255+
&metrics_port,
216256
];
217257

218258
let args = args

0 commit comments

Comments
 (0)