Skip to content

Commit d24214d

Browse files
committed
[BUG] Fixing org.opensearch.monitor.os.OsProbeTests > testLogWarnCpuMessageOnlyOnes when cgroups are available but cgroup stats is not
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
1 parent 5320b68 commit d24214d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

server/src/test/java/org/opensearch/monitor/os/OsProbeTests.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
package org.opensearch.monitor.os;
3434

35+
import static org.hamcrest.CoreMatchers.not;
36+
import static org.hamcrest.CoreMatchers.nullValue;
3537
import static org.hamcrest.Matchers.allOf;
3638
import static org.hamcrest.Matchers.anyOf;
3739
import static org.hamcrest.Matchers.both;
@@ -296,8 +298,12 @@ List<String> readSysFsCgroupCpuAcctCpuStat(String controlGroup) throws IOExcepti
296298
}
297299
};
298300

299-
assumeThat("CGroups are not available", noCpuStatsOsProbe.areCgroupStatsAvailable(), is(true));
300-
noCpuStatsOsProbe.osStats();
301+
assumeThat("CGroups are available", noCpuStatsOsProbe.areCgroupStatsAvailable(), is(true));
302+
OsStats osStats = noCpuStatsOsProbe.osStats();
303+
304+
// Depending on CGroups v1/v2, the cgroup stats may not be available
305+
assumeThat("CGroup is available", osStats.getCgroup(), is(not(nullValue())));
306+
301307
// no nr_throttled and throttled_time
302308
verify(logger, times(2)).warn(anyString());
303309
reset(logger);

0 commit comments

Comments
 (0)