-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the stack frame is now part of addRandomChanceOfFailure() because it is needed for all branching logic.
- Loading branch information
Showing
3 changed files
with
51 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/test/java/uk/co/probablyfine/bytemonkey/latency/Rate100Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package uk.co.probablyfine.bytemonkey.latency; | ||
|
||
import com.ea.agentloader.AgentLoader; | ||
import org.junit.Test; | ||
import uk.co.probablyfine.bytemonkey.ByteMonkeyAgent; | ||
import uk.co.probablyfine.bytemonkey.testfiles.TestObject; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
public class Rate100Test { | ||
|
||
@Test | ||
public void shouldThrowExceptionWhenInstrumented_throwPercentageIs100() throws IOException { | ||
AgentLoader.loadAgentClass( | ||
ByteMonkeyAgent.class.getName(), | ||
"mode:latency,rate:1,latency:200,filter:uk/co/probablyfine/bytemonkey/testfiles" | ||
); | ||
|
||
long timeTaken = timed(new TestObject()::safePrint); | ||
|
||
assertTrue("Actually took "+timeTaken+"ms", timeTaken >= 200 && timeTaken < 300); | ||
} | ||
|
||
public static long timed(Runnable runnable) { | ||
long startTime = System.currentTimeMillis(); | ||
|
||
runnable.run(); | ||
|
||
return System.currentTimeMillis() - startTime; | ||
} | ||
|
||
} |