-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Greg Haskins <greg@manetu.com>
- Loading branch information
Showing
2 changed files
with
44 additions
and
4 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
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,40 @@ | ||
;; Copyright © Manetu, Inc. All rights reserved | ||
|
||
(ns temporal.test.retry-coherence | ||
(:require [clojure.test :refer :all] | ||
[taoensso.timbre :as log] | ||
[temporal.client.core :as c] | ||
[temporal.workflow :refer [defworkflow]] | ||
[temporal.activity :refer [defactivity] :as a] | ||
[temporal.test.utils :as t]) | ||
(:import [java.time Duration])) | ||
|
||
(use-fixtures :once t/wrap-service) | ||
|
||
(defactivity retry-activity | ||
[_ {:keys [mode]}] | ||
(let [{:keys [activity-id]} (a/get-info)] | ||
(log/info "retry-activity:" activity-id) | ||
(if-let [details (a/get-heartbeat-details)] | ||
(do | ||
(log/info "original activity-id:" activity-id "current activity-id:" details) | ||
(= activity-id details)) | ||
(do | ||
(a/heartbeat activity-id) | ||
(case mode | ||
:crash (throw (ex-info "synthetic crash" {})) | ||
:timeout (Thread/sleep 2000)))))) | ||
|
||
(defworkflow retry-workflow | ||
[args] | ||
@(a/invoke retry-activity args {:start-to-close-timeout (Duration/ofSeconds 1)})) | ||
|
||
(deftest the-test | ||
(testing "Verifies that a retriable crash has a stable activity-id" | ||
(let [workflow (t/create-workflow retry-workflow)] | ||
(c/start workflow {:mode :crash}) | ||
(is (-> workflow c/get-result deref true?)))) | ||
(testing "Verifies that a timeout retry has a stable activity-id" | ||
(let [workflow (t/create-workflow retry-workflow)] | ||
(c/start workflow {:mode :timeout}) | ||
(is (-> workflow c/get-result deref true?))))) |