Skip to content

Commit e87f810

Browse files
committed
Fix gradle tests on Windows
Addresses #7637 Fixes #7716
1 parent 85fc814 commit e87f810

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

ci/ci_test.bat

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
goto no_test
21
@echo off
32

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

logstash-core/src/test/java/org/logstash/instruments/monitors/HotThreadMonitorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public void testStackTraceSizeOption(){
5050
Map<String, String> options = new HashMap<>();
5151
options.put("stacktrace_size", testStackSize);
5252
HotThreadsMonitor.detect(options).stream().filter(tr -> !tr.getThreadName().equals("Signal Dispatcher") &&
53-
!tr.getThreadName().equals("Reference Handler"))
53+
!tr.getThreadName().equals("Reference Handler") &&
54+
!tr.getThreadName().equals("Attach Listener"))
5455
.forEach(tr -> {
5556
List stackTrace = (List)tr.toMap().get("thread.stacktrace");
5657
assertThat(stackTrace.size(), is(Integer.valueOf(testStackSize)));

logstash-core/src/test/java/org/logstash/instruments/monitors/ProcessMonitorTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,23 @@
88
import static org.hamcrest.CoreMatchers.instanceOf;
99
import static org.hamcrest.CoreMatchers.is;
1010
import static org.hamcrest.MatcherAssert.assertThat;
11+
import static org.junit.Assume.assumeTrue;
1112

1213
public class ProcessMonitorTest {
1314

1415

1516
@Test
1617
public void testReportFDStats(){
1718
Map<String, Object> processStats = ProcessMonitor.detect().toMap();
19+
assumeTrue((Boolean) processStats.get("is_unix"));
1820
assertThat("open_file_descriptors", (Long)processStats.get("open_file_descriptors") > 0L, is(true));
1921
assertThat("max_file_descriptors", (Long)processStats.get("max_file_descriptors") > 0L, is(true));
2022
}
2123

2224
@Test
2325
public void testReportCpuStats(){
2426
Map<String, Object> processStats = ProcessMonitor.detect().toMap();
27+
assumeTrue((Boolean) processStats.get("is_unix"));
2528
assertThat("cpu", processStats.get("cpu"), instanceOf(Map.class));
2629
Map cpuStats = ((Map)processStats.get("cpu"));
2730
assertThat("cpu.process_percent", (Short)cpuStats.get("process_percent") >= 0, is(true));
@@ -32,6 +35,7 @@ public void testReportCpuStats(){
3235
@Test
3336
public void testReportMemStats() {
3437
Map<String, Object> processStats = ProcessMonitor.detect().toMap();
38+
assumeTrue((Boolean) processStats.get("is_unix"));
3539
assertThat("mem", processStats.get("mem"), instanceOf(Map.class));
3640
Map memStats = ((Map)processStats.get("mem"));
3741
assertThat("mem.total_virtual_in_bytes", (Long)memStats.get("total_virtual_in_bytes") >= 0L, is(true));

logstash-core/src/test/java/org/logstash/instruments/monitors/SystemMonitorTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ public class SystemMonitorTest {
1414
@Test
1515
public void systemMonitorTest(){
1616
Map<String, Object> map = SystemMonitor.detect().toMap();
17-
assertThat("system.load_average is missing", (Double)map.get("system.load_average") > 0, is(true));
17+
assertThat("os.name is missing", map.get("os.name"), allOf(notNullValue(), instanceOf(String.class)));
18+
if (!((String) map.get("os.name")).startsWith("Windows")) {
19+
assertThat("system.load_average is missing", (Double) map.get("system.load_average") > 0, is(true));
20+
}
1821
assertThat("system.available_processors is missing ", ((Integer)map.get("system.available_processors")) > 0, is(true));
1922
assertThat("os.version is missing", map.get("os.version"), allOf(notNullValue(), instanceOf(String.class)));
2023
assertThat("os.arch is missing", map.get("os.arch"), allOf(notNullValue(), instanceOf(String.class)));
21-
assertThat("os.name is missing", map.get("os.name"), allOf(notNullValue(), instanceOf(String.class)));
2224
}
2325
}

0 commit comments

Comments
 (0)