-
Notifications
You must be signed in to change notification settings - Fork 20
168 lines (144 loc) · 7.42 KB
/
external-opensearch-test.yml
File metadata and controls
168 lines (144 loc) · 7.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: External OpenSearch Test
on:
pull_request:
branches:
- main
- dev
paths:
- "Dockerfile"
- "src/**"
- "docker-compose*.yml"
- ".last_release"
- "pyproject.toml"
- "uv.lock"
- ".github/workflows/external-opensearch-test.yml"
jobs:
test-external-opensearch:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Read Photon version from .last_release
id: photon_version
run: |
PHOTON_VERSION=$(cat .last_release | tr -d '[:space:]')
if [[ -z "$PHOTON_VERSION" || ! "$PHOTON_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: .last_release is missing, empty, or contains an invalid version: '$PHOTON_VERSION'"
exit 1
fi
echo "PHOTON_VERSION=$PHOTON_VERSION" >> "$GITHUB_ENV"
echo "Photon Version: $PHOTON_VERSION"
- name: Build test image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
build-args: |
PHOTON_VERSION=${{ env.PHOTON_VERSION }}
push: false
load: true
tags: photon-test:ext-os-${{ github.event.pull_request.number }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Create Docker network
run: docker network create photon-ext-os-test
- name: Start OpenSearch
run: |
docker run -d \
--name opensearch-test \
--network photon-ext-os-test \
-p 9200:9200 \
-e "discovery.type=single-node" \
-e "DISABLE_SECURITY_PLUGIN=true" \
-e "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" \
opensearchproject/opensearch:3.0.0
- name: Wait for OpenSearch cluster health
run: |
echo "Waiting for OpenSearch cluster to be healthy (timeout: 120s)..."
SECONDS=0
TIMEOUT=120
while [ $SECONDS -lt $TIMEOUT ]; do
if curl -sf "http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=5s" > /dev/null 2>&1; then
echo "OpenSearch cluster is healthy after ${SECONDS}s"
curl -s "http://localhost:9200/_cluster/health" | python3 -m json.tool
break
fi
echo "Waiting for OpenSearch... (elapsed: ${SECONDS}s)"
sleep 5
SECONDS=$((SECONDS + 5))
done
if [ $SECONDS -ge $TIMEOUT ]; then
echo "OpenSearch failed to become healthy within ${TIMEOUT}s"
docker logs opensearch-test
exit 1
fi
- name: Import test data into OpenSearch via photon
run: |
# Create a minimal Nominatim dump file (JSONL format)
cat > /tmp/photon-dump.jsonl << 'DUMP'
{"type":"NominatimDumpFile","content":{"version":"0.1.0","data_timestamp":"2025-01-01T00:00:00Z"}}
{"type":"Place","place_id":1,"object_type":"R","object_id":9407,"osm_key":"place","osm_value":"country","name":{"default":"Andorra"},"country_code":"ad","centroid":[1.5218,42.5063],"importance":0.63527,"address_type":"country"}
{"type":"Place","place_id":2,"object_type":"N","object_id":4929848842,"osm_key":"place","osm_value":"city","name":{"default":"Andorra la Vella"},"country_code":"ad","centroid":[1.5209,42.5076],"importance":0.45,"address_type":"city","address":{"country":{"name":{"default":"Andorra"}}}}
DUMP
echo "Importing test data into OpenSearch using photon.jar..."
docker run --rm \
--network photon-ext-os-test \
--entrypoint java \
-v /tmp/photon-dump.jsonl:/tmp/dump.jsonl \
photon-test:ext-os-${{ github.event.pull_request.number }} \
--add-modules jdk.incubator.vector \
--enable-native-access=ALL-UNNAMED \
-jar /photon/photon.jar import \
-transport-addresses opensearch-test:9200 \
-import-file /tmp/dump.jsonl
echo "Import complete. Verifying index:"
curl -s "http://localhost:9200/_cat/indices?v"
curl -s "http://localhost:9200/photon/_count" | python3 -m json.tool
- name: Start photon container
run: |
docker run -d \
--name photon-ext-os-test \
--network photon-ext-os-test \
-e OPENSEARCH_TRANSPORT_ADDRESSES=opensearch-test:9200 \
photon-test:ext-os-${{ github.event.pull_request.number }}
- name: Wait for photon to be healthy
run: |
echo "Waiting for photon container to become healthy (timeout: 6 minutes)..."
CONTAINER_NAME=photon-ext-os-test
docker logs -f $CONTAINER_NAME &
LOGS_PID=$!
SECONDS=0
TIMEOUT=360
while [ $SECONDS -lt $TIMEOUT ]; do
HEALTH_STATUS=$(docker inspect --format='{{.State.Health.Status}}' $CONTAINER_NAME 2>/dev/null || echo "unknown")
if [ "$HEALTH_STATUS" = "healthy" ]; then
echo "Photon container is healthy after $SECONDS seconds"
kill $LOGS_PID 2>/dev/null || true
exit 0
fi
echo "Health status: $HEALTH_STATUS (elapsed: ${SECONDS}s)"
sleep 10
SECONDS=$((SECONDS + 10))
done
kill $LOGS_PID 2>/dev/null || true
echo "Photon container failed to become healthy within $TIMEOUT seconds"
docker logs $CONTAINER_NAME
exit 1
- name: Cleanup
if: always()
run: |
docker stop photon-ext-os-test opensearch-test 2>/dev/null || true
docker rm photon-ext-os-test opensearch-test 2>/dev/null || true
docker network rm photon-ext-os-test 2>/dev/null || true
docker rmi photon-test:ext-os-${{ github.event.pull_request.number }} 2>/dev/null || true
- name: Output summary
if: always()
run: |
echo "## External OpenSearch Test Summary" >> $GITHUB_STEP_SUMMARY
echo "- **PR Number:** ${{ github.event.pull_request.number }}" >> $GITHUB_STEP_SUMMARY
echo "- **Photon Version:** ${{ env.PHOTON_VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- **OpenSearch Version:** 3.0.0" >> $GITHUB_STEP_SUMMARY
echo "- **Status:** ${{ job.status }}" >> $GITHUB_STEP_SUMMARY