Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Reinit OsPluginTest if testCpuUtilisation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Barnsteiner committed Apr 5, 2015
1 parent 87620e1 commit 4785764
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public static void reset() {
started = false;
disabled = false;
measurementSession = new MeasurementSession(null, null, null);
SharedMetricRegistries.clear();
reloadConfiguration();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@RunWith(ConditionalTravisTestRunner.class)
public class OsPluginTest {

private final MetricRegistry metricRegistry = new MetricRegistry();
private MetricRegistry metricRegistry;
private static Sigar sigar;

static {
Expand All @@ -40,6 +40,7 @@ public class OsPluginTest {

@Before
public void setUp() throws Exception {
metricRegistry = new MetricRegistry();
OsPlugin osPlugin = new OsPlugin(sigar);
final Configuration configuration = mock(Configuration.class);
when(configuration.getConfig(CorePlugin.class)).thenReturn(mock(CorePlugin.class));
Expand All @@ -50,6 +51,7 @@ public void setUp() throws Exception {
public void testCpuUtilisation() throws Exception {
double cpu = Double.NaN;
for (int i = 0; i < 5 && Double.isNaN(cpu); i++) {
setUp();
cpu = getDoubleGauge("os.cpu.usage.sys") +
getDoubleGauge("os.cpu.usage.user") +
getDoubleGauge("os.cpu.usage.idle") +
Expand Down

0 comments on commit 4785764

Please sign in to comment.