Skip to content

Commit

Permalink
Merge pull request #619 from Opetushallitus/EH-1584-ddb-handlers
Browse files Browse the repository at this point in the history
EH-1584: Writing herätteet directly to DynamoDB
  • Loading branch information
pkalliok authored Jul 19, 2024
2 parents 1089403 + c15543d commit 9c33aca
Show file tree
Hide file tree
Showing 17 changed files with 348 additions and 107 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:
git clone https://github.com/Opetushallitus/ci-tools.git
lein deps
# Do the tests even use the database?
- name: Run Database
- name: Run Databases
shell: bash
env:
CONFIG: oph-configuration/test-ci.edn
run: |
./scripts/ci-scripts/run_postgres.sh
lein dbmigrate
make stamps/local-ddb-schema # DynamoDB
- name: Pre-Build
shell: bash
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/checkouts
/classes
/lib
/myenv
/scripts/session-cookie.txt
/scripts/cas-tgt-url.txt
/resources/uberjar/buildversion.txt
Expand Down
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ stamps/db-running: stamps/db-image
docker ps --format '{{.Names}}' | grep -qx 'ehoks-postgres' \
|| docker run -d --rm --name ehoks-postgres \
-p 5432:5432 ehoks-postgres > $@ || (rm $@ && false)
until echo pingping | nc localhost 5432; do \
until psql -h localhost -U postgres ehoks -c "SELECT 3" \
| grep -x ' *3 *'; do \
echo "Waiting for database to come up..."; \
sleep 1; \
done
Expand All @@ -25,12 +26,20 @@ stamps/local-ddb-running:

DDB_TABLES = amisherate jaksotunnus tep-nippu tpk-nippu

myenv:
python3 -m venv myenv

stamps/install-awscli: myenv
./myenv/bin/pip install awscli
touch $@

stamps/local-ddb-schema: $(DDB_TABLES:%=stamps/local-ddb-schema-%)
touch $@

stamps/local-ddb-schema-%: resources/dev/demo-data/%-schema.json
stamps/local-ddb-schema-%: resources/dev/demo-data/%-schema.json \
stamps/local-ddb-running stamps/install-awscli
AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar \
aws dynamodb create-table --region eu-west-1 \
./myenv/bin/aws dynamodb create-table --region eu-west-1 \
--endpoint http://localhost:18000 --cli-input-json "$$(cat $<)"
touch $@

Expand Down Expand Up @@ -59,7 +68,8 @@ stamps/example-data: stamps/server-running
touch $@

tags::
ctags -R --exclude='*.min.js' --exclude='json-schema-viewer' .
ctags -R --exclude='*.min.js' --exclude='json-schema-viewer' \
--exclude='myenv' .

pom.xml::
lein pom
Expand Down Expand Up @@ -90,4 +100,6 @@ stop:
-rm stamps/db-running
-test -f stamps/server-running && kill $$(cat stamps/server-running)
-rm stamps/server-running
-test -f stamps/local-ddb-running && docker rm -f ehoks-dynamodb
-rm stamps/local-ddb-running

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Muut riippuvuudet:
+ Ehkä: `make` automaatiosääntöjen käyttöön (ks alla)
+ Ehkä: `curl` jos haluaa käyttää rajapintaa suoraan (esim luoda testidataa), myös jotkin skriptit käyttävät tätä
+ Ehkä: `jq` joidenkin skriptien toimintaan
+ Ehkä: `aws` kun tarvitsee käsitellä DynamoDB:tä
+ Ehkä: `graphviz` tietokantakaavioihin kun tekee `make schemaDoc`

### RESTful API
Expand All @@ -47,8 +46,9 @@ tyylit.

### Testien ajaminen

(Pystytä ensin tietokanta, testit toimivat aitoa tietokantaa vasten:
`make stamps/db-schema`)
Pystytä ensin tietokanta, testit toimivat aitoa tietokantaa vasten:
`make stamps/db-schema`. DynamoDB-testit tarvitsevat myös lokaalin
DynamoDB:n: `make stamps/local-ddb-schema`.

Kerran:

