@@ -98,28 +98,34 @@ jobs:
9898 run : |
9999 pip install pytest-timeout
100100
101- - name : Wait for OpenSearch to be ready
101+ - name : Wait for Search Service to be ready
102102 run : |
103103 set -e
104- host="${{ env.OPENSEARCH_HOST:- localhost }} "
105- port="${{ env.OPENSEARCH_PORT:- 9202 }}"
104+ host="localhost"
105+ port="${{ matrix.backend == 'elasticsearch8' && '9200' || ' 9202' }}"
106106 url="http://$host:$port/_cluster/health"
107- echo "Waiting for OpenSearch at $url"
108- for i in $(seq 1 60); do
109- if curl -sS "$url" | grep -E '"status":"(yellow|green)"' >/dev/null 2>&1; then
110- echo "OpenSearch is ready"
107+ echo "Waiting for ${{ matrix.backend }} at $url"
108+
109+ # Add initial delay
110+ echo "Waiting 10s for service to start..."
111+ sleep 10
112+
113+ for i in $(seq 1 10); do # 10 retries * 5s = 50s max wait
114+ if curl -sS --fail --show-error --max-time 5 "$url" 2>/dev/null | grep -E '"status":"(yellow|green)"' >/dev/null; then
115+ echo "${{ matrix.backend }} is ready"
111116 curl -sS "http://$host:$port" || true
112- break
117+ exit 0
113118 fi
114- echo "OpenSearch not ready yet ($i/60) — sleeping 5s"
119+ echo "${{ matrix.backend }} not ready yet ($((i*5))s/50s) - waiting 5s"
115120 sleep 5
116121 done
117- # Final check: fail the job if still not ready
118- if ! curl -sS "$url" | grep -E '"status":"(yellow|green)"' >/dev/null 2>&1; then
119- echo "OpenSearch failed to become ready within timeout"
120- curl -sS "http://$host:$port" || true
121- exit 1
122- fi
122+
123+ echo "${{ matrix.backend }} failed to become ready within timeout"
124+ curl -sS -v "http://$host:$port/_cluster/health" || true
125+ echo "Container logs:"
126+ docker ps -a
127+ docker logs $(docker ps -q --filter "ancestor=${{ matrix.backend == 'elasticsearch8' && 'docker.elastic.co/elasticsearch/elasticsearch:8.19.5' || 'opensearchproject/opensearch:2.12.0' }}" | head -1) || true
128+ exit 1
123129
124130 - name : Debug OpenSearch/Elasticsearch status
125131 run : |
0 commit comments