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 57f968aead56ca00b02e8f719e6cad987fe50238
Author: youjin <[email protected]>
AuthorDate: Thu Dec 25 19:08:11 2025 +0800

    [ci] Enable testing for all Flink versions in CI
---
 .github/workflows/ci.yml                           |  10 +-
 .../pom.xml                                        |  55 +++++-
 tools/ut.sh                                        | 215 ++++++++++++++-------
 3 files changed, 202 insertions(+), 78 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2f9260c..f21d34f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -93,13 +93,14 @@ jobs:
         run: tools/ut.sh -p
 
   python_it_tests:
-    name: it-python [${{ matrix.os }}] [python-${{ matrix.python-version}}]
+    name: it-python [${{ matrix.os }}] [python-${{ matrix.python-version}}] 
[flink-${{ matrix.flink-version}}]
     runs-on: ${{ matrix.os }}
     strategy:
       fail-fast: false
       matrix:
         os: [ 'ubuntu-latest' ]
         python-version: [ '3.11' ]
+        flink-version: [ "1.20", "2.0", "2.1", "2.2" ]
     steps:
       - uses: actions/checkout@v4
       - name: Install java
@@ -120,16 +121,17 @@ jobs:
       - name: Install ollama
         run: bash tools/start_ollama_server.sh
       - name: Run Python IT
-        run: tools/ut.sh -p -e
+        run: tools/ut.sh -p -e -f ${{ matrix.flink-version }}
 
   java_it_tests:
-    name: it-java [${{ matrix.os }}] [java-${{ matrix.java-version}}]
+    name: it-java [${{ matrix.os }}] [java-${{ matrix.java-version}}]  
[flink-${{ matrix.flink-version}}]
     runs-on: ${{ matrix.os }}
     strategy:
       fail-fast: false
       matrix:
         os: [ 'ubuntu-latest' ]
         java-version: [ "17" ]
+        flink-version: [ "1.20", "2.0", "2.1", "2.2" ]
     steps:
       - uses: actions/checkout@v4
       - name: Install java
@@ -142,7 +144,7 @@ jobs:
       - name: Install ollama
         run: bash tools/start_ollama_server.sh
       - name: Run Java IT
-        run: tools/ut.sh -j -e
+        run: tools/ut.sh -j -e -f ${{ matrix.flink-version }}
 
   cross_language_tests:
     name: cross-language [${{ matrix.os }}] [python-${{ 
matrix.python-version}}] [java-${{ matrix.java-version}}]
diff --git a/e2e-test/flink-agents-end-to-end-tests-integration/pom.xml 
b/e2e-test/flink-agents-end-to-end-tests-integration/pom.xml
index 66f1766..2adf275 100644
--- a/e2e-test/flink-agents-end-to-end-tests-integration/pom.xml
+++ b/e2e-test/flink-agents-end-to-end-tests-integration/pom.xml
@@ -28,15 +28,17 @@ under the License.
     <artifactId>flink-agents-end-to-end-tests-integration</artifactId>
     <name>Flink Agents : E2E Tests: Integration</name>
 
+    <properties>
+        <flink.1.20.version>1.20.3</flink.1.20.version>
+        <flink.2.0.version>2.0.1</flink.2.0.version>
+        <flink.2.1.version>2.1.1</flink.2.1.version>
+        <flink.2.2.version>2.2.0</flink.2.2.version>
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.flink</groupId>
-            <artifactId>flink-agents-api</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.flink</groupId>
-            <artifactId>flink-agents-runtime</artifactId>
+            <artifactId>${flink.agents.dist.artifactId}</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
@@ -91,4 +93,45 @@ under the License.
         </dependency>
     </dependencies>
 
+    <profiles>
+        <!-- Flink 2.2 Profile(Default) -->
+        <profile>
+            <id>flink-2.2</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <properties>
+                <flink.version>${flink.2.2.version}</flink.version>
+                
<flink.agents.dist.artifactId>flink-agents-dist-flink-2.2</flink.agents.dist.artifactId>
+            </properties>
+        </profile>
+
+        <!-- Flink 1.20 Profile -->
+        <profile>
+            <id>flink-1.20</id>
+            <properties>
+                <flink.version>${flink.1.20.version}</flink.version>
+                
<flink.agents.dist.artifactId>flink-agents-dist-flink-1.20</flink.agents.dist.artifactId>
+            </properties>
+        </profile>
+
+        <!-- Flink 2.0 Profile -->
+        <profile>
+            <id>flink-2.0</id>
+            <properties>
+                <flink.version>${flink.2.0.version}</flink.version>
+                
<flink.agents.dist.artifactId>flink-agents-dist-flink-2.0</flink.agents.dist.artifactId>
+            </properties>
+        </profile>
+
+        <!-- Flink 2.1 Profile -->
+        <profile>
+            <id>flink-2.1</id>
+            <properties>
+                <flink.version>${flink.2.1.version}</flink.version>
+                
<flink.agents.dist.artifactId>flink-agents-dist-flink-2.1</flink.agents.dist.artifactId>
+            </properties>
+        </profile>
+    </profiles>
+
 </project>
