Skip to content

Commit b5de449

Browse files
authored
Merge pull request #1 from efrain-mejia/29-changes
java version update & debian
2 parents 7dedd79 + 56d3608 commit b5de449

25 files changed

+184187
-23607
lines changed

.dockerignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Build outputs
2+
build/
3+
target/
4+
*.war
5+
*.jar
6+
7+
# Gradle cache and wrapper cache
8+
.gradle/
9+
gradle/caches/
10+
11+
# IDE files
12+
.idea/
13+
*.iml
14+
.vscode/
15+
.eclipse/
16+
17+
# Version control
18+
.git/
19+
.gitignore
20+
21+
# Documentation
22+
*.md
23+
LICENSE
24+
25+
# Docker files
26+
docker-compose*.yml
27+
Dockerfile
28+
29+
# Environment files
30+
*.env
31+
.env*
32+
33+
# Logs
34+
*.log
35+
36+
# OS files
37+
.DS_Store
38+
Thumbs.db
39+
40+
# Temporary files
41+
tmp/
42+
temp/

.github/workflows/pr-test.yml

Lines changed: 336 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,336 @@
1+
name: PR Tests
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
test-all-lookup-types:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v4
17+
with:
18+
java-version: '17'
19+
distribution: 'temurin'
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '18'
25+
26+
- name: Clone and build web-api-commander
27+
run: |
28+
echo "Cloning web-api-commander repository..."
29+
git clone https://github.com/RESOStandards/web-api-commander.git ../web-api-commander
30+
cd ../web-api-commander
31+
echo "Building web-api-commander..."
32+
chmod +x gradlew
33+
./gradlew build -x test
34+
echo "Web-api-commander built successfully"
35+
36+
- name: Install reso-certification-utils
37+
run: |
38+
echo "Installing reso-certification-utils..."
39+
npm install -g RESOStandards/reso-certification-utils
40+
echo "Verifying installation..."
41+
reso-certification-utils --help
42+
43+
- name: Create refServLocal.json configuration
44+
run: |
45+
echo "Creating refServLocal.json for ${{ matrix.user_config.config_name }}..."
46+
cat > refServLocal.json << EOF
47+
{
48+
"providerUoi": "providerUoi",
49+
"configs": [
50+
{
51+
"serviceRootUri": "http://localhost:8080/core/2.0.0/",
52+
"recipientUoi": "recipientUoi",
53+
"providerUsi": "providerUsi",
54+
"token": "reso-test-token"
55+
}
56+
]
57+
}
58+
EOF
59+
60+
- name: Create base environment files
61+
run: |
62+
echo "Creating base .env file..."
63+
cat > .env << 'EOF'
64+
# Database Configuration
65+
DB_TYPE=mongodb
66+
MONGO_SYNC_CONNECTION_STR=mongodb://mongo-db:27017/reso
67+
MONGO_DATABASE=reso
68+
MYSQL_HOST=mysql-db
69+
MYSQL_DATABASE=reso
70+
MYSQL_USER=root
71+
MYSQL_PASSWORD=root
72+
MYSQL_URL=jdbc:mysql://${MYSQL_HOST}:3306/${MYSQL_DATABASE}?autoReconnect=true&maxReconnects=4
73+
74+
# Lookup Configuration
75+
LOOKUP_TYPE=STRING
76+
77+
# Other Configuration
78+
CERT_REPORT_FILENAME=RESODataDictionary-2.0.metadata-report.json
79+
80+
# JWT Secret
81+
JWT_SECRET=${{ secrets.JWT_SECRET }}
82+
EOF
83+
84+
- name: Set environment variables
85+
run: |
86+
echo "WEB_API_COMMANDER_PATH=$GITHUB_WORKSPACE/../web-api-commander" >> $GITHUB_ENV
87+
88+
- name: Build the project
89+
run: |
90+
echo "######################################################"
91+
echo "Starting project build with docker-compose..."
92+
echo "######################################################"
93+
echo "Build started at: $(date)"
94+
echo "Working directory: $(pwd)"
95+
echo "Docker version: $(docker --version)"
96+
echo "Docker compose version: $(docker compose version)"
97+
98+
# Start the build and capture both stdout and stderr
99+
echo "Executing: docker compose -f docker-compose.builder.yml --project-name builder-stack up --build"
100+
101+
if docker compose -f docker-compose.builder.yml --project-name builder-stack up --build; then
102+
echo "✅ BUILD SUCCESS: Docker compose build completed successfully"
103+
echo "Build completed at: $(date)"
104+
105+
# Show what was built
106+
echo "Checking build artifacts..."
107+
ls -la build/libs/ 2>/dev/null || echo "No build/libs directory found yet"
108+
109+
# Show running containers
110+
echo "Running containers:"
111+
docker ps
112+
113+
# Show container logs
114+
echo "Container logs:"
115+
docker compose -f docker-compose.builder.yml --project-name builder-stack logs
116+
117+
else
118+
echo "❌ BUILD FAILED: Docker compose build failed"
119+
echo "Build failed at: $(date)"
120+
echo "Exit code: $?"
121+
122+
# Show container logs for debugging
123+
echo "Container logs for debugging:"
124+
docker compose -f docker-compose.builder.yml --project-name builder-stack logs || true
125+
126+
# Show docker status
127+
echo "Docker status:"
128+
docker ps -a
129+
130+
exit 1
131+
fi
132+
133+
- name: Grant execute permission for gradlew and fix permissions
134+
run: |
135+
chmod +x gradlew
136+
sudo rm -rf .gradle
137+
sudo chown -R $USER:$USER . || true
138+
139+
- name: Verify environment setup
140+
run: |
141+
echo "Verifying .env file contents:"
142+
cat .env
143+
echo "Build artifacts:"
144+
ls -la build/libs/ || echo "No build/libs directory found"
145+
146+
- name: Start server and verify API endpoints
147+
run: |
148+
echo "=== Starting server with docker compose ==="
149+
echo "Server startup initiated at: $(date)"
150+
151+
# Start the server in detached mode
152+
docker compose up -d
153+
154+
echo "Waiting for server to be ready..."
155+
156+
# Wait for health endpoint to return 200
157+
max_attempts=30
158+
attempt=1
159+
while [ $attempt -le $max_attempts ]; do
160+
echo "Health check attempt $attempt/$max_attempts..."
161+
162+
if response=$(curl -s -w "%{http_code}" -o /tmp/health_response.txt http://localhost:8080/core/health 2>/dev/null); then
163+
http_code="${response: -3}"
164+
response_body=$(cat /tmp/health_response.txt)
165+
166+
echo "Health check response code: $http_code"
167+
echo "Health check response body: $response_body"
168+
169+
if [ "$http_code" = "200" ]; then
170+
echo "✅ Health check successful at $(date)"
171+
break
172+
fi
173+
else
174+
echo "Health check request failed"
175+
fi
176+
177+
if [ $attempt -eq $max_attempts ]; then
178+
echo "❌ Health check failed after $max_attempts attempts"
179+
echo "Container logs:"
180+
docker compose logs
181+
exit 1
182+
fi
183+
184+
echo "Waiting 10 seconds before next attempt..."
185+
sleep 10
186+
((attempt++))
187+
done
188+
189+
echo "=== Testing API endpoint ==="
190+
191+
# Test the Property endpoint with bearer token
192+
echo "Making API request to Property endpoint..."
193+
api_response=$(curl -s -w "%{http_code}" -H "Authorization: Bearer reso-test-token" \
194+
-o /tmp/api_response.txt \
195+
"http://localhost:8080/core/2.0.0/Property?\$top=1&\$count=true" 2>/dev/null || echo "000")
196+
197+
api_http_code="${api_response: -3}"
198+
api_response_body=$(cat /tmp/api_response.txt)
199+
200+
echo "API request status code: $api_http_code"
201+
echo "API response body: $api_response_body"
202+
203+
if [ "$api_http_code" = "200" ]; then
204+
echo "✅ API test successful at $(date)"
205+
else
206+
echo "⚠️ API test returned status code: $api_http_code"
207+
echo "This may be expected depending on server configuration"
208+
209+
echo "=== DEBUG INFORMATION ==="
210+
echo "Gathering debug information for MongoDB connection issue..."
211+
212+
echo "--- Docker container status ---"
213+
docker ps -a
214+
215+
echo "--- Environment variables in use ---"
216+
echo "DB_TYPE: $DB_TYPE"
217+
echo "MONGO_DATABASE: $MONGO_DATABASE"
218+
echo "MONGO_SYNC_CONNECTION_STR: $MONGO_SYNC_CONNECTION_STR"
219+
220+
echo "--- Docker compose services ---"
221+
docker compose ps
222+
223+
echo "--- Container environment variables ---"
224+
echo "Current .env file contents:"
225+
cat .env | grep -E "(MONGO|DB_|LOOKUP)" || echo "No matching env vars in .env file"
226+
227+
echo "App container env vars (trying different service names):"
228+
docker compose exec -T odata-manager-app env | grep -E "(MONGO|DB_|LOOKUP)" 2>/dev/null || \
229+
docker compose exec -T app env | grep -E "(MONGO|DB_|LOOKUP)" 2>/dev/null || \
230+
echo "Failed to get app container env vars - service name unknown"
231+
232+
echo "--- MongoDB container logs ---"
233+
docker compose logs mongo-db || echo "No mongo-db container found"
234+
235+
echo "--- App container logs (last 300 lines) ---"
236+
docker compose logs --tail=300 odata-manager-app || \
237+
docker compose logs --tail=300 app || \
238+
echo "Failed to get app container logs"
239+
240+
echo "--- Java system properties and environment inside container ---"
241+
docker compose exec -T odata-manager-app java -XshowSettings:properties -version 2>/dev/null || \
242+
docker compose exec -T app java -XshowSettings:properties -version 2>/dev/null || \
243+
echo "Failed to get Java system properties"
244+
245+
echo "--- MongoDB connection debugging ---"
246+
echo "Checking if MongoDB host is resolvable from app container:"
247+
docker compose exec -T odata-manager-app nslookup mongo-db 2>/dev/null || \
248+
docker compose exec -T app nslookup mongo-db 2>/dev/null || \
249+
echo "DNS lookup failed"
250+
251+
echo "Testing direct MongoDB connection from app container:"
252+
docker compose exec -T odata-manager-app nc -zv mongo-db 27017 2>/dev/null || \
253+
docker compose exec -T app nc -zv mongo-db 27017 2>/dev/null || \
254+
echo "Direct connection test failed"
255+
256+
echo "--- Network connectivity test ---"
257+
echo "Testing connectivity from app to mongo-db..."
258+
docker compose exec -T odata-manager-app ping -c 3 mongo-db 2>/dev/null || \
259+
docker compose exec -T app ping -c 3 mongo-db 2>/dev/null || \
260+
echo "Ping test failed - could not find correct service name"
261+
262+
echo "--- MongoDB connection test ---"
263+
echo "Testing MongoDB connection directly..."
264+
docker compose exec -T mongo-db mongosh --eval "db.adminCommand('ping')" || echo "MongoDB connection test failed"
265+
266+
echo "=== END DEBUG INFORMATION ==="
267+
fi
268+
269+
echo "Server verification completed at: $(date)"
270+
271+
echo "=== Cleaning up server ==="
272+
docker compose down --volumes --remove-orphans
273+
echo "Server cleanup completed at: $(date)"
274+
275+
- name: Run LookupStringTest
276+
run: |
277+
echo "=== LookupStringTest ==="
278+
echo "Test started at: $(date)"
279+
# Update only LOOKUP_TYPE in existing .env file
280+
sed -i 's/LOOKUP_TYPE=.*/LOOKUP_TYPE=STRING/' .env
281+
echo "Updated LOOKUP_TYPE to STRING"
282+
283+
if LOOKUP_TYPE=STRING ./gradlew test --tests org.reso.tests.LookupStringTest --info; then
284+
echo "✅ LookupStringTest PASSED at $(date)"
285+
else
286+
echo "❌ LookupStringTest FAILED at $(date)"
287+
exit 1
288+
fi
289+
290+
- name: Run LookupEnumFlagsTest
291+
run: |
292+
echo "=== LookupEnumFlagsTest ==="
293+
echo "Test started at: $(date)"
294+
# Update only LOOKUP_TYPE in existing .env file
295+
sed -i 's/LOOKUP_TYPE=.*/LOOKUP_TYPE=ENUM_FLAGS/' .env
296+
echo "Updated LOOKUP_TYPE to ENUM_FLAGS"
297+
298+
if LOOKUP_TYPE=ENUM_FLAGS ./gradlew test --tests org.reso.tests.LookupEnumFlagsTest --info; then
299+
echo "✅ LookupEnumFlagsTest PASSED at $(date)"
300+
else
301+
echo "❌ LookupEnumFlagsTest FAILED at $(date)"
302+
exit 1
303+
fi
304+
305+
- name: Run LookupEnumTest
306+
run: |
307+
echo "=== LookupEnumTest ==="
308+
echo "Test started at: $(date)"
309+
# Update only LOOKUP_TYPE in existing .env file
310+
sed -i 's/LOOKUP_TYPE=.*/LOOKUP_TYPE=ENUM_COLLECTION/' .env
311+
echo "Updated LOOKUP_TYPE to ENUM_COLLECTION"
312+
313+
if LOOKUP_TYPE=ENUM_COLLECTION ./gradlew test --tests org.reso.tests.LookupEnumTest --info; then
314+
echo "✅ LookupEnumTest PASSED at $(date)"
315+
else
316+
echo "❌ LookupEnumTest FAILED at $(date)"
317+
exit 1
318+
fi
319+
320+
- name: Final cleanup
321+
if: always()
322+
run: |
323+
echo "Performing final cleanup of Docker containers..."
324+
docker compose down --volumes --remove-orphans || true
325+
echo "Final cleanup completed"
326+
327+
- name: Upload test results
328+
if: always()
329+
uses: actions/upload-artifact@v4
330+
with:
331+
name: test-results
332+
path: |
333+
build/test-results/
334+
build/reports/
335+
results/
336+
retention-days: 7

0 commit comments

Comments
 (0)