Files
spring-boot-microservices-p…/cloud-2026-upgrade/scripts/native-labels.sh
T

27 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Native config repository asked for two labels at once ("a,b"): which one wins on each train?
# $1 = built copy on 2025.1.5 (upgrade.sh 1), $2 = built copy on 2026.0.0 (upgrade.sh 2)
MOD=$(cd "$(dirname "$0")/.." && pwd); cd "$MOD" || exit 1
unset JAVA_TOOL_OPTIONS
repo=run/labels; mkdir -p $repo/a $repo/b
echo 'demo.source: from a/app-prod.yml' > $repo/a/app-prod.yml
echo 'demo.source: from b/app.yml' > $repo/b/app.yml
F=output/43-native-multi-label.txt
{ echo "# a/app-prod.yml and b/app.yml both set demo.source. Request: /app/prod/a,b"
echo "# search-locations: file:<repo>/ (label directories are added automatically)"; } > $F
ask() { # title dir extra...
local title=$1 dir=$2; shift 2
java -Xmx200m -jar "$dir/config-server/target/config-server-1.0.0.jar" \
"--spring.cloud.config.server.native.search-locations=file:$MOD/$repo/" "$@" > run/labels.log 2>&1 &
local pid=$!
for _ in $(seq 1 60); do curl -fs localhost:8888/actuator/health >/dev/null 2>&1 && break; sleep 1; done
{ echo; echo "=== $title"; curl -s localhost:8888/app/prod/a,b | python3 -I -c 'import sys,json
for i,ps in enumerate(json.load(sys.stdin)["propertySources"]):
print(" ", "wins " if i==0 else " ", ps["source"].get("demo.source"))'; } >> $F
kill $pid; wait $pid 2>/dev/null
}
ask "Spring Cloud 2025.1.5" "$1"
ask "Spring Cloud 2026.0.0" "$2"
ask "Spring Cloud 2026.0.0 + spring.cloud.config.server.native.last-label-wins=false" "$2" --spring.cloud.config.server.native.last-label-wins=false
cat $F