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

Run rethink from integration tests #137

Merged
merged 5 commits into from
Sep 22, 2013

Conversation

tetious
Copy link
Collaborator

@tetious tetious commented Sep 21, 2013

This is a first pass at running rethink from the integration tests. I'm not sure if this is what you had in mind, but it seems to work pretty well.

I also changed the spawned rethink to bind to a different port, and use a temp folder for its DB to prevent stomping on an already running development instance.

@mfenniak
Copy link
Owner

Hey Greg,

Thanks for the PR. I love getting new contributions to this project. This looks like it's a great start (fixing #124), but there are a few things that I think could be improved; here are some suggestions:

  • build.sh should be updated to not start/stop rethinkdb, since that won't be required anymore.
  • In GetRethinkPath, it might make sense to search System.Environment.GetEnvironmentVariable("PATH") for the rethinkdb executable. This would be a little more flexible than the hard-coded paths.
  • Rather than Thread.Sleep(1000), how about a loop checking the expected network port for availability? A random delay like this in a unit test I find always bites me in the ass eventually; either it's not long enough to work reliably, or it introduces too long of a delay.
  • I think it'd be great to have the startup/shutdown done as a SetUpFixture instead of as part of TestBase. Putting it in TestBase means that it's started and shutdown for every derived test fixture, of which we currently have 9. A SetUpFixture can perform setup that is done once for an entire namespace of test fixtures.

In addition to the suggestions, I have two concerns:

  • It doesn't work on my machine. :-) I immediately got an error that the directory bin/Debug/tmp/rethink doesn't exist. I suspect that you could reproduce this by deleting your Debug directory and trying it, I don't see any code that creates the "tmp" or "rethink" directories?
  • I'd like to maintain the capability of running the tests under Windows, against a remote host. Currently I do this by modifying the App.config and pointing my Windows desktop at my Linux rethinkdb, but with this change I wouldn't be able to do that anymore. My first thought is that we could introduce an appSetting in the App.config file to enable/disable the starting of rethinkdb by the tests; that way I can still do the same thing by just modifying App.config on my Windows box. Another option might be to only proceed with local startup if GetRethinkPath doesn't return null. I'm open to any other ideas you might have, but those are two thoughts from me.

Check path for rethinkdb binary
Use port from app.config for rethinkdb instance
Do not start rethinkdb if something is already running on the configured endpoint
@tetious
Copy link
Collaborator Author

tetious commented Sep 21, 2013

Thanks for the excellent suggestions and encouragement!

I have implemented all of them, and made a couple tweaks to address your concerns, as well:

  • It will use the port in app.config for the test instance, so you can use whatever you like.
  • If something is already running on the configured endpoint, it will not try to start anything. This should address Windows users who set app.config to a remote machine for testing. Also, if it can't find rethinkdb in the path, it will try to continue anyway.

I ran into one snag searching path, though. I found if I ran it from the test runner in MonoDevelop, the path was mangled and didn't include /usr/local/bin, which homebrew uses for things. (That's how I installed rethinkdb.) I left in a hardcoded path for that, but it uses PATH as well. There might be an alternative I didn't think of, though.

mfenniak added a commit that referenced this pull request Sep 22, 2013
Run rethink from integration tests; fixes #124
@mfenniak mfenniak merged commit f9320f1 into mfenniak:master Sep 22, 2013
@mfenniak
Copy link
Owner

Thanks @tetious, this looks great. :-)

@dragan
Copy link
Collaborator

dragan commented Sep 22, 2013

Thanks @tetious, I like removing things from my TODO list, especially if I didn't have to do it.

@karlgrz
Copy link
Collaborator

karlgrz commented Sep 23, 2013

Thanks, @tetious, I agree with @dragan on that!

This is great!

@tetious
Copy link
Collaborator Author

tetious commented Sep 23, 2013

Thanks guys. Glad I could help!

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

Successfully merging this pull request may close these issues.

4 participants