You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let container = GenericImage::new("quay.io/coreos/etcd","v3.6.4")
317
327
.with_exposed_port(2379.tcp())
318
-
// .with_wait_for(WaitFor::message_on_stdout("ready to serve client requests"))
319
-
.with_wait_for(WaitFor::seconds(20))
320
-
.with_network("bridge")
328
+
.with_wait_for(WaitFor::message_on_either_std(
329
+
"ready to serve client requests",
330
+
))
331
+
.with_privileged(true)
332
+
.with_cmd(CMD)
333
+
.with_startup_timeout(Duration::from_secs(90))
334
+
.start()
335
+
.expect("An etcd image was supposed to be started");
336
+
337
+
let host = container
338
+
.get_host()
339
+
.expect("Host-address should be available");
340
+
341
+
let port = container
342
+
.get_host_port_ipv4(2379.tcp())
343
+
.expect("Exposed host port should be available");
344
+
345
+
let url = format!("{}:{}", host, port);
346
+
dbg!("Testing FDW on container at {}",&url);
347
+
348
+
// Create our fdw
349
+
Spi::run("CREATE FOREIGN DATA WRAPPER etcd_fdw handler etcd_fdw_handler validator etcd_fdw_validator;").expect("FDW should have been created");
350
+
351
+
// Create a server
352
+
Spi::run(
353
+
format!(
354
+
"CREATE SERVER etcd_test_server FOREIGN DATA WRAPPER etcd_fdw options(connstr '{}')",
355
+
url
356
+
)
357
+
.as_str(),
358
+
)
359
+
.expect("Server should have been created");
360
+
361
+
// Create a foreign table
362
+
Spi::run("CREATE FOREIGN TABLE test (key text, value text) server etcd_test_server options (rowid_column 'key')").expect("Test table should have been created");
363
+
}
364
+
#[pg_test]
365
+
fntest_insert_select(){
366
+
let container = GenericImage::new("quay.io/coreos/etcd","v3.6.4")
367
+
.with_exposed_port(2379.tcp())
368
+
.with_wait_for(WaitFor::message_on_either_std(
369
+
"ready to serve client requests",
370
+
))
371
+
.with_cmd(CMD)
372
+
.with_privileged(true)
373
+
.with_startup_timeout(Duration::from_secs(90))
321
374
.start()
322
375
.expect("An etcd image was supposed to be started");
323
376
@@ -347,5 +400,18 @@ mod tests {
347
400
348
401
// Create a foreign table
349
402
Spi::run("CREATE FOREIGN TABLE test (key text, value text) server etcd_test_server options (rowid_column 'key')").expect("Test table should have been created");
403
+
404
+
// Insert into the foreign table
405
+
Spi::run("INSERT INTO test (key, value) VALUES ('foo','bar'),('bar','baz')")
406
+
.expect("INSERT should work");
407
+
408
+
let query_result = Spi::get_two::<String,String>("SELECT * FROM test WHERE key='foo'")
0 commit comments