Skip to content
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

Fix HugeResourceTest #9411

Merged
merged 3 commits into from
Feb 27, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ public void onPartContent(Content.Chunk chunk)
}

partChunks.forEach(Content.Chunk::release);
partChunks.clear();
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.MultiPart;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.server.HttpConfiguration;
Expand All @@ -70,7 +71,6 @@
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand All @@ -83,7 +83,6 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

@Tag("large-disk-resource")
@Disabled // TODO investigate
public class HugeResourceTest
{
private static final long KB = 1024;
Expand Down Expand Up @@ -114,11 +113,12 @@ public static void prepareStaticFiles() throws IOException
String.format("FileStore %s of %s needs at least 30GB of free space for this test (only had %,.2fGB)",
baseFileStore, staticBase, (double)(baseFileStore.getUnallocatedSpace() / GB)));

makeStaticFile(staticBase.resolve("test-1M.dat"), MB);
makeStaticFile(staticBase.resolve("test-100M.dat"), 100 * MB);
makeStaticFile(staticBase.resolve("test-1G.dat"), GB);
// makeStaticFile(staticBase.resolve("test-4G.dat"), 4 * GB);
// makeStaticFile(staticBase.resolve("test-10G.dat"), 10 * GB);
makeStaticFile(staticBase.resolve("test-1m.dat"), MB);
makeStaticFile(staticBase.resolve("test-1g.dat"), GB);
// The reason for testing 4GB and 10GB were because of various filesystem handling bugs
// we had in our code (the 2GB threshold and the 8GB threshold in various FileSystem APIs).
makeStaticFile(staticBase.resolve("test-4g.dat"), 4 * GB);
makeStaticFile(staticBase.resolve("test-10g.dat"), 10 * GB);

outputDir = MavenTestingUtils.getTargetTestingPath(HugeResourceTest.class.getSimpleName() + "-outputdir");
FS.ensureEmpty(outputDir);
Expand All @@ -131,11 +131,10 @@ public static Stream<Arguments> staticFiles()
{
ArrayList<Arguments> ret = new ArrayList<>();

ret.add(Arguments.of("test-1M.dat", MB));
ret.add(Arguments.of("test-100M.dat", 100 * MB));
ret.add(Arguments.of("test-1G.dat", GB));
// ret.add(Arguments.of("test-4G.dat", 4 * GB));
// ret.add(Arguments.of("test-1Gg.dat", 10 * GB));
ret.add(Arguments.of("test-1m.dat", MB));
ret.add(Arguments.of("test-1g.dat", GB));
ret.add(Arguments.of("test-4g.dat", 4 * GB));
ret.add(Arguments.of("test-10g.dat", 10 * GB));

return ret.stream();
}
Expand Down Expand Up @@ -202,7 +201,8 @@ public void startServer() throws Exception
QueuedThreadPool serverThreads = new QueuedThreadPool();
serverThreads.setDetailedDump(true);
serverThreads.setName("server");
server = new Server(serverThreads);
// TODO: Use normal pool when a fix for https://github.com/eclipse/jetty.project/issues/9311 is merged.
server = new Server(serverThreads, null, new ByteBufferPool.NonPooling());
httpConfig = new HttpConfiguration();
ServerConnector connector = new ServerConnector(server, 1, 1, new HttpConnectionFactory(httpConfig));
connector.setPort(0);
Expand Down Expand Up @@ -249,6 +249,8 @@ public void startClient() throws Exception
connector.setSelectors(1);
connector.setExecutor(clientThreads);
client = new HttpClient(new HttpClientTransportOverHTTP(connector));
// TODO: Use normal pool when a fix for https://github.com/eclipse/jetty.project/issues/9311 is merged.
client.setByteBufferPool(new ByteBufferPool.NonPooling());
client.start();
}

Expand Down Expand Up @@ -428,7 +430,7 @@ public void demand(Runnable demandCallback)
Thread.sleep(100);
stalled.set(false);
demand.get().run();
assertTrue(complete.await(30, TimeUnit.SECONDS));
assertTrue(complete.await(60, TimeUnit.SECONDS));
Response response = responseRef.get();
assertThat("HTTP Response Code", response.getStatus(), is(200));

Expand Down Expand Up @@ -603,9 +605,9 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S
IO.copy(inputStream, byteCounting);
out.printf("part[%s].inputStream.length=%d%n", part.getName(), byteCounting.getCount());
}
catch (IOException e)
catch (Throwable x)
{
e.printStackTrace(out);
throw new AssertionError(x);
}
});
}
Expand Down