@@ -917,3 +917,64 @@ def test_get_base_identifier(mock_mc):
917
917
assert (
918
918
mock_mc .get_base_identifier (stack ) == "tip"
919
919
), "`tip` commit should be used when `use_latest_revision` is `True`."
920
+
921
+
922
+ @responses .activate
923
+ @pytest .mark .asyncio
924
+ async def test_push_failure_diff_expiry (PhabricatorMock , mock_mc ):
925
+ diff = {
926
+ "revisionPHID" : "PHID-DREV-badutf8" ,
927
+ "baseRevision" : "missing" ,
928
+ "phid" : "PHID-DIFF-badutf8" ,
929
+ "id" : 555 ,
930
+ # a date in 2017
931
+ "fields" : {"dateCreated" : 1510251135 },
932
+ }
933
+ build = MockBuild (4444 , "PHID-REPO-mc" , 5555 , "PHID-build-badutf8" , diff )
934
+ with PhabricatorMock as phab :
935
+ phab .load_patches_stack (build )
936
+
937
+ bus = MessageBus ()
938
+ bus .add_queue ("phabricator" )
939
+
940
+ from libmozevent import mercurial
941
+
942
+ mercurial .TRY_STATUS_URL = "http://test.status/try"
943
+
944
+ sleep_history = []
945
+
946
+ class AsyncioMock (object ):
947
+ async def sleep (self , value ):
948
+ nonlocal sleep_history
949
+ sleep_history .append (value )
950
+
951
+ mercurial .asyncio = AsyncioMock ()
952
+
953
+ responses .get (
954
+ "http://test.status/try" , status = 200 , json = {"result" : {"status" : "open" }}
955
+ )
956
+
957
+ repository_mock = MagicMock (spec = Repository )
958
+
959
+ worker = MercurialWorker (
960
+ "mercurial" , "phabricator" , repositories = {"PHID-REPO-mc" : repository_mock }
961
+ )
962
+ worker .register (bus )
963
+
964
+ await bus .send ("mercurial" , build )
965
+ assert bus .queues ["mercurial" ].qsize () == 1
966
+ task = asyncio .create_task (worker .run ())
967
+
968
+ # Check the treeherder link was queued
969
+ mode , out_build , details = await bus .receive ("phabricator" )
970
+ task .cancel ()
971
+
972
+ assert build .retries == 0
973
+
974
+ assert mode == "fail:mercurial"
975
+ assert out_build == build
976
+ assert details ["duration" ] > 0
977
+ assert details ["message" ] == "This build is too old to push to try repository"
978
+
979
+ # no call sent to TRY_STATUS_URL
980
+ assert len (responses .calls ) == 0
0 commit comments