@@ -52,6 +52,9 @@ declare -A ENDPOINT_DESCRIPTIONS
5252# Array to store created object IDs for cleanup
5353declare -a CREATED_IDS=()
5454
55+ # Associative array to store full created objects (to avoid unnecessary GET requests)
56+ declare -A CREATED_OBJECTS
57+
5558# Report file - go up to repo root first
5659SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
5760REPO_ROOT=" $( cd " $SCRIPT_DIR /../.." && pwd) "
@@ -368,12 +371,36 @@ create_test_object() {
368371
369372 if [ -n " $obj_id " ] && [ " $obj_id " != " null" ]; then
370373 CREATED_IDS+=(" $obj_id " )
374+ # Store the full object for later use (to avoid unnecessary GET requests)
375+ CREATED_OBJECTS[" $obj_id " ]=" $response "
371376 sleep 1 # Allow DB and cache to process
372377 fi
373378
374379 echo " $obj_id "
375380}
376381
382+ # Create test object and return the full object (not just ID)
383+ create_test_object_with_body () {
384+ local data=$1
385+ local description=${2:- " Creating test object" }
386+
387+ local response=$( curl -s -X POST " ${API_BASE} /api/create" \
388+ -H " Content-Type: application/json" \
389+ -H " Authorization: Bearer ${AUTH_TOKEN} " \
390+ -d " $data " 2> /dev/null)
391+
392+ local obj_id=$( echo " $response " | jq -r ' .["@id"]' 2> /dev/null)
393+
394+ if [ -n " $obj_id " ] && [ " $obj_id " != " null" ]; then
395+ CREATED_IDS+=(" $obj_id " )
396+ CREATED_OBJECTS[" $obj_id " ]=" $response "
397+ sleep 1 # Allow DB and cache to process
398+ echo " $response "
399+ else
400+ echo " "
401+ fi
402+ }
403+
377404# ###############################################################################
378405# Functionality Tests
379406# ###############################################################################
@@ -1844,7 +1871,8 @@ test_update_endpoint_empty() {
18441871
18451872 local NUM_ITERATIONS=50
18461873
1847- local test_id=$( create_test_object ' {"type":"UpdateTest","value":"original"}' )
1874+ local test_obj=$( create_test_object_with_body ' {"type":"UpdateTest","value":"original"}' )
1875+ local test_id=$( echo " $test_obj " | jq -r ' .["@id"]' 2> /dev/null)
18481876
18491877 if [ -z " $test_id " ] || [ " $test_id " == " null" ]; then
18501878 log_failure " Failed to create test object for update test"
@@ -1857,21 +1885,24 @@ test_update_endpoint_empty() {
18571885 declare -a empty_times=()
18581886 local empty_total=0
18591887 local empty_success=0
1888+ local full_object=" $test_obj "
18601889
18611890 for i in $( seq 1 $NUM_ITERATIONS ) ; do
1862- local full_object=$( curl -s " $test_id " 2> /dev/null)
18631891 local update_body=$( echo " $full_object " | jq " . + {value: \" updated_$i \" }" 2> /dev/null)
18641892
18651893 local result=$( measure_endpoint " ${API_BASE} /api/update" " PUT" \
18661894 " $update_body " \
18671895 " Update object" true)
18681896 local time=$( echo " $result " | cut -d' |' -f1)
18691897 local code=$( echo " $result " | cut -d' |' -f2)
1898+ local response=$( echo " $result " | cut -d' |' -f3-)
18701899
18711900 if [ " $code " == " 200" ]; then
18721901 empty_times+=($time )
18731902 empty_total=$(( empty_total + time))
18741903 empty_success=$(( empty_success + 1 ))
1904+ # Update full_object with the response for next iteration
1905+ full_object=" $response "
18751906 fi
18761907
18771908 # Progress indicator
@@ -1904,7 +1935,8 @@ test_update_endpoint_full() {
19041935
19051936 local NUM_ITERATIONS=50
19061937
1907- local test_id=$( create_test_object ' {"type":"UpdateTest","value":"original"}' )
1938+ local test_obj=$( create_test_object_with_body ' {"type":"UpdateTest","value":"original"}' )
1939+ local test_id=$( echo " $test_obj " | jq -r ' .["@id"]' 2> /dev/null)
19081940
19091941 if [ -z " $test_id " ] || [ " $test_id " == " null" ]; then
19101942 log_failure " Failed to create test object for update test"
@@ -1916,21 +1948,24 @@ test_update_endpoint_full() {
19161948 declare -a full_times=()
19171949 local full_total=0
19181950 local full_success=0
1951+ local full_object=" $test_obj "
19191952
19201953 for i in $( seq 1 $NUM_ITERATIONS ) ; do
1921- local full_object=$( curl -s " $test_id " 2> /dev/null)
19221954 local update_body=$( echo " $full_object " | jq " . + {value: \" updated_full_$i \" }" 2> /dev/null)
19231955
19241956 local result=$( measure_endpoint " ${API_BASE} /api/update" " PUT" \
19251957 " $update_body " \
19261958 " Update object" true)
19271959 local time=$( echo " $result " | cut -d' |' -f1)
19281960 local code=$( echo " $result " | cut -d' |' -f2)
1961+ local response=$( echo " $result " | cut -d' |' -f3-)
19291962
19301963 if [ " $code " == " 200" ]; then
19311964 full_times+=($time )
19321965 full_total=$(( full_total + time))
19331966 full_success=$(( full_success + 1 ))
1967+ # Update full_object with the response for next iteration
1968+ full_object=" $response "
19341969 fi
19351970
19361971 # Progress indicator
0 commit comments