mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-10-13 13:44:26 +00:00
Turn off transfer messages when running tests when possible (#790)
This commit is contained in:
@@ -25,9 +25,10 @@ import java.io.IOException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mvndaemon.mvnd.assertj.TestClientOutput;
|
||||
import org.mvndaemon.mvnd.client.Client;
|
||||
import org.mvndaemon.mvnd.client.DaemonParameters;
|
||||
import org.mvndaemon.mvnd.common.Message;
|
||||
import org.mvndaemon.mvnd.junit.ClientFactory;
|
||||
import org.mvndaemon.mvnd.junit.MvndTest;
|
||||
import org.mvndaemon.mvnd.junit.TestParameters;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@@ -35,15 +36,16 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
public class ConcurrentDownloadsTest {
|
||||
|
||||
@Inject
|
||||
Client client;
|
||||
ClientFactory clientFactory;
|
||||
|
||||
@Inject
|
||||
DaemonParameters parameters;
|
||||
TestParameters parameters;
|
||||
|
||||
@Test
|
||||
void build() throws IOException, InterruptedException {
|
||||
|
||||
final TestClientOutput o = new TestClientOutput();
|
||||
Client client = clientFactory.newClient(parameters.withTransferProgress());
|
||||
client.execute(o, "clean", "install", "-e", "-B").assertSuccess();
|
||||
|
||||
int maxConcurrentDownloads = 0;
|
||||
|
@@ -81,8 +81,4 @@ public class ThreadOptionNativeIT {
|
||||
|
||||
output.assertContainsMatchingSubsequence("Using the SmartBuilder implementation with a thread count of 2");
|
||||
}
|
||||
|
||||
protected boolean isNative() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -21,9 +21,4 @@ package org.mvndaemon.mvnd.it;
|
||||
import org.mvndaemon.mvnd.junit.MvndTest;
|
||||
|
||||
@MvndTest(projectDir = "src/test/projects/multi-module")
|
||||
public class ThreadOptionTest extends ThreadOptionNativeIT {
|
||||
|
||||
protected boolean isNative() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public class ThreadOptionTest extends ThreadOptionNativeIT {}
|
||||
|
@@ -20,6 +20,7 @@ package org.mvndaemon.mvnd.junit;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.mvndaemon.mvnd.assertj.TestClientOutput;
|
||||
@@ -31,7 +32,7 @@ import org.mvndaemon.mvnd.common.logging.ClientOutput;
|
||||
|
||||
public class JvmTestClient extends DefaultClient {
|
||||
|
||||
private DaemonParameters parameters;
|
||||
private final DaemonParameters parameters;
|
||||
|
||||
public JvmTestClient(DaemonParameters parameters) {
|
||||
super(parameters);
|
||||
@@ -42,6 +43,10 @@ public class JvmTestClient extends DefaultClient {
|
||||
public ExecutionResult execute(ClientOutput output, List<String> argv) {
|
||||
setMultiModuleProjectDirectory(argv);
|
||||
setSystemPropertiesFromCommandLine(argv);
|
||||
argv = new ArrayList<>(argv);
|
||||
if (parameters instanceof TestParameters && ((TestParameters) parameters).isNoTransferProgress()) {
|
||||
argv.add("-ntp");
|
||||
}
|
||||
final ExecutionResult delegate = super.execute(output, argv);
|
||||
if (output instanceof TestClientOutput) {
|
||||
return new JvmTestResult(delegate, ((TestClientOutput) output).messagesToString());
|
||||
|
@@ -41,6 +41,7 @@ import org.mvndaemon.mvnd.common.DaemonRegistry;
|
||||
import org.mvndaemon.mvnd.common.Environment;
|
||||
import org.mvndaemon.mvnd.common.TimeUtils;
|
||||
|
||||
import static org.mvndaemon.mvnd.junit.TestParameters.TEST_MIN_THREADS;
|
||||
import static org.mvndaemon.mvnd.junit.TestUtils.deleteDir;
|
||||
|
||||
public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback, AfterAllCallback {
|
||||
@@ -253,7 +254,9 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
|
||||
.multipliedBy(10),
|
||||
maxLostKeepAlive != null && !maxLostKeepAlive.isEmpty()
|
||||
? Integer.parseInt(maxLostKeepAlive)
|
||||
: Integer.parseInt(Environment.MVND_MAX_LOST_KEEP_ALIVE.getDefault()) * 10);
|
||||
: Integer.parseInt(Environment.MVND_MAX_LOST_KEEP_ALIVE.getDefault()) * 10,
|
||||
TEST_MIN_THREADS,
|
||||
true);
|
||||
final TestRegistry registry = new TestRegistry(parameters.registry());
|
||||
|
||||
return new MvndResource(parameters, registry, isNative, timeoutMs);
|
||||
|
@@ -28,6 +28,7 @@ import org.mvndaemon.mvnd.common.TimeUtils;
|
||||
public class TestParameters extends DaemonParameters {
|
||||
static final int TEST_MIN_THREADS = 2;
|
||||
private final Path testDir;
|
||||
private final boolean noTransferProgress;
|
||||
|
||||
public TestParameters(
|
||||
Path testDir,
|
||||
@@ -42,7 +43,9 @@ public class TestParameters extends DaemonParameters {
|
||||
Path logbackConfigurationPath,
|
||||
Duration idleTimeout,
|
||||
Duration keepAlive,
|
||||
int maxLostKeepAlive) {
|
||||
int maxLostKeepAlive,
|
||||
int minThreads,
|
||||
boolean noTransferProgress) {
|
||||
super(new PropertiesBuilder()
|
||||
.put(Environment.MVND_PROPERTIES_PATH, mvndPropertiesPath)
|
||||
.put(Environment.MVND_HOME, mavenHome)
|
||||
@@ -56,8 +59,9 @@ public class TestParameters extends DaemonParameters {
|
||||
.put(Environment.MVND_IDLE_TIMEOUT, TimeUtils.printDuration(idleTimeout))
|
||||
.put(Environment.MVND_KEEP_ALIVE, TimeUtils.printDuration(keepAlive))
|
||||
.put(Environment.MVND_MAX_LOST_KEEP_ALIVE, maxLostKeepAlive)
|
||||
.put(Environment.MVND_MIN_THREADS, TEST_MIN_THREADS));
|
||||
.put(Environment.MVND_MIN_THREADS, minThreads));
|
||||
this.testDir = testDir;
|
||||
this.noTransferProgress = noTransferProgress;
|
||||
}
|
||||
|
||||
public DaemonParameters clearMavenMultiModuleProjectDirectory() {
|
||||
@@ -68,7 +72,30 @@ public class TestParameters extends DaemonParameters {
|
||||
return derive(b -> b.put(Environment.MAVEN_MULTIMODULE_PROJECT_DIRECTORY, dir.toString()));
|
||||
}
|
||||
|
||||
public TestParameters withTransferProgress() {
|
||||
return new TestParameters(
|
||||
testDir,
|
||||
value(Environment.MVND_PROPERTIES_PATH).asPath(),
|
||||
value(Environment.MVND_HOME).asPath(),
|
||||
value(Environment.USER_HOME).asPath(),
|
||||
value(Environment.USER_DIR).asPath(),
|
||||
value(Environment.MAVEN_MULTIMODULE_PROJECT_DIRECTORY).asPath(),
|
||||
value(Environment.JAVA_HOME).asPath(),
|
||||
value(Environment.MAVEN_REPO_LOCAL).asPath(),
|
||||
value(Environment.MAVEN_SETTINGS).asPath(),
|
||||
value(Environment.MVND_LOGBACK).asPath(),
|
||||
value(Environment.MVND_IDLE_TIMEOUT).asDuration(),
|
||||
value(Environment.MVND_KEEP_ALIVE).asDuration(),
|
||||
value(Environment.MVND_MAX_LOST_KEEP_ALIVE).asInt(),
|
||||
value(Environment.MVND_MIN_THREADS).asInt(),
|
||||
false);
|
||||
}
|
||||
|
||||
public Path getTestDir() {
|
||||
return testDir;
|
||||
}
|
||||
|
||||
public boolean isNoTransferProgress() {
|
||||
return noTransferProgress;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user