Skip to content

Commit

Permalink
Schedule should use UTC; fixed name job (#310)
Browse files Browse the repository at this point in the history
* Schedule should use UTC; fixed name job

* Remove initial repl config option

* Check schedule working hour in Clojure where timezone is known
  • Loading branch information
mdemare authored Jun 24, 2024
1 parent 566c48a commit 6d0003a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
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

0 comments on commit 6d0003a

Please sign in to comment.