Skip to content

Commit 6b4e2be

Browse files
committed
test: Handle method rename and log level changes in petclinic fixture
The upstream spring-petclinic project renamed the `testOwnerDetails` test method to `ownerDetails` and changed the log level of some statements from INFO to DEBUG. Updated `petclinic-tests.bats` to support both variations by using wildcards/regex for the test method name and allowing both `info` and `debug` function names in the log label assertion. This ensures compatibility across different versions of the fixture.
1 parent 001ab6f commit 6b4e2be

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

agent/test/petclinic/petclinic-tests.bats

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ run_petclinic_test() {
4040
@test "hooked functions are ordered correctly" {
4141
run_petclinic_test
4242
assert_success
43-
run cat ./tmp/appmap/junit/org_springframework_samples_petclinic_${TEST_NAME}_testOwnerDetails.appmap.json
43+
run cat ./tmp/appmap/junit/org_springframework_samples_petclinic_${TEST_NAME}_*wnerDetails.appmap.json
4444
assert_success
4545

4646
# Find the test runner's main thread (the one with testOwnerDetails method).
4747
# Check to make sure that parent_id of the "return" event matches the id of the "call" event.
4848
# Note: In Java 21 the main thread is typically thread 1, but in Java 25 it can be thread 3.
49-
local main_thread_id=$(jq -r '[.events[] | select(.method_id == "testOwnerDetails")][0].thread_id' ./tmp/appmap/junit/org_springframework_samples_petclinic_${TEST_NAME}_testOwnerDetails.appmap.json)
49+
local main_thread_id=$(jq -r '[.events[] | select(.method_id | test("^.*wnerDetails$")?)][0].thread_id' ./tmp/appmap/junit/org_springframework_samples_petclinic_${TEST_NAME}_*wnerDetails.appmap.json)
5050
assert_json_eq ".events | map(select(.thread_id == ${main_thread_id})) | ((.[0].event == \"call\" and .[1].event == \"return\") and (.[1].parent_id == .[0].id))" "true"
5151
}
5252

@@ -62,9 +62,9 @@ run_petclinic_test() {
6262
@test "log methods are labeled" {
6363
run_petclinic_test "${TEST_NAME}" appmap-labels.yml
6464
assert_success
65-
run cat ./tmp/appmap/junit/org_springframework_samples_petclinic_${TEST_NAME}_testOwnerDetails.appmap.json
65+
run cat ./tmp/appmap/junit/org_springframework_samples_petclinic_${TEST_NAME}_*wnerDetails.appmap.json
6666

67-
assert_json_eq '.classMap[0] | recurse(.children[]?) | select(.type? == "function" and .name? == "info").labels[0]' 'log'
67+
assert_json_eq '.classMap[0] | recurse(.children[]?) | select(.type? == "function" and (.name? | IN("info", "debug"))).labels[0]' 'log'
6868
}
6969

7070
@test "test_status set for successful test" {

0 commit comments

Comments
 (0)