This is an automated email from the ASF dual-hosted git repository. xtsong pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/flink-agents.git
commit a6999826ae6b2695176ae78e08f9a3fb17f06e90 Author: Marcelo Colomer <[email protected]> AuthorDate: Sat Oct 25 21:15:31 2025 +0800 [hotfix] Improve e2e test robustness --- .../test-scripts/test_agent_plan_compatibility.sh | 7 +- .../test-scripts/test_java_config_in_python.sh | 7 +- tools/e2e.sh | 100 +++++++++++++++++++-- 3 files changed, 105 insertions(+), 9 deletions(-) diff --git a/e2e-test/test-scripts/test_agent_plan_compatibility.sh b/e2e-test/test-scripts/test_agent_plan_compatibility.sh index 59dc1d0..457e57b 100644 --- a/e2e-test/test-scripts/test_agent_plan_compatibility.sh +++ b/e2e-test/test-scripts/test_agent_plan_compatibility.sh @@ -19,6 +19,11 @@ root_dir=$(pwd) +# If we're running from the python subdirectory, adjust the root_dir +if [[ "$(basename "$root_dir")" == "python" ]]; then + root_dir=$(dirname "$root_dir") +fi + echo $root_dir tempdir=$1 @@ -69,4 +74,4 @@ function test_create_python_agent_from_java_agent_json { } test_create_java_agent_from_python_agent_json -test_create_python_agent_from_java_agent_json \ No newline at end of file +test_create_python_agent_from_java_agent_json diff --git a/e2e-test/test-scripts/test_java_config_in_python.sh b/e2e-test/test-scripts/test_java_config_in_python.sh index 5302283..c0ebff9 100644 --- a/e2e-test/test-scripts/test_java_config_in_python.sh +++ b/e2e-test/test-scripts/test_java_config_in_python.sh @@ -19,6 +19,11 @@ root_dir=$(pwd) +# If we're running from the python subdirectory, adjust the root_dir +if [[ "$(basename "$root_dir")" == "python" ]]; then + root_dir=$(dirname "$root_dir") +fi + echo $root_dir python_script_path=$root_dir/python/flink_agents/plan/tests/compatibility @@ -37,4 +42,4 @@ function test_create_python_option_from_java_option { rm -f $json_path } -test_create_python_option_from_java_option \ No newline at end of file +test_create_python_option_from_java_option diff --git a/tools/e2e.sh b/tools/e2e.sh index 1a15cfb..939d4bc 100755 --- a/tools/e2e.sh +++ b/tools/e2e.sh @@ -35,26 +35,112 @@ function run_test { fi } -if [[ ! -d "e2e-test/target" || ! -d "python/.venv" ]]; then +function run_python_test { + local test_script="$1" + shift + local args=("$@") + + if [[ ! -d "$python_dir" ]]; then + echo "Error: Python directory '$python_dir' does not exist. Skipping test." + return 1 + fi + + cd "$python_dir" && uv run bash "$test_script" "${args[@]}" +} + +function run_agent_plan_compatibility_test { + if [[ ! -d "$python_dir" ]]; then + echo "Error: Python directory '$python_dir' does not exist. Skipping test." + return 1 + fi + + cd "$python_dir" && uv run bash ../e2e-test/test-scripts/test_agent_plan_compatibility.sh "$tempdir" "$jar_path" +} + +function run_cross_language_config_test { + if [[ ! -d "$python_dir" ]]; then + echo "Error: Python directory '$python_dir' does not exist. Skipping test." + return 1 + fi + + cd "$python_dir" && uv run bash ../e2e-test/test-scripts/test_java_config_in_python.sh +} + +if [[ ! -d "e2e-test/target" ]]; then echo "Build flink-agents before run e2e tests." bash tools/build.sh fi -source python/.venv/bin/activate +# Ensure Python environment is properly set up with uv +if [[ ! -d "python" ]]; then + echo "Error: Python directory does not exist. Please ensure the project structure is correct." + exit 1 +fi + +cd python +if [[ ! -f "uv.lock" ]]; then + echo "Python dependencies not installed. Running build.sh..." + cd .. + bash tools/build.sh + if [[ ! -d "python" ]]; then + echo "Error: Python directory still does not exist after build. Exiting." + exit 1 + fi + cd python +fi + +# Sync dependencies and ensure flink_agents is installed in editable mode +uv sync --extra dev +uv pip install -e . +cd .. export TOTAL=0 export PASSED=0 -tempdir=$(mktemp -d) +# Create temporary directory with better cross-platform compatibility +if command -v mktemp >/dev/null 2>&1; then + tempdir=$(mktemp -d) +else + # Fallback for systems without mktemp + tempdir="/tmp/flink_agents_e2e_$$_$(date +%s)" + mkdir -p "$tempdir" +fi echo "tmpdir:$tempdir" -jar_path=e2e-test/agent-plan-compatibility-test/target/flink-agents*.jar -run_test "Agent plan compatibility end-to-end test" "bash e2e-test/test-scripts/test_agent_plan_compatibility.sh $tempdir $jar_path" -run_test "Cross-Language Config Option end-to-end test" "bash e2e-test/test-scripts/test_java_config_in_python.sh" +# Get absolute paths to avoid relative path issues +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +project_root="$(cd "$script_dir/.." && pwd)" + +# Find jar file more robustly +jar_files=("$project_root"/e2e-test/agent-plan-compatibility-test/target/flink-agents-agent-plan-compatibility-tests-*.jar) +if [[ ${#jar_files[@]} -eq 0 ]] || [[ ! -f "${jar_files[0]}" ]]; then + echo "Error: Could not find jar file in e2e-test/agent-plan-compatibility-test/target/" + exit 1 +fi +jar_path="${jar_files[0]}" + +python_dir="$project_root/python" + +# Verify python directory exists before running tests +if [[ ! -d "$python_dir" ]]; then + echo "Error: Python directory '$python_dir' does not exist. Skipping tests." + printf "\n0/2 bash e2e-tests passed (skipped due to missing python directory)\n" + exit 1 +fi + +# Set up environment variables for uv +export PYTHONPATH="$(pwd)/python" + +run_test "Agent plan compatibility end-to-end test" "run_agent_plan_compatibility_test" +run_test "Cross-Language Config Option end-to-end test" "run_cross_language_config_test" + +# Clean up temporary directory +if [[ -d "$tempdir" ]]; then + rm -rf "$tempdir" +fi printf "\n$PASSED/$TOTAL bash e2e-tests passed\n" if [[ "$PASSED" != "$TOTAL" ]]; then exit 1 fi -
