distributedlife

passionate about everything

QC Service Test Cleanup a job to cleanup the ridiculous number of files generated during a service testing run Published by Ryan Boucher @ 11:55 pm

One problem with 10,000 odd service tests is that you can run out hard drive space. They don’t put that on the side of the box.

Service Test has a odd result setup where each step in an action refers to an INF file (using a different file format) that refers to another XML document. I love the fact that they changed file formats from XML to MS-INI back to XML.

If you have a 10,000 tests each test has 20 steps and each step has 2 files you are going to end up with 400,000 files; the problem is that we have often have more than 20 steps so our file count is about 26 million.

26 million small files doesn’t seem like a problem but on Windows the minimum file size is 4KB and those 26 million files consume 10GB of space with a bloat of about 66-75%.

I know what you’re thinking; 10GB is chicken feed; you could run that off your mobile phone and still have space to spare.

That’s 10GB per test run

We run tests every single night; not all tests but enough that we generating about 5GB of result data every night.

So, we ran out of space.

I’ve written a batch job that will run each night and delete all result files that are no longer needed. We need result data from the most recent run but we don’t need any historical data.

It’s a pretty simple task; iterate every test and get the run collection for the test sorted by the run id; more recent runs have a higher run id. Iterate the run collection and look for the results.xml file in the result location property; if the file exists then this is our most recent result set. If not we can ignore this folder.

There are circumstances where the run id will have a result location that does not exist on the file system. I believe this can occur when our nightly test runner gets stopped at 8 in the morning or when we run out of hard drive space.

Once we have our most recent folder then every other run result folder can be deleted.

Wait!

It turns out that for some not yet known reason run objects can have a result folder that refers to the folder where your test code exists. So if you were to delete the “result folder” you would delete the entire test.

Not cool.

So you need to check that the run id exists in the result path.

But the result path also includes the test id; what if they are the same?

Don’t delete it then.

The point of it is that if you run your service tests every night you need to be prepared to cleanup result data over time and when you cleanup that result data you should be mighty careful you don’t delete something important.

So backup before you begin. 26 million files takes a while to backup so it’s best to do it over the weekend.

My Mug Ryan Boucher is a Software Inquisitor and is passionate about it. You can find a whole raft of articles and anecdotes about software testing and other topics he gets excited about.
Tags , , , , , ,