Jaa


Stress Test Best Practice

When doing testing, we always want to cover as much area as possible. Unfortunately, it's almost impossible to test all possible combinations areas all of the time. Stress test can help covering areas that normal testing might not touch.

The main purpose of stress test is to simulate real world load under a control environment. Again, even in stress test, often time it's almost impossible to cover all possibilities. Thus, we need to design the stress test in such a way to aim to the right target. Analyze how the system is being used in the real world and think of how you could simulate the behaviors under the stress test. We want to maximize our time, focusing on issues that are relevant to the real world.

Secondly, it's very important to use randomness on the stress test. This increases the chance of covering more combinations in our control environment. Randomize the data, size of the data used during the testing, and even the order of processes. For example, you can define a function table whereas each entry is a function that has common parameters:

static const PFN_TESTPROC TEST_FUNCTION_TABLE[] = {
Tst_Func1,
Tst_Func2,
Tst_Func3,


};
static const DWORD TEST_FUNCTION_TABLE_COUNT = sizeof(TEST_FUNCTION_TABLE)/sizeof(TEST_FUNCTION_TABLE[0]);

Then, you can execute the functions in random order:

DWORD indexTest = rand() % TEST_FUNCTION_TABLE_COUNT;
TEST_FUNCTION_TABLE[indexTest])( [parameters] )

Thirdly, it’s a good idea to clean up after each iteration. You don’t want your test to grow, eating up disk space/memory since the idea is to run it for a long period of time.

In summary, aim what you stress test for, introduce randomness on the stress (data, length, processes, etc.), then don’t forget to do clean up on each iteration. These are basic principles for stress test that we often forget.

Comments