Guys, there is the new ImpermanentGraphDatabase, that is fully functional but operating on non-persistent RAM-backed FileChannels at the lowest level. We use it for testing in Java land, I think it would be very applicable here, too!
> But the problem is that the saved models within that transactions are > not traversable.
> So that this is false:
> User.create > User.count.should > 0
> This is pretty unexpected to me.
> So my question is how to clean-up the database before each test.
> -- > You received this message because you are subscribed to the Google Groups "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
Does the ImpermanentGraphDatabase support transactions and lucene ? Check this issue https://github.com/neo4j/community/issues/44 and the following workaround using multitenancy :
c.after(:each) do finish_tx Neo4j::Rails::Model.close_lucene_connections Neo4j::Transaction.run do Neo4j::Index::IndexerRegistry.delete_all_indexes end Neo4j::Transaction.run do Neo4j.threadlocal_ref_node = Neo4j::Node.new :name => "ref_#{$name_counter}" $name_counter += 1 end end
<peter.neuba...@neotechnology.com> wrote: > Guys, there is the new ImpermanentGraphDatabase, that is fully > functional but operating on non-persistent RAM-backed FileChannels at > the lowest level. We use it for testing in Java land, I think it would > be very applicable here, too!
>> But the problem is that the saved models within that transactions are >> not traversable.
>> So that this is false:
>> User.create >> User.count.should > 0
>> This is pretty unexpected to me.
>> So my question is how to clean-up the database before each test.
>> -- >> You received this message because you are subscribed to the Google Groups "neo4jrb" group. >> To post to this group, send email to neo4jrb@googlegroups.com. >> To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. >> For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
> -- > You received this message because you are subscribed to the Google Groups "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
You have a few choices for doing this. Unfortunately, Neo4j does not yet support a 'clear' for deleting all the nodes in a database.
The options are: - Manually delete all nodes in your after(:each) block Neo4j::Transaction.run do Neo4j._all_nodes.each { |n| n.del unless n.neo_id == 0 } end
- Exploit the multitenancy feature to create a new reference node before each test, and then delete the entire database after(:all). We use this approach with the neo4j.rb tests, our tests run in approximately a minute on a Macbook pro. Please take a look at https://github.com/andreasronge/neo4j/blob/master/spec/spec_helper.rb in case you'd like more info. Here's a snippet that shows this approach
RSpec.configure do |c| $name_counter = 0 c.after(:each) do Neo4j::Rails::Model.close_lucene_connections Neo4j::Transaction do Neo4j::Index::IndexRegistry.delete_all_indexes end Neo4j::Transaction.run do Neo4j.threadlocal_ref_node = Neo4j::Node.new :name => "ref_#{$name_counter}" $name_counter += 1 end end
c.before(:all) do rm_db_storage unless Neo4j.running? end c.after(:all) do Neo4j.shutdown rm_db_storage end
def rm_db_storage FileUtils.rm_rf Neo4j::Config[:storage_path] raise "Can't delete db" if File.exist?(Neo4j::Config[:storage_path]) end
A gotcha with this approach is that multiple lucene files will be opened (the multitenancy feature creates a fresh set of lucene indices per tenant). The delete_all_indexes call has the side-effect of closing all open lucene files. There's a patch that is now part of Neo4j (should hopefully be released as part of 1.6) that takes care of this issue without requiring this hack. Info about this patch here: https://github.com/neo4j/community/pull/51#issuecomment-2442894
Peter, is the ImpermanentGraphDatabase part of Neo4j 1.5? If so, we can try and add support for it so that it can be used for writing tests.
> But the problem is that the saved models within that transactions are > not traversable.
> So that this is false:
> User.create > User.count.should > 0
> This is pretty unexpected to me.
> So my question is how to clean-up the database before each test.
> -- > You received this message because you are subscribed to the Google Groups > "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to > neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/neo4jrb?hl=en.
> You have a few choices for doing this. Unfortunately, Neo4j does not yet > support a 'clear' for deleting all the nodes in a database.
> The options are: > - Manually delete all nodes in your after(:each) block > Neo4j::Transaction.run do > Neo4j._all_nodes.each { |n| n.del unless n.neo_id == 0 } > end
> - Exploit the multitenancy feature to create a new reference node before > each test, and then delete the entire database after(:all). We use this > approach with the neo4j.rb tests, our tests run in approximately a minute > on a Macbook pro. Please take a look at > https://github.com/andreasronge/neo4j/blob/master/spec/spec_helper.rb in > case you'd like more info. Here's a snippet that shows this approach
> RSpec.configure do |c| > $name_counter = 0 > c.after(:each) do > Neo4j::Rails::Model.close_lucene_connections > Neo4j::Transaction do > Neo4j::Index::IndexRegistry.delete_all_indexes > end > Neo4j::Transaction.run do > Neo4j.threadlocal_ref_node = Neo4j::Node.new :name => > "ref_#{$name_counter}" > $name_counter += 1 > end > end
> c.before(:all) do > rm_db_storage unless Neo4j.running? > end > c.after(:all) do > Neo4j.shutdown > rm_db_storage > end
> def rm_db_storage > FileUtils.rm_rf Neo4j::Config[:storage_path] > raise "Can't delete db" if File.exist?(Neo4j::Config[:storage_path]) > end
> A gotcha with this approach is that multiple lucene files will be opened > (the multitenancy feature creates a fresh set of lucene indices per > tenant). The delete_all_indexes call has the side-effect of closing all > open lucene files. There's a patch that is now part of Neo4j (should > hopefully be released as part of 1.6) that takes care of this issue without > requiring this hack. Info about this patch here: > https://github.com/neo4j/community/pull/51#issuecomment-2442894
> Peter, is the ImpermanentGraphDatabase part of Neo4j 1.5? If so, we can > try and add support for it so that it can be used for writing tests.
> Hope this helps,
> Vivek
> On Fri, Dec 9, 2011 at 2:24 PM, dnagir <dna...@gmail.com> wrote:
>> Hi,
>> I wonder how can I clear the database before each spec?
>> But the problem is that the saved models within that transactions are >> not traversable.
>> So that this is false:
>> User.create >> User.count.should > 0
>> This is pretty unexpected to me.
>> So my question is how to clean-up the database before each test.
>> -- >> You received this message because you are subscribed to the Google Groups >> "neo4jrb" group. >> To post to this group, send email to neo4jrb@googlegroups.com. >> To unsubscribe from this group, send email to >> neo4jrb+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/neo4jrb?hl=en.
On Fri, Dec 9, 2011 at 10:16 AM, Vivek Prahlad <vivek.prah...@gmail.com> wrote: > Just saw that Andreas beat me to it :) - the second approach below is the > same as what he's suggested.
> Vivek
> On Fri, Dec 9, 2011 at 2:44 PM, Vivek Prahlad <vivek.prah...@gmail.com> > wrote:
>> Hi,
>> You have a few choices for doing this. Unfortunately, Neo4j does not yet >> support a 'clear' for deleting all the nodes in a database.
>> The options are: >> - Manually delete all nodes in your after(:each) block >> Neo4j::Transaction.run do >> Neo4j._all_nodes.each { |n| n.del unless n.neo_id == 0 } >> end
>> - Exploit the multitenancy feature to create a new reference node before >> each test, and then delete the entire database after(:all). We use this >> approach with the neo4j.rb tests, our tests run in approximately a minute on >> a Macbook pro. Please take a look at >> https://github.com/andreasronge/neo4j/blob/master/spec/spec_helper.rb in >> case you'd like more info. Here's a snippet that shows this approach
>> RSpec.configure do |c| >> $name_counter = 0 >> c.after(:each) do >> Neo4j::Rails::Model.close_lucene_connections >> Neo4j::Transaction do >> Neo4j::Index::IndexRegistry.delete_all_indexes >> end >> Neo4j::Transaction.run do >> Neo4j.threadlocal_ref_node = Neo4j::Node.new :name => >> "ref_#{$name_counter}" >> $name_counter += 1 >> end >> end
>> c.before(:all) do >> rm_db_storage unless Neo4j.running? >> end >> c.after(:all) do >> Neo4j.shutdown >> rm_db_storage >> end
>> def rm_db_storage >> FileUtils.rm_rf Neo4j::Config[:storage_path] >> raise "Can't delete db" if File.exist?(Neo4j::Config[:storage_path]) >> end
>> A gotcha with this approach is that multiple lucene files will be opened >> (the multitenancy feature creates a fresh set of lucene indices per tenant). >> The delete_all_indexes call has the side-effect of closing all open lucene >> files. There's a patch that is now part of Neo4j (should hopefully be >> released as part of 1.6) that takes care of this issue without requiring >> this hack. Info about this patch here: >> https://github.com/neo4j/community/pull/51#issuecomment-2442894
>> Peter, is the ImpermanentGraphDatabase part of Neo4j 1.5? If so, we can >> try and add support for it so that it can be used for writing tests.
>> Hope this helps,
>> Vivek
>> On Fri, Dec 9, 2011 at 2:24 PM, dnagir <dna...@gmail.com> wrote:
>>> Hi,
>>> I wonder how can I clear the database before each spec?
>>> But the problem is that the saved models within that transactions are >>> not traversable.
>>> So that this is false:
>>> User.create >>> User.count.should > 0
>>> This is pretty unexpected to me.
>>> So my question is how to clean-up the database before each test.
>>> -- >>> You received this message because you are subscribed to the Google Groups >>> "neo4jrb" group. >>> To post to this group, send email to neo4jrb@googlegroups.com. >>> To unsubscribe from this group, send email to >>> neo4jrb+unsubscribe@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/neo4jrb?hl=en.
> -- > You received this message because you are subscribed to the Google Groups > "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to > neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/neo4jrb?hl=en.
> Guys, there is the new ImpermanentGraphDatabase, that is fully > functional but operating on non-persistent RAM-backed FileChannels at > the lowest level. We use it for testing in Java land, I think it would > be very applicable here, too!
That is exactly the perfect solution that I'm after. In RDBMS world I use in-memory SQLite for that.
So we can just drop the database and create a new one before the test and it should be cheap and fast. Sounds awesome.
But I'm a little bit lost how I can make use of it (sorry just starting with all this), especially with the issues outlined by Andreas.
Or maybe for now I need to clean it up as Vivek explained?
BTW, I would call the class Transient/Memory Database instead of Impermanent :-)
@Dmytrii - I'm thinking of moving the lighthouse issues to github, since it looks like github now has support for crosslinking between commits and issues and support for hash tags in commit messages to open close issues etc..
On Fri, Dec 9, 2011 at 10:45 AM, Dmytrii Nagirniak <dna...@gmail.com> wrote: > On 09/12/2011, at 8:00 PM, Peter Neubauer wrote:
>> Guys, there is the new ImpermanentGraphDatabase, that is fully >> functional but operating on non-persistent RAM-backed FileChannels at >> the lowest level. We use it for testing in Java land, I think it would >> be very applicable here, too!
> That is exactly the perfect solution that I'm after. > In RDBMS world I use in-memory SQLite for that.
> So we can just drop the database and create a new one before the test and it should be cheap and fast. > Sounds awesome.
> But I'm a little bit lost how I can make use of it (sorry just starting with all this), especially with the issues outlined by Andreas.
> Or maybe for now I need to clean it up as Vivek explained?
> BTW, I would call the class Transient/Memory Database instead of Impermanent :-)
> Cheers.
> -- > You received this message because you are subscribed to the Google Groups "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
Thanks for that. Hope it won't take too much time to implement it.
Unfortunately I won't be able to contribute PRs. Really have to switch the current app over. And that's the last chance I am giving to neo4j :)
> @Dmytrii - I'm thinking of moving the lighthouse issues to github, > since it looks like github now has support for crosslinking between > commits and issues and support for hash tags in commit messages to > open close issues etc..
Way to go! But I still can't see the "Issues" section on the repo. Also with that in mind you could have created the "cleanup specs" issue on the Github.
> Thanks for that. > Hope it won't take too much time to implement it.
> Unfortunately I won't be able to contribute PRs. > Really have to switch the current app over. And that's the last chance I > am giving to neo4j :)
> > @Dmytrii - I'm thinking of moving the lighthouse issues to github, > > since it looks like github now has support for crosslinking between > > commits and issues and support for hash tags in commit messages to > > open close issues etc..
> Way to go! But I still can't see the "Issues" section on the repo. > Also with that in mind you could have created the "cleanup specs" issue on > the Github.
> Cheers.
> -- > You received this message because you are subscribed to the Google Groups > "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to > neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/neo4jrb?hl=en.
> The only thing I am missing now is commit logs referring to other repos issues, and voting on issues. Otherwise, github is great.
The voting is a bit controversial since Github REMOVED it :) I guess it should be an issue with "+1 comments" and the number of currently existing issues. Tags/milestones should also help with that.
> On 09/12/2011, at 10:03 PM, Peter Neubauer wrote:
> The only thing I am missing now is commit logs referring to other repos > issues, and voting on issues. Otherwise, github is great.
> The voting is a bit controversial since Github REMOVED it :) > I guess it should be an issue with "+1 comments" and the number of > currently existing issues. > Tags/milestones should also help with that.
> Quote: > You can *reference issues between repositories* by mentioning * > user/repository#number* in an issue.
> Anyway, so what do I do with the spec cleanups for now?
> -- > You received this message because you are subscribed to the Google Groups > "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to > neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/neo4jrb?hl=en.
For now, I'd suggest the approach both Andreas and me suggested. Getting in the ImpermanentGraphDatabase will need a small amount of work, I think it should be fairly easy to switch to it once it's there.
On Fri, Dec 9, 2011 at 4:50 PM, Dmytrii Nagirniak <dna...@gmail.com> wrote:
> On 09/12/2011, at 10:03 PM, Peter Neubauer wrote:
> The only thing I am missing now is commit logs referring to other repos > issues, and voting on issues. Otherwise, github is great.
> The voting is a bit controversial since Github REMOVED it :) > I guess it should be an issue with "+1 comments" and the number of > currently existing issues. > Tags/milestones should also help with that.
> Quote: > You can *reference issues between repositories* by mentioning * > user/repository#number* in an issue.
> Anyway, so what do I do with the spec cleanups for now?
> -- > You received this message because you are subscribed to the Google Groups > "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to > neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/neo4jrb?hl=en.
> For now, I'd suggest the approach both Andreas and me suggested. Getting in the ImpermanentGraphDatabase will need a small amount of work, I think it should be fairly easy to switch to it once it's there.
> Thanks, > Vivek
> On Fri, Dec 9, 2011 at 4:50 PM, Dmytrii Nagirniak <dna...@gmail.com> wrote:
> On 09/12/2011, at 10:03 PM, Peter Neubauer wrote: >> The only thing I am missing now is commit logs referring to other repos issues, and voting on issues. Otherwise, github is great.
> The voting is a bit controversial since Github REMOVED it :) > I guess it should be an issue with "+1 comments" and the number of currently existing issues. > Tags/milestones should also help with that.
> Quote: > You can reference issues between repositories by mentioning user/repository#number in an issue.
> Anyway, so what do I do with the spec cleanups for now?
> -- > You received this message because you are subscribed to the Google Groups "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
> -- > You received this message because you are subscribed to the Google Groups "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
> Done that. It works fairly well. > Passed my first set of specs :)
> The first little win :)
> Cheers.
> On 09/12/2011, at 10:33 PM, Vivek Prahlad wrote:
>> For now, I'd suggest the approach both Andreas and me suggested. Getting in the ImpermanentGraphDatabase will need a small amount of work, I think it should be fairly easy to switch to it once it's there.
>> Thanks, >> Vivek
>> On Fri, Dec 9, 2011 at 4:50 PM, Dmytrii Nagirniak <dna...@gmail.com> wrote:
>> On 09/12/2011, at 10:03 PM, Peter Neubauer wrote: >>> The only thing I am missing now is commit logs referring to other repos issues, and voting on issues. Otherwise, github is great.
>> The voting is a bit controversial since Github REMOVED it :) >> I guess it should be an issue with "+1 comments" and the number of currently existing issues. >> Tags/milestones should also help with that.
>> Quote: >> You can reference issues between repositories by mentioning user/repository#number in an issue.
>> Anyway, so what do I do with the spec cleanups for now?
>> -- >> You received this message because you are subscribed to the Google Groups "neo4jrb" group. >> To post to this group, send email to neo4jrb@googlegroups.com. >> To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. >> For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
>> -- >> You received this message because you are subscribed to the Google Groups "neo4jrb" group. >> To post to this group, send email to neo4jrb@googlegroups.com. >> To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. >> For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
Yes, you're right. I actually forgot to mention that - we're using memory disks on both the linux and mac platforms on my project and it does significantly speed up the tests.
On Wed, Dec 14, 2011 at 7:13 AM, Dmytrii Nagirniak <dna...@gmail.com> wrote: > Another option would be to use memory disk for testing. > That should significantly increase the speed without any additional > changes.
> On 09/12/2011, at 10:57 PM, Dmytrii Nagirniak wrote:
> Thank,
> Done that. It works fairly well. > Passed my first set of specs :)
> The first little win :)
> Cheers.
> On 09/12/2011, at 10:33 PM, Vivek Prahlad wrote:
> For now, I'd suggest the approach both Andreas and me suggested. Getting > in the ImpermanentGraphDatabase will need a small amount of work, I think > it should be fairly easy to switch to it once it's there.
> Thanks, > Vivek
> On Fri, Dec 9, 2011 at 4:50 PM, Dmytrii Nagirniak <dna...@gmail.com>wrote:
>> On 09/12/2011, at 10:03 PM, Peter Neubauer wrote:
>> The only thing I am missing now is commit logs referring to other repos >> issues, and voting on issues. Otherwise, github is great.
>> The voting is a bit controversial since Github REMOVED it :) >> I guess it should be an issue with "+1 comments" and the number of >> currently existing issues. >> Tags/milestones should also help with that.
>> Quote: >> You can *reference issues between repositories* by mentioning * >> user/repository#number* in an issue.
>> Anyway, so what do I do with the spec cleanups for now?
>> -- >> You received this message because you are subscribed to the Google Groups >> "neo4jrb" group. >> To post to this group, send email to neo4jrb@googlegroups.com. >> To unsubscribe from this group, send email to >> neo4jrb+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/neo4jrb?hl=en.
> -- > You received this message because you are subscribed to the Google Groups > "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to > neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/neo4jrb?hl=en.
> -- > You received this message because you are subscribed to the Google Groups > "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to > neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/neo4jrb?hl=en.
> Yes, you're right. I actually forgot to mention that - we're using memory disks on both the linux and mac platforms on my project and it does significantly speed up the tests.
Well done!
I just can't get my hands on to that. Also want to avoid any huge setups and create the memory disk before all specs and the drop it at the end.
*Linux* You can create a RAM disk with 500MB like this: (the mount command needs to be issued as root) mkdir -p /tmp/neo4j_testing mount -t tmpfs -o size=500M tmpfs /tmp/neo4j_testing
*Mac *You can create a 550MB RAM disk like this: diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://1165430`
This will create a RAM disk under /Volumes/ramdisk
For both of these, in your spec_helper, you'll have to change the Neo4j config to use the RAM disk.
Neo4j::Config[:storage_path] = /path/to/ram/disk
You can use umount to unmount the ram disk on both platforms.
Cheers, Vivek On Wed, Dec 14, 2011 at 10:36 AM, Dmytrii Nagirniak <dna...@gmail.com>wrote:
> > Yes, you're right. I actually forgot to mention that - we're using > memory disks on both the linux and mac platforms on my project and it does > significantly speed up the tests.
> Well done!
> I just can't get my hands on to that. Also want to avoid any huge setups > and create the memory disk before all specs and the drop it at the end.
> Do you mind to share your setup?
> -- > You received this message because you are subscribed to the Google Groups > "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to > neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/neo4jrb?hl=en.
> Linux > You can create a RAM disk with 500MB like this: (the mount command needs to be issued as root) > mkdir -p /tmp/neo4j_testing > mount -t tmpfs -o size=500M tmpfs /tmp/neo4j_testing
> Mac > You can create a 550MB RAM disk like this: > diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://1165430`
> This will create a RAM disk under /Volumes/ramdisk
> For both of these, in your spec_helper, you'll have to change the Neo4j config to use the RAM disk.
> You can use umount to unmount the ram disk on both platforms.
> Cheers, > Vivek > On Wed, Dec 14, 2011 at 10:36 AM, Dmytrii Nagirniak <dna...@gmail.com> wrote: > On 14/12/2011, at 3:09 PM, Vivek Prahlad wrote:
> > Yes, you're right. I actually forgot to mention that - we're using memory disks on both the linux and mac platforms on my project and it does significantly speed up the tests.
> Well done!
> I just can't get my hands on to that. Also want to avoid any huge setups and create the memory disk before all specs and the drop it at the end.
> Do you mind to share your setup?
> -- > You received this message because you are subscribed to the Google Groups "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
> -- > You received this message because you are subscribed to the Google Groups "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
Unfortunately this approach doesn't work for Cucumber testing :(
It preserves indexes between the scenarios. So every time I do "User.all" it returns the same objects that were created in the very first scenario!
How can I really make sure the DB is clear?
Here is my cleanup in Cucumber:
require 'fileutils'
# TODO: Remove dup: copy paste from the spec/support/neo4j.rb def rm_db_storage! FileUtils.rm_rf Neo4j::Config[:storage_path] raise "Can't delete db" if File.exist?(Neo4j::Config[:storage_path]) end
rm_db_storage! unless Neo4j.running?
$spec_counter = Time.now.to_f After do |s| Neo4j::Rails::Model.close_lucene_connections Neo4j::Transaction.run do Neo4j::Index::IndexerRegistry.delete_all_indexes end Neo4j::Transaction.run do Neo4j.threadlocal_ref_node = Neo4j::Node.new :name => "ref_#{$spec_counter}" $spec_counter += 1 end end
On 09/12/2011, at 10:57 PM, Dmytrii Nagirniak wrote:
> Done that. It works fairly well. > Passed my first set of specs :)
> The first little win :)
> Cheers.
> On 09/12/2011, at 10:33 PM, Vivek Prahlad wrote:
>> For now, I'd suggest the approach both Andreas and me suggested. Getting in the ImpermanentGraphDatabase will need a small amount of work, I think it should be fairly easy to switch to it once it's there.
>> Thanks, >> Vivek
>> On Fri, Dec 9, 2011 at 4:50 PM, Dmytrii Nagirniak <dna...@gmail.com> wrote:
>> On 09/12/2011, at 10:03 PM, Peter Neubauer wrote: >>> The only thing I am missing now is commit logs referring to other repos issues, and voting on issues. Otherwise, github is great.
>> The voting is a bit controversial since Github REMOVED it :) >> I guess it should be an issue with "+1 comments" and the number of currently existing issues. >> Tags/milestones should also help with that.
>> Quote: >> You can reference issues between repositories by mentioning user/repository#number in an issue.
>> Anyway, so what do I do with the spec cleanups for now?
>> -- >> You received this message because you are subscribed to the Google Groups "neo4jrb" group. >> To post to this group, send email to neo4jrb@googlegroups.com. >> To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. >> For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
>> -- >> You received this message because you are subscribed to the Google Groups "neo4jrb" group. >> To post to this group, send email to neo4jrb@googlegroups.com. >> To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. >> For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
> Unfortunately this approach doesn't work for Cucumber testing :(
> It preserves indexes between the scenarios. > So every time I do "User.all" it returns the same objects that were created in the very first scenario!
> How can I really make sure the DB is clear?
> Here is my cleanup in Cucumber:
> require 'fileutils'
> # TODO: Remove dup: copy paste from the spec/support/neo4j.rb > def rm_db_storage! > FileUtils.rm_rf Neo4j::Config[:storage_path] > raise "Can't delete db" if File.exist?(Neo4j::Config[:storage_path]) > end
> rm_db_storage! unless Neo4j.running?
> $spec_counter = Time.now.to_f > After do |s| > Neo4j::Rails::Model.close_lucene_connections > Neo4j::Transaction.run do > Neo4j::Index::IndexerRegistry.delete_all_indexes > end > Neo4j::Transaction.run do > Neo4j.threadlocal_ref_node = Neo4j::Node.new :name => "ref_#{$spec_counter}" > $spec_counter += 1 > end > end
> On 09/12/2011, at 10:57 PM, Dmytrii Nagirniak wrote:
>> Thank,
>> Done that. It works fairly well. >> Passed my first set of specs :)
>> The first little win :)
>> Cheers.
>> On 09/12/2011, at 10:33 PM, Vivek Prahlad wrote:
>>> For now, I'd suggest the approach both Andreas and me suggested. Getting in the ImpermanentGraphDatabase will need a small amount of work, I think it should be fairly easy to switch to it once it's there.
>>> Thanks, >>> Vivek
>>> On Fri, Dec 9, 2011 at 4:50 PM, Dmytrii Nagirniak <dna...@gmail.com> wrote:
>>> On 09/12/2011, at 10:03 PM, Peter Neubauer wrote: >>>> The only thing I am missing now is commit logs referring to other repos issues, and voting on issues. Otherwise, github is great.
>>> The voting is a bit controversial since Github REMOVED it :) >>> I guess it should be an issue with "+1 comments" and the number of currently existing issues. >>> Tags/milestones should also help with that.
>>> Quote: >>> You can reference issues between repositories by mentioning user/repository#number in an issue.
>>> Anyway, so what do I do with the spec cleanups for now?
>>> -- >>> You received this message because you are subscribed to the Google Groups "neo4jrb" group. >>> To post to this group, send email to neo4jrb@googlegroups.com. >>> To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. >>> For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
>>> -- >>> You received this message because you are subscribed to the Google Groups "neo4jrb" group. >>> To post to this group, send email to neo4jrb@googlegroups.com. >>> To unsubscribe from this group, send email to neo4jrb+unsubscribe@googlegroups.com. >>> For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
You may need to do a User.destroy_all after each test as a workaround. Otherwise, you'll have to delete all the nodes in your database like I'd suggested in an earlier thread. The 'all' call doesn't use the lucene index AFAIK, it uses traversals.
Is your user model shared across tenants (ie, does it have a
ref_node {Neo4j.default_ref_node}
declaration anywhere?
Vivek
On Thu, Dec 15, 2011 at 10:11 AM, Dmytrii Nagirniak <dna...@gmail.com>wrote:
> Unfortunately this approach doesn't work for Cucumber testing :(
> It preserves indexes between the scenarios. > So every time I do "User.all" it returns the same objects that were > created in the very first scenario!
> How can I really make sure the DB is clear?
> Here is my cleanup in Cucumber:
> require 'fileutils'
> # TODO: Remove dup: copy paste from the spec/support/neo4j.rb > def rm_db_storage! > FileUtils.rm_rf Neo4j::Config[:storage_path] > raise "Can't delete db" if File.exist?(Neo4j::Config[:storage_path]) > end
> rm_db_storage! unless Neo4j.running?
> $spec_counter = Time.now.to_f > After do |s| > Neo4j::Rails::Model.close_lucene_connections > Neo4j::Transaction.run do > Neo4j::Index::IndexerRegistry.delete_all_indexes > end > Neo4j::Transaction.run do > Neo4j.threadlocal_ref_node = Neo4j::Node.new :name => > "ref_#{$spec_counter}" > $spec_counter += 1 > end > end
> On 09/12/2011, at 10:57 PM, Dmytrii Nagirniak wrote:
> Thank,
> Done that. It works fairly well. > Passed my first set of specs :)
> The first little win :)
> Cheers.
> On 09/12/2011, at 10:33 PM, Vivek Prahlad wrote:
> For now, I'd suggest the approach both Andreas and me suggested. Getting > in the ImpermanentGraphDatabase will need a small amount of work, I think > it should be fairly easy to switch to it once it's there.
> Thanks, > Vivek
> On Fri, Dec 9, 2011 at 4:50 PM, Dmytrii Nagirniak <dna...@gmail.com>wrote:
>> On 09/12/2011, at 10:03 PM, Peter Neubauer wrote:
>> The only thing I am missing now is commit logs referring to other repos >> issues, and voting on issues. Otherwise, github is great.
>> The voting is a bit controversial since Github REMOVED it :) >> I guess it should be an issue with "+1 comments" and the number of >> currently existing issues. >> Tags/milestones should also help with that.
>> Quote: >> You can *reference issues between repositories* by mentioning * >> user/repository#number* in an issue.
>> Anyway, so what do I do with the spec cleanups for now?
>> -- >> You received this message because you are subscribed to the Google Groups >> "neo4jrb" group. >> To post to this group, send email to neo4jrb@googlegroups.com. >> To unsubscribe from this group, send email to >> neo4jrb+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/neo4jrb?hl=en.
> -- > You received this message because you are subscribed to the Google Groups > "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to > neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/neo4jrb?hl=en.
> -- > You received this message because you are subscribed to the Google Groups > "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to > neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/neo4jrb?hl=en.
> You may need to do a User.destroy_all after each test as a workaround. Otherwise, you'll have to delete all the nodes in your database like I'd suggested in an earlier thread. The 'all' call doesn't use the lucene index AFAIK, it uses traversals.
I am kind of lost here. At the end of each spec I swap out ref_node which loses all the references to existing nodes. So "User.all" should not return anything, especially if it's using traversals. I don't understand how come it still does?
> Is your user model shared across tenants (ie, does it have a
Hard to say what exactly is going on without examining what's happening at runtime. I've seen this kind of behaviour when top level transactions are inadvertently created in tests / migrations. Is any of your before / after stuff creating Neo4j transactions anywhere?
In your test, you could try asserting that the Neo4j threadlocal ref node is the same as what was assigned in the before / after block? Are your user objects created by the test, or as part of setup?
Could you try looking at the database using Neoclipse? You should not see any user nodes attached to the home node.
On Fri, Dec 16, 2011 at 9:51 AM, Dmytrii Nagirniak <dna...@gmail.com> wrote: > On 16/12/2011, at 3:06 PM, Vivek Prahlad wrote:
> You may need to do a User.destroy_all after each test as a workaround. > Otherwise, you'll have to delete all the nodes in your database like I'd > suggested in an earlier thread. The 'all' call doesn't use the lucene index > AFAIK, it uses traversals.
> I am kind of lost here. > At the end of each spec I swap out ref_node which loses all the references > to existing nodes. > So "User.all" should not return anything, especially if it's using > traversals. > I don't understand how come it still does?
> Is your user model shared across tenants (ie, does it have a
> ref_node {Neo4j.default_ref_node}
> declaration anywhere?
> Nope.
> -- > You received this message because you are subscribed to the Google Groups > "neo4jrb" group. > To post to this group, send email to neo4jrb@googlegroups.com. > To unsubscribe from this group, send email to > neo4jrb+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/neo4jrb?hl=en.
> Hard to say what exactly is going on without examining what's happening at runtime. I've seen this kind of behaviour when top level transactions are inadvertently created in tests / migrations. Is any of your before / after stuff creating Neo4j transactions anywhere?
Yes, it's basically done the same is neo4j.rb does
The problem is that it work fine for RSpec, but not for Cucumber!
Anyway, here is my "features/support/ne4j.rb" file that is supposed to take care of the clean-up:
require 'fileutils'
# TODO: Remove dup: copy paste from the spec/support/neo4j.rb def rm_db_storage! FileUtils.rm_rf Neo4j::Config[:storage_path] raise "Can't delete db" if File.exist?(Neo4j::Config[:storage_path]) end
rm_db_storage! unless Neo4j.running?
$spec_counter = Time.now.to_f After do |s| Neo4j::Rails::Model.close_lucene_connections Neo4j::Transaction.run do Neo4j::Index::IndexerRegistry.delete_all_indexes end Neo4j::Transaction.run do Neo4j.threadlocal_ref_node = Neo4j::Node.new :name => "ref_#{$spec_counter}" $spec_counter += 1 end end
> In your test, you could try asserting that the Neo4j threadlocal ref node is the same as what was assigned in the before / after block?
ref_node is the same before tests, during tests and after. It only changes after the block above.
> Are your user objects created by the test, or as part of setup?
As part of the test. In Cucumber there is really no setup as such.
> Could you try looking at the database using Neoclipse? You should not see any user nodes attached to the home node.
That is not correct. The setup I showed you deletes the database in the beginning. At the end of each test the ref_node is replaced,
So the data will be left in the DB (and I can see it with Neoclipse).