@@ -193,6 +193,7 @@ public void testExecutionMultipleTimes() {
193
193
194
194
// semaphore isolated
195
195
assertFalse (command .isExecutedInThread ());
196
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
196
197
}
197
198
198
199
/**
@@ -870,6 +871,8 @@ public void onNext(Boolean args) {
870
871
// semaphore isolated
871
872
assertFalse (command .isExecutedInThread ());
872
873
874
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
875
+
873
876
assertFalse (command .isResponseFromFallback ());
874
877
}
875
878
@@ -2184,6 +2187,8 @@ public void testDynamicOwnerFails() {
2184
2187
2185
2188
// semaphore isolated
2186
2189
assertFalse (command .isExecutedInThread ());
2190
+
2191
+ assertEquals (0 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
2187
2192
} catch (Exception e ) {
2188
2193
// success if we get here
2189
2194
}
@@ -2205,6 +2210,8 @@ public void testDynamicKey() {
2205
2210
2206
2211
// semaphore isolated
2207
2212
assertFalse (command1 .isExecutedInThread ());
2213
+
2214
+ assertEquals (2 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
2208
2215
} catch (Exception e ) {
2209
2216
e .printStackTrace ();
2210
2217
fail ("We received an exception." );
@@ -2447,8 +2454,6 @@ public void testRequestCacheWithSlowExecution() {
2447
2454
2448
2455
assertEquals (4 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
2449
2456
2450
- System .out .println ("HystrixRequestLog: " + HystrixRequestLog .getCurrentRequest ().getExecutedCommandsAsString ());
2451
-
2452
2457
// semaphore isolated
2453
2458
assertFalse (command1 .isExecutedInThread ());
2454
2459
assertFalse (command2 .isExecutedInThread ());
@@ -3025,7 +3030,7 @@ public void testRequestCacheOnThreadRejectionThrowsException() throws Exception
3025
3030
3026
3031
assertEquals (100 , circuitBreaker .metrics .getHealthCounts ().getErrorPercentage ());
3027
3032
3028
- // assertEquals(4, HystrixRequestLog.getCurrentRequest().getExecutedCommands ().size());
3033
+ assertEquals (4 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3029
3034
}
3030
3035
3031
3036
/**
@@ -3054,6 +3059,13 @@ public void testBasicExecutionWorksWithoutRequestVariable() {
3054
3059
e .printStackTrace ();
3055
3060
fail ("We received an exception => " + e .getMessage ());
3056
3061
}
3062
+
3063
+ try {
3064
+ HystrixRequestLog .getCurrentRequest ();
3065
+ fail ("Should not have a RequestLog when RequestContext not initialized" );
3066
+ } catch (IllegalStateException ise ) {
3067
+ //expected
3068
+ }
3057
3069
}
3058
3070
3059
3071
/**
@@ -3080,6 +3092,13 @@ public void testCacheKeyExecutionRequiresRequestVariable() {
3080
3092
} catch (Exception e ) {
3081
3093
e .printStackTrace ();
3082
3094
}
3095
+
3096
+ try {
3097
+ HystrixRequestLog .getCurrentRequest ();
3098
+ fail ("Should not have a RequestLog when RequestContext not initialized" );
3099
+ } catch (IllegalStateException ise ) {
3100
+ //expected
3101
+ }
3083
3102
}
3084
3103
3085
3104
/**
@@ -3102,6 +3121,8 @@ public void testBadRequestExceptionViaExecuteInThread() {
3102
3121
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .SUCCESS ));
3103
3122
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .EXCEPTION_THROWN ));
3104
3123
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .FAILURE ));
3124
+
3125
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3105
3126
}
3106
3127
3107
3128
/**
@@ -3128,6 +3149,8 @@ public void testBadRequestExceptionViaQueueInThread() {
3128
3149
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .SUCCESS ));
3129
3150
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .EXCEPTION_THROWN ));
3130
3151
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .FAILURE ));
3152
+
3153
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3131
3154
}
3132
3155
3133
3156
/**
@@ -3162,6 +3185,8 @@ public void testBadRequestExceptionViaQueueInThreadOnResponseFromCache() {
3162
3185
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .SUCCESS ));
3163
3186
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .EXCEPTION_THROWN ));
3164
3187
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .FAILURE ));
3188
+
3189
+ assertEquals (2 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3165
3190
}
3166
3191
3167
3192
/**
@@ -3184,6 +3209,8 @@ public void testBadRequestExceptionViaExecuteInSemaphore() {
3184
3209
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .SUCCESS ));
3185
3210
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .EXCEPTION_THROWN ));
3186
3211
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .FAILURE ));
3212
+
3213
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3187
3214
}
3188
3215
3189
3216
/**
@@ -3210,6 +3237,8 @@ public void testBadRequestExceptionViaQueueInSemaphore() {
3210
3237
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .SUCCESS ));
3211
3238
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .EXCEPTION_THROWN ));
3212
3239
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .FAILURE ));
3240
+
3241
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3213
3242
}
3214
3243
3215
3244
/**
@@ -3234,6 +3263,8 @@ public void testCheckedExceptionViaExecute() {
3234
3263
assertEquals (0 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .SUCCESS ));
3235
3264
assertEquals (1 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .FAILURE ));
3236
3265
assertEquals (1 , circuitBreaker .metrics .getRollingCount (HystrixRollingNumberEvent .EXCEPTION_THROWN ));
3266
+
3267
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3237
3268
}
3238
3269
3239
3270
/**
@@ -3289,6 +3320,8 @@ public void onNext(Boolean args) {
3289
3320
3290
3321
// semaphore isolated
3291
3322
assertFalse (command .isExecutedInThread ());
3323
+
3324
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3292
3325
}
3293
3326
3294
3327
/**
@@ -3319,6 +3352,8 @@ public void testErrorThrownViaExecute() {
3319
3352
3320
3353
// semaphore isolated
3321
3354
assertFalse (command .isExecutedInThread ());
3355
+
3356
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3322
3357
}
3323
3358
3324
3359
/**
@@ -3350,6 +3385,8 @@ public void testErrorThrownViaQueue() {
3350
3385
3351
3386
// semaphore isolated
3352
3387
assertFalse (command .isExecutedInThread ());
3388
+
3389
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3353
3390
}
3354
3391
3355
3392
/**
@@ -3407,6 +3444,8 @@ public void onNext(Boolean args) {
3407
3444
3408
3445
// semaphore isolated
3409
3446
assertFalse (command .isExecutedInThread ());
3447
+
3448
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3410
3449
}
3411
3450
3412
3451
/**
@@ -3478,6 +3517,8 @@ public void testExecutionHookSuccessfulCommand() {
3478
3517
3479
3518
// semaphore isolated
3480
3519
assertFalse (command .isExecutedInThread ());
3520
+
3521
+ assertEquals (2 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3481
3522
}
3482
3523
3483
3524
/**
@@ -3531,6 +3572,8 @@ public void testExecutionHookSuccessfulCommandViaFireAndForget() {
3531
3572
3532
3573
// semaphore isolated
3533
3574
assertFalse (command .isExecutedInThread ());
3575
+
3576
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3534
3577
}
3535
3578
3536
3579
/**
@@ -3578,6 +3621,8 @@ public void testExecutionHookSuccessfulCommandWithMultipleGetsOnFuture() {
3578
3621
3579
3622
// semaphore isolated
3580
3623
assertFalse (command .isExecutedInThread ());
3624
+
3625
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3581
3626
}
3582
3627
3583
3628
/**
@@ -3660,6 +3705,7 @@ public void testExecutionHookRunFailureWithoutFallback() {
3660
3705
// semaphore isolated
3661
3706
assertFalse (command .isExecutedInThread ());
3662
3707
3708
+ assertEquals (2 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3663
3709
}
3664
3710
3665
3711
/**
@@ -3731,6 +3777,8 @@ public void testExecutionHookRunFailureWithFallback() {
3731
3777
3732
3778
// semaphore isolated
3733
3779
assertFalse (command .isExecutedInThread ());
3780
+
3781
+ assertEquals (2 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3734
3782
}
3735
3783
3736
3784
/**
@@ -3812,6 +3860,8 @@ public void testExecutionHookRunFailureWithFallbackFailure() {
3812
3860
3813
3861
// semaphore isolated
3814
3862
assertFalse (command .isExecutedInThread ());
3863
+
3864
+ assertEquals (2 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3815
3865
}
3816
3866
3817
3867
/**
@@ -3851,19 +3901,10 @@ public void testExecutionHookTimeoutWithoutFallback() {
3851
3901
// timeout failure
3852
3902
assertEquals (FailureType .TIMEOUT , command .builder .executionHook .endExecuteFailureType );
3853
3903
3854
- // thread execution
3855
- // assertEquals(1, command.builder.executionHook.threadStart.get());
3856
-
3857
- // we need to wait for the thread to complete before the onThreadComplete hook will be called
3858
- // try {
3859
- // Thread.sleep(400);
3860
- // } catch (InterruptedException e) {
3861
- // // ignore
3862
- // }
3863
- // assertEquals(1, command.builder.executionHook.threadComplete.get());
3864
-
3865
3904
// semaphore isolated
3866
3905
assertFalse (command .isExecutedInThread ());
3906
+
3907
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3867
3908
}
3868
3909
3869
3910
/**
@@ -3912,6 +3953,8 @@ public void testExecutionHookTimeoutWithFallback() {
3912
3953
3913
3954
// semaphore isolated
3914
3955
assertFalse (command .isExecutedInThread ());
3956
+
3957
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
3915
3958
}
3916
3959
3917
3960
/**
@@ -4013,6 +4056,8 @@ public void testExecutionHookShortCircuitedWithFallbackViaQueue() {
4013
4056
4014
4057
// semaphore isolated
4015
4058
assertFalse (command .isExecutedInThread ());
4059
+
4060
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
4016
4061
}
4017
4062
4018
4063
/**
@@ -4061,6 +4106,8 @@ public void testExecutionHookShortCircuitedWithFallbackViaExecute() {
4061
4106
4062
4107
// semaphore isolated
4063
4108
assertFalse (command .isExecutedInThread ());
4109
+
4110
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
4064
4111
}
4065
4112
4066
4113
/**
@@ -4136,6 +4183,8 @@ public void testExecutionHookSuccessfulCommandWithSemaphoreIsolation() {
4136
4183
4137
4184
// semaphore isolated
4138
4185
assertFalse (command .isExecutedInThread ());
4186
+
4187
+ assertEquals (2 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
4139
4188
}
4140
4189
4141
4190
/**
@@ -4187,6 +4236,8 @@ public void testExecutionHookFailureWithSemaphoreIsolation() {
4187
4236
4188
4237
// semaphore isolated
4189
4238
assertFalse (command .isExecutedInThread ());
4239
+
4240
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
4190
4241
}
4191
4242
4192
4243
/**
@@ -4228,13 +4279,13 @@ public void testExecutionFailureWithFallbackImplementedButDisabled() {
4228
4279
4229
4280
assertEquals (100 , commandDisabled .builder .metrics .getHealthCounts ().getErrorPercentage ());
4230
4281
4231
- // assertEquals(2, HystrixRequestLog.getCurrentRequest().getExecutedCommands ().size());
4282
+ assertEquals (2 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
4232
4283
}
4233
4284
4234
4285
/**
4235
4286
* Test that we can still use thread isolation if desired.
4236
4287
*/
4237
- @ Test ( timeout = 500 )
4288
+ @ Test
4238
4289
public void testSynchronousExecutionTimeoutValueViaExecute () {
4239
4290
HystrixObservableCommand .Setter properties = HystrixObservableCommand .Setter
4240
4291
.withGroupKey (HystrixCommandGroupKey .Factory .asKey ("TestKey" ))
@@ -4247,6 +4298,7 @@ public void testSynchronousExecutionTimeoutValueViaExecute() {
4247
4298
HystrixObservableCommand <String > command = new HystrixObservableCommand <String >(properties ) {
4248
4299
@ Override
4249
4300
protected Observable <String > construct () {
4301
+
4250
4302
return Observable .create (new OnSubscribe <String >() {
4251
4303
4252
4304
@ Override
@@ -4281,9 +4333,11 @@ protected Observable<String> resumeWithFallback() {
4281
4333
4282
4334
// Thread isolated
4283
4335
assertTrue (command .isExecutedInThread ());
4336
+
4337
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
4284
4338
}
4285
4339
4286
- @ Test ( timeout = 500 )
4340
+ @ Test
4287
4341
public void testSynchronousExecutionUsingThreadIsolationTimeoutValueViaObserve () {
4288
4342
HystrixObservableCommand .Setter properties = HystrixObservableCommand .Setter
4289
4343
.withGroupKey (HystrixCommandGroupKey .Factory .asKey ("TestKey" ))
@@ -4326,9 +4380,11 @@ protected Observable<String> resumeWithFallback() {
4326
4380
4327
4381
// Thread isolated
4328
4382
assertTrue (command .isExecutedInThread ());
4383
+
4384
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
4329
4385
}
4330
4386
4331
- @ Test ( timeout = 500 )
4387
+ @ Test
4332
4388
public void testAsyncExecutionTimeoutValueViaObserve () {
4333
4389
HystrixObservableCommand .Setter properties = HystrixObservableCommand .Setter
4334
4390
.withGroupKey (HystrixCommandGroupKey .Factory .asKey ("TestKey" ))
@@ -4371,6 +4427,8 @@ protected Observable<String> resumeWithFallback() {
4371
4427
4372
4428
// semaphore isolated
4373
4429
assertFalse (command .isExecutedInThread ());
4430
+
4431
+ assertEquals (1 , HystrixRequestLog .getCurrentRequest ().getAllExecutedCommands ().size ());
4374
4432
}
4375
4433
4376
4434
/**
0 commit comments