diff --git a/tools/ut.sh b/tools/ut.sh
index ee43037..134493b 100755
--- a/tools/ut.sh
+++ b/tools/ut.sh
@@ -20,11 +20,15 @@ set -e
 
 ROOT="$(cd "$( dirname "$0" )" && pwd)/.."
 
+# Default Flink version
+DEFAULT_FLINK_VERSION="2.2"
+
 # Default values
 run_java=true
 run_python=true
 run_e2e=false
 verbose=false
+flink_versions=()
 
 # Help information
 show_help() {
@@ -38,12 +42,18 @@ Options:
   -p, --python      Run only Python tests
   -e, --e2e         Run e2e tests
   -b, --both        Run both Java and Python tests (default)
+  -f, --flink       Specify Flink version to test (can be used multiple times)
+                    Supported versions: 2.2, 1.20
+                    Examples: -f 2.2, -f 1.20, -f 2.2 -f 1.20
+                    Default: run all versions if not specified
   -v, --verbose     Show verbose output
   -h, --help        Display this help message
 
 Examples:
-  $0 --java         # Run only Java tests
+  $0 --java         # Run only Java tests (all Flink versions)
   $0 -p             # Run only Python tests
+  $0 -f 2.2         # Run tests only for Flink 2.2
+  $0 -f 1.20        # Run tests only for Flink 1.20
   $0 -v             # Run all tests with verbose output
 
 Exit codes:
@@ -72,6 +82,15 @@ while [[ "$#" -gt 0 ]]; do
         -e|--e2e)
             run_e2e=true
             ;;
+        -f|--flink)
+            if [[ -z "$2" || "$2" == -* ]]; then
+                echo "Error: -f requires a version argument (e.g., -f 1.20)" 
>&2
+                show_help
+                exit 1
+            fi
+            flink_versions+=("$2")
+            shift
+            ;;
         -v|--verbose)
             verbose=true
             ;;
@@ -88,6 +107,18 @@ while [[ "$#" -gt 0 ]]; do
     shift
 done
 
