Skip to content

Commit

Permalink
migrate server to postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
Yalz committed May 22, 2024
1 parent c1370cd commit c813478
Show file tree
Hide file tree
Showing 28 changed files with 455 additions and 224 deletions.
13 changes: 0 additions & 13 deletions cypress/support/services/mongo-rest-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,4 @@ export class MongoRestApi {
.then(response => response.body)
.then((result: CountResult) => result.count);
}

private documentIds(database: string, document: string) {
return cy.request(`${this.baseUrl}/${database}/${document}?includeIds=true`)
.then(response => response.body && (response.body.ids as string[]));
}

fragmentIds(database: string) {
return this.documentIds(database, 'fragmentation_fragment');
}

snapshotIds(database: string) {
return this.documentIds(database, 'snapshot');
}
}
15 changes: 3 additions & 12 deletions cypress/support/services/postgres-rest-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import { timeouts } from "../common";

type CountResult = { count: number, ids: string[] };

type FragmentInfo = { _id: string, nrOfMembersAdded: number }
type DocumentResult = { count: number, documents: FragmentInfo[] };

export class PostgresRestApi {

constructor(public baseUrl: string) { }

checkCount(collection: string, count: number, checkFn: (actual: number, expected: number) => boolean = (x, y) => x === y) {
Expand All @@ -28,18 +26,11 @@ export class PostgresRestApi {

private hasCount(collection: string, count: number, checkFn: (actual: number, expected: number) => boolean) {
return cy.request(`${this.baseUrl}/${collection}`)
.then(response => response.body)
.then((result: CountResult) => cy.log('Actual count: ' + result.count).then(() => checkFn(result.count , count)));
.then((response => cy.log('Actual count: ' + response.body.length).then(() => checkFn(response.body.length , count))));
}

count(collection: string) {
return cy.request(`${this.baseUrl}/${collection}`)
.then(response => response.body)
.then((result: CountResult) => result.count);
}

private documentIds(document: string) {
return cy.request(`${this.baseUrl}/${document}?includeIds=true`)
.then(response => response.body && (response.body.ids as string[]));
.then(response => response.body.length);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ management:
ldes-server:
host-name: http://localhost:8080
spring:
data:
mongodb:
database: iow
host: ldes-mongodb
port: 27017
datasource:
url: jdbc:postgresql://ldes-postgres:5432/test
username: admin
password: admin
jpa:
hibernate:
ddl-auto: update
44 changes: 29 additions & 15 deletions tests/014.workbench-ngsi-v2-to-ngsi-ld/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ services:
profiles:
- delay-started

ldes-mongodb:
container_name: ${USECASE_NAME:-iow-context}_ldes-mongodb
image: mongo:${MONGODB_TAG:-latest}
ports:
- ${MONGODB_PORT:-27017}:27017
networks:
- ldes

ldes-server:
container_name: ${USECASE_NAME:-iow-context}_ldes-server
image: ${LDES_SERVER:-ghcr.io/informatievlaanderen/ldes-server}:${LDES_SERVER_TAG:-latest}
Expand All @@ -70,16 +62,38 @@ services:
networks:
- ldes
depends_on:
- ldes-mongodb
- ldes-postgres

mongodb-rest-api:
container_name: ${USECASE_NAME:-iow-context}_mongodb-rest-api
image: ghcr.io/informatievlaanderen/mongodb-rest-api:${MONGODB_REST_API_TAG:-latest}
ldes-postgres:
container_name: ldes-postgres
image: postgres:14-alpine
ports:
- "5432:5432"
environment:
- SILENT=false
- CONNECTION_URI=mongodb://ldes-mongodb:27017
- POSTGRES_PASSWORD=admin
- POSTGRES_USER=admin
- POSTGRES_DB=test
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U admin -d test" ]
interval: 5s
timeout: 5s
retries: 5
restart: always
networks:
- ldes

postgrest:
container_name: postgres-rest-api
image: postgrest/postgrest:latest
ports:
- ${MONGODB_REST_API_PORT:-9019}:80
- "9018:3000"
environment:
- PGRST_DB_URI=postgres://admin:admin@ldes-postgres:5432/test
- PGRST_DB_ANON_ROLE=admin
- PGRST_OPENAPI_SERVER_PROXY_URI=http://localhost:9018

depends_on:
- ldes-postgres
networks:
- ldes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ management:
ldes-server:
host-name: http://localhost:8080
spring:
data:
mongodb:
database: iow
host: ldes-mongodb
port: 27017
datasource:
url: jdbc:postgresql://ldes-postgres:5432/test
username: admin
password: admin
jpa:
hibernate:
ddl-auto: update
46 changes: 30 additions & 16 deletions tests/015.nifi-workbench-ngsi-v2-to-oslo/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ services:
networks:
- ldes

ldes-mongodb:
container_name: ${USECASE_NAME:-iow-oslo-compliancy}_ldes-mongodb
image: mongo:${MONGODB_TAG:-latest}
ports:
- ${MONGODB_PORT:-27017}:27017
networks:
- ldes

ldes-server:
container_name: ${USECASE_NAME:-iow-oslo-compliancy}_ldes-server
image: ${LDES_SERVER:-ghcr.io/informatievlaanderen/ldes-server}:${LDES_SERVER_TAG:-latest}
Expand All @@ -53,18 +45,40 @@ services:
networks:
- ldes
depends_on:
- ldes-mongodb
- ldes-postgres

mongodb-rest-api:
container_name: ${USECASE_NAME:-iow-oslo-compliancy}_mongodb-rest-api
image: ghcr.io/informatievlaanderen/mongodb-rest-api:${MONGODB_REST_API_TAG:-latest}
ldes-postgres:
container_name: ldes-postgres
image: postgres:14-alpine
ports:
- "5432:5432"
environment:
- SILENT=false
- CONNECTION_URI=mongodb://ldes-mongodb:27017
- POSTGRES_PASSWORD=admin
- POSTGRES_USER=admin
- POSTGRES_DB=test
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U admin -d test" ]
interval: 5s
timeout: 5s
retries: 5
restart: always
networks:
- ldes

postgrest:
container_name: postgres-rest-api
image: postgrest/postgrest:latest
ports:
- ${MONGODB_REST_API_PORT:-9019}:80
- "9018:3000"
environment:
- PGRST_DB_URI=postgres://admin:admin@ldes-postgres:5432/test
- PGRST_DB_ANON_ROLE=admin
- PGRST_OPENAPI_SERVER_PROXY_URI=http://localhost:9018

depends_on:
- ldes-postgres
networks:
- ldes
- ldes

networks:
ldes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ management:
ldes-server:
host-name: http://localhost:8080
spring:
data:
mongodb:
database: iow
host: ldes-mongodb
port: 27017
datasource:
url: jdbc:postgresql://ldes-postgres:5432/test
username: admin
password: admin
jpa:
hibernate:
ddl-auto: update

41 changes: 27 additions & 14 deletions tests/016.mixed-workbench-ngsi-v2-to-oslo/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ services:
networks:
- ldes

ldes-mongodb:
container_name: ${USECASE_NAME:-iow-use-ldio}_ldes-mongodb
image: mongo:${MONGODB_TAG:-latest}
ports:
- ${MONGODB_PORT:-27017}:27017
networks:
- ldes

ldes-server:
container_name: ${USECASE_NAME:-iow-use-ldio}_ldes-server
image: ${LDES_SERVER:-ghcr.io/informatievlaanderen/ldes-server}:${LDES_SERVER_TAG:-latest}
Expand All @@ -64,14 +56,35 @@ services:
networks:
- ldes

mongodb-rest-api:
container_name: ${USECASE_NAME:-iow-use-ldio}_mongodb-rest-api
image: ghcr.io/informatievlaanderen/mongodb-rest-api:${MONGODB_REST_API_TAG:-latest}
ldes-postgres:
container_name: ldes-postgres
image: postgres:14-alpine
ports:
- "5432:5432"
environment:
- SILENT=false
- CONNECTION_URI=mongodb://ldes-mongodb:27017
- POSTGRES_PASSWORD=admin
- POSTGRES_USER=admin
- POSTGRES_DB=test
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U admin -d test" ]
interval: 5s
timeout: 5s
retries: 5
restart: always
networks:
- ldes

postgrest:
container_name: postgres-rest-api
image: postgrest/postgrest:latest
ports:
- ${MONGODB_REST_API_PORT:-9019}:80
- "9018:3000"
environment:
- PGRST_DB_URI=postgres://admin:admin@ldes-postgres:5432/test
- PGRST_DB_ANON_ROLE=admin
- PGRST_OPENAPI_SERVER_PROXY_URI=http://localhost:9018
depends_on:
- ldes-postgres
networks:
- ldes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ management:
ldes-server:
host-name: http://localhost:8080
spring:
data:
mongodb:
database: iow
host: ldes-mongodb
port: 27017
datasource:
url: jdbc:postgresql://ldes-postgres:5432/test
username: admin
password: admin
jpa:
hibernate:
ddl-auto: update


44 changes: 29 additions & 15 deletions tests/017.ldio-workbench-ngsi-v2-to-oslo/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ services:
depends_on:
- ldio-workbench

ldes-mongodb:
container_name: ${USECASE_NAME:-nifi-less-approach}_ldes-mongodb
image: mongo:${MONGODB_TAG:-latest}
ports:
- ${MONGODB_PORT:-27017}:27017
networks:
- ldes

ldes-server:
container_name: ${USECASE_NAME:-nifi-less-approach}_ldes-server
image: ${LDES_SERVER:-ghcr.io/informatievlaanderen/ldes-server}:${LDES_SERVER_TAG:-latest}
Expand All @@ -40,7 +32,7 @@ services:
networks:
- ldes
depends_on:
- ldes-mongodb
- ldes-postgres

ldio-workbench:
container_name: ${USECASE_NAME:-nifi-less-approach}_ldio-workbench
Expand All @@ -53,14 +45,36 @@ services:
networks:
- ldes

mongodb-rest-api:
container_name: ${USECASE_NAME:-nifi-less-approach}_mongodb-rest-api
image: ghcr.io/informatievlaanderen/mongodb-rest-api:${MONGODB_REST_API_TAG:-latest}
ldes-postgres:
container_name: ldes-postgres
image: postgres:14-alpine
ports:
- "5432:5432"
environment:
- SILENT=false
- CONNECTION_URI=mongodb://ldes-mongodb:27017
- POSTGRES_PASSWORD=admin
- POSTGRES_USER=admin
- POSTGRES_DB=test
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U admin -d test" ]
interval: 5s
timeout: 5s
retries: 5
restart: always
networks:
- ldes

postgrest:
container_name: postgres-rest-api
image: postgrest/postgrest:latest
ports:
- ${MONGODB_REST_API_PORT:-9019}:80
- "9018:3000"
environment:
- PGRST_DB_URI=postgres://admin:admin@ldes-postgres:5432/test
- PGRST_DB_ANON_ROLE=admin
- PGRST_OPENAPI_SERVER_PROXY_URI=http://localhost:9018

depends_on:
- ldes-postgres
networks:
- ldes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ management:
ldes-server:
host-name: http://localhost:8080
spring:
data:
mongodb:
database: Gent
host: ldes-mongodb
port: 27017
datasource:
url: jdbc:postgresql://ldes-postgres:5432/test
username: admin
password: admin
jpa:
hibernate:
ddl-auto: update
rest:
maxage: 10
maxage-immutable: 604800
Loading

0 comments on commit c813478

Please sign in to comment.