Skip to content

Commit 58dea98

Browse files
authored
Upgrade Mimir (#11274)
And collect more information, and we seems loose some information in case of IT failures. Changes: * upgrade to Mimir 0.10.0 * GH action collects IT failsafe outputs as well (as I sus we have something on stdout or stderr) * centrally manage Toolbox and Mimir versions * make Maven 3 tests use Mimir as well (by doing UW or PW setup for it); so far those did not use Mimir, but went directly to Central instead * in maven-executor and maven-cli test disable prefix RRF (for now)
1 parent e51666b commit 58dea98

File tree

10 files changed

+128
-41
lines changed

10 files changed

+128
-41
lines changed

.github/workflows/maven.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ concurrency:
3232
permissions: {}
3333

3434
env:
35-
MIMIR_VERSION: 0.9.4
35+
MIMIR_VERSION: 0.10.0
3636
MIMIR_BASEDIR: ~/.mimir
3737
MIMIR_LOCAL: ~/.mimir/local
3838
MAVEN_OPTS: -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./target/java_heapdump.hprof
@@ -286,5 +286,7 @@ jobs:
286286
with:
287287
name: ${{ github.run_number }}-integration-test-artifact-${{ runner.os }}-${{ matrix.java }}
288288
path: |
289-
./its/core-it-suite/target/test-classes/
289+
**/target/surefire-reports/*
290+
**/target/failsafe-reports/*
291+
./its/core-it-suite/target/test-classes/**
290292
**/target/java_heapdump.hprof

api/maven-api-cli/src/main/java/org/apache/maven/api/cli/InvokerException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static final class ExitException extends InvokerException {
5858
private final int exitCode;
5959

6060
public ExitException(int exitCode) {
61-
super("EXIT");
61+
super("EXIT=" + exitCode);
6262
this.exitCode = exitCode;
6363
}
6464

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.cling.invoker.mvn;
20+
21+
public final class Environment {
22+
private Environment() {}
23+
24+
public static final String TOOLBOX_VERSION = System.getProperty("version.toolbox", "UNSET version.toolbox");
25+
26+
public static final String MIMIR_VERSION = System.getProperty("version.mimir", "UNSET version.mimir");
27+
}

impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTest.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ void defaultFs(
6666
invoke(cwd, userHome, List.of("verify"), List.of());
6767
}
6868

69+
@Disabled("Enable it when fully moved to NIO2 with Path/Filesystem (ie MavenExecutionRequest)")
70+
@Test
71+
void jimFs() throws Exception {
72+
try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
73+
invoke(fs.getPath("/cwd"), fs.getPath("/home"), List.of("verify"), List.of());
74+
}
75+
}
76+
6977
/**
7078
* Same source (user or project extensions.xml) must not contain same GA with different V.
7179
*/
@@ -214,20 +222,11 @@ void conflictingSettings(
214222
Map<String, String> logs = invoke(
215223
cwd,
216224
userHome,
217-
List.of("eu.maveniverse.maven.plugins:toolbox:" + System.getProperty("version.toolbox") + ":help"),
225+
List.of("eu.maveniverse.maven.plugins:toolbox:" + Environment.TOOLBOX_VERSION + ":help"),
218226
List.of("--force-interactive"));
219227

220-
String log =
221-
logs.get("eu.maveniverse.maven.plugins:toolbox:" + System.getProperty("version.toolbox") + ":help");
228+
String log = logs.get("eu.maveniverse.maven.plugins:toolbox:" + Environment.TOOLBOX_VERSION + ":help");
222229
assertTrue(log.contains("https://repo1.maven.org/maven2"), log);
223230
assertFalse(log.contains("https://repo.maven.apache.org/maven2"), log);
224231
}
225-
226-
@Disabled("Until we move off fully from File")
227-
@Test
228-
void jimFs() throws Exception {
229-
try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
230-
invoke(fs.getPath("/cwd"), fs.getPath("/home"), List.of("verify"), List.of());
231-
}
232-
}
233232
}

impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/MavenInvokerTestSupport.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import eu.maveniverse.maven.mimir.testing.MimirInfuser;
3232
import org.apache.maven.api.cli.Invoker;
33+
import org.apache.maven.api.cli.InvokerException;
3334
import org.apache.maven.api.cli.Parser;
3435
import org.apache.maven.api.cli.ParserRequest;
3536
import org.apache.maven.jline.JLineMessageBuilderFactory;
@@ -97,7 +98,9 @@ protected Map<String, String> invoke(Path cwd, Path userHome, Collection<String>
9798
Files.createDirectories(appJava.getParent());
9899
Files.writeString(appJava, APP_JAVA_STRING);
99100

100-
MimirInfuser.infuseUW(userHome);
101+
if (MimirInfuser.isMimirPresentUW()) {
102+
MimirInfuser.doInfuseUW(Environment.MIMIR_VERSION, userHome);
103+
}
101104

102105
HashMap<String, String> logs = new HashMap<>();
103106
Parser parser = createParser();
@@ -107,6 +110,7 @@ protected Map<String, String> invoke(Path cwd, Path userHome, Collection<String>
107110
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
108111
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
109112
List<String> mvnArgs = new ArrayList<>(args);
113+
mvnArgs.add("-Daether.remoteRepositoryFilter.prefixes=false");
110114
mvnArgs.add(goal);
111115
int exitCode = -1;
112116
Exception exception = null;
@@ -119,6 +123,9 @@ protected Map<String, String> invoke(Path cwd, Path userHome, Collection<String>
119123
.stdErr(stderr)
120124
.embedded(true)
121125
.build()));
126+
} catch (InvokerException.ExitException e) {
127+
exitCode = e.getExitCode();
128+
exception = e;
122129
} catch (Exception e) {
123130
exception = e;
124131
}

impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/resident/ResidentMavenInvokerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void defaultFs(
6161
invoke(cwd, userHome, List.of("verify"), List.of());
6262
}
6363

