Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf testing: aligned with functionality from master
- Loading branch information
Showing
9 changed files
with
125 additions
and
65 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
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
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
55 changes: 55 additions & 0 deletions
55
.../test-ng/src/main/java/com/evolveum/midpoint/tools/testng/PerformanceTestCommonMixin.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,55 @@ | ||
/* | ||
* Copyright (C) 2010-2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.tools.testng; | ||
|
||
import com.google.common.base.Joiner; | ||
import org.javasimon.Stopwatch; | ||
|
||
/** | ||
* Common mixin supporting work with {@link TestMonitor}, use one of the sub-interfaces based | ||
* on the required scope measured by the test monitor (class or method). | ||
* Test class (perhaps abstract superclass) must implement create/destroy/"get" methods, | ||
* the rest should be taken care of by the lifecycle methods in sub-interfaces. | ||
*/ | ||
public interface PerformanceTestCommonMixin extends MidpointTestMixin { | ||
|
||
Joiner MONITOR_JOINER = Joiner.on("."); | ||
|
||
/** Used for reporting at the end of the scope, but also for adding monitors by the test code. */ | ||
TestMonitor testMonitor(); | ||
|
||
/** Called after method or class, see sub-interfaces. */ | ||
TestMonitor createTestMonitor(); | ||
|
||
/** Implement, don't call, used by {@link #dumpReport}. */ | ||
void destroyTestMonitor(); | ||
|
||
/** | ||
* Dumps the report and <b>"destroys" the test monitor</b> to allow its garbage collection. | ||
* Otherwise if many test objects are part of the test runtime it can take a lot of memory. | ||
* Called after method or class, see sub-interfaces. | ||
* | ||
* @param reportedTestName reported test name can be a class name or class+method name | ||
* combination depending on the test monitor scope | ||
*/ | ||
default void dumpReport(String reportedTestName) { | ||
TestMonitor testMonitor = testMonitor(); | ||
testMonitor.dumpReport(reportedTestName); | ||
destroyTestMonitor(); | ||
} | ||
|
||
default Stopwatch stopwatch(String name, String description) { | ||
return testMonitor().stopwatch(name, description); | ||
} | ||
|
||
/** | ||
* Returns final name from name parts, joined with predefined character (yes, it's a dot). | ||
*/ | ||
default String monitorName(String... nameParts) { | ||
return MONITOR_JOINER.join(nameParts); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
.../test-ng/src/main/java/com/evolveum/midpoint/tools/testng/PerformanceTestMethodMixin.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,31 @@ | ||
/* | ||
* Copyright (C) 2010-2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.tools.testng; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
|
||
/** | ||
* Mixin supporting work with {@link TestMonitor} at the method-scope level | ||
* (one test report for each test method). | ||
* Details of setting of {@link TestMonitor} is up to the class, methods from | ||
* {@link PerformanceTestCommonMixin} must be implemented. | ||
*/ | ||
public interface PerformanceTestMethodMixin extends PerformanceTestCommonMixin { | ||
|
||
@BeforeMethod | ||
default void initTestMonitor() { | ||
createTestMonitor(); | ||
} | ||
|
||
@AfterMethod | ||
default void dumpReport(Method method) { | ||
dumpReport(getClass().getSimpleName() + "#" + method.getName()); | ||
} | ||
} |
48 changes: 0 additions & 48 deletions
48
tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/PerformanceTestMixin.java
This file was deleted.
Oops, something went wrong.