@@ -62,6 +62,16 @@ def make_ref_time(**kwargs):
62
62
return task_run_ts , sub_task_run_ts , trimmed_ts
63
63
64
64
65
+ def get_checkin_timeout_kwargs (checkin : MonitorCheckIn ):
66
+ return {
67
+ "monitor_id" : checkin .monitor .id ,
68
+ "monitor_environment_id" : checkin .monitor_environment .id ,
69
+ "status" : checkin .status ,
70
+ "date_added" : checkin .date_added ,
71
+ "timeout_at" : checkin .timeout_at ,
72
+ }
73
+
74
+
65
75
class MonitorTaskCheckMissingTest (TestCase ):
66
76
@mock .patch ("sentry.monitors.tasks.mark_environment_missing" )
67
77
def test_missing_checkin (self , mark_environment_missing_mock ):
@@ -652,15 +662,18 @@ def test_timeout(self, mark_checkin_timeout_mock):
652
662
assert mark_checkin_timeout_mock .delay .call_count == 0
653
663
654
664
# Timout at 12:30
665
+ checkin_kwargs = get_checkin_timeout_kwargs (checkin )
655
666
check_timeout (task_run_ts + timedelta (minutes = 30 ))
656
667
assert mark_checkin_timeout_mock .delay .call_count == 1
657
668
assert mark_checkin_timeout_mock .delay .mock_calls [0 ] == mock .call (
658
669
checkin .id ,
659
670
sub_task_run_ts + timedelta (minutes = 30 ),
671
+ ** checkin_kwargs ,
660
672
)
661
673
mark_checkin_timeout (
662
674
checkin .id ,
663
675
sub_task_run_ts + timedelta (minutes = 30 ),
676
+ ** checkin_kwargs ,
664
677
)
665
678
666
679
# Check in is marked as timed out
@@ -744,16 +757,19 @@ def test_timeout_with_overlapping_concurrent_checkins(self, mark_checkin_timeout
744
757
assert mark_checkin_timeout_mock .delay .call_count == 0
745
758
746
759
# First checkin timed out
760
+ checkin_kwargs = get_checkin_timeout_kwargs (checkin1 )
747
761
check_timeout (task_run_ts + timedelta (minutes = 30 ))
748
762
assert mark_checkin_timeout_mock .delay .call_count == 1
749
763
assert mark_checkin_timeout_mock .delay .mock_calls [0 ] == mock .call (
750
764
checkin1 .id ,
751
765
sub_task_run_ts + timedelta (minutes = 30 ),
766
+ ** checkin_kwargs ,
752
767
)
753
768
754
769
mark_checkin_timeout (
755
770
checkin1 .id ,
756
771
sub_task_run_ts + timedelta (minutes = 30 ),
772
+ ** checkin_kwargs ,
757
773
)
758
774
759
775
# First checkin is marked as timed out
@@ -819,13 +835,15 @@ def test_timeout_at_next_checkin_time(self, mark_checkin_timeout_mock):
819
835
)
820
836
821
837
# Check in was marked as timed out
838
+ checkin_kwargs = get_checkin_timeout_kwargs (checkin )
822
839
check_timeout (task_run_ts )
823
840
assert mark_checkin_timeout_mock .delay .call_count == 1
824
841
assert mark_checkin_timeout_mock .delay .mock_calls [0 ] == mock .call (
825
842
checkin .id ,
826
843
sub_task_run_ts ,
844
+ ** checkin_kwargs ,
827
845
)
828
- mark_checkin_timeout (checkin .id , sub_task_run_ts )
846
+ mark_checkin_timeout (checkin .id , sub_task_run_ts , ** checkin_kwargs )
829
847
830
848
# First checkin is marked as timed out
831
849
assert MonitorCheckIn .objects .filter (id = checkin .id , status = CheckInStatus .TIMEOUT ).exists ()
@@ -879,15 +897,18 @@ def test_timeout_using_interval(self, mark_checkin_timeout_mock):
879
897
)
880
898
881
899
# Timout at 12:05
900
+ checkin_kwargs = get_checkin_timeout_kwargs (checkin )
882
901
check_timeout (task_run_ts + timedelta (minutes = 5 ))
883
902
assert mark_checkin_timeout_mock .delay .call_count == 1
884
903
assert mark_checkin_timeout_mock .delay .mock_calls [0 ] == mock .call (
885
904
checkin .id ,
886
905
sub_task_run_ts + timedelta (minutes = 5 ),
906
+ ** checkin_kwargs ,
887
907
)
888
908
mark_checkin_timeout (
889
909
checkin .id ,
890
910
sub_task_run_ts + timedelta (minutes = 5 ),
911
+ ** checkin_kwargs ,
891
912
)
892
913
893
914
# Check in is marked as timed out
@@ -958,16 +979,18 @@ def test_timeout_with_future_complete_checkin(self, mark_checkin_timeout_mock):
958
979
959
980
# Running check monitor will mark the first checkin as timed out. The
960
981
# second checkin was already marked as OK.
982
+ checkin_kwargs = get_checkin_timeout_kwargs (checkin1 )
961
983
check_timeout (task_run_ts )
962
984
963
985
# assert that task is called for the specific checkin
964
986
assert mark_checkin_timeout_mock .delay .call_count == 1
965
987
assert mark_checkin_timeout_mock .delay .mock_calls [0 ] == mock .call (
966
988
checkin1 .id ,
967
989
sub_task_run_ts ,
990
+ ** checkin_kwargs ,
968
991
)
969
992
970
- mark_checkin_timeout (checkin1 .id , sub_task_run_ts )
993
+ mark_checkin_timeout (checkin1 .id , sub_task_run_ts , ** checkin_kwargs )
971
994
972
995
# The first checkin is marked as timed out
973
996
assert MonitorCheckIn .objects .filter (id = checkin1 .id , status = CheckInStatus .TIMEOUT ).exists ()
0 commit comments