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

Tests fail unless forced to run on single thread #17

Open
lolgesten opened this issue Mar 8, 2018 · 6 comments
Open

Tests fail unless forced to run on single thread #17

lolgesten opened this issue Mar 8, 2018 · 6 comments

Comments

@lolgesten
Copy link

Hi! In my code I think I have an issue with renaming of nullable enum values, so I figured I try running your tests and maybe extending them. However I didn't get that far, because I get test fails with the tests that are already there.

Is this something to do with my setup? I tried both postgres 9 and 10.

martin@rexlk:~/dev/diesel-derive-enum/tests$ cargo test --features postgres nullable
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running target/debug/deps/tests-4a7899a1fb646353

running 2 tests
test nullable::nullable_enum_round_trip ... FAILED
test nullable::not_nullable_enum_round_trip ... ok

failures:

---- nullable::nullable_enum_round_trip stdout ----
	thread 'nullable::nullable_enum_round_trip' panicked at 'called `Result::unwrap()` on an `Err` value: DatabaseError(__Unknown, "column \"my_enum\" is of type my_enum but expression is of type pg_temp_2.my_enum")', src/libcore/result.rs:916:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.


failures:
    nullable::nullable_enum_round_trip

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 3 filtered out
@lolgesten
Copy link
Author

Oh wait. It's stranger than that. It's intermittent. Running the tests over and over, sometimes it succeeds.

@lolgesten
Copy link
Author

Could it be that the pg_temp is not isolated per connection and we get concurrency problems between the two tests?

@adwhit
Copy link
Owner

adwhit commented Mar 8, 2018

Hi, yeah there is some kind of problem with isolating the tables in Postgres. I think the problem is that CREATE TYPE ENUM is not local to the (temporary) schema. Rather than bother to understand it properly I just serialized the tests like RUST_TEST_THREADS=1 cargo test --manifest-path=tests/Cargo.toml --features="postgres" (see travis.yml). Still inexplicably fails sometimes but much more rarely.

But I would welcome a proper way to do it!

@adwhit
Copy link
Owner

adwhit commented Mar 8, 2018

To go into more detail, when we obtain a PgConnection, we run conn.execute("SET search_path TO pg_temp;").unwrap();. Now pg_temp is actually an alias to a temporary schema which by my understanding should be connection-local (see https://dba.stackexchange.com/questions/76494/temporary-schema-per-connection). Then we should be able to create types and tables isolated from other connections.

But, for whatever reason, it just don't work the way I expect.

@lolgesten
Copy link
Author

Exciting stuff. Thanks! My problem was (obviously) not your package, but my code :D

@adwhit
Copy link
Owner

adwhit commented Mar 8, 2018

Good to know. I'll keep this issue open to remind myself that the testing setup is an unfortunate hack.

@adwhit adwhit changed the title nullable test fails Tests fail unless forced to run on single thread Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants