@@ -42,107 +42,49 @@ verify:
4242 cases :
4343 # create profiling task for Go service
4444 - query : |
45- echo "=== Creating profiling task ===" >&2
4645 swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql \
4746 profiling trace create --service-name=go-service \
4847 --endpoint-name=GET:/profile \
4948 --start-time=-1 \
5049 --duration=1 --min-duration-threshold=1000 \
5150 --dump-period=500 --max-sampling-count=3
52- echo "=== Profiling task created ===" >&2
5351 expected: expected/profile-create.yml
5452
55- # profiling list notified
56- - query : |
57- echo "=== Checking profiling list (NOTIFIED) ===" >&2
58- sleep 3
59- result=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace list -service-name=go-service --endpoint-name=GET:/profile)
60- echo "Profiling list result: $result" >&2
61- echo "$result"
53+ # profiling list notified: sleep to wait agent notices and query profiling list
54+ - query : sleep 3 && swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace list -service-name=go-service --endpoint-name=GET:/profile
6255 expected : expected/profile-list-notified.yml
6356
6457
6558 # profiling list finished
6659 - query : |
67- echo "=== Sending requests and checking profiling list (FINISHED) ===" >&2
68- go_host=$(printenv go-service_host || printenv go_service_host)
69- go_port=$(printenv go-service_8080 || printenv go_service_8080)
70- curl -s -XGET "http://$go_host:$go_port/profile"
71- sleep 120
72- result=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace list -service-name=go-service --endpoint-name=GET:/profile)
73- echo "Profiling list result: $result" >&2
74- echo "$result"
60+ curl -s -XGET http://${go-service_host}:${go-service_8080}/profile > /dev/null;
61+ sleep 10;
62+ swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace list -service-name=go-service --endpoint-name=GET:/profile
7563 expected: expected/profile-list-finished.yml
7664
7765 # profiled segment list
7866 - query : |
79- echo "=== Getting profiled segment list ===" >&2
80- sleep 30
81- task_id=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace list -service-name=go-service --endpoint-name=GET:/profile | yq e '.[0].id' -)
82- echo "Task ID: $task_id" >&2
83- if [ -z "$task_id" ]; then
84- echo "ERROR: Task ID is empty!" >&2
85- exit 1
86- fi
87-
88- for attempt in {1..5}; do
89- echo "Attempt $attempt to get segments..." >&2
90- result=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace segment-list --task-id=$task_id)
91- echo "Segment list result (attempt $attempt): $result" >&2
92- if [ "$result" != "[]" ] && [ "$result" != "" ]; then
93- echo "Found segments on attempt $attempt!" >&2
94- echo "$result"
95- exit 0
96- fi
97- if [ $attempt -lt 5 ]; then
98- echo "No segments found, waiting 10 seconds before retry..." >&2
99- sleep 10
100- fi
101- done
102- echo "ERROR: No segments found after 5 attempts!" >&2
103- echo "$result"
67+ swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace segment-list --task-id=$( \
68+ swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace list -service-name=go-service --endpoint-name=GET:/profile | yq e '.[0].id' - \
69+ )
10470 expected: expected/profile-segment-list.yml
10571
10672 # query profiled segment analyze
10773 - query : |
108- echo "=== Analyzing profiled segment ===" >&2
109- sleep 5
110- task_id=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace list -service-name=go-service --endpoint-name=GET:/profile | yq e '.[0].id' -)
111- echo "Task ID: $task_id" >&2
112- if [ -z "$task_id" ]; then
113- echo "ERROR: Task ID is empty!" >&2
114- exit 1
115- fi
116-
117- segment_result=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace segment-list --task-id=$task_id)
118- echo "Segment list result: $segment_result" >&2
119-
120- segmentid=$(echo "$segment_result" | yq e '.[0].spans.[] | select(.spanid == 0) | .segmentid' -)
121- echo "Segment ID: $segmentid" >&2
122- if [ -z "$segmentid" ]; then
123- echo "ERROR: Segment ID is empty!" >&2
124- exit 1
125- fi
126-
127- start=$(echo "$segment_result" | yq e '.[0].spans.[] | select(.spanid == 0) | .starttime' -)
128- echo "Start time: $start" >&2
129- if [ -z "$start" ]; then
130- echo "ERROR: Start time is empty!" >&2
131- exit 1
132- fi
133-
134- end=$(echo "$segment_result" | yq e '.[0].spans.[] | select(.spanid == 0) | .endtime' -)
135- echo "End time: $end" >&2
136- if [ -z "$end" ]; then
137- echo "ERROR: End time is empty!" >&2
138- exit 1
139- fi
140-
141- time_range=$(echo $start"-"$end)
142- echo "Time range: $time_range" >&2
143-
144- echo "Running analysis with segment-id=$segmentid and time-ranges=$time_range" >&2
145- result=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace analysis --segment-ids=$segmentid --time-ranges=$time_range)
146- echo "Analysis result: $result" >&2
147- echo "$result"
74+ segmentid=$( \
75+ swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace segment-list --task-id=$( \
76+ swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace list -service-name=go-service --endpoint-name=GET:/profile | yq e '.[0].id' - \
77+ ) | yq e '.[0].spans.[] | select(.spanid == 0) | .segmentid' - \
78+ );
79+ start=$(
80+ swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace segment-list --task-id=$( \
81+ swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace list -service-name=go-service --endpoint-name=GET:/profile | yq e '.[0].id' - \
82+ ) | yq e '.[0].spans.[] | select(.spanid == 0) | .starttime' - \
83+ );
84+ end=$(
85+ swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace segment-list --task-id=$( \
86+ swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace list -service-name=go-service --endpoint-name=GET:/profile | yq e '.[0].id' - \
87+ ) | yq e '.[0].spans.[] | select(.spanid == 0) | .endtime' - \
88+ );
89+ swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling trace analysis --segment-ids=$segmentid --time-ranges=$(echo $start"-"$end)
14890 expected: expected/profile-segment-analyze.yml
0 commit comments