@@ -1900,4 +1900,73 @@ await store.CreateFunction(
19001900 effects . Count . ShouldBe ( 0 ) ;
19011901 messages . Count . ShouldBe ( 0 ) ;
19021902 }
1903+
1904+ public abstract Task FunctionOwnedByReplicaIsPostponedAfterRescheduleFunctionsInvocation ( ) ;
1905+ protected async Task FunctionOwnedByReplicaIsPostponedAfterRescheduleFunctionsInvocation ( Task < IFunctionStore > storeTask )
1906+ {
1907+ var store = await storeTask ;
1908+ var replicaId1 = ReplicaId . NewId ( ) ;
1909+ var replicaId2 = ReplicaId . NewId ( ) ;
1910+ var storedId1 = TestStoredId . Create ( ) ;
1911+ await store . CreateFunction (
1912+ storedId1 ,
1913+ humanInstanceId : "SomeInstanceId" ,
1914+ param : null ,
1915+ leaseExpiration : DateTime . UtcNow . Ticks ,
1916+ postponeUntil : null ,
1917+ timestamp : DateTime . UtcNow . Ticks ,
1918+ parent : null ,
1919+ owner : replicaId1
1920+ ) . ShouldBeTrueAsync ( ) ;
1921+ var storedId2 = TestStoredId . Create ( ) ;
1922+ await store . CreateFunction (
1923+ storedId2 ,
1924+ humanInstanceId : "SomeInstanceId1" ,
1925+ param : null ,
1926+ leaseExpiration : DateTime . UtcNow . Ticks ,
1927+ postponeUntil : null ,
1928+ timestamp : DateTime . UtcNow . Ticks ,
1929+ parent : null ,
1930+ owner : replicaId1
1931+ ) . ShouldBeTrueAsync ( ) ;
1932+ var storedId3 = TestStoredId . Create ( ) ;
1933+ await store . CreateFunction (
1934+ storedId3 ,
1935+ humanInstanceId : "SomeInstanceId" ,
1936+ param : null ,
1937+ leaseExpiration : DateTime . UtcNow . Ticks ,
1938+ postponeUntil : null ,
1939+ timestamp : DateTime . UtcNow . Ticks ,
1940+ parent : null ,
1941+ owner : replicaId2
1942+ ) . ShouldBeTrueAsync ( ) ;
1943+
1944+ var replicas = await store . GetOwnerReplicas ( ) ;
1945+ replicas . Count . ShouldBe ( 2 ) ;
1946+ replicas . Any ( r => r == replicaId1 ) . ShouldBeTrue ( ) ;
1947+ replicas . Any ( r => r == replicaId2 ) . ShouldBeTrue ( ) ;
1948+
1949+ await store . RescheduleCrashedFunctions ( replicaId1 ) ;
1950+
1951+ var sf1 = await store . GetFunction ( storedId1 ) . ShouldNotBeNullAsync ( ) ;
1952+ sf1 . Status . ShouldBe ( Status . Postponed ) ;
1953+ sf1 . OwnerId . ShouldBeNull ( ) ;
1954+ sf1 . Epoch . ShouldBe ( 1 ) ;
1955+ sf1 . Expires . ShouldBe ( 0 ) ;
1956+
1957+ var sf2 = await store . GetFunction ( storedId2 ) . ShouldNotBeNullAsync ( ) ;
1958+ sf2 . Status . ShouldBe ( Status . Postponed ) ;
1959+ sf2 . OwnerId . ShouldBeNull ( ) ;
1960+ sf2 . Epoch . ShouldBe ( 1 ) ;
1961+ sf2 . Expires . ShouldBe ( 0 ) ;
1962+
1963+ var sf3 = await store . GetFunction ( storedId3 ) . ShouldNotBeNullAsync ( ) ;
1964+ sf3 . Status . ShouldBe ( Status . Executing ) ;
1965+ sf3 . OwnerId . ShouldBe ( replicaId2 ) ;
1966+ sf3 . Epoch . ShouldBe ( 0 ) ;
1967+
1968+ replicas = await store . GetOwnerReplicas ( ) ;
1969+ replicas . Count . ShouldBe ( 1 ) ;
1970+ replicas . Any ( r => r == replicaId2 ) . ShouldBeTrue ( ) ;
1971+ }
19031972}
0 commit comments