@@ -18,7 +18,7 @@ func Test_AutoExpiration(t *testing.T) {
18
18
t .Skip ()
19
19
}
20
20
21
- autoExpirationTime := time .Second * 1
21
+ autoExpirationTime := time .Second * 2
22
22
23
23
redisClient := getClient ()
24
24
setup := getCreateBackend (redisClient , WithAutoExpiration (autoExpirationTime ))
@@ -45,7 +45,7 @@ func Test_AutoExpiration(t *testing.T) {
45
45
require .NoError (t , c .WaitForWorkflowInstance (ctx , wfi , time .Second * 10 ))
46
46
47
47
// Wait for redis to expire the keys
48
- time .Sleep (autoExpirationTime )
48
+ time .Sleep (autoExpirationTime * 2 )
49
49
50
50
_ , err = b .GetWorkflowInstanceState (ctx , wfi )
51
51
require .ErrorIs (t , err , backend .ErrInstanceNotFound )
@@ -59,7 +59,7 @@ func Test_AutoExpiration_SubWorkflow(t *testing.T) {
59
59
t .Skip ()
60
60
}
61
61
62
- autoExpirationTime := time .Second * 1
62
+ autoExpirationTime := time .Second * 2
63
63
64
64
redisClient := getClient ()
65
65
setup := getCreateBackend (redisClient , WithAutoExpiration (autoExpirationTime ))
@@ -71,6 +71,11 @@ func Test_AutoExpiration_SubWorkflow(t *testing.T) {
71
71
ctx , cancel := context .WithCancel (context .Background ())
72
72
73
73
require .NoError (t , w .Start (ctx ))
74
+ defer func () {
75
+ cancel ()
76
+
77
+ require .NoError (t , w .WaitForCompletion ())
78
+ }()
74
79
75
80
swf := func (ctx workflow.Context ) (int , error ) {
76
81
return 42 , nil
@@ -79,6 +84,9 @@ func Test_AutoExpiration_SubWorkflow(t *testing.T) {
79
84
swfInstanceID := uuid .NewString ()
80
85
81
86
wf := func (ctx workflow.Context ) (int , error ) {
87
+ l := workflow .Logger (ctx )
88
+ l .Debug ("Starting sub workflow" , "instanceID" , swfInstanceID )
89
+
82
90
r , err := workflow .CreateSubWorkflowInstance [int ](ctx , workflow.SubWorkflowOptions {
83
91
InstanceID : swfInstanceID ,
84
92
}, swf ).Get (ctx )
@@ -101,12 +109,9 @@ func Test_AutoExpiration_SubWorkflow(t *testing.T) {
101
109
require .Equal (t , 42 , r )
102
110
103
111
// Wait for redis to expire the keys
104
- time .Sleep (autoExpirationTime )
112
+ time .Sleep (autoExpirationTime * 2 )
105
113
106
114
// Main workflow should now be expired
107
115
_ , err = b .GetWorkflowInstanceState (ctx , wfi )
108
116
require .ErrorIs (t , err , backend .ErrInstanceNotFound )
109
-
110
- cancel ()
111
- require .NoError (t , w .WaitForCompletion ())
112
117
}
0 commit comments