Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output/
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Dockerfile

# Use the official citydb-tool image as our starting point
FROM 3dcitydb/citydb-tool:latest

# Switch to the root user to be able to install packages
USER root

# Update the package list and install the PostgreSQL client (which includes psql)
RUN apt-get update && \
apt-get install -y --no-install-recommends postgresql-client && \
rm -rf /var/lib/apt/lists/*
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,49 @@ citydb-tool and integration tests for interactions between modules.

This README provides a roadmap for establishing a robust testing foundation for 3DCityDB 5.0 and the citydb-tool. By
starting with essential scenarios in a controlled Docker environment, we can systematically build a comprehensive and
reliable test suite.
reliable test suite.

## 7. Executing the Test Suite

This section provides instructions on how to run the automated tests using Docker Compose.

### Prerequisites
Before running the tests, ensure you have the following installed on your system:

- Docker
- Docker Compose

### Running the Full Test Suite
The easiest way to run all tests in the correct sequence (import, then export) is to use the default test-all service.

From the root directory of the project, run the following command:

```bash
docker compose up --build --exit-code-from test-all
```
- --build: This flag tells Docker Compose to build the custom tester image from the Dockerfile if it doesn't exist or if the Dockerfile has changed.
- --exit-code-from test-all: This makes the command exit with the same code as the test-all container. This is crucial for automation, as it will return a non-zero code if any test fails, signaling a failure in a CI/CD pipeline.

### Running Individual Tests
You can run specific tests individually using Docker Compose profiles. This is useful for debugging a particular feature without running the entire suite.

To run only the import test:
```Bash

docker compose --profile import up --build --exit-code-from test-import
```
To run only the export test:
This assumes the database already contains data from a previous import.

```Bash

docker compose --profile export up --build --exit-code-from test-export
```
### Cleaning Up the Environment
After a test run, you can completely remove all containers, networks, and the database volume to ensure a clean state for the next run.

```Bash

docker compose down -v
```
The -v flag is important as it removes the named volume containing the PostgreSQL data. Without it, the data would persist between runs.
31 changes: 31 additions & 0 deletions config/config_citygml_export.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"databaseOptions": {
"connections": {
"defaultConnectionId": {
"description": "Default database connection",
"user": "citydb",
"password": "test",
"host": "db",
"port": 5432,
"database": "citydb",
"srid": 25832
}
},
"defaultConnectionId": "defaultConnectionId"
},
"exportOptions": {
"query": {
"filterSrs": {
"srid": 25832
}
}
},
"readOptions": {},
"writeOptions": {
"formatOptions": {
"CityGML": {
"version": "3.0"
}
}
}
}
18 changes: 18 additions & 0 deletions config/config_citygml_import.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"databaseOptions": {
"connections": {
"defaultConnectionId": {
"description": "Default database connection",
"user": "citydb",
"password": "test",
"host": "db",
"port": 5432,
"database": "citydb",
"srid": 25832
}
},
"defaultConnectionId": "defaultConnectionId"
},
"importOptions": {
}
}
654,696 changes: 654,696 additions & 0 deletions data/Railway_Scene/Railway_Scene_LoD3.gml

Large diffs are not rendered by default.

Binary file added data/Railway_Scene/appearance/Asphalt_New.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/Railway_Scene/appearance/Asphalt_New_CF.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/Railway_Scene/appearance/Bruecke-Beton.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/Railway_Scene/appearance/Bruecken-Metall.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/Railway_Scene/appearance/MaerZ-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/Railway_Scene/appearance/MaerZ-0_CF.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/Railway_Scene/appearance/Meran_03rh 10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/Railway_Scene/appearance/Metal-Sheet-KIT.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/Railway_Scene/appearance/Metal_Panel.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/Railway_Scene/appearance/Metal_Rough_CF.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/Railway_Scene/appearance/Metal_Rusted.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/Railway_Scene/appearance/Metal_Rusted_CF.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/Railway_Scene/appearance/Water_Sparkling.jpg
Binary file added data/Railway_Scene/appearance/granit-128x128.jpg
Binary file added data/Railway_Scene/appearance/wand_18-128-128.jpg
Binary file added data/Railway_Scene/appearance/wand_25-128x128.jpg
57 changes: 57 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: '3.8'

x-tester-base: &tester-base
build:
context: .
dockerfile: Dockerfile
volumes:
- ./data:/data
- ./output:/output
- ./config:/config
- ./scripts:/scripts
depends_on:
db:
condition: service_healthy

# ---------------------------------------------------------------------------
# --- SERVICE DEFINITIONS ---
# These are the actual services that Docker will run.
# ---------------------------------------------------------------------------
services:
db:
image: 3dcitydb/3dcitydb-pg
environment:
- POSTGRES_USER=citydb
- POSTGRES_PASSWORD=test
- POSTGRES_DB=citydb
- SRID=25832
volumes:
- citydb_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U citydb -d citydb"]
interval: 5s
timeout: 5s
retries: 5

# Default service to run all tests
test-all:
<<: *tester-base
entrypoint: /bin/bash
command: /scripts/run_all_tests.sh

# Service to run only the IMPORT test
test-import:
<<: *tester-base
profiles: ["import"]
entrypoint: /bin/bash
command: /scripts/test_import.sh

# Service to run only the EXPORT test
test-export:
<<: *tester-base
profiles: ["export"]
entrypoint: /bin/bash
command: /scripts/test_export.sh

volumes:
citydb_data:
20 changes: 20 additions & 0 deletions scripts/run_all_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# This script acts as a master test runner.
set -e

echo "============================"
echo " STARTING FULL TEST SUITE "
echo "============================"

echo ""
echo "--- Running Import Test ---"
/scripts/test_import.sh

echo ""
echo "--- Running Export Test ---"
/scripts/test_export.sh

echo ""
echo "============================"
echo " FULL TEST SUITE PASSED! "
echo "============================"
32 changes: 32 additions & 0 deletions scripts/test_export.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e

CONFIG_FILE="/config/config_citygml_export.json"
OUTPUT_FILE="/output/exported_railway.gml"

echo "🧪 Running EXPORT test..."
echo "-------------------------------------------"

citydb --config $CONFIG_FILE export citygml -o $OUTPUT_FILE
echo "✔️ Export command finished."

echo "▶️ Verifying export by checking the output file size..."

# Define a minimum file size threshold in bytes (e.g., 3 KB -> if 0 Features are exported)
THRESHOLD=3072

if [ -f "$OUTPUT_FILE" ]; then
# Get the actual file size in bytes
FILESIZE=$(stat -c %s "$OUTPUT_FILE")

if [ $FILESIZE -gt $THRESHOLD ]; then
echo "✔️ Verification successful: Output file created with size ${FILESIZE} bytes (greater than ${THRESHOLD} bytes)."
echo "🎉 EXPORT TEST SUCCEEDED! 🎉"
else
echo "❌ Verification FAILED: Output file size is ${FILESIZE} bytes, which is not greater than the threshold of ${THRESHOLD} bytes."
exit 1
fi
else
echo "❌ Verification FAILED: Output file not found."
exit 1
fi
24 changes: 24 additions & 0 deletions scripts/test_import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -e

CONFIG_FILE="/config/config_citygml_import.json"
INPUT_FILE="/data/Railway_Scene/Railway_Scene_LoD3.gml"

echo "🧪 Running IMPORT test..."
echo "-------------------------------------------"

citydb --config $CONFIG_FILE import citygml $INPUT_FILE
echo "✔️ Import command finished."

echo "▶️ Verifying import by querying the feature table..."
export PGPASSWORD=test
COUNT=$(psql -h db -U citydb -d citydb -t -c "SELECT count(*) FROM feature;")
COUNT=$(echo $COUNT | xargs)

if [ "$COUNT" -gt 0 ]; then
echo "✔️ Verification successful: Found $COUNT features."
echo "🎉 IMPORT TEST SUCCEEDED! 🎉"
else
echo "❌ Verification FAILED: No features found."
exit 1
fi