Waitfor it
Suppose you are charged with system QA for a complicated system that expects dozens or hundreds of simultaneous users. The system has a user front end through either a browswer of through deployed software, and it sends transactions back and forth with a Microsoft SQL Server database.
What do you do, if you’ve confirmed the functionality, but you have doubts about the system’s ability to handle all of those simultaneious connections and database transactions?
One way to do a quick and dirty test is to trace the software’s database statements, and then run them many times in a batch. You’ll probably have to tweak the script, but a trace is a good place to start. Then, you can kick off your script from dozens of connections at about the same time.
(This might not be the best way to verify a system, but it’s 99% better than most companies do, which is to not test this at all.)
Thinking through such a scenario, I found a useful SQL trick. In order to simulate a real user interacting with a system, you can use the WAITFOR statement to delay statements being sent. With the “time” option, you can even make sure your connections start at the same second.
Some examples are in order.
1 2 |
waitfor delay '0:0:15' print 'Hello world.' |
This waits for 15 seconds, then prints ‘Hello world’.
1 2 |
waitfor time '14:01:15' print 'Hello world.' |
This waits for 15 seconds past 2:01 PM, and then printes ‘Hello world.”