mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-19 15:39:09 +00:00
8236617: jtreg test containers/docker/TestMemoryAwareness.java fails after 8226575
Reviewed-by: bobv, clanger, mdoerr
This commit is contained in:
parent
9549cd2877
commit
44f7fe57a8
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -61,7 +61,8 @@ class OperatingSystemImpl extends BaseOperatingSystemImpl
|
||||
// it can use as much memory as the host's OS allows.
|
||||
long memLimit = containerMetrics.getMemoryLimit();
|
||||
if (limit >= 0 && memLimit >= 0) {
|
||||
return limit - memLimit;
|
||||
// we see a limit == 0 on some machines where "kernel does not support swap limit capabilities"
|
||||
return (limit < memLimit) ? 0 : limit - memLimit;
|
||||
}
|
||||
}
|
||||
return getTotalSwapSpaceSize0();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -144,16 +144,21 @@ public class TestMemoryAwareness {
|
||||
"--memory-swap", swapAllocation
|
||||
);
|
||||
|
||||
DockerTestUtils.dockerRunJava(opts)
|
||||
.shouldHaveExitValue(0)
|
||||
.shouldContain("Checking OperatingSystemMXBean")
|
||||
.shouldContain("OperatingSystemMXBean.getTotalPhysicalMemorySize: " + expectedMemory)
|
||||
.shouldMatch("OperatingSystemMXBean\\.getFreePhysicalMemorySize: [1-9][0-9]+")
|
||||
.shouldContain("OperatingSystemMXBean.getTotalMemorySize: " + expectedMemory)
|
||||
.shouldMatch("OperatingSystemMXBean\\.getFreeMemorySize: [1-9][0-9]+")
|
||||
.shouldContain("OperatingSystemMXBean.getTotalSwapSpaceSize: " + expectedSwap)
|
||||
.shouldMatch("OperatingSystemMXBean\\.getFreeSwapSpaceSize: [1-9][0-9]+")
|
||||
;
|
||||
OutputAnalyzer out = DockerTestUtils.dockerRunJava(opts);
|
||||
out.shouldHaveExitValue(0)
|
||||
.shouldContain("Checking OperatingSystemMXBean")
|
||||
.shouldContain("OperatingSystemMXBean.getTotalPhysicalMemorySize: " + expectedMemory)
|
||||
.shouldMatch("OperatingSystemMXBean\\.getFreePhysicalMemorySize: [1-9][0-9]+")
|
||||
.shouldContain("OperatingSystemMXBean.getTotalMemorySize: " + expectedMemory)
|
||||
.shouldMatch("OperatingSystemMXBean\\.getFreeMemorySize: [1-9][0-9]+")
|
||||
.shouldMatch("OperatingSystemMXBean\\.getFreeSwapSpaceSize: [1-9][0-9]+");
|
||||
// in case of warnings like : "Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap."
|
||||
// the getTotalSwapSpaceSize does not return the expected result, but 0
|
||||
try {
|
||||
out.shouldContain("OperatingSystemMXBean.getTotalSwapSpaceSize: " + expectedSwap);
|
||||
} catch(RuntimeException ex) {
|
||||
out.shouldContain("OperatingSystemMXBean.getTotalSwapSpaceSize: 0");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user