Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schedule should use UTC; fixed name job #310

Merged
merged 3 commits into from
Jun 24, 2024
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/test-rio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Check if RIO queue is up or down

on:
schedule:
- cron: '6 9-17 * * 1-5' # every hour on weekdays during working hours
- cron: '6 7-18 * * 1-5' # every hour on weekdays during working hours. Code will to a timezone check.

jobs:
deps:
riotest:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -54,4 +54,4 @@ jobs:
TOKEN_ENDPOINT: ${{ secrets.TOKEN_ENDPOINT }}
TRUSTSTORE: truststore.jks
TRUSTSTORE_PASSWORD: ${{ secrets.TRUSTSTORE_PASSWORD }}
run: lein mapper test-rio rio-mapper-dev.jomco.nl
run: lein mapper test-rio rio-mapper-dev.jomco.nl cron
4 changes: 1 addition & 3 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,4 @@
:test-selectors {:default #(not-any? % [:e2e :redis])
:redis :redis
:e2e :e2e
:all (constantly true)}

:repl-options {:init-ns nl.surf.eduhub-rio-mapper.ooapi})
:all (constantly true)})
36 changes: 20 additions & 16 deletions src/nl/surf/eduhub_rio_mapper/cli_commands.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
[nl.surf.eduhub-rio-mapper.specs.ooapi :as ooapi]
[nl.surf.eduhub-rio-mapper.specs.rio :as rio]
[nl.surf.eduhub-rio-mapper.worker :as worker])
(:import [java.util UUID]))
(:import [java.time LocalTime]
[java.util UUID]))

(defn- parse-getter-args [[type id & [pagina]]]
{:pre [type id (string? type)]}
Expand Down Expand Up @@ -73,28 +74,31 @@
(worker/start-worker! config)))

"test-rio"
(let [[client-info _] (parse-client-info-args args clients)
(let [[client-info args] (parse-client-info-args args clients)
cron (= "cron" (first args))
working (< 9 (.getHour (LocalTime/now)) 17) ; only run between 9:00 and 17:00 local time
uuid (UUID/randomUUID)
eduspec (-> "../test/fixtures/ooapi/education-specification-template.json"
io/resource
slurp
(json/read-str :key-fn keyword)
(assoc :educationSpecificationId uuid))]

(try
(insert! {:institution-oin (:institution-oin client-info)
:institution-schac-home (:institution-schac-home client-info)
::ooapi/type "education-specification"
::ooapi/id uuid
::ooapi/entity eduspec})
(println "The RIO Queue is UP")
(catch Exception ex
(when-let [ex-data (ex-data ex)]
(when (= :down (:rio-queue-status ex-data))
(println "The RIO Queue is DOWN")
(System/exit -1)))
(println "An unexpected exception has occurred: " ex)
(System/exit -2))))
(when (or working (not cron))
(try
(insert! {:institution-oin (:institution-oin client-info)
:institution-schac-home (:institution-schac-home client-info)
::ooapi/type "education-specification"
::ooapi/id uuid
::ooapi/entity eduspec})
(println "The RIO Queue is UP")
(catch Exception ex
(when-let [ex-data (ex-data ex)]
(when (= :down (:rio-queue-status ex-data))
(println "The RIO Queue is DOWN")
(System/exit -1)))
(println "An unexpected exception has occurred: " ex)
(System/exit -2)))))

"get"
(let [[client-info rest-args] (parse-client-info-args args clients)]
Expand Down