Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-dev] @Stress support in @RunWith(AdvancedRunner.class)

Decided to keep this topic separate, as it has nothing to do with @Slow classification in the test cases and is just another type of classification of special tests in our codebase.

@Stress is a new annotation for classifying test methods that are aggressive with resources (memory, cpu, file handles, etc ....)

Example (contrived for purposes of discussion)
    @Test
    @Stress("Requires at least -DforkMode=never -Xmx4g")
    public void testSomethingStressy()
    {
        int len = 1024000;
        int numBuffers = 2700;
        byte buf[][] = new byte[numBuffers][];
        for(int i=0; i<numBuffers; i++) {
            buf[i] = new byte[len];
        }
        for(int i=0; i<numBuffers; i++) {
            Assert.assertEquals("buf[" + i + "].length", len, buf[i].length);
        }
    }

The @Stress classification is for labeling test methods that have excessive resource utilization (briefly considered calling this @Hog), and has a non-optional parameter to specify the rationale behind tagging this method as @Stress.

By default, a normal maven build (mvn clean install) does not run @Stress tagged methods (to junit, they are ignored, and reported as such)

Historically, we've had various test cases that require a large amount of some resource that would require us to think before we run the test case (adding more memory to JVM, closing down other programs to free file handles, etc ...)  those test methods can be labelled to indicate the reason for the stress introduced.
Our turbulent history with these kinds of tests have often seen a neutering of stress tests that use too many resources just to get the test case to run more often and consistently across the various systems we all use, often with an assumption that the original author didn't really mean to use that many of X resource.
Ideally, the @Stress annotation can address the original intent of the test case and justify the aggressive resource utilization intent of the original author.

--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
www.webtide.com
Developer advice, services and support
from the Jetty & CometD experts.


Back to the top