Skip to content

Commit

Permalink
8292206: TestCgroupMetrics.java fails as getMemoryUsage() is lower th…
Browse files Browse the repository at this point in the history
…an expected

Reviewed-by: dholmes, sgehwolf
  • Loading branch information
iklam committed Dec 22, 2022
1 parent b378381 commit 6ccee83
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
13 changes: 2 additions & 11 deletions test/jdk/jdk/internal/platform/cgroup/TestCgroupMetrics.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, 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
Expand Down Expand Up @@ -36,16 +36,7 @@
public class TestCgroupMetrics {

public static void main(String[] args) throws Exception {
// If cgroups is not configured, report success.
Metrics metrics = Metrics.systemMetrics();
if (metrics == null) {
System.out.println("TEST PASSED!!!");
return;
}

MetricsTester metricsTester = new MetricsTester();
metricsTester.testAll(metrics);
System.out.println("TEST PASSED!!!");
MetricsTester.main(args);
}

}
3 changes: 2 additions & 1 deletion test/jdk/jdk/internal/platform/docker/TestSystemMetrics.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, 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
Expand Down Expand Up @@ -55,6 +55,7 @@ public static void main(String[] args) throws Exception {
opts.addDockerOpts("--memory=256m");
opts.addJavaOpts("-cp", "/test-classes/");
opts.addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED");
opts.addClassOptions("-incontainer");
DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
} finally {
DockerTestUtils.removeDockerImage(imageName);
Expand Down
24 changes: 19 additions & 5 deletions test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Red Hat Inc.
* Copyright (c) 2020, 2022, Red Hat Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -52,14 +52,22 @@ private static CgroupMetricsTester createInstance(Metrics m) {
}
}

public void testAll(Metrics m) throws Exception {
private void testAll(Metrics m, boolean inContainer) throws Exception {
CgroupMetricsTester tester = createInstance(m);
tester.testCpuAccounting();
tester.testCpuConsumption();
tester.testCpuSchedulingMetrics();
tester.testCpuSets();
tester.testMemorySubsystem();
tester.testMemoryUsage();
if (!inContainer) {
// If not running in a container, these test cases query the memory usage.
// of all processes in the entire system (or those belonging to the current
// Linux user). They cannot produce predictable results due to interference
// from unrelated processes.
System.out.println("testMemorySubsystem and testMemoryUsage skipped");
} else {
tester.testMemorySubsystem();
tester.testMemoryUsage();
}
tester.testMisc();
}

Expand All @@ -71,8 +79,14 @@ public static void main(String[] args) throws Exception {
return;
}

boolean inContainer = false;
if (args.length > 0 && "-incontainer".equals(args[0])) {
inContainer = true;
}
System.out.println("inContainer = " + inContainer);

MetricsTester metricsTester = new MetricsTester();
metricsTester.testAll(m);
metricsTester.testAll(m, inContainer);
System.out.println("TEST PASSED!!!");
}
}

5 comments on commit 6ccee83

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 6ccee83 May 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 6ccee83 May 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch GoeLin-backport-6ccee839 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 6ccee839 from the openjdk/jdk repository.

The commit being backported was authored by Ioi Lam on 22 Dec 2022 and was reviewed by David Holmes and Severin Gehwolf.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-6ccee839:GoeLin-backport-6ccee839
$ git checkout GoeLin-backport-6ccee839
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-6ccee839

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 6ccee83 May 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 6ccee83 May 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch GoeLin-backport-6ccee839 in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 6ccee839 from the openjdk/jdk repository.

The commit being backported was authored by Ioi Lam on 22 Dec 2022 and was reviewed by David Holmes and Severin Gehwolf.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev.git GoeLin-backport-6ccee839:GoeLin-backport-6ccee839
$ git checkout GoeLin-backport-6ccee839
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev.git GoeLin-backport-6ccee839

Please sign in to comment.