Expand Down
3 changes: 3 additions & 0 deletions oph-configuration/default.edn
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
:heratepalvelu-queue "services-heratepalvelu-eHOKSHerateQueue"
:heratepalvelu-tyoelamapalaute-queue "services-heratepalvelu-tep-HerateQueue"
:heratepalvelu-resend-queue "services-heratepalvelu-eHOKSAmisResendQueue"
:heratepalvelu-amis-table "pallero-services-heratepalvelu-AMISHerateTable717F426F-1NY1YMTKJOF7Y"
:heratepalvelu-jakso-table "pallero-services-heratepalvelu-tep-jaksotunnusTable87D50EF4-1KUH8IGOE8ZV3"
:heratepalvelu-nippu-table "pallero-services-heratepalvelu-tep-nippuTableDE910D47-102WQ3OSVMOEI"
:send-herate-messages? false
:audit? true
:db-type "postgresql"
Expand Down
4 changes: 3 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@
:profiles {:test {:resource-paths ["resources/test" "resources/test/src"]
:dependencies [[ring/ring-mock]
[ring/ring-devel]]
:env {:config "oph-configuration/test.edn"}}
:env {:config "oph-configuration/test.edn"
:aws-region "eu-west-1"
:aws-endpoint-url "http://localhost:18000"}}
:schemaspy {:dependencies [[net.sourceforge.schemaspy/schemaspy "5.0.0"]]}
:dev {:main oph.ehoks.dev-server
:dependencies [[ring/ring-mock]
Expand Down
48 changes: 24 additions & 24 deletions resources/dev/demo-data/anonymised-example-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"osaamisen-hankkimistavat": []
}
],
"ensikertainen-hyvaksyminen": "2022-10-06",
"ensikertainen-hyvaksyminen": "2023-10-06",
"hankittavat-koulutuksen-osat": [],
"sahkoposti": "[email protected]",
"osaamisen-hankkimisen-tarve": true,
"urasuunnitelma-koodi-uri": "urasuunnitelma_0002",
"aiemmin-hankitut-paikalliset-tutkinnon-osat": [],
"opiskeluoikeus-oid": "1.2.246.562.15.76811932086",
"aiemmin-hankitut-ammat-tutkinnon-osat": [],
"paivitetty": "2023-05-16T00:00:00Z",
"paivitetty": "2024-05-16T00:00:00Z",
"hankittavat-yhteiset-tutkinnon-osat": [
{
"tutkinnon-osa-koodi-uri": "tutkinnonosat_106727",
Expand Down Expand Up @@ -233,14 +233,14 @@
"yksiloiva-tunniste": "44728951585344033343",
"muut-oppimisymparistot": [
{
"alku": "2023-06-03",
"loppu": "2023-06-30",
"alku": "2024-06-03",
"loppu": "2024-06-30",
"oppimisymparisto-koodi-uri": "oppimisymparistot_0002",
"oppimisymparisto-koodi-versio": 1
}
],
"alku": "2023-06-03",
"loppu": "2023-06-30"
"alku": "2024-06-03",
"loppu": "2024-06-30"
}
]
},
Expand Down Expand Up @@ -295,9 +295,9 @@
}
}
],
"alku": "2023-03-09",
"alku": "2024-03-09",
"yksilolliset-kriteerit": [],
"loppu": "2023-03-15"
"loppu": "2024-03-15"
}
],
"osaamisen-hankkimistavat": [
Expand All @@ -308,14 +308,14 @@
"yksiloiva-tunniste": "44728950164671337776",
"muut-oppimisymparistot": [
{
"alku": "2022-08-10",
"loppu": "2023-01-13",
"alku": "2023-08-10",
"loppu": "2024-01-13",
"oppimisymparisto-koodi-uri": "oppimisymparistot_0001",
"oppimisymparisto-koodi-versio": 1
}
],
"alku": "2022-08-10",
"loppu": "2023-01-13"
"alku": "2023-08-10",
"loppu": "2024-01-13"
},
{
"keskeytymisajanjaksot": [],
Expand All @@ -336,8 +336,8 @@
"osaamisen-hankkimistapa-koodi-versio": 1,
"yksiloiva-tunniste": "447289501649525720624952571844",
"muut-oppimisymparistot": [],
"alku": "2023-01-16",
"loppu": "2023-03-17"
"alku": "2024-01-16",
"loppu": "2024-03-17"
}
]
},
Expand All @@ -355,14 +355,14 @@
"yksiloiva-tunniste": "44728950185149468939",
"muut-oppimisymparistot": [
{
"alku": "2023-03-20",
"loppu": "2023-06-02",
"alku": "2024-03-20",
"loppu": "2024-06-02",
"oppimisymparisto-koodi-uri": "oppimisymparistot_0001",
"oppimisymparisto-koodi-versio": 1
}
],
"alku": "2023-03-20",
"loppu": "2023-06-02"
"alku": "2024-03-20",
"loppu": "2024-06-02"
},
{
"keskeytymisajanjaksot": [],
Expand All @@ -371,14 +371,14 @@
"yksiloiva-tunniste": "44728950185590812544",
"muut-oppimisymparistot": [
{
"alku": "2023-08-07",
"loppu": "2023-10-27",
"alku": "2024-08-07",
"loppu": "2024-10-27",
"oppimisymparisto-koodi-uri": "oppimisymparistot_0001",
"oppimisymparisto-koodi-versio": 1
}
],
"alku": "2023-08-07",
"loppu": "2023-10-27"
"alku": "2024-08-07",
"loppu": "2024-10-27"
},
{
"keskeytymisajanjaksot": [],
Expand All @@ -399,8 +399,8 @@
"osaamisen-hankkimistapa-koodi-versio": 1,
"yksiloiva-tunniste": "447289501856807906785680790783",
"muut-oppimisymparistot": [],
"alku": "2023-10-30",
"loppu": "2023-12-15"
"alku": "2024-10-30",
"loppu": "2024-12-15"
}
]
},
Expand Down
Loading

0 comments on commit 9c33aca

Please sign in to comment.