64-
@Disabled("Until we move off fully from File")
64+
@Disabled("Enable it when fully moved to NIO2 with Path/Filesystem (ie MavenExecutionRequest)")
6565
@Test
6666
void jimFs() throws Exception {
6767
try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.cling.executor;
20+
21+
public final class Environment {
22+
private Environment() {}
23+
24+
public static final String TOOLBOX_VERSION = System.getProperty("version.toolbox", "UNSET version.toolbox");
25+
26+
public static final String MIMIR_VERSION = System.getProperty("version.mimir", "UNSET version.mimir");
27+
}

impl/maven-executor/src/test/java/org/apache/maven/cling/executor/MavenExecutorTestSupport.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.apache.maven.api.annotations.Nullable;
3131
import org.apache.maven.api.cli.Executor;
3232
import org.apache.maven.api.cli.ExecutorRequest;
33-
import org.apache.maven.cling.executor.impl.ToolboxToolTest;
3433
import org.junit.jupiter.api.AfterAll;
3534
import org.junit.jupiter.api.BeforeEach;
3635
import org.junit.jupiter.api.Test;
@@ -112,8 +111,7 @@ void dump3() throws Exception {
112111
List.of(mvn3ExecutorRequestBuilder()
113112
.cwd(cwd)
114113
.userHomeDirectory(userHome)
115-
.argument(
116-
"eu.maveniverse.maven.plugins:toolbox:" + ToolboxToolTest.TOOLBOX_VERSION + ":gav-dump")
114+
.argument("eu.maveniverse.maven.plugins:toolbox:" + Environment.TOOLBOX_VERSION + ":gav-dump")
117115
.argument("-l")
118116
.argument(logfile)
119117
.build()));
@@ -128,8 +126,7 @@ void dump4() throws Exception {
128126
List.of(mvn4ExecutorRequestBuilder()
129127
.cwd(cwd)
130128
.userHomeDirectory(userHome)
131-
.argument(
132-
"eu.maveniverse.maven.plugins:toolbox:" + ToolboxToolTest.TOOLBOX_VERSION + ":gav-dump")
129+
.argument("eu.maveniverse.maven.plugins:toolbox:" + Environment.TOOLBOX_VERSION + ":gav-dump")
133130
.argument("-l")
134131
.argument(logfile)
135132
.build()));
@@ -338,10 +335,13 @@ public static void main(String... args) {
338335

339336
protected void execute(@Nullable Path logFile, Collection<ExecutorRequest> requests) throws Exception {
340337
Executor invoker = createAndMemoizeExecutor();
341-
String mavenVersion = invoker.mavenVersion(requests.iterator().next());
342338
for (ExecutorRequest request : requests) {
343-
if (mavenVersion.startsWith("4.")) {
344-
MimirInfuser.infuseUW(request.userHomeDirectory());
339+
if (MimirInfuser.isMimirPresentUW()) {
340+
if (maven3Home().equals(request.installationDirectory())) {
341+
MimirInfuser.doInfusePW(Environment.MIMIR_VERSION, request.cwd(), request.userHomeDirectory());
342+
} else if (maven4Home().equals(request.installationDirectory())) {
343+
MimirInfuser.doInfuseUW(Environment.MIMIR_VERSION, request.userHomeDirectory());
344+
}
345345
}
346346
int exitCode = invoker.execute(request);
347347
if (exitCode != 0) {
@@ -355,15 +355,24 @@ protected String mavenVersion(ExecutorRequest request) throws Exception {
355355
}
356356

357357
public ExecutorRequest.Builder mvn3ExecutorRequestBuilder() {
358-
return customize(ExecutorRequest.mavenBuilder(Paths.get(System.getProperty("maven3home"))));
358+
return customize(ExecutorRequest.mavenBuilder(maven3Home()));
359+
}
360+
361+
private Path maven3Home() {
362+
return ExecutorRequest.getCanonicalPath(Paths.get(System.getProperty("maven3home")));
359363
}
360364

361365
public ExecutorRequest.Builder mvn4ExecutorRequestBuilder() {
362-
return customize(ExecutorRequest.mavenBuilder(Paths.get(System.getProperty("maven4home"))));
366+
return customize(ExecutorRequest.mavenBuilder(maven4Home()));
367+
}
368+
369+
private Path maven4Home() {
370+
return ExecutorRequest.getCanonicalPath(Paths.get(System.getProperty("maven4home")));
363371
}
364372

365373
private ExecutorRequest.Builder customize(ExecutorRequest.Builder builder) {
366-
builder = builder.cwd(cwd).userHomeDirectory(userHome);
374+
builder =
375+
builder.cwd(cwd).userHomeDirectory(userHome).argument("-Daether.remoteRepositoryFilter.prefixes=false");
367376
if (System.getProperty("localRepository") != null) {
368377
builder.argument("-Dmaven.repo.local.tail=" + System.getProperty("localRepository"));
369378
}

impl/maven-executor/src/test/java/org/apache/maven/cling/executor/impl/ToolboxToolTest.java

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import eu.maveniverse.maven.mimir.testing.MimirInfuser;
2828
import org.apache.maven.api.cli.Executor;
2929
import org.apache.maven.api.cli.ExecutorRequest;
30+
import org.apache.maven.cling.executor.Environment;
3031
import org.apache.maven.cling.executor.ExecutorHelper;
3132
import org.apache.maven.cling.executor.embedded.EmbeddedMavenExecutor;
3233
import org.apache.maven.cling.executor.forked.ForkedMavenExecutor;
@@ -48,24 +49,33 @@ public class ToolboxToolTest {
4849
private static final Executor EMBEDDED_MAVEN_EXECUTOR = new EmbeddedMavenExecutor();
4950
private static final Executor FORKED_MAVEN_EXECUTOR = new ForkedMavenExecutor();
5051

51-
public static final String TOOLBOX_VERSION = System.getProperty("version.toolbox");
52-
5352
@TempDir(cleanup = CleanupMode.NEVER)
5453
private static Path tempDir;
5554

5655
private Path userHome;
56+
private Path cwd;
5757

5858
@BeforeEach
5959
void beforeEach(TestInfo testInfo) throws Exception {
60-
userHome = tempDir.resolve(testInfo.getTestMethod().orElseThrow().getName());
61-
Files.createDirectories(userHome);
62-
MimirInfuser.infuseUW(userHome);
60+
String testName = testInfo.getTestMethod().orElseThrow().getName();
61+
userHome = tempDir.resolve(testName);
62+
cwd = userHome.resolve("cwd");
63+
Files.createDirectories(cwd);
64+
65+
if (MimirInfuser.isMimirPresentUW()) {
66+
if (testName.contains("3")) {
67+
MimirInfuser.doInfusePW(Environment.MIMIR_VERSION, cwd, userHome);
68+
} else {
69+
MimirInfuser.doInfuseUW(Environment.MIMIR_VERSION, userHome);
70+
}
71+
}
6372

6473
System.out.println("=== " + testInfo.getTestMethod().orElseThrow().getName());
6574
}
6675

6776
private ExecutorRequest.Builder getExecutorRequest(ExecutorHelper helper) {
68-
ExecutorRequest.Builder builder = helper.executorRequest();
77+
ExecutorRequest.Builder builder =
78+
helper.executorRequest().cwd(cwd).argument("-Daether.remoteRepositoryFilter.prefixes=false");
6979
if (System.getProperty("localRepository") != null) {
7080
builder.argument("-Dmaven.repo.local.tail=" + System.getProperty("localRepository"));
7181
}
@@ -77,7 +87,8 @@ private ExecutorRequest.Builder getExecutorRequest(ExecutorHelper helper) {
7787
void dump3(ExecutorHelper.Mode mode) throws Exception {
7888
ExecutorHelper helper =
7989
new HelperImpl(mode, mvn3Home(), userHome, EMBEDDED_MAVEN_EXECUTOR, FORKED_MAVEN_EXECUTOR);
80-
Map<String, String> dump = new ToolboxTool(helper, TOOLBOX_VERSION).dump(getExecutorRequest(helper));
90+
Map<String, String> dump =
91+
new ToolboxTool(helper, Environment.TOOLBOX_VERSION).dump(getExecutorRequest(helper));
8192
System.out.println(mode.name() + ": " + dump.toString());
8293
assertEquals(System.getProperty("maven3version"), dump.get("maven.version"));
8394
}
@@ -87,7 +98,8 @@ void dump3(ExecutorHelper.Mode mode) throws Exception {
8798
void dump4(ExecutorHelper.Mode mode) throws Exception {
8899
ExecutorHelper helper =
89100
new HelperImpl(mode, mvn4Home(), userHome, EMBEDDED_MAVEN_EXECUTOR, FORKED_MAVEN_EXECUTOR);
90-
Map<String, String> dump = new ToolboxTool(helper, TOOLBOX_VERSION).dump(getExecutorRequest(helper));
101+
Map<String, String> dump =
102+
new ToolboxTool(helper, Environment.TOOLBOX_VERSION).dump(getExecutorRequest(helper));
91103
System.out.println(mode.name() + ": " + dump.toString());
92104
assertEquals(System.getProperty("maven4version"), dump.get("maven.version"));
93105
}
@@ -115,7 +127,8 @@ void version4(ExecutorHelper.Mode mode) {
115127
void localRepository3(ExecutorHelper.Mode mode) {
116128
ExecutorHelper helper =
117129
new HelperImpl(mode, mvn3Home(), userHome, EMBEDDED_MAVEN_EXECUTOR, FORKED_MAVEN_EXECUTOR);
118-
String localRepository = new ToolboxTool(helper, TOOLBOX_VERSION).localRepository(getExecutorRequest(helper));
130+
String localRepository =
131+
new ToolboxTool(helper, Environment.TOOLBOX_VERSION).localRepository(getExecutorRequest(helper));
119132
System.out.println(mode.name() + ": " + localRepository);
120133
Path local = Paths.get(localRepository);
121134
assertTrue(Files.isDirectory(local));
@@ -126,7 +139,8 @@ void localRepository3(ExecutorHelper.Mode mode) {
126139
void localRepository4(ExecutorHelper.Mode mode) {
127140
ExecutorHelper helper =
128141
new HelperImpl(mode, mvn4Home(), userHome, EMBEDDED_MAVEN_EXECUTOR, FORKED_MAVEN_EXECUTOR);
129-
String localRepository = new ToolboxTool(helper, TOOLBOX_VERSION).localRepository(getExecutorRequest(helper));
142+
String localRepository =
143+
new ToolboxTool(helper, Environment.TOOLBOX_VERSION).localRepository(getExecutorRequest(helper));
130144
System.out.println(mode.name() + ": " + localRepository);
131145
Path local = Paths.get(localRepository);
132146
assertTrue(Files.isDirectory(local));
@@ -137,7 +151,7 @@ void localRepository4(ExecutorHelper.Mode mode) {
137151
void artifactPath3(ExecutorHelper.Mode mode) {
138152
ExecutorHelper helper =
139153
new HelperImpl(mode, mvn3Home(), userHome, EMBEDDED_MAVEN_EXECUTOR, FORKED_MAVEN_EXECUTOR);
140-
String path = new ToolboxTool(helper, TOOLBOX_VERSION)
154+
String path = new ToolboxTool(helper, Environment.TOOLBOX_VERSION)
141155
.artifactPath(getExecutorRequest(helper), "aopalliance:aopalliance:1.0", "central");
142156
System.out.println(mode.name() + ": " + path);
143157
// split repository: assert "ends with" as split may introduce prefixes
@@ -152,7 +166,7 @@ void artifactPath3(ExecutorHelper.Mode mode) {
152166
void artifactPath4(ExecutorHelper.Mode mode) {
153167
ExecutorHelper helper =
154168
new HelperImpl(mode, mvn4Home(), userHome, EMBEDDED_MAVEN_EXECUTOR, FORKED_MAVEN_EXECUTOR);
155-
String path = new ToolboxTool(helper, TOOLBOX_VERSION)
169+
String path = new ToolboxTool(helper, Environment.TOOLBOX_VERSION)
156170
.artifactPath(getExecutorRequest(helper), "aopalliance:aopalliance:1.0", "central");
157171
System.out.println(mode.name() + ": " + path);
158172
// split repository: assert "ends with" as split may introduce prefixes
@@ -167,7 +181,7 @@ void artifactPath4(ExecutorHelper.Mode mode) {
167181
void metadataPath3(ExecutorHelper.Mode mode) {
168182
ExecutorHelper helper =
169183
new HelperImpl(mode, mvn4Home(), userHome, EMBEDDED_MAVEN_EXECUTOR, FORKED_MAVEN_EXECUTOR);
170-
String path = new ToolboxTool(helper, TOOLBOX_VERSION)
184+
String path = new ToolboxTool(helper, Environment.TOOLBOX_VERSION)
171185
.metadataPath(getExecutorRequest(helper), "aopalliance", "someremote");
172186
System.out.println(mode.name() + ": " + path);
173187
// split repository: assert "ends with" as split may introduce prefixes
@@ -179,7 +193,7 @@ void metadataPath3(ExecutorHelper.Mode mode) {
179193
void metadataPath4(ExecutorHelper.Mode mode) {
180194
ExecutorHelper helper =
181195
new HelperImpl(mode, mvn4Home(), userHome, EMBEDDED_MAVEN_EXECUTOR, FORKED_MAVEN_EXECUTOR);
182-
String path = new ToolboxTool(helper, TOOLBOX_VERSION)
196+
String path = new ToolboxTool(helper, Environment.TOOLBOX_VERSION)
183197
.metadataPath(getExecutorRequest(helper), "aopalliance", "someremote");
184198
System.out.println(mode.name() + ": " + path);
185199
// split repository: assert "ends with" as split may introduce prefixes

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ under the License.
695695
<argLine>-Xmx256m @{jacocoArgLine}</argLine>
696696
<systemPropertyVariables combine.children="append">
697697
<version.toolbox>${toolboxVersion}</version.toolbox>
698+
<version.mimir>${env.MIMIR_VERSION}</version.mimir>
698699
</systemPropertyVariables>
699700
</configuration>
700701
</plugin>
@@ -706,6 +707,7 @@ under the License.
706707
<argLine>-Xmx256m @{jacocoArgLine}</argLine>
707708
<systemPropertyVariables combine.children="append">
708709
<version.toolbox>${toolboxVersion}</version.toolbox>
710+
<version.mimir>${env.MIMIR_VERSION}</version.mimir>
709711
</systemPropertyVariables>
710712
</configuration>
711713
</plugin>

0 commit comments

Comments
 (0)