Before coming to Fortigent, I had the fortune of working primarily on green-field or fairly new systems, all of which were autonomous within an organization. Fortigent is the first time I have had to work with a legacy system I did not build, and a database that is shared with many other applications in the enterprise. Managing database schema and developing test-first has proven to be a whole new and challenging experience in the new kind of environment.
Coming to grips with working against a shared database.
The first time I noticed that my development web.config file was pointing to a shared development database, I automatically assumed someone had inadvertently committed the file. I knew we had a sanitized database that would allow testers and product owners to preview development with a more realistic set of data, so someone had obviously pointed to one of these databases to track down some obscure bug that was hard to reproduce without more realistic data. We’ve all made that accidental commit, it happens.
The trouble was, I kept going back in time, and couldn’t find where the local database reference had been switched to point to the development database.
It had never been switched. It was the way it was.
I had to come to terms with the fact that I was in an enterprise, with many developers, and I couldn’t be the new guy that tells everyone they’re doing it wrong.
I had to learn a different way of writing my WatiN tests. I had to assume my data was in a constant state of flux and each test had to be self sufficient in getting the shared database into a state I could test. I had to accept that sometimes the build would fail, not because my code had changes, but because a completely different application team had modified the database in a way that would cause my tests to fail.
One day every test started to fail.
I was happily working from home when suddenly every test started failing. I quickly connected to my desktop at the office and noticed the same thing. What in the world just happened?
The database administrators had just tightened security on all of our database servers by removing SQL authentication. After updating the web configs to use Windows authentication, I could no longer work from home because my home computer is not on our domain.
Discovering the “local” database.
As it turned out, we do have a local database against which run many of our view model tests. Finally, I thought. I asked why we weren’t pointing our local sites to this database instead of the shared database. Like a parent who realizes that telling your child not to touch something because it is hot is not as effective as letting them feel the pain just once, a kind member of my team said, “great idea, go do that.” It turns out I couldn’t even load the login screen because the local database was basically just schema, and the existing tests that used it would simply add the data they needed and clean up after themselves.
Getting a local site to run against the local database.
Being the TDD fanatic I was, I wasn’t content with this situation. I wanted some integration tests in addition to my unit tests. I wanted to see that the view model was actually rendering the HTML correctly. I wanted to see that clicking the save button really did add a new record to the database.
And so I began several days worth of work pointing my server at the local database, and adding the metadata needed to resolve the error message. Which would be followed by another error message, and another, until one day — VOILA! — I could successfully log into the site. Whew!
The long road ahead.
Our database schema is a large, interdependent behemoth that requires the coordination of many disparate data points to generate a meaningful screen. I have managed to get enough metadata into the data base to allow me to work locally on my current feature without worrying about what is going on in the larger enterprise until I commit my changes.
For now I am happy with having made things just a tiny bit better.