lulianqi commented on code in PR #23:
URL: https://github.com/apache/dubbo-net/pull/23#discussion_r4465109128


##########
Tests/EndToEndTestEnvironment/wait-for-environment.sh:
##########
@@ -0,0 +1,81 @@
+#!/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.
+
+set -euo pipefail
+
+script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
+log_dir=${1:-"$script_dir/logs"}
+provider_host=${DUBBONET_PROVIDER_HOST:-}
+if [[ -z "$provider_host" && -f "$log_dir/provider-host" ]]; then
+  provider_host=$(<"$log_dir/provider-host")
+fi
+if [[ -z "$provider_host" ]]; then
+  echo "Cannot determine the provider host." >&2
+  exit 1
+fi
+
+ready_timeout=${DUBBONET_E2E_READY_TIMEOUT:-180}
+if [[ ! "$ready_timeout" =~ ^[1-9][0-9]*$ ]]; then
+  echo "DUBBONET_E2E_READY_TIMEOUT must be a positive number of seconds." >&2
+  exit 1
+fi
+ready_deadline=$((SECONDS + ready_timeout))
+
+check_provider_processes() {
+  if [[ ! -s "$log_dir/provider-pids" ]]; then
+    echo "No provider PID file found; start the providers first." >&2
+    return 1
+  fi
+  while IFS= read -r provider_pid; do
+    if [[ ! "$provider_pid" =~ ^[0-9]+$ ]] || ! kill -0 "$provider_pid" 
2>/dev/null; then
+      echo "Provider process $provider_pid exited during startup. Inspect 
$log_dir." >&2
+      return 1
+    fi
+  done < "$log_dir/provider-pids"
+}
+
+wait_for_tcp() {
+  local host=$1
+  local port=$2
+  local label=$3
+
+  while (( SECONDS < ready_deadline )); do
+    check_provider_processes
+    if timeout 2 bash -c 'echo > "/dev/tcp/$1/$2"' _ "$host" "$port" 
>/dev/null 2>&1; then
+      echo "$label is ready on $host:$port."
+      return 0
+    fi
+    sleep 2
+  done
+
+  echo "Timed out waiting for $label on $host:$port." >&2
+  return 1
+}
+
+wait_for_tcp 127.0.0.1 2181 ZooKeeper
+wait_for_tcp 127.0.0.1 8848 Nacos
+wait_for_tcp 127.0.0.1 9848 "Nacos gRPC"
+wait_for_tcp "$provider_host" 20883 "Dubbo 2.7.23 provider"
+wait_for_tcp "$provider_host" 20882 "Dubbo 3.1.11 provider"
+wait_for_tcp "$provider_host" 20881 "Dubbo 3.2.20 provider"
+wait_for_tcp "$provider_host" 20880 "Dubbo 3.3.6 provider"
+wait_for_tcp "$provider_host" 50051 "Dubbo 3.3.6 Triple provider"
+
+check_provider_processes
+
+# Ports open before registry metadata is always visible. Give both registries a
+# short, deterministic settling window before the first discovery request.
+sleep 10

Review Comment:
   谢谢您指出这里的就绪判断问题,已移除固定的 `sleep 10`。现在复用集成程序新增的只读 `--check-readiness` 
模式,逐一确认各版本/root 下的 5 个服务:预期地址、端口和服务身份的有效 
Provider,以及元数据中心中非空的类型和方法定义。ZooKeeper、Nacos 共用启动超时,每次重试使用新进程,超时会输出具体 
registry/version/interface;不发送业务 RPC,也不重试正式测试用例。另补充了元数据延迟发布、始终缺失时的脚本故障验证。



