Skip to content

8362087: Test containers/docker/ShareTmpDir.java intermittent fails #26605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions test/hotspot/jtreg/containers/docker/ShareTmpDir.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, 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 @@ -70,31 +70,40 @@ public static void main(String[] args) throws Exception {
private static void test() throws Exception {
File sharedtmpdir = new File("sharedtmpdir");
File flag = new File(sharedtmpdir, "flag");
File started = new File(sharedtmpdir, "started");
File started1 = new File(sharedtmpdir, "started-1");
File started2 = new File(sharedtmpdir, "started-2");
sharedtmpdir.mkdir();
flag.delete();
started.delete();
started1.delete();
started2.delete();
DockerRunOptions opts = new DockerRunOptions(imageName, "/jdk/bin/java", "WaitForFlagFile");
Object lock = new Object();
opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/");
opts.addDockerOpts("--volume", sharedtmpdir.getAbsolutePath() + ":/tmp/");
opts.addJavaOpts("-Xlog:os+container=trace", "-Xlog:perf+memops=debug", "-cp", "/test-classes/");

Thread t1 = new Thread() {
public void run() {
synchronized(lock) {
opts.addClassOptions("1");
}
try { out1 = Common.run(opts); } catch (Exception e) { e.printStackTrace(); }
}
};
t1.start();

Thread t2 = new Thread() {
public void run() {
synchronized(lock) {
opts.addClassOptions("2");
}
try { out2 = Common.run(opts); } catch (Exception e) { e.printStackTrace(); }
}
};
t2.start();

while (!started.exists()) {
System.out.println("Wait for at least one JVM to start");
while (!started1.exists() || !started2.exists()) {
System.out.println("Waiting for all the two JVM started");
Thread.sleep(1000);
}

Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/jtreg/containers/docker/WaitForFlagFile.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, 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 @@ -28,7 +28,7 @@ public class WaitForFlagFile {
public static void main(String[] args) throws Exception {
System.out.println("WaitForFlagFile: Entering");

File started = new File("/tmp/started");
File started = new File("/tmp/started-" + args.length);
FileOutputStream fout = new FileOutputStream(started);
fout.close();

Expand Down