diff --git a/.github/scripts/resolve-ci-modules.sh b/.github/scripts/resolve-ci-modules.sh index 5c505bc9b0c6..9b41d5ff4e5b 100644 --- a/.github/scripts/resolve-ci-modules.sh +++ b/.github/scripts/resolve-ci-modules.sh @@ -41,9 +41,24 @@ add_module() { modules+=("${module}") } +is_root_reactor_module() { + local module="$1" + local candidate="${module}" + + while [[ "${candidate}" == */* ]]; do + if grep -Fq "${candidate}" pom.xml; then + return 0 + fi + candidate="${candidate%/*}" + done + + grep -Fq "${candidate}" pom.xml +} + find_module() { local path="$1" local dir + local module if [[ -d "${path}" ]]; then dir="${path}" @@ -53,7 +68,10 @@ find_module() { while [[ "${dir}" != "." && "${dir}" != "/" ]]; do if [[ -f "${dir}/pom.xml" ]]; then - printf '%s\n' "${dir#./}" + module="${dir#./}" + if is_root_reactor_module "${module}"; then + printf '%s\n' "${module}" + fi return fi dir="$(dirname "${dir}")" @@ -95,6 +113,8 @@ while IFS= read -r file; do module="$(find_module "${file}")" if [[ -n "${module:-}" ]]; then add_module "${module}" + else + full_build_required=true fi fi done < <(printf '%s' "${changed_files_json}" | jq -r '.[]') diff --git a/shenyu-e2e/shenyu-e2e-case/compose/storage/shenyu-storage-opengauss.yml b/shenyu-e2e/shenyu-e2e-case/compose/storage/shenyu-storage-opengauss.yml index 62c2318c1389..d0c3b6622836 100644 --- a/shenyu-e2e/shenyu-e2e-case/compose/storage/shenyu-storage-opengauss.yml +++ b/shenyu-e2e/shenyu-e2e-case/compose/storage/shenyu-storage-opengauss.yml @@ -18,7 +18,7 @@ version: '3.9' services: shenyu-opengauss: - image: enmotech/opengauss:5.0.0 + image: enmotech/opengauss-lite:5.0.1 container_name: shenyu-opengauss environment: - GS_PASSWORD=ShenYuE2E@123 @@ -26,7 +26,7 @@ services: ports: - "30432:5432" volumes: - - /tmp/shenyu-e2e/opengauss/schema/create-table.sql:/docker-entrypoint-initdb.d + - /tmp/shenyu-e2e/opengauss/schema/create-table.sql:/docker-entrypoint-initdb.d/create-table.sql deploy: resources: limits: @@ -36,7 +36,7 @@ services: cpus: '0.5' memory: 512M healthcheck: - test: [ "CMD-SHELL", "gsql -U gaussdb -h127.0.0.1 -p5432 -dshenyu -WShenYuE2E@123 -c \"SELECT 1\"" ] + test: [ "CMD-SHELL", "LD_LIBRARY_PATH=/usr/local/opengauss/lib /usr/local/opengauss/bin/gsql -U gaussdb --password $$GS_PASSWORD -h 127.0.0.1 -p 5432 -d shenyu -c \"SELECT 1\"" ] interval: 10s timeout: 5s retries: 3 diff --git a/shenyu-e2e/shenyu-e2e-case/compose/storage/shenyu-storage-postgres.yml b/shenyu-e2e/shenyu-e2e-case/compose/storage/shenyu-storage-postgres.yml index 357a7d884b6e..29e3e87acae0 100644 --- a/shenyu-e2e/shenyu-e2e-case/compose/storage/shenyu-storage-postgres.yml +++ b/shenyu-e2e/shenyu-e2e-case/compose/storage/shenyu-storage-postgres.yml @@ -27,7 +27,7 @@ services: ports: - "30432:5432" volumes: - - /tmp/shenyu-e2e/postgres/schema/create-table.sql:/docker-entrypoint-initdb.d + - /tmp/shenyu-e2e/postgres/schema/create-table.sql:/docker-entrypoint-initdb.d/create-table.sql healthcheck: test: [ "CMD-SHELL", "psql -U shenyue2e -h127.0.0.1 -p5432 -dshenyu -c \"SELECT 1\"" ] interval: 10s diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-h2-compose.sh b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-h2-compose.sh index 191a68fc3ba4..6aabed43b1cc 100644 --- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-h2-compose.sh +++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-h2-compose.sh @@ -16,24 +16,34 @@ # limitations under the License. # +set -euo pipefail + # init kubernetes for h2 SHENYU_TESTCASE_DIR=$(dirname "$(dirname "$(dirname "$(dirname "$0")")")") curPath=$(readlink -f "$(dirname "$0")") PRGDIR=$(dirname "$curPath") -docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-h2.yml up -d --quiet-pull -sleep 30s +COMPOSE_FILE="$SHENYU_TESTCASE_DIR/compose/storage/shenyu-storage-h2.yml" -# execute healthcheck.sh -chmod +x "${curPath}"/healthcheck.sh -sh "${curPath}"/healthcheck.sh h2 http://localhost:31095/actuator/health http://localhost:31195/actuator/health +# Start services and wait for their healthchecks. +docker network create -d bridge shenyu || true +trap 'docker compose -f "$COMPOSE_FILE" down || true' EXIT +dump_logs() { + echo "shenyu-admin log:" + echo "------------------" + docker compose -f "$COMPOSE_FILE" logs shenyu-admin || true + echo "shenyu-bootstrap log:" + echo "------------------" + docker compose -f "$COMPOSE_FILE" logs shenyu-bootstrap || true +} +if ! docker compose -f "$COMPOSE_FILE" up -d --quiet-pull --wait --wait-timeout 300; then + dump_logs + exit 1 +fi ## run e2e-test -sleep 60s -./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-storage -am test +if ! ./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-storage -am test; then + dump_logs + exit 1 +fi -echo "shenyu-admin log:" -echo "------------------" -docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-h2.yml logs shenyu-admin -echo "shenyu-bootstrap log:" -echo "------------------" -docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-h2.yml logs shenyu-bootstrap +dump_logs diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-mysql-compose.sh b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-mysql-compose.sh index ec4af5917f54..c1f95f952653 100644 --- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-mysql-compose.sh +++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-mysql-compose.sh @@ -16,25 +16,38 @@ # limitations under the License. # +set -euo pipefail + # init kubernetes for h2 SHENYU_TESTCASE_DIR=$(dirname "$(dirname "$(dirname "$(dirname "$0")")")") bash "${SHENYU_TESTCASE_DIR}"/k8s/script/storage/storage_init_mysql.sh curPath=$(readlink -f "$(dirname "$0")") PRGDIR=$(dirname "$curPath") -docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-mysql.yml up -d --quiet-pull -sleep 30s +COMPOSE_FILE="$SHENYU_TESTCASE_DIR/compose/storage/shenyu-storage-mysql.yml" -# execute healthcheck.sh -chmod +x "${curPath}"/healthcheck.sh -sh "${curPath}"/healthcheck.sh h2 http://localhost:31095/actuator/health http://localhost:31195/actuator/health +# Start services and wait for their healthchecks. +docker network create -d bridge shenyu || true +trap 'docker compose -f "$COMPOSE_FILE" down || true' EXIT +dump_logs() { + echo "shenyu-mysql log:" + echo "------------------" + docker compose -f "$COMPOSE_FILE" logs shenyu-mysql || true + echo "shenyu-admin log:" + echo "------------------" + docker compose -f "$COMPOSE_FILE" logs shenyu-admin || true + echo "shenyu-bootstrap log:" + echo "------------------" + docker compose -f "$COMPOSE_FILE" logs shenyu-bootstrap || true +} +if ! docker compose -f "$COMPOSE_FILE" up -d --quiet-pull --wait --wait-timeout 300; then + dump_logs + exit 1 +fi ## run e2e-test -sleep 60s -./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-storage -am test +if ! ./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-storage -am test; then + dump_logs + exit 1 +fi -echo "shenyu-admin log:" -echo "------------------" -docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-mysql.yml logs shenyu-admin -echo "shenyu-bootstrap log:" -echo "------------------" -docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-mysql.yml logs shenyu-bootstrap +dump_logs diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-opengauss-compose.sh b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-opengauss-compose.sh index e9447c1185a2..32d9c1a9ca9d 100644 --- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-opengauss-compose.sh +++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-opengauss-compose.sh @@ -16,25 +16,39 @@ # limitations under the License. # +set -euo pipefail + # init kubernetes for h2 SHENYU_TESTCASE_DIR=$(dirname "$(dirname "$(dirname "$(dirname "$0")")")") bash "${SHENYU_TESTCASE_DIR}"/k8s/script/storage/storage_init_opengauss.sh curPath=$(readlink -f "$(dirname "$0")") PRGDIR=$(dirname "$curPath") -docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-opengauss.yml up -d --quiet-pull -sleep 30s +COMPOSE_FILE="$SHENYU_TESTCASE_DIR/compose/storage/shenyu-storage-opengauss.yml" -# execute healthcheck.sh -chmod +x "${curPath}"/healthcheck.sh -sh "${curPath}"/healthcheck.sh h2 http://localhost:31095/actuator/health http://localhost:31195/actuator/health +# Start services and wait for their healthchecks. +docker network create -d bridge shenyu || true +trap 'docker compose -f "$COMPOSE_FILE" down || true' EXIT +dump_logs() { + echo "shenyu-opengauss log:" + echo "------------------" + docker compose -f "$COMPOSE_FILE" logs shenyu-opengauss || true + docker inspect --format '{{range .State.Health.Log}}{{println .ExitCode .Output}}{{end}}' shenyu-opengauss || true + echo "shenyu-admin log:" + echo "------------------" + docker compose -f "$COMPOSE_FILE" logs shenyu-admin || true + echo "shenyu-bootstrap log:" + echo "------------------" + docker compose -f "$COMPOSE_FILE" logs shenyu-bootstrap || true +} +if ! docker compose -f "$COMPOSE_FILE" up -d --quiet-pull --wait --wait-timeout 300; then + dump_logs + exit 1 +fi ## run e2e-test -sleep 60s -./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-storage -am test +if ! ./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-storage -am test; then + dump_logs + exit 1 +fi -echo "shenyu-admin log:" -echo "------------------" -docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-opengauss.yml logs shenyu-admin -echo "shenyu-bootstrap log:" -echo "------------------" -docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-opengauss.yml logs shenyu-bootstrap +dump_logs diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-postgres-compose.sh b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-postgres-compose.sh index 38c7047f03cc..a5fbdb49c9a5 100644 --- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-postgres-compose.sh +++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-postgres-compose.sh @@ -16,25 +16,38 @@ # limitations under the License. # +set -euo pipefail + # init kubernetes for h2 SHENYU_TESTCASE_DIR=$(dirname "$(dirname "$(dirname "$(dirname "$0")")")") bash "${SHENYU_TESTCASE_DIR}"/k8s/script/storage/storage_init_postgres.sh curPath=$(readlink -f "$(dirname "$0")") PRGDIR=$(dirname "$curPath") -docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-postgres.yml up -d --quiet-pull -sleep 30s +COMPOSE_FILE="$SHENYU_TESTCASE_DIR/compose/storage/shenyu-storage-postgres.yml" -# execute healthcheck.sh -chmod +x "${curPath}"/healthcheck.sh -sh "${curPath}"/healthcheck.sh h2 http://localhost:31095/actuator/health http://localhost:31195/actuator/health +# Start services and wait for their healthchecks. +docker network create -d bridge shenyu || true +trap 'docker compose -f "$COMPOSE_FILE" down || true' EXIT +dump_logs() { + echo "shenyu-postgres log:" + echo "------------------" + docker compose -f "$COMPOSE_FILE" logs shenyu-postgres || true + echo "shenyu-admin log:" + echo "------------------" + docker compose -f "$COMPOSE_FILE" logs shenyu-admin || true + echo "shenyu-bootstrap log:" + echo "------------------" + docker compose -f "$COMPOSE_FILE" logs shenyu-bootstrap || true +} +if ! docker compose -f "$COMPOSE_FILE" up -d --quiet-pull --wait --wait-timeout 300; then + dump_logs + exit 1 +fi ## run e2e-test -sleep 60s -./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-storage -am test +if ! ./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-storage -am test; then + dump_logs + exit 1 +fi -echo "shenyu-admin log:" -echo "------------------" -docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-postgres.yml logs shenyu-admin -echo "shenyu-bootstrap log:" -echo "------------------" -docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-postgres.yml logs shenyu-bootstrap +dump_logs diff --git a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-storage-compose.sh b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-storage-compose.sh index 4c1454427043..517a4f773614 100644 --- a/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-storage-compose.sh +++ b/shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-storage/compose/script/e2e-storage-compose.sh @@ -16,12 +16,27 @@ # limitations under the License. # +set -euo pipefail + # init kubernetes for h2 SHENYU_TESTCASE_DIR=$(dirname "$(dirname "$(dirname "$(dirname "$0")")")") curPath=$(readlink -f "$(dirname "$0")") PRGDIR=$(dirname "$curPath") -docker network create -d bridge shenyu +docker network create -d bridge shenyu || true + +COMPOSE_FILE="" +cleanup() { + if [ -n "$COMPOSE_FILE" ]; then + docker compose -f "$COMPOSE_FILE" down || true + fi +} +dump_logs() { + echo "compose service logs:" + echo "------------------" + docker compose -f "$COMPOSE_FILE" logs || true +} +trap cleanup EXIT STORAGE_ARRAY=("h2" "mysql" "opengauss" "postgres") for storage in "${STORAGE_ARRAY[@]}"; do @@ -29,21 +44,18 @@ for storage in "${STORAGE_ARRAY[@]}"; do bash "${SHENYU_TESTCASE_DIR}"/k8s/script/storage/storage_init_"${storage}".sh fi - docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-"${storage}".yml up -d --quiet-pull - sleep 30s - - # execute healthcheck.sh - chmod +x "${curPath}"/healthcheck.sh - sh "${curPath}"/healthcheck.sh "${storage}" http://localhost:31095/actuator/health http://localhost:31195/actuator/health + COMPOSE_FILE="$SHENYU_TESTCASE_DIR/compose/storage/shenyu-storage-$storage.yml" + if ! docker compose -f "$COMPOSE_FILE" up -d --quiet-pull --wait --wait-timeout 300; then + dump_logs + exit 1 + fi ## run e2e-test - sleep 60s - - ./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-storage -am test - - echo "shenyu-admin log:" - echo "------------------" - docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-"${storage}".yml logs shenyu-admin - echo "shenyu-bootstrap log:" - echo "------------------" - docker compose -f "$SHENYU_TESTCASE_DIR"/compose/storage/shenyu-storage-"${storage}".yml logs shenyu-bootstrap + if ! ./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-storage -am test; then + dump_logs + exit 1 + fi + + dump_logs + docker compose -f "$COMPOSE_FILE" down || true + COMPOSE_FILE="" done