OpenJDK / jdk / jdk
changeset 51162:52f96cca600f
8206456: [TESTBUG] docker jtreg tests fail on systems without cpuset.effective_cpus / cpuset.effective_mem
Reviewed-by: mbaesken, mchung
author | bobv |
---|---|
date | Thu, 19 Jul 2018 12:57:12 -0400 |
parents | afe2cecf8867 |
children | 8b8658b1b7e4 7cfc6c381cfa |
files | test/jdk/jdk/internal/platform/docker/MetricsCpuTester.java test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java |
diffstat | 2 files changed, 54 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/test/jdk/jdk/internal/platform/docker/MetricsCpuTester.java Thu Jul 19 09:42:15 2018 -0700 +++ b/test/jdk/jdk/internal/platform/docker/MetricsCpuTester.java Thu Jul 19 12:57:12 2018 -0400 @@ -95,10 +95,13 @@ + Arrays.toString(ipCpuSet) + ", got : " + Arrays.toString(cpuSets)); } - if (!Arrays.equals(ipCpuSet, effectiveCpus)) { - throw new RuntimeException("Effective Cpusets not equal, expected : " - + Arrays.toString(ipCpuSet) + ", got : " - + Arrays.toString(effectiveCpus)); + // Check to see if this metric is supported on this platform + if (effectiveCpus.length != 0) { + if (!Arrays.equals(ipCpuSet, effectiveCpus)) { + throw new RuntimeException("Effective Cpusets not equal, expected : " + + Arrays.toString(ipCpuSet) + ", got : " + + Arrays.toString(effectiveCpus)); + } } System.out.println("TEST PASSED!!!"); } @@ -127,10 +130,13 @@ + Arrays.toString(cpuSets)); } - if (!Arrays.equals(ipCpuSet, effectiveMems)) { - throw new RuntimeException("Effective mem nodes not equal, expected : " - + Arrays.toString(ipCpuSet) + ", got : " - + Arrays.toString(effectiveMems)); + // Check to see if this metric is supported on this platform + if (effectiveMems.length != 0) { + if (!Arrays.equals(ipCpuSet, effectiveMems)) { + throw new RuntimeException("Effective mem nodes not equal, expected : " + + Arrays.toString(ipCpuSet) + ", got : " + + Arrays.toString(effectiveMems)); + } } System.out.println("TEST PASSED!!!"); }
--- a/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java Thu Jul 19 09:42:15 2018 -0700 +++ b/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java Thu Jul 19 12:57:12 2018 -0400 @@ -150,7 +150,7 @@ try { return new Scanner(new File(fname)).useDelimiter("\\Z").next(); } catch (FileNotFoundException e) { - System.err.println("Unale to open : " + fname); + System.err.println("Unable to open : " + fname); return ""; } } @@ -428,24 +428,27 @@ Arrays.toString(newVal)); } - - oldVal = Arrays.stream(metrics.getEffectiveCpuSetCpus()).boxed().toArray(Integer[]::new); - Arrays.sort(oldVal); + int [] cpuSets = metrics.getEffectiveCpuSetCpus(); - cpusstr = getFileContents(SubSystem.CPUSET, "cpuset.effective_cpus"); - newVal = Stream.of(cpusstr.split(",")).flatMap(a -> { - if (a.contains("-")) { - String[] range = a.split("-"); - return IntStream.rangeClosed(Integer.parseInt(range[0]), - Integer.parseInt(range[1])).boxed(); - } else { - return Stream.of(Integer.parseInt(a)); + // Skip this test if this metric is supported on this platform + if (cpuSets.length != 0) { + oldVal = Arrays.stream(cpuSets).boxed().toArray(Integer[]::new); + Arrays.sort(oldVal); + cpusstr = getFileContents(SubSystem.CPUSET, "cpuset.effective_cpus"); + newVal = Stream.of(cpusstr.split(",")).flatMap(a -> { + if (a.contains("-")) { + String[] range = a.split("-"); + return IntStream.rangeClosed(Integer.parseInt(range[0]), + Integer.parseInt(range[1])).boxed(); + } else { + return Stream.of(Integer.parseInt(a)); + } + }).toArray(Integer[]::new); + Arrays.sort(newVal); + if (Arrays.compare(oldVal, newVal) != 0) { + fail(SubSystem.CPUSET, "cpuset.effective_cpus", Arrays.toString(oldVal), + Arrays.toString(newVal)); } - }).toArray(Integer[]::new); - Arrays.sort(newVal); - if (Arrays.compare(oldVal, newVal) != 0) { - fail(SubSystem.CPUSET, "cpuset.effective_cpus", Arrays.toString(oldVal), - Arrays.toString(newVal)); } oldVal = Arrays.stream(metrics.getCpuSetMems()).boxed().toArray(Integer[]::new); @@ -466,22 +469,27 @@ Arrays.toString(newVal)); } - oldVal = Arrays.stream(metrics.getEffectiveCpuSetMems()).boxed().toArray(Integer[]::new); - Arrays.sort(oldVal); - cpusstr = getFileContents(SubSystem.CPUSET, "cpuset.effective_mems"); - newVal = Stream.of(cpusstr.split(",")).flatMap(a -> { - if (a.contains("-")) { - String[] range = a.split("-"); - return IntStream.rangeClosed(Integer.parseInt(range[0]), - Integer.parseInt(range[1])).boxed(); - } else { - return Stream.of(Integer.parseInt(a)); + int [] cpuSetMems = metrics.getEffectiveCpuSetMems(); + + // Skip this test if this metric is supported on this platform + if (cpuSetMems.length != 0) { + oldVal = Arrays.stream(cpuSetMems).boxed().toArray(Integer[]::new); + Arrays.sort(oldVal); + cpusstr = getFileContents(SubSystem.CPUSET, "cpuset.effective_mems"); + newVal = Stream.of(cpusstr.split(",")).flatMap(a -> { + if (a.contains("-")) { + String[] range = a.split("-"); + return IntStream.rangeClosed(Integer.parseInt(range[0]), + Integer.parseInt(range[1])).boxed(); + } else { + return Stream.of(Integer.parseInt(a)); + } + }).toArray(Integer[]::new); + Arrays.sort(newVal); + if (Arrays.compare(oldVal, newVal) != 0) { + fail(SubSystem.CPUSET, "cpuset.effective_mems", Arrays.toString(oldVal), + Arrays.toString(newVal)); } - }).toArray(Integer[]::new); - Arrays.sort(newVal); - if (Arrays.compare(oldVal, newVal) != 0) { - fail(SubSystem.CPUSET, "cpuset.effective_mems", Arrays.toString(oldVal), - Arrays.toString(newVal)); } double oldValue = metrics.getCpuSetMemoryPressure();