-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
179 additions
and
3 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
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.
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 @@ | ||
<!-- | ||
This file contains [mermaid](https://mermaid.js.org) diagrams. | ||
In VSCode: | ||
* install `bierner.markdown-mermaid` to have easy preview. | ||
* install `bpruitt-goddard.mermaid-markdown-syntax-highlighting` for syntax highlighting. | ||
To Export: | ||
* npm install -g @mermaid-js/mermaid-cli | ||
* mmdc -i arch.template.md -o arch.md | ||
Syntax, see https://mermaid.js.org/syntax/entityRelationshipDiagram.html | ||
--> | ||
|
||
# IntegreSQL Architecture | ||
|
||
## Pool structure | ||
|
||
The following describes the relationship between the components of IntegreSQL. | ||
|
||
![diagram](./arch-1.svg) | ||
|
||
## TestDatabase states | ||
|
||
The following describes the state and transitions of a TestDatabase. | ||
|
||
![diagram](./arch-2.svg) |
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,70 @@ | ||
<!-- | ||
This file contains [mermaid](https://mermaid.js.org) diagrams. | ||
In VSCode: | ||
* install `bierner.markdown-mermaid` to have easy preview. | ||
* install `bpruitt-goddard.mermaid-markdown-syntax-highlighting` for syntax highlighting. | ||
To Export: | ||
* npm install -g @mermaid-js/mermaid-cli | ||
* mmdc -i arch.template.md -o arch.md | ||
Syntax, see https://mermaid.js.org/syntax/entityRelationshipDiagram.html | ||
--> | ||
|
||
# IntegreSQL Architecture | ||
|
||
## Pool structure | ||
|
||
The following describes the relationship between the components of IntegreSQL. | ||
|
||
```mermaid | ||
erDiagram | ||
Server ||--o| Manager : owns | ||
Manager { | ||
Template[] templateCollection | ||
HashPool[] poolCollection | ||
} | ||
Manager ||--o{ HashPool : has | ||
Manager ||--o{ Template : has | ||
Template { | ||
TemplateDatabase database | ||
} | ||
HashPool { | ||
TestDatabase database | ||
} | ||
HashPool ||--o{ TestDatabase : "manages" | ||
Template ||--|| TemplateDatabase : "sets" | ||
TestDatabase { | ||
int ID | ||
Database database | ||
} | ||
TemplateDatabase { | ||
Database database | ||
} | ||
Database { | ||
string TemplateHash | ||
Config DatabaseConfig | ||
} | ||
TestDatabase o|--|| Database : "is" | ||
TemplateDatabase o|--|| Database : "is" | ||
``` | ||
|
||
## TestDatabase states | ||
|
||
The following describes the state and transitions of a TestDatabase. | ||
|
||
```mermaid | ||
stateDiagram-v2 | ||
HashPool --> TestDatabase: Task EXTEND | ||
state TestDatabase { | ||
[*] --> ready: init | ||
ready --> dirty: GetTestDatabase() | ||
dirty --> ready: ReturnTestDatabase() | ||
dirty --> recreating: RecreateTestDatabase()\nTask CLEAN_DIRTY | ||
recreating --> ready: generation++ | ||
recreating --> recreating: retry (still in use) | ||
} | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,19 @@ | ||
<!-- | ||
This file contains [mermaid](https://mermaid.js.org) diagrams. | ||
In VSCode: | ||
* install `bierner.markdown-mermaid` to have easy preview. | ||
* install `bpruitt-goddard.mermaid-markdown-syntax-highlighting` for syntax highlighting. | ||
To Export: | ||
* npm install -g @mermaid-js/mermaid-cli | ||
* mmdc -i integration.template.md -o integration.md | ||
Syntax, see https://mermaid.js.org/syntax/entityRelationshipDiagram.html | ||
--> | ||
|
||
# Integrate via REST API | ||
|
||
## Once per test runner/process: | ||
|
||
![diagram](./integration-1.svg) |
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,57 @@ | ||
<!-- | ||
This file contains [mermaid](https://mermaid.js.org) diagrams. | ||
In VSCode: | ||
* install `bierner.markdown-mermaid` to have easy preview. | ||
* install `bpruitt-goddard.mermaid-markdown-syntax-highlighting` for syntax highlighting. | ||
To Export: | ||
* npm install -g @mermaid-js/mermaid-cli | ||
* mmdc -i integration.template.md -o integration.md | ||
Syntax, see https://mermaid.js.org/syntax/entityRelationshipDiagram.html | ||
--> | ||
|
||
# Integrate via REST API | ||
|
||
## Once per test runner/process: | ||
|
||
```mermaid | ||
sequenceDiagram | ||
You->>Testrunner: make test | ||
Note right of Testrunner: Compute a migrations/fixtures files hash over all related database files | ||
Testrunner->>IntegreSQL: InitializeTemplate: POST /api/v1/templates | ||
Note over Testrunner,IntegreSQL: Create a new PostgreSQL template database<br/> identified a the same unique hash <br/>payload: {"hash": "string"} | ||
IntegreSQL->>PostgreSQL: CREATE DATABASE <br/>template_<hash> | ||
PostgreSQL-->>IntegreSQL: | ||
IntegreSQL-->>Testrunner: StatusOK: 200 | ||
Note over Testrunner,PostgreSQL: Parse the received database connection payload and connect to the template database. | ||
Testrunner->>PostgreSQL: Truncate, apply all migrations, seed all fixtures, ..., disconnect. | ||
PostgreSQL-->>Testrunner: | ||
Note over Testrunner,IntegreSQL: Finalize the template so it can be used! | ||
Testrunner->>IntegreSQL: FinalizeTemplate: PUT /api/v1/templates/:hash | ||
IntegreSQL-->>Testrunner: StatusOK: 200 | ||
Note over Testrunner,IntegreSQL: You can now get isolated test databases from the pool! | ||
Note over Testrunner,IntegreSQL: In case you have multiple testrunners/processes <br/>and call with the same template hash again | ||
Testrunner->>IntegreSQL: InitializeTemplate: POST /api/v1/templates | ||
IntegreSQL-->>Testrunner: StatusLocked: 423 | ||
Note over Testrunner,IntegreSQL: Some other process has already recreated <br/> a PostgreSQL template database for this hash<br/> (or is currently doing it), you can just consider<br/> the template ready at this point. | ||
IntegreSQL-->>Testrunner: StatusServiceUnavailable: 503 | ||
Note over Testrunner,IntegreSQL: Typically happens if IntegreSQL cannot communicate with<br/>PostgreSQL, fail the test runner process | ||
``` |