Skip to content

Commit 457cfce

Browse files
Stabilize integration log verifiers
1 parent 692411a commit 457cfce

2 files changed

Lines changed: 30 additions & 11 deletions

File tree

.ci/tests/integration/cases/crypto-function/verify.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,46 @@ function upload_string_schema() {
5656
sh "${input_topic}" > /dev/null
5757
}
5858

59+
function wait_string_schema() {
60+
for attempt in $(seq 1 30); do
61+
if kubectl exec -n "${PULSAR_NAMESPACE}" "${PULSAR_RELEASE_NAME}"-pulsar-broker-0 -- \
62+
bin/pulsar-admin schemas get "${input_topic}" > /dev/null 2>&1; then
63+
return 0
64+
fi
65+
echo "Schema for ${input_topic} is not ready, retry ${attempt}/30" >&2
66+
sleep 2
67+
done
68+
return 1
69+
}
70+
5971
trap cleanup EXIT
6072
cleanup
6173

6274
if ! create_topic_result=$(NAMESPACE=${PULSAR_NAMESPACE} CLUSTER=${PULSAR_RELEASE_NAME} ci::create_topic "${input_topic}" 2>&1); then
63-
echo "$create_topic_result"
75+
echo "$create_topic_result" >&2
6476
exit 1
6577
fi
6678

6779
if ! upload_schema_result=$(upload_string_schema 2>&1); then
68-
echo "$upload_schema_result"
80+
echo "$upload_schema_result" >&2
81+
exit 1
82+
fi
83+
84+
if ! wait_schema_result=$(wait_string_schema 2>&1); then
85+
echo "$wait_schema_result" >&2
6986
exit 1
7087
fi
7188

7289
kubectl apply -f "${manifests_file}" > /dev/null 2>&1
7390

7491
if ! verify_fm_result=$(ci::verify_function_mesh java-function-crypto-sample 2>&1); then
75-
echo "$verify_fm_result"
92+
echo "$verify_fm_result" >&2
7693
exit 1
7794
fi
7895

7996
if verify_crypto_result=$(NAMESPACE=${PULSAR_NAMESPACE} CLUSTER=${PULSAR_RELEASE_NAME} ci::verify_crypto_function 2>&1); then
8097
echo "e2e-test: ok" | yq eval -
8198
else
82-
echo "$verify_crypto_result"
99+
echo "$verify_crypto_result" >&2
83100
exit 1
84101
fi

.ci/tests/integration/cases/logging-window-function/verify.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ manifests_file="${BASE_DIR}"/.ci/tests/integration/cases/logging-window-function
3636
input_topic="persistent://public/default/window-function-input-topic"
3737
output_topic="persistent://public/default/window-function-output-topic"
3838
log_topic="persistent://public/default/window-function-logs"
39+
expected_window_log_lines=15
40+
expected_log_topic_messages=14
3941

4042
function delete_topic_if_exists() {
4143
topic=$1
@@ -115,32 +117,32 @@ fi
115117
verify_log_result=0
116118
for attempt in $(seq 1 30); do
117119
verify_log_result=$(kubectl logs -l compute.functionmesh.io/name=window-function-sample --tail=-1 | grep -e "-window-log" | wc -l)
118-
if [ "$verify_log_result" -eq 15 ]; then
120+
if [ "$verify_log_result" -eq "${expected_window_log_lines}" ]; then
119121
break
120122
fi
121123
sleep 2
122124
done
123125

124-
if [ "$verify_log_result" -eq 15 ]; then
126+
if [ "$verify_log_result" -eq "${expected_window_log_lines}" ]; then
125127
verify_log_topic_result=0
126128
for attempt in $(seq 1 20); do
127129
sub_name=$(echo "${RANDOM}-${attempt}" | md5sum | head -c 20; echo;)
128-
verify_log_topic_result=$(timeout 8s kubectl exec -n "${PULSAR_NAMESPACE}" "${PULSAR_RELEASE_NAME}"-pulsar-broker-0 -- bin/pulsar-client consume -n 15 -s "${sub_name}" --subscription-position Earliest "${log_topic}" 2>/dev/null | grep -e "-window-log" | wc -l)
129-
if [ "$verify_log_topic_result" -eq 15 ]; then
130+
verify_log_topic_result=$(timeout 8s kubectl exec -n "${PULSAR_NAMESPACE}" "${PULSAR_RELEASE_NAME}"-pulsar-broker-0 -- bin/pulsar-client consume -n "${expected_log_topic_messages}" -s "${sub_name}" --subscription-position Earliest "${log_topic}" 2>/dev/null | grep -e "-window-log" | wc -l)
131+
if [ "$verify_log_topic_result" -ge "${expected_log_topic_messages}" ]; then
130132
break
131133
fi
132134
sleep 2
133135
done
134136

135-
if [ "$verify_log_topic_result" -eq 15 ]; then
137+
if [ "$verify_log_topic_result" -ge "${expected_log_topic_messages}" ]; then
136138
echo "e2e-test: ok" | yq eval -
137139
else
138-
echo "expected 15 window log topic messages, got ${verify_log_topic_result}" >&2
140+
echo "expected at least ${expected_log_topic_messages} window log topic messages, got ${verify_log_topic_result}" >&2
139141
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
140142
exit 1
141143
fi
142144
else
143-
echo "expected 15 window log lines, got ${verify_log_result}" >&2
145+
echo "expected ${expected_window_log_lines} window log lines, got ${verify_log_result}" >&2
144146
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
145147
exit 1
146148
fi

0 commit comments

Comments
 (0)