Skip to content

Commit f949655

Browse files
committed
Test basic converter operation and fix missing resources
1 parent 36297ba commit f949655

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

bin/copy_java_sources.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,29 @@
1414
VERSION = RELEASE.split("-")[0]
1515
AP_SOURCE_DIR = BASEDIR / "ap-releases" / f"async-profiler-{VERSION}-code" / "src"
1616
AP_CONVERTER_SOURCE_DIR = AP_SOURCE_DIR / "converter"
17+
AP_RESOURCES_SOURCE_DIR = AP_SOURCE_DIR / "res"
1718
AP_API_SOURCE_DIR = AP_SOURCE_DIR / "api" / "one" / "profiler"
1819
TARGET_SOURCE_DIR = BASEDIR / "src" / "main" / "java"
1920
TARGET_ONE_DIR = TARGET_SOURCE_DIR / "one"
2021
TARGET_ONE_PROFILER_DIR = TARGET_ONE_DIR / "profiler"
2122
TARGET_CONVERTER_DIR = TARGET_ONE_DIR / "converter"
23+
TARGET_RESOURCES_DIR = BASEDIR / "src" / "main" / "resources"
2224

2325
assert AP_SOURCE_DIR.exists(), f"Source directory {AP_SOURCE_DIR} does not exist"
2426
assert AP_CONVERTER_SOURCE_DIR.exists(), f"Source directory {AP_CONVERTER_SOURCE_DIR} does not exist"
2527
assert AP_API_SOURCE_DIR.exists()
2628
assert TARGET_SOURCE_DIR.exists()
2729
assert TARGET_ONE_PROFILER_DIR.exists()
30+
assert AP_RESOURCES_SOURCE_DIR.exists()
2831

2932
PROJECT_FILES = ["AsyncProfilerLoader.java"]
3033

3134
DRY_RUN = False
3235

3336
os.chdir(BASEDIR)
3437

38+
os.makedirs(TARGET_RESOURCES_DIR, exist_ok=True)
39+
3540
print("Remove old files")
3641
for f in TARGET_ONE_PROFILER_DIR.glob("*"):
3742
if f.name not in PROJECT_FILES:
@@ -42,13 +47,15 @@
4247
f.rmdir()
4348
else:
4449
f.unlink()
50+
4551
for f in TARGET_ONE_DIR.glob("*"):
4652
if not f.is_dir() or f.name == "profiler":
4753
continue
4854
if DRY_RUN:
4955
print("would remove " + str(f))
5056
else:
5157
shutil.rmtree(f)
58+
5259
for f in TARGET_SOURCE_DIR.glob("*.java"):
5360
if DRY_RUN:
5461
print("would remove " + str(f))
@@ -64,6 +71,13 @@
6471
else:
6572
shutil.copy(f, target_file)
6673

74+
print("Copy converter resource files")
75+
for f in AP_RESOURCES_SOURCE_DIR.glob("*"):
76+
target_file = TARGET_RESOURCES_DIR / f.name
77+
if DRY_RUN:
78+
print(f"would copy {f} to {target_file}")
79+
else:
80+
shutil.copy(f, target_file)
6781

6882
print("Copy converter directories")
6983
for directory in AP_CONVERTER_SOURCE_DIR.glob("one/*"):

bin/releaser.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,21 @@ def test_release_basic_execution(release: str, platform: str, ignore_output=True
196196
if not agentpath.endswith(".so") or not os.path.exists(agentpath):
197197
print(f"Invalid agentpath: {agentpath}")
198198
return False
199-
profile_file = f"{TESTS_DIR}/profile.html"
200-
cmd = f"java -javaagent:{release_file}=start,file={profile_file} " \
199+
profile_file = f"{TESTS_DIR}/profile.jfr"
200+
cmd = f"java -javaagent:{release_file}=start,file={profile_file},jfr " \
201201
f"-cp {TESTS_CODE_DIR}/test ThreadsTarget"
202202
if not ignore_output:
203203
print(f"Execute {cmd}")
204204
subprocess.check_call(cmd, shell=True, cwd=CURRENT_DIR, stdout=pipe, stderr=pipe)
205205
if not os.path.exists(profile_file):
206206
return False
207+
flamegraph_file = f"{TESTS_DIR}/flamegraph.html"
208+
cmd = f"java -jar '{release_file}' converter jfr2flame {profile_file} {flamegraph_file}"
209+
if not ignore_output:
210+
print(f"Execute {cmd}")
211+
subprocess.check_call(cmd, shell=True, cwd=CURRENT_DIR, stdout=pipe, stderr=pipe)
212+
if not os.path.exists(flamegraph_file):
213+
return False
207214
return True
208215
except subprocess.CalledProcessError:
209216
return False

0 commit comments

Comments
 (0)