+# If no version is specified, the default version will be run by default.
+if [ ${#flink_versions[@]} -eq 0 ]; then
+    flink_versions=("${DEFAULT_FLINK_VERSION}")
+fi
+
+# Remove duplicates and sort version numbers
+flink_versions=($(echo "${flink_versions[@]}" | tr ' ' '\n' | sort -u | tr 
'\n' ' '))
+
+if $verbose; then
+    echo "Will run tests for Flink versions: ${flink_versions[*]}"
+fi
+
 java_tests() {
     if $verbose; then
         echo "Running Java tests..."
@@ -96,11 +127,52 @@ java_tests() {
     echo "Executing Java test suite..."
     pushd "${ROOT}"
     if $run_e2e; then
-        mvn -T16 --batch-mode --no-transfer-progress test -pl 
'e2e-test/flink-agents-end-to-end-tests-integration'
+        echo "Installing dist packages to local repository..."
+
+        dist_modules=""
+        for version in "${flink_versions[@]}"; do
+            dist_modules="${dist_modules},dist/flink-${version}"
+        done
+        dist_modules="${dist_modules#,}"
+
+        mvn --batch-mode --no-transfer-progress install -pl "$dist_modules" 
-DskipTests
+        install_code=$?
+        if [ $install_code -ne 0 ]; then
+            echo "Failed to install dist packages" >&2
+            return 1
+        fi
+
+        local all_passed=true
+        for version in "${flink_versions[@]}"; do
+            echo "Running E2E tests for Flink ${version}..."
+            mvn --batch-mode --no-transfer-progress test -pl 
'e2e-test/flink-agents-end-to-end-tests-integration' -Pflink-${version}
+
+            if [ $? -ne 0 ]; then
+                echo "E2E tests failed for Flink ${version}" >&2
+                all_passed=false
+            fi
+        done
+
+        if [ "$all_passed" = false ]; then
+            return 1
+        fi
+        testcode=0
     else
-        mvn -T16 --batch-mode --no-transfer-progress test -pl 
'!e2e-test/flink-agents-end-to-end-tests-integration,!e2e-test/flink-agents-end-to-end-tests-resource-cross-language'
+        echo "Installing all modules (including test-jars) to local 
repository..."
+        mvn --batch-mode --no-transfer-progress test-compile jar:test-jar 
install -DskipTests
+        install_code=$?
+        if [ $install_code -ne 0 ]; then
+            echo "Failed to install modules to local repository" >&2
+            return 1
+        fi
+
+        local all_passed=true
+
+        
exclude_list="!e2e-test/flink-agents-end-to-end-tests-integration,!e2e-test/flink-agents-end-to-end-tests-resource-cross-language"
+
+        mvn -T16 --batch-mode --no-transfer-progress test -pl "${exclude_list}"
+        testcode=$?
     fi
-    testcode=$?
     case $testcode in
         0)  # All tests passed
             if $verbose; then
@@ -130,78 +202,85 @@ python_tests() {
 
     set +e
     pushd "${ROOT}"/python
-    
-    # Install dependencies and run tests
-    echo "Installing Python test dependencies..."
-    if command -v uv >/dev/null 2>&1; then
-        if $verbose; then
-            echo "Using uv for dependency management"
-        fi
-        if $verbose; then
-            echo "Running tests with uv..."
-        fi
-        if $run_e2e; then
-            # There will be an individual build step before run e2e test for 
including java dist
-            uv run --no-sync pytest flink_agents -s -k "e2e_tests_integration"
-        else
-            uv sync --extra test
-            uv run pytest flink_agents -k "not e2e_tests"
-        fi
-        testcode=$?
-    else
-        if $verbose; then
-            echo "uv not found, falling back to pip"
-        fi
-        # Try modern pyproject.toml first, then fallback to requirements.txt
-        if [ -f "pyproject.toml" ]; then
+
+    # Run tests for each Flink version
+    local all_passed=true
+    for version in "${flink_versions[@]}"; do
+        echo "Running Python tests for Flink ${version}..."
+
+        # Install dependencies and run tests
+        if command -v uv >/dev/null 2>&1; then
             if $verbose; then
-                echo "Using pyproject.toml dependency groups"
+                echo "Using uv for dependency management"
             fi
-            pip install -e ".[test]"
-        else
             if $verbose; then
-                echo "Using legacy requirements.txt"
+                echo "Running tests with uv for Flink ${version}..."
             fi
-            pip install -r requirements/test_requirements.txt
-        fi
-        if $verbose; then
-            echo "Running tests with pytest..."
-        fi
-        if $run_e2e; then
-            pytest flink_agents -k "e2e_tests_integration"
+            if $run_e2e; then
+                # There will be an individual build step before run e2e test 
for including java dist
+                uv pip install apache-flink~=${version}.0
+                uv run --no-sync pytest flink_agents -s -k 
"e2e_tests_integration"
+            else
+                uv sync --extra test
+                uv pip install apache-flink~=${version}.0
+                uv run --no-sync pytest flink_agents -k "not e2e_tests"
+            fi
+            testcode=$?
         else
-            pytest flink_agents -k "not e2e_tests"
+            if $verbose; then
+                echo "uv not found, falling back to pip"
+            fi
+            # Try modern pyproject.toml first, then fallback to 
requirements.txt
+            if [ -f "pyproject.toml" ]; then
+                if $verbose; then
+                    echo "Using pyproject.toml dependency groups"
+                fi
+                pip install -e ".[test]"
+                pip install apache-flink~=${version}.0
+            fi
+            if $verbose; then
+                echo "Running tests with pytest..."
+            fi
+            if $run_e2e; then
+                pytest flink_agents -k "e2e_tests_integration"
+            else
+                pytest flink_agents -k "not e2e_tests"
+            fi
+            testcode=$?
         fi
-        testcode=$?
-    fi
-    
+
+        # Handle pytest exit codes
+        case $testcode in
+            0)  # All tests passed
+                if $verbose; then
+                    echo "Python tests passed for Flink ${version}"
+                fi
+                ;;
+            1)  # Tests failed
+                echo "Python tests failed for Flink ${version}" >&2
+                all_passed=false
+                ;;
+            2)  # Test execution interrupted
+                echo "Python tests interrupted for Flink ${version}" >&2
+                all_passed=false
+                ;;
+            5)  # No tests collected
+                echo "Warning: No Python tests collected for Flink ${version}" 
>&2
+                ;;
+            *)  # Unknown error
+                echo "Python tests encountered unknown error for Flink 
${version} (exit code: $testcode)" >&2
+                all_passed=false
+                ;;
+        esac
+    done
+
     popd
 
-    # Handle pytest exit codes
-    case $testcode in
-        0)  # All tests passed
-            if $verbose; then
-                echo "All Python tests passed"
-            fi
-            return 0
-            ;;
-        1)  # Tests failed
-            echo "Python tests failed" >&2
-            return 2
-            ;;
-        2)  # Test execution interrupted
-            echo "Python tests interrupted" >&2
-            return 2
-            ;;
-        5)  # No tests collected
-            echo "Warning: No Python tests collected" >&2
-            return 0  # Treat as success
-            ;;
-        *)  # Unknown error
-            echo "Python tests encountered unknown error (exit code: 
$testcode)" >&2
-            return 2
-            ;;
-    esac
+    if [ "$all_passed" = false ]; then
+        return 2
+    else
+        return 0
+    fi
 }
 
 main() {

Reply via email to