Skip to content

Consider solutions to reseting the database back to some prior state #26

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

Closed
justin808 opened this issue Jul 11, 2019 · 6 comments
Closed

Comments

@justin808
Copy link
Member

Would it be useful if we could seed a database once and then reset it between tests using something like https://github.com/fastmonkeys/stellar?

or is https://github.com/DatabaseCleaner/database_cleaner sufficient for just about any use case?

@MUTOgen wrote:

One particular thing i was thinking about is ability to partly reseting DB. For some cases it would speed up testing, b/c reseting and re-seeding sometimes look pretty heavy.

@grantspeelman wrote:

Can you elaborate more on the partly reseting of the DB? is this not something that database_cleaner already provides, ie so won't updating the clean.rb be enough?

Or are you thinking tighter integration with database_cleaner so you can specify it's options from within cypress.

For example

cy.appCleanerStrategy('truncation', { only:  ["widgets", "dogs", "some_other_table"] })
cy.appCleanerClean()
@MUTOgen
Copy link
Contributor

MUTOgen commented Jul 18, 2019

@justin808 @grantspeelman I played a little bit with one client project with Cypress on Rails setup.
Here are some thoughts:

  1. For a quite big amount of fixtures, it might take about 10 seconds to load data. I tested it on ~60 yml files full of data. So, in case of big Cypress tests coverage, this might be a serious amount of time.

  2. I like the idea of this tool https://github.com/fastmonkeys/stellar Nice thing about this is that it could apply in various projects. This is gonna be much faster for beforeEach hook. Bad thing is that it's an external tool in terms of project and code itself, just dumping tool.

  3. DatabaseCleaner has one good strategy - transaction. It could be also considered to use. For example, we could fire DatabaseCleaner.start and DatabaseCleaner.clean on beforeEach and afterEach respectively. In this case, we don't need to worry about preparing data, it will roll back to the initial state automatically. Unfortunately, this approach has some limitation.

@gsouf
Copy link

gsouf commented Jun 26, 2021

@MUTOgen did you find a solution to be able to use transaction strategy with this gem?

@MUTOgen
Copy link
Contributor

MUTOgen commented Jun 26, 2021

@gsouf Not really.
Actually, I use truncation strategy most of the time.
Do you have any reasons to do only transaction?

@gsouf
Copy link

gsouf commented Jul 1, 2021

@MUTOgen transaction is much faster for my use case. With rails test I use it to make everything faster.

It seems like that somehow this other gem has a way to do it using a "transactional server", not sure if it works well I have never tested this gem

@grantspeelman
Copy link
Collaborator

hmmm, that is very interesting. I wonder how they manage to get a shared transaction scope across multiple connections.
I'll try and look into this at some point.

@bmulholland
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants