Fix gradle tests on Windows

Addresses #7637

Fixes #7716
This commit is contained in:
Jake Landis 2017-07-17 14:58:34 -05:00
parent 85fc814105
commit e87f810c76
4 changed files with 10 additions and 6 deletions

View file

@ -1,4 +1,3 @@
goto no_test
@echo off
setlocal
@ -40,5 +39,3 @@ IF "%SELECTEDTESTSUITE%"=="core-fail-fast" (
%RAKEPATH% test:core
)
)
:no_test
echo ***** SKIPPING TESTS : https://github.com/elastic/logstash/issues/7634 *****

View file

@ -50,7 +50,8 @@ public class HotThreadMonitorTest {
Map<String, String> options = new HashMap<>();
options.put("stacktrace_size", testStackSize);
HotThreadsMonitor.detect(options).stream().filter(tr -> !tr.getThreadName().equals("Signal Dispatcher") &&
!tr.getThreadName().equals("Reference Handler"))
!tr.getThreadName().equals("Reference Handler") &&
!tr.getThreadName().equals("Attach Listener"))
.forEach(tr -> {
List stackTrace = (List)tr.toMap().get("thread.stacktrace");
assertThat(stackTrace.size(), is(Integer.valueOf(testStackSize)));

View file

@ -8,6 +8,7 @@ import java.util.Map;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assume.assumeTrue;
public class ProcessMonitorTest {
@ -15,6 +16,7 @@ public class ProcessMonitorTest {
@Test
public void testReportFDStats(){
Map<String, Object> processStats = ProcessMonitor.detect().toMap();
assumeTrue((Boolean) processStats.get("is_unix"));
assertThat("open_file_descriptors", (Long)processStats.get("open_file_descriptors") > 0L, is(true));
assertThat("max_file_descriptors", (Long)processStats.get("max_file_descriptors") > 0L, is(true));
}
@ -22,6 +24,7 @@ public class ProcessMonitorTest {
@Test
public void testReportCpuStats(){
Map<String, Object> processStats = ProcessMonitor.detect().toMap();
assumeTrue((Boolean) processStats.get("is_unix"));
assertThat("cpu", processStats.get("cpu"), instanceOf(Map.class));
Map cpuStats = ((Map)processStats.get("cpu"));
assertThat("cpu.process_percent", (Short)cpuStats.get("process_percent") >= 0, is(true));
@ -32,6 +35,7 @@ public class ProcessMonitorTest {
@Test
public void testReportMemStats() {
Map<String, Object> processStats = ProcessMonitor.detect().toMap();
assumeTrue((Boolean) processStats.get("is_unix"));
assertThat("mem", processStats.get("mem"), instanceOf(Map.class));
Map memStats = ((Map)processStats.get("mem"));
assertThat("mem.total_virtual_in_bytes", (Long)memStats.get("total_virtual_in_bytes") >= 0L, is(true));

View file

@ -14,10 +14,12 @@ public class SystemMonitorTest {
@Test
public void systemMonitorTest(){
Map<String, Object> map = SystemMonitor.detect().toMap();
assertThat("system.load_average is missing", (Double)map.get("system.load_average") > 0, is(true));
assertThat("os.name is missing", map.get("os.name"), allOf(notNullValue(), instanceOf(String.class)));
if (!((String) map.get("os.name")).startsWith("Windows")) {
assertThat("system.load_average is missing", (Double) map.get("system.load_average") > 0, is(true));
}
assertThat("system.available_processors is missing ", ((Integer)map.get("system.available_processors")) > 0, is(true));
assertThat("os.version is missing", map.get("os.version"), allOf(notNullValue(), instanceOf(String.class)));
assertThat("os.arch is missing", map.get("os.arch"), allOf(notNullValue(), instanceOf(String.class)));
assertThat("os.name is missing", map.get("os.name"), allOf(notNullValue(), instanceOf(String.class)));
}
}