Skip to content

Commit 7bade8e

Browse files
committed
1 parent 388b848 commit 7bade8e

2 files changed

Lines changed: 72 additions & 2 deletions

File tree

modules/control-utility/src/test/java/org/apache/ignite/util/RollingUpgradeCommandTest.java

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717

1818
package org.apache.ignite.util;
1919

20+
import java.io.IOException;
21+
import java.nio.file.Files;
22+
import java.nio.file.Path;
23+
import java.nio.file.Paths;
24+
import java.nio.file.StandardCopyOption;
25+
import jdk.jfr.Recording;
2026
import org.apache.ignite.internal.management.rollingupgrade.RollingUpgradeCommand;
2127
import org.apache.ignite.internal.management.rollingupgrade.RollingUpgradeTaskResult;
2228
import org.apache.ignite.lang.IgniteProductVersion;
@@ -30,6 +36,9 @@ public class RollingUpgradeCommandTest extends GridCommandHandlerClusterByClassA
3036
/** */
3137
public static final String ENABLE = "enable";
3238

39+
/** Recording. */
40+
private Recording recording;
41+
3342
/** */
3443
public static final String DISABLE = "disable";
3544

@@ -42,7 +51,6 @@ public class RollingUpgradeCommandTest extends GridCommandHandlerClusterByClassA
4251
/** {@inheritDoc} */
4352
@Override protected void beforeTestsStarted() throws Exception {
4453
super.beforeTestsStarted();
45-
4654
autoConfirmation = true;
4755
}
4856

@@ -56,7 +64,11 @@ public class RollingUpgradeCommandTest extends GridCommandHandlerClusterByClassA
5664

5765
/** */
5866
@Test
59-
public void testEnableAndDisable() {
67+
public void testEnableAndDisable() throws IOException {
68+
recording = new Recording();
69+
recording.setName("ignite-jfr");
70+
recording.start();
71+
6072
IgniteProductVersion curVer = IgniteProductVersion.fromString(crd.localNode().attribute(ATTR_BUILD_VER));
6173

6274
String targetVerStr = curVer.major() + "." + (curVer.minor() + 1) + ".0";
@@ -85,6 +97,25 @@ public void testEnableAndDisable() {
8597
assertNull(taskRes.targetVersion());
8698

8799
assertFalse(crd.context().rollingUpgrade().enabled());
100+
101+
Path jfrDir = Paths.get("target", "jfr");
102+
Files.createDirectories(jfrDir);
103+
104+
String fileName = "ignite-jfr-" + System.currentTimeMillis() + ".jfr";
105+
Path jfrFile = jfrDir.resolve(fileName);
106+
107+
recording.stop();
108+
recording.dump(jfrFile);
109+
System.out.println("✅ JFR saved to: " + jfrFile.toAbsolutePath());
110+
111+
Path root = findIgniteRoot();
112+
Path workLog = root.resolve("work/log");
113+
Files.createDirectories(workLog);
114+
115+
Path jfrInArtifacts = workLog.resolve("ignite.jfr");
116+
Files.copy(jfrFile, jfrInArtifacts, StandardCopyOption.REPLACE_EXISTING);
117+
118+
System.out.println("📦 Saved JFR to: " + jfrInArtifacts.toAbsolutePath());
88119
}
89120

90121
/** */
@@ -177,4 +208,24 @@ public void testForceEnable() {
177208

178209
assertTrue(crd.context().rollingUpgrade().enabled());
179210
}
211+
212+
private static Path findIgniteRoot() throws IOException {
213+
Path p = Paths.get("").toAbsolutePath();
214+
215+
while (p != null) {
216+
Path pom = p.resolve("pom.xml");
217+
if (pom.toFile().exists()) {
218+
String content = Files.readString(pom);
219+
// родительский pom содержит секцию <modules>
220+
if (content.contains("<modules>"))
221+
return p;
222+
}
223+
224+
p = p.getParent();
225+
}
226+
227+
throw new IllegalStateException("Ignite root not found");
228+
}
229+
230+
180231
}

parent/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,25 @@
891891
</build>
892892
</profile>
893893

894+
<profile>
895+
<id>jfr</id>
896+
<activation>
897+
<property>
898+
<name>JFR</name>
899+
</property>
900+
</activation>
901+
<build>
902+
<plugins>
903+
<plugin>
904+
<artifactId>maven-surefire-plugin</artifactId>
905+
<configuration>
906+
<argLine>@{argLine} -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:StartFlightRecording=duration=1000s,filename=surefire.jfr</argLine>
907+
</configuration>
908+
</plugin>
909+
</plugins>
910+
</build>
911+
</profile>
912+
894913
<profile>
895914
<id>surefire-fork-count-1</id>
896915
<activation>

0 commit comments

Comments
 (0)