##########
.github/workflows/end-to-end.yml:
##########
@@ -0,0 +1,180 @@
+# 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.
+
+name: End-to-end tests
+
+on:
+  push:
+    branches: [main]
+  pull_request:
+    branches: [main]
+  workflow_dispatch:
+
+permissions:
+  contents: read
+
+concurrency:
+  group: end-to-end-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  end-to-end:
+    name: ZooKeeper, Nacos and direct protocols
+    runs-on: ubuntu-22.04
+    timeout-minutes: 30
+    defaults:
+      run:
+        shell: bash
+    env:
+      COMPOSE_PROJECT_NAME: dubbonet-e2e-${{ github.run_id }}-${{ 
github.run_attempt }}
+
+    steps:
+      - name: Check out source
+        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 
v7.0.1
+        with:
+          persist-credentials: false
+
+      - name: Configure the end-to-end log directory
+        run: echo "E2E_LOG_DIR=$RUNNER_TEMP/dubbonet-e2e-logs" >> "$GITHUB_ENV"
+
+      - name: Set up Java
+        uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5
+        with:
+          distribution: temurin
+          java-version: "8"
+          cache: maven
+          cache-dependency-path: |
+            Tests/EndToEndTestEnvironment/JavaProviders/pom.xml
+            Tests/EndToEndTestEnvironment/JavaProviders/*/pom.xml
+
+      - name: Set up .NET
+        uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # 
v6.0.0
+        with:
+          dotnet-version: 10.0.x
+
+      - name: Start temporary registries
+        run: docker compose -f Tests/EndToEndTestEnvironment/compose.yaml up -d
+
+      - name: Resolve the Runner provider address
+        run: |
+          provider_host=$(ip -4 route get 1.1.1.1 | awk '{ for (field = 1; 
field <= NF; field++) if ($field == "src") { print $(field + 1); exit } }')
+          if [[ -z "$provider_host" || "$provider_host" == 127.* ]]; then
+            echo "Cannot resolve a non-loopback Runner IPv4 address." >&2
+            exit 1
+          fi
+          echo "DUBBONET_PROVIDER_HOST=$provider_host" >> "$GITHUB_ENV"
+          echo "Providers will register $provider_host."
+
+      - name: Build Java providers
+        run: >-
+          mvn -B -ntp
+          -f Tests/EndToEndTestEnvironment/JavaProviders/pom.xml
+          package
+          -DskipTests
+
+      - name: Start Java providers
+        run: Tests/EndToEndTestEnvironment/start-providers.sh "$E2E_LOG_DIR"
+
+      - name: Wait for the temporary environment
+        run: Tests/EndToEndTestEnvironment/wait-for-environment.sh 
"$E2E_LOG_DIR"
+
+      - name: Restore .NET projects
+        run: dotnet restore DubboNet.sln
+
+      - name: Test every provider method end to end
+        env:
+          DUBBONET_E2E_ENABLED: "true"
+          DUBBONET_E2E_ZOOKEEPER_ADDRESS: 127.0.0.1:2181
+          DUBBONET_E2E_NACOS_ADDRESS: nacos://127.0.0.1:8848
+        run: >-
+          dotnet test
+          Tests/DubboNetEndToEndTests/DubboNetEndToEndTests.csproj
+          --configuration Release
+          --no-restore
+          -p:GeneratePackageOnBuild=false
+          --logger "console;verbosity=detailed"
+          --logger "trx;LogFileName=dubbonet-end-to-end.trx"
+          --results-directory "$E2E_LOG_DIR/test-results"
+          2>&1 | tee "$E2E_LOG_DIR/end-to-end-tests.log"
+
+      - name: Test ZooKeeper discovery and all Dubbo versions
+        run: >-
+          dotnet run
+          --project 
Tests/DubboClientIntegrationTests/DubboClientIntegrationTests.csproj
+          --configuration Release
+          --no-restore
+          -p:GeneratePackageOnBuild=false
+          -- --registry 127.0.0.1:2181 --provider-host 
"$DUBBONET_PROVIDER_HOST"
+          2>&1 | tee "$E2E_LOG_DIR/integration-zookeeper.log"
+
+      - name: Test Nacos discovery
+        run: >-
+          dotnet run
+          --project 
Tests/DubboClientIntegrationTests/DubboClientIntegrationTests.csproj
+          --configuration Release
+          --no-restore
+          -p:GeneratePackageOnBuild=false
+          -- --registry nacos://127.0.0.1:8848 --provider-host 
"$DUBBONET_PROVIDER_HOST"
+          2>&1 | tee "$E2E_LOG_DIR/integration-nacos.log"
+
+      - name: Run QueryDemo with ZooKeeper
+        run: >-
+          dotnet run
+          --project Tests/QueryDemo/QueryDemo.csproj
+          --configuration Release
+          --no-restore
+          -p:GeneratePackageOnBuild=false
+          -- --registry 127.0.0.1:2181 --provider-host 
"$DUBBONET_PROVIDER_HOST"
+          2>&1 | tee "$E2E_LOG_DIR/query-demo-zookeeper.log"
+
+      - name: Run QueryDemo with Nacos
+        run: >-
+          dotnet run
+          --project Tests/QueryDemo/QueryDemo.csproj
+          --configuration Release
+          --no-restore
+          -p:GeneratePackageOnBuild=false
+          -- --registry nacos://127.0.0.1:8848 --provider-host 
"$DUBBONET_PROVIDER_HOST"
+          2>&1 | tee "$E2E_LOG_DIR/query-demo-nacos.log"
+
+      - name: Collect registry logs
+        if: always()
+        run: |
+          mkdir -p "$E2E_LOG_DIR"
+          docker compose -f Tests/EndToEndTestEnvironment/compose.yaml logs 
--no-color > "$E2E_LOG_DIR/registries.log" 2>&1 || true
+
+      - name: Upload end-to-end logs
+        if: always()
+        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 
# v7
+        with:
+          name: end-to-end-logs-${{ github.run_attempt }}
+          path: ${{ env.E2E_LOG_DIR }}
+          retention-days: 7
+          if-no-files-found: warn
+
+      - name: Upload end-to-end test results
+        if: always()
+        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 
# v7
+        with:
+          name: end-to-end-test-results-${{ github.run_attempt }}
+          path: ${{ env.E2E_LOG_DIR }}/test-results
+          retention-days: 7
+          if-no-files-found: warn
+
+      - name: Stop temporary environment
+        if: always()
+        run: |
+          Tests/EndToEndTestEnvironment/stop-providers.sh "$E2E_LOG_DIR"

Review Comment:
   感谢建议,已拆成两个独立的 `if: always()` 清理步骤,分别设置超时和 `continue-on-error`,失败时输出明确的 
warning。这样即使 Provider 停止失败,Compose 
清理仍会执行,且不会覆盖正式测试的结果;日志上传仍在清理之前。也用故障注入检查了两项清理分别失败的情况。本地运行脚本则继续保留清理失败返回非零的行为。



##########
Tests/EndToEndTestEnvironment/run-local.sh:
##########
@@ -0,0 +1,83 @@
+#!/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.
+
+set -euo pipefail
+
+script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
+repo_root=$(CDPATH= cd -- "$script_dir/../.." && pwd)
+cd "$repo_root"
+
+for required in docker java mvn dotnet timeout; do
+  if ! command -v "$required" >/dev/null 2>&1; then
+    echo "Required tool is missing: $required. See $script_dir/README.md." >&2
+    exit 1
+  fi
+done
+docker compose version >/dev/null
+docker info >/dev/null
+
+log_dir=${1:-$(mktemp -d "${TMPDIR:-/tmp}/dubbonet-e2e.XXXXXX")}
+mkdir -p "$log_dir"
+log_dir=$(CDPATH= cd -- "$log_dir" && pwd)
+export COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-dubbonet-e2e-local-$$}
+
+cleanup() {
+  local status=$?
+  trap - EXIT
+  docker compose -f "$script_dir/compose.yaml" logs --no-color > 
"$log_dir/registries.log" 2>&1 || true
+  "$script_dir/stop-providers.sh" "$log_dir" || status=1
+  docker compose -f "$script_dir/compose.yaml" down --volumes --remove-orphans 
|| status=1
+  echo "End-to-end logs: $log_dir"
+  exit "$status"
+}
+trap cleanup EXIT
+trap 'exit 130' INT
+trap 'exit 143' TERM
+
+run_logged() {
+  local name=$1
+  shift
+  "$@" 2>&1 | tee "$log_dir/$name.log"
+}
+
+docker compose -f "$script_dir/compose.yaml" up -d
+run_logged java-build mvn -B -ntp -f "$script_dir/JavaProviders/pom.xml" 
package -DskipTests
+"$script_dir/start-providers.sh" "$log_dir"
+export DUBBONET_PROVIDER_HOST

Review Comment:
   谢谢您仔细检查,已调整为先读取并赋值、检查 host 非空,再 `export`,让这里的执行顺序更清楚。



##########
.github/workflows/end-to-end.yml:
##########
@@ -0,0 +1,180 @@
+# 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.
+
+name: End-to-end tests
+
+on:
+  push:
+    branches: [main]
+  pull_request:
+    branches: [main]
+  workflow_dispatch:
+
+permissions:
+  contents: read
+
+concurrency:
+  group: end-to-end-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true

Review Comment:
   谢谢提醒,已将取消策略限定为 PR 更新。PR 仍按编号保留最新运行;`main` 推送和手动运行使用各自的 run-ID 
分组,避免正在运行或等待中的其他提交被替换。原有 `on` 触发条件保持不变,文档也同步说明了这一区别。



##########
Tests/EndToEndTestEnvironment/compose.yaml:
##########
@@ -0,0 +1,38 @@
+# 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.
+
+name: dubbonet-e2e

Review Comment:
   谢谢建议,这里采用了您提到的补充注释方案:明确 `name:` 仅用于未指定项目名时的手动调用,CI 和 `run-local.sh` 
都会覆盖它。同时本地脚本会打印实际项目名及对应清理命令,环境文档也补充了从另一终端清理时需要使用同一项目名的说明。



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to