matrixsparse commented on code in PR #708:
URL: https://github.com/apache/flink-agents/pull/708#discussion_r3331104039


##########
e2e-test/test-scripts/test_submit_examples_to_flink.sh:
##########
@@ -0,0 +1,339 @@
+#!/usr/bin/env bash
+#
+#   Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# Submits the Java/Python examples to a local Flink standalone cluster and
+# checks that the JobManager accepts each one. The examples talk to remote
+# LLM APIs, so we only verify submission, then cancel the jobs.
+#
+# Env: FLINK_VERSION (default 2.2.0), FLINK_HOME (reuse existing install),
+#      VERBOSE=1 (set -x).
+
+set -euo pipefail
+
+if [[ "${VERBOSE:-0}" == "1" ]]; then
+    set -x
+fi
+
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[0;33m'
+BLUE='\033[0;34m'
+NC='\033[0m'
+
+log_info()    { printf "${BLUE}[INFO]${NC}  %s\n"  "$*"; }
+log_ok()      { printf "${GREEN}[OK]${NC}    %s\n" "$*"; }
+log_warn()    { printf "${YELLOW}[WARN]${NC}  %s\n" "$*"; }
+log_error()   { printf "${RED}[ERROR]${NC} %s\n"   "$*" >&2; }
+log_section() {
+    printf 
"\n${BLUE}==============================================================${NC}\n"
+    printf "${BLUE}>>> %s${NC}\n" "$*"
+    printf   
"${BLUE}==============================================================${NC}\n"
+}
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+ROOT_DIR="$(cd "$SCRIPT_DIR/../.."; pwd)"
+log_info "Project root: $ROOT_DIR"
+
+FLINK_VERSION="${FLINK_VERSION:-2.2.0}"
+FLINK_MAJOR_MINOR="${FLINK_VERSION%.*}"
+SUBMIT_TIMEOUT="${SUBMIT_TIMEOUT:-180}"
+
+# Bash 3 (default on macOS) lacks associative arrays.
+RESULT_NAMES=()
+RESULT_STATES=()
+SUBMITTED_JOB_IDS=()
+
+cleanup() {
+    local exit_code=$?
+    log_section "Cleanup"
+
+    if [[ -n "${FLINK_HOME:-}" && -x "$FLINK_HOME/bin/flink" ]]; then
+        for jid in "${SUBMITTED_JOB_IDS[@]:-}"; do
+            [[ -n "$jid" ]] || continue
+            log_info "Cancelling job $jid"
+            "$FLINK_HOME/bin/flink" cancel "$jid" >/dev/null 2>&1 || true
+        done
+
+        if [[ -x "$FLINK_HOME/bin/stop-cluster.sh" ]]; then
+            log_info "Stopping Flink cluster"
+            "$FLINK_HOME/bin/stop-cluster.sh" >/dev/null 2>&1 || true
+        fi
+
+        if [[ -d "$FLINK_HOME/log" ]]; then
+            local log_archive="$ROOT_DIR/flink-logs-$(date 
+%Y%m%d-%H%M%S).tar.gz"
+            tar -czf "$log_archive" -C "$FLINK_HOME" log >/dev/null 2>&1 \
+                && log_info "Flink logs archived to: $log_archive" \
+                || log_warn "Failed to archive Flink logs"
+        fi
+    fi
+
+    print_summary
+    exit "$exit_code"
+}
+trap cleanup EXIT
+
+print_summary() {
+    log_section "Test summary"
+    local total=${#RESULT_NAMES[@]}
+    local passed=0
+    local failed=0
+    local i
+    for (( i = 0; i < total; i++ )); do
+        local name="${RESULT_NAMES[$i]}"
+        local state="${RESULT_STATES[$i]}"
+        if [[ "$state" == "PASS" ]]; then
+            printf "  ${GREEN}PASS${NC}  %s\n" "$name"
+            passed=$((passed + 1))
+        else
+            printf "  ${RED}FAIL${NC}  %s\n" "$name"
+            failed=$((failed + 1))
+        fi
+    done
+    printf "\nTotal: %d   Passed: %d   Failed: %d\n" "$total" "$passed" 
"$failed"

Review Comment:
   Fixed exactly as you suggested. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to