Skip to content

Commit

Permalink
[BUG] Fixing org.opensearch.monitor.os.OsProbeTests > testLogWarnCpuM…
Browse files Browse the repository at this point in the history
…essageOnlyOnes when cgroups are available but cgroup stats is not (#3448)

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta authored and Bukhtawar committed Jun 20, 2022
1 parent 1535c67 commit 3dd7121
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server/src/test/java/org/opensearch/monitor/os/OsProbeTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

package org.opensearch.monitor.os;

import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.both;
Expand Down Expand Up @@ -296,8 +298,12 @@ List<String> readSysFsCgroupCpuAcctCpuStat(String controlGroup) throws IOExcepti
}
};

assumeThat("CGroups are not available", noCpuStatsOsProbe.areCgroupStatsAvailable(), is(true));
noCpuStatsOsProbe.osStats();
assumeThat("CGroups are available", noCpuStatsOsProbe.areCgroupStatsAvailable(), is(true));
OsStats osStats = noCpuStatsOsProbe.osStats();

// Depending on CGroups v1/v2, the cgroup stats may not be available
assumeThat("CGroup is available", osStats.getCgroup(), is(not(nullValue())));

// no nr_throttled and throttled_time
verify(logger, times(2)).warn(anyString());
reset(logger);
Expand Down

0 comments on commit 3dd7121

Please sign in to comment.