Skip to content

Commit

Permalink
Fix test isolation failure with DeleteFileOnExitHooks (netty#12809)
Browse files Browse the repository at this point in the history
Motivation:
DiskAttributes add themselves to a static mutable map when their `deleteOnExit` is `true`.
The `DeleteOnExitHooksTest` manipulates this map and deletes the files in it, causing random test isolation failures.

Modification:
Make the `DeleteFileOnExitHookTest` isolated.
Also make the test use a new random temp directory every time.

Result:
No more tests in the http module randomly failing with "file not found".
  • Loading branch information
chrisvest authored Sep 15, 2022
1 parent a29217c commit d684f15
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
import io.netty.handler.codec.http.HttpRequest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Isolated;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.UUID;

import static io.netty.handler.codec.http.HttpMethod.POST;
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
Expand All @@ -34,9 +36,11 @@
/**
* Test DeleteFileOnExitHook
*/
@Isolated("The DeleteFileOnExitHook has static shared mutable, " +
"and can interferre with other tests that use DiskAttribute")
public class DeleteFileOnExitHookTest {
private static final HttpRequest REQUEST = new DefaultHttpRequest(HTTP_1_1, POST, "/form");
private static final String HOOK_TEST_TMP = "target/DeleteFileOnExitHookTest/tmp";
private static final String HOOK_TEST_TMP = "target/DeleteFileOnExitHookTest-" + UUID.randomUUID() + "/tmp";
private FileUpload fu;

@BeforeEach
Expand Down

0 comments on commit d684f15

Please sign in to comment.