8229182: runtime/containers/docker/TestMemoryAwareness.java test fails on SLES12
Reviewed-by: clanger, mseledtsov
This commit is contained in:
parent
7cb28198a1
commit
a41b9a71ac
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2019, 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
|
||||
@ -37,7 +37,7 @@
|
||||
import jdk.test.lib.containers.docker.Common;
|
||||
import jdk.test.lib.containers.docker.DockerRunOptions;
|
||||
import jdk.test.lib.containers.docker.DockerTestUtils;
|
||||
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
public class TestMemoryAwareness {
|
||||
private static final String imageName = Common.imageName("memory");
|
||||
@ -98,15 +98,26 @@ public class TestMemoryAwareness {
|
||||
private static void testOOM(String dockerMemLimit, int sizeToAllocInMb) throws Exception {
|
||||
Common.logNewTestCase("OOM");
|
||||
|
||||
// add "--memory-swappiness 0" so as to disable anonymous page swapping.
|
||||
DockerRunOptions opts = Common.newOpts(imageName, "AttemptOOM")
|
||||
.addDockerOpts("--memory", dockerMemLimit, "--memory-swap", dockerMemLimit);
|
||||
.addDockerOpts("--memory", dockerMemLimit, "--memory-swappiness", "0", "--memory-swap", dockerMemLimit);
|
||||
opts.classParams.add("" + sizeToAllocInMb);
|
||||
|
||||
DockerTestUtils.dockerRunJava(opts)
|
||||
.shouldHaveExitValue(1)
|
||||
.shouldContain("Entering AttemptOOM main")
|
||||
.shouldNotContain("AttemptOOM allocation successful")
|
||||
.shouldContain("java.lang.OutOfMemoryError");
|
||||
// make sure we avoid inherited Xmx settings from the jtreg vmoptions
|
||||
// set Xmx ourselves instead
|
||||
System.out.println("sizeToAllocInMb is:" + sizeToAllocInMb + " sizeToAllocInMb/2 is:" + sizeToAllocInMb/2);
|
||||
String javaHeapSize = sizeToAllocInMb/2 + "m";
|
||||
opts.addJavaOptsAppended("-Xmx" + javaHeapSize);
|
||||
|
||||
OutputAnalyzer out = DockerTestUtils.dockerRunJava(opts);
|
||||
|
||||
if (out.getExitValue() == 0) {
|
||||
throw new RuntimeException("We exited successfully, but we wanted to provoke an OOM inside the container");
|
||||
}
|
||||
|
||||
out.shouldContain("Entering AttemptOOM main")
|
||||
.shouldNotContain("AttemptOOM allocation successful")
|
||||
.shouldContain("java.lang.OutOfMemoryError");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2019, 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
|
||||
@ -31,11 +31,13 @@ import java.util.Collections;
|
||||
// in test environment.
|
||||
public class DockerRunOptions {
|
||||
public String imageNameAndTag;
|
||||
public ArrayList<String> dockerOpts = new ArrayList<String>();
|
||||
public ArrayList<String> dockerOpts = new ArrayList<>();
|
||||
public String command; // normally a full path to java
|
||||
public ArrayList<String> javaOpts = new ArrayList<String>();
|
||||
public ArrayList<String> javaOpts = new ArrayList<>();
|
||||
// more java options, but to be set AFTER the test Java options
|
||||
public ArrayList<String> javaOptsAppended = new ArrayList<>();
|
||||
public String classToRun; // class or "-version"
|
||||
public ArrayList<String> classParams = new ArrayList<String>();
|
||||
public ArrayList<String> classParams = new ArrayList<>();
|
||||
|
||||
public boolean tty = true;
|
||||
public boolean removeContainerAfterUse = true;
|
||||
@ -70,6 +72,11 @@ public class DockerRunOptions {
|
||||
return this;
|
||||
}
|
||||
|
||||
public DockerRunOptions addJavaOptsAppended(String... opts) {
|
||||
Collections.addAll(javaOptsAppended, opts);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DockerRunOptions addClassOptions(String... opts) {
|
||||
Collections.addAll(classParams,opts);
|
||||
return this;
|
||||
|
@ -40,12 +40,10 @@ import java.util.List;
|
||||
import jdk.test.lib.Container;
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jtreg.SkippedException;
|
||||
|
||||
|
||||
public class DockerTestUtils {
|
||||
private static final String FS = File.separator;
|
||||
private static boolean isDockerEngineAvailable = false;
|
||||
private static boolean wasDockerEngineChecked = false;
|
||||
|
||||
@ -212,6 +210,7 @@ public class DockerTestUtils {
|
||||
if (opts.appendTestJavaOptions) {
|
||||
Collections.addAll(cmd, Utils.getTestJavaOpts());
|
||||
}
|
||||
cmd.addAll(opts.javaOptsAppended);
|
||||
|
||||
cmd.add(opts.classToRun);
|
||||
cmd.addAll(opts.classParams);
|
||||
|
Loading…
x
Reference in New Issue
Block a user