sandro/specjour

Using specjour with Microsoft SQLServer on OS X

Closed this issue · 2 comments

I'm using OS X 10.6.3, Rails 2.3.5, rSpec 1.3.0, rSpec-Rails 1.3.2 and I have found that with how I have my system configured for access to Microsoft SQLServer, I needed to do things a bit more manually... but it does work.

I have a dual core machine and nothing to SSH to so I'm just rolling tests locally, but I'd like to be able to use both cores and 2 databases.

To do so I edited my "odbc.ini" file and created 2 explicit DSN entries. I have [APP_TEST1] and [APP_TEST2].

The reason this is important is that the DSN entries seems to override the setting in the database.yml file for the database name. Without manually specifying 2 DSN entries I was getting deadlock conflicts since 2 workers were both trying to hit the same DB. It's possible some other configuration (perhaps not specifying the database name in the DNS at all) would not require 2 DSN entries but getting SQL talking to OS X or Linux is always such a PITA that if it ain't broke... ya know how it goes.

Configuration details below:

odbc.ini (in /opt/local/etc/odbc.ini)

[APP_TEST1]
Driver = FreeTDS
Description = my app's development/test db
Servername = APPSQL_LOCAL
Server = APPSQL_LOCAL
Port = 1433
Database = app_test1

[APP_TEST2]
Driver = FreeTDS
Description = my app's development/test db
Servername = APPSQL_LOCAL
Server = APPSQL_LOCAL
Port = 1433
Database = app_test2

_In the interest of being complete I'll include the rest of my OS X -> SQLServer configuration that I _DID NOT* have to edit to get this working*


odbcinst.ini (in /opt/local/etc/odbcinst.ini)

[FreeTDS]
Decscription = FreeTDS driver for SQLServer
Driver = /opt/local/lib/libtdsodbc.so
Setup = /opt/local/lib/libtdsodbc.so
FileUsage = 1

freetds.conf (in /opt/local/etc/freetds/freetds.conf)

[APPSQL_LOCAL]
        host = 10.211.55.3
        port = 1433
        tds version = 8.0

I'd like to add that it's pretty easy to retain the ability to do single focused tests in Textmate (bypassing specjour) by adding the following Shell Variable (Textmate -> Preferences -> Advanced)...

Variable: TEST_ENV_NUMBER
Value: 1

By doing this it allows you to keep your database.yml configured for specjour but as I said allows a quick focused single test from within Textmate, nice! Though at the moment I only seem to be able to get this working for cucumber. Not sure why rSpec isn't taking the env var...

I now have this working with rSpec and Cucumber. The issue was that I had not setup RVM correctly to reference textmate_ruby. The right way to do that is here: http://rvm.beginrescueend.com/integration/textmate/ and now I can run focused rSpec and Cucumber tests when my machine is configured for specjour as long as that env var is set in the textmate prefs (as mentioned in my previous comment above).

However, I did upgrade my setup to use my wife's macbook pro that just sits downstairs idle all day. It is working great now and cut my time down even more... however, I'm not sure if this is solely a SQL thing but, when the 2 other workers (she has a core duo machine) were spun up they were spun up by specjour as workers 1 and 2 when on my macbook pro i7 I already had workers 1,2,3,4 so with my setup that meant I was back to deadlock city since workers 1,2 on both machine were fighting for testdb1 and testdb2 again. What I ended up doing is on my wife's machine I setup my ODBC.ini to have the DSN for TEST1 and TEST2 point to the test5 and test6 databases. Now it works great, but that feels like some extra configuration I probably shouldn't have had to do. Again, maybe it's just a DSN issue with SQL and FreeTDS/ODBC... but if specjour had recognized that there were already 4 workers started and properly spun up workers 5,6 on her macbook then I wouldn't have had to do anything additional on my end. Just an FYI.

Thanks for the great library!