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

Feature/pull request: Reseed Id's #38

Closed
robertmantissa opened this issue Jan 31, 2018 · 6 comments
Closed

Feature/pull request: Reseed Id's #38

robertmantissa opened this issue Jan 31, 2018 · 6 comments

Comments

@robertmantissa
Copy link
Contributor

Hey!
I've added Respawn in an existing acceptance test project that dropped, recreated and migrated the database between every test. (With some 600 tests, the time saved using Respawn is almost two hours)

But in this specific project, since the all the tables were dropped, all id-columns were reset between every test. I ran into all kinds of contraint-issues and even some of the asserts expected certain id values.

Instead of fixing hundreds of failing tests I did a DBCC CHECKIDENT reseed on all tables needed. After some issues with some unexpected behavior with that command, this actually works fine. And it's fast.
The result is that the database is truly in the same state after each checkpoint.Reset()

Anyone interested in this as feature in Respawn? I can repackage this into a pull request if anyone is. (Only for SQL-Server, now at least)

@jbogard
Copy link
Owner

jbogard commented Jan 31, 2018

Oh that's interesting. I don't know if other databases support this kind of thing, maybe it could be exposed through some kind of options object?

@robertmantissa
Copy link
Contributor Author

After some quick googling it seems to be possible in both MySQL and Oracle.
I will create a fork and add the SQL Server functionality first, and we'll take it from there.

Regarding temporal tables, those were new to me. I guess there might be issues with reseeding those. I'll keep them in mind.

@jbogard
Copy link
Owner

jbogard commented Jan 31, 2018 via email

@robertmantissa
Copy link
Contributor Author

Got it, haven't bothered with temporal tables at all, so chances are that those won't work.
Anyway, check out my fork here:
https://github.com/robertmantissa/Respawn
(Simply did a:

  var checkpoint = new Checkpoint();
  checkpoint.WithReseed = true;

to keep the current api)

@Lazys
Copy link

Lazys commented Feb 8, 2018

Hi,
I want to add few words:

We had problems with randomly failing tests.. I was struggling almost 2 days until I've found out that the problem is with Respawn and Identity value when tests are run in appropriate order. Then I've run into this pull request!

For my team changes that @robertmantissa proposed are crucial to be able to still use Respawn with ease. Please consider this @jbogard .

Important note: code prepared by @robertmantissa not covers scenario when table has custom IDENTITY SEED initial value. For example 1000 instead of 1. I had problems with it, so I've added fix to the @robertmantissa code and created pull request to his fork. Please check it out here: pull request

Right now I have to use locally compiled version of respawn which includes @robertmantissa and my changes, but I would like to go back to yours nugget package as soon as possible.

@robertmantissa
Copy link
Contributor Author

Solved with pull request #40

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

3 participants