-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add sql-query test environment documentation (#43)
- Loading branch information
1 parent
48f7c29
commit c4aa04d
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
## Local setup for SQL query testing | ||
|
||
### Requirements | ||
|
||
- Docker | ||
- HTTP Client of your choice | ||
- Access to ghcr.io with permissions for Aam Digital private repositories | ||
|
||
### Start containers | ||
|
||
Take a look into the `docker-compose.yml` and adapt the file if necessary. | ||
|
||
If you're on an ARM based system, you need to enable for the SQS container: | ||
|
||
- `platform: linux/amd64` | ||
|
||
#### Authorization ghcr.io | ||
SQS is not open source and only available to developers of the Aam Digital team through a private docker image. | ||
|
||
You will need to do a `docker login` for ghcr.io, to be able to fetch sqs image. | ||
|
||
See [GitHub Documentation](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry) for details. | ||
|
||
### Access CouchDb web interface | ||
|
||
You can access the CouchDb webinterface here: http://localhost:5984/_utils/ | ||
|
||
The default credentials are: | ||
|
||
username: `admin` | ||
password: `docker` | ||
|
||
### Using existing Database | ||
|
||
If you have a copy from an existing database, stop the couchdb container and just copy all files from the `couchdb/data` directory | ||
into your mapped couchdb volume. | ||
The default mapping is: `~/docker-volumes/aam-digital/db-couch/document-data:/opt/couchdb/data` | ||
|
||
Then start the couchdb container again. Nothing more to do. | ||
|
||
### Running SQL queries against SQS | ||
|
||
To run a Query, you can use the POST endpoint: `http://localhost:4984/app/_design/sqlite:config` | ||
|
||
Note that the query payload you send here is _not_ the ReportConfig entity used within Aam Digital but the raw SQS payload as shown in the example below. | ||
|
||
#### Authentication | ||
|
||
You need to set a 'basic auth' Authorization-Header with the couchdb credentials. | ||
|
||
#### Example | ||
|
||
```curl | ||
## Example Request | ||
curl -X "POST" "http://localhost:4984/app/_design/sqlite:config" \ | ||
-H 'Content-Type: application/json; charset=utf-8' \ | ||
-u 'admin:docker' \ | ||
-d $'{ | ||
"query": "SELECT count(*) FROM School", | ||
"args": [] | ||
}' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# *************************************************************** | ||
# start local development environment for SQL query testing | ||
# *************************************************************** | ||
name: aam-services-sql-environment | ||
services: | ||
db-couch: | ||
image: couchdb:3.4 | ||
volumes: | ||
- ~/docker-volumes/aam-digital/db-couch/document-data:/opt/couchdb/data | ||
environment: | ||
COUCHDB_USER: admin | ||
COUCHDB_PASSWORD: docker | ||
COUCHDB_SECRET: docker | ||
ports: | ||
- "5984:5984" | ||
|
||
sqs: | ||
image: ghcr.io/aam-digital/aam-sqs-linux:latest | ||
# platform: linux/amd64 | ||
depends_on: | ||
- db-couch | ||
ports: | ||
- "4984:4984" | ||
volumes: | ||
- ~/docker-volumes/aam-digital/sqs/data:/data | ||
environment: | ||
SQS_COUCHDB_URL: http://db-couch:5984 |