Skip to content

Commit 40bc589

Browse files
retagithub-actions[bot]
authored andcommitted
[BUG] Fixing org.opensearch.monitor.os.OsProbeTests > testLogWarnCpuMessageOnlyOnes when cgroups are available but cgroup stats is not (#3448)
Signed-off-by: Andriy Redko <[email protected]> (cherry picked from commit 1b93cf8)
1 parent f76fd5d commit 40bc589

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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)