summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-09 00:28:19 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-09 00:31:52 -0800
commitaef5781fdf5eca67ea7b2c04399500994090050d (patch)
treef16e53d7714e9a980cdb6a58d14491784b90b229
parent5dca65fa0992bedb826aa7a762dc69e1beaed2de (diff)
downloadfatcat-aef5781fdf5eca67ea7b2c04399500994090050d.tar.gz
fatcat-aef5781fdf5eca67ea7b2c04399500994090050d.zip
revert pg_tmp parallel tests (for now)
I really want these to work, but even with jitter get frequent test failures, and CI is broken.
-rw-r--r--rust/README.md4
-rw-r--r--rust/src/server.rs19
-rw-r--r--rust/tests/helpers.rs4
3 files changed, 7 insertions, 20 deletions
diff --git a/rust/README.md b/rust/README.md
index 33249a44..decfc74d 100644
--- a/rust/README.md
+++ b/rust/README.md
@@ -42,10 +42,6 @@ Build and run:
Tests:
- cargo test
-
- # if you get weird postgres errors, try running only one test at a time
- # (slow and conservative)
cargo test -- --test-threads 1
Note that most "integration" level tests are written in python and run by
diff --git a/rust/src/server.rs b/rust/src/server.rs
index 70e667be..6b389a97 100644
--- a/rust/src/server.rs
+++ b/rust/src/server.rs
@@ -7,9 +7,7 @@ use diesel;
use diesel::pg::PgConnection;
use diesel::r2d2::ConnectionManager;
use dotenv::dotenv;
-use rand::Rng;
-use std::process::Command;
-use std::{env, thread, time};
+use std::env;
#[cfg(feature = "postgres")]
embed_migrations!("../migrations/");
@@ -59,23 +57,16 @@ pub fn create_server() -> Result<Server> {
/// CI should run tests serially.
pub fn create_test_server() -> Result<Server> {
dotenv().ok();
- // sleep a bit so we don't have thundering herd collisions, resuliting in
- // "pg_extension_name_index" or "pg_proc_proname_args_nsp_index" or "pg_type_typname_nsp_index"
- // duplicate key violations.
- thread::sleep(time::Duration::from_millis(
- rand::thread_rng().gen_range(0, 200),
- ));
- let pg_tmp = Command::new("./tests/pg_tmp.sh")
- .output()
- .expect("run ./tests/pg_tmp.sh to get temporary postgres DB");
- let database_url = String::from_utf8_lossy(&pg_tmp.stdout).to_string();
+ let database_url = env::var("TEST_DATABASE_URL").expect("TEST_DATABASE_URL must be set");
env::set_var("DATABASE_URL", database_url);
let mut server = create_server()?;
server.auth_confectionary = AuthConfectionary::new_dummy();
let conn = server.db_pool.get().expect("db_pool error");
- // run migrations; this is a fresh/bare database
+ // create fresh database
+ diesel_migrations::run_pending_migrations(&conn).unwrap();
+ diesel_migrations::revert_latest_migration(&conn).unwrap();
diesel_migrations::run_pending_migrations(&conn).unwrap();
Ok(server)
}
diff --git a/rust/tests/helpers.rs b/rust/tests/helpers.rs
index 2ba94a5c..677a8855 100644
--- a/rust/tests/helpers.rs
+++ b/rust/tests/helpers.rs
@@ -36,7 +36,7 @@ pub fn setup_client() -> (Client, Context, Listening) {
let mut iron_server = Iron::new(chain);
iron_server.threads = 1;
- // XXX: this isn't support to block, but it is. Disabling these tests for now.
+ // XXX: this isn't supposed to block, but it is. Disabling these tests for now.
let iron_server = iron_server
.http("localhost:9300")
.expect("Failed to start HTTP server");
@@ -51,7 +51,7 @@ pub fn setup_http() -> (
iron::middleware::Chain,
diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::PgConnection>>,
) {
- let server = fatcat::create_test_server().unwrap();
+ let server = server::create_test_server().unwrap();
let conn = server.db_pool.get().expect("db_pool error");
// setup auth as admin user