@@ -1844,275 +1844,6 @@ await store.SucceedFunction(
18441844 storedFunction . OwnerId . ShouldBeNull ( ) ;
18451845 }
18461846
1847- public abstract Task SetFunctionSucceedsWithSucceededStatus ( ) ;
1848- protected async Task SetFunctionSucceedsWithSucceededStatus ( Task < IFunctionStore > storeTask )
1849- {
1850- var functionId = TestStoredId . Create ( ) ;
1851-
1852- var store = await storeTask ;
1853- await store . CreateFunction (
1854- functionId ,
1855- "humanInstanceId" ,
1856- param : "test" . ToJson ( ) . ToUtf8Bytes ( ) ,
1857- leaseExpiration : DateTime . UtcNow . Ticks ,
1858- postponeUntil : null ,
1859- timestamp : DateTime . UtcNow . Ticks ,
1860- parent : null ,
1861- owner : ReplicaId . Empty
1862- ) . ShouldNotBeNullAsync ( ) ;
1863-
1864- var result = "success" . ToJson ( ) . ToUtf8Bytes ( ) ;
1865- var timestamp = DateTime . UtcNow . Ticks ;
1866-
1867- await store . SetFunction (
1868- functionId ,
1869- result : result ,
1870- status : new FunctionStatus ( Status . Succeeded ) ,
1871- postponeUntil : null ,
1872- storedException : null ,
1873- timestamp : timestamp ,
1874- expectedReplica : ReplicaId . Empty ,
1875- effects : null ,
1876- messages : null ,
1877- storageSession : null
1878- ) . ShouldBeTrueAsync ( ) ;
1879-
1880- var storedFunction = await store . GetFunction ( functionId ) ;
1881- storedFunction . ShouldNotBeNull ( ) ;
1882- storedFunction . Status . ShouldBe ( Status . Succeeded ) ;
1883- storedFunction . Result . ShouldBe ( result ) ;
1884- storedFunction . Timestamp . ShouldBe ( timestamp ) ;
1885- storedFunction . OwnerId . ShouldBeNull ( ) ;
1886- }
1887-
1888- public abstract Task SetFunctionSucceedsWithFailedStatus ( ) ;
1889- protected async Task SetFunctionSucceedsWithFailedStatus ( Task < IFunctionStore > storeTask )
1890- {
1891- var functionId = TestStoredId . Create ( ) ;
1892-
1893- var store = await storeTask ;
1894- await store . CreateFunction (
1895- functionId ,
1896- "humanInstanceId" ,
1897- param : "test" . ToJson ( ) . ToUtf8Bytes ( ) ,
1898- leaseExpiration : DateTime . UtcNow . Ticks ,
1899- postponeUntil : null ,
1900- timestamp : DateTime . UtcNow . Ticks ,
1901- parent : null ,
1902- owner : ReplicaId . Empty
1903- ) . ShouldNotBeNullAsync ( ) ;
1904-
1905- var storedException = new StoredException (
1906- ExceptionMessage : "Test exception" ,
1907- ExceptionStackTrace : "Test stack trace" ,
1908- ExceptionType : typeof ( InvalidOperationException ) . SimpleQualifiedName ( )
1909- ) ;
1910- var timestamp = DateTime . UtcNow . Ticks ;
1911-
1912- await store . SetFunction (
1913- functionId ,
1914- result : null ,
1915- status : new FunctionStatus ( Status . Failed ) ,
1916- postponeUntil : null ,
1917- storedException : storedException ,
1918- timestamp : timestamp ,
1919- expectedReplica : ReplicaId . Empty ,
1920- effects : null ,
1921- messages : null ,
1922- storageSession : null
1923- ) . ShouldBeTrueAsync ( ) ;
1924-
1925- var storedFunction = await store . GetFunction ( functionId ) ;
1926- storedFunction . ShouldNotBeNull ( ) ;
1927- storedFunction . Status . ShouldBe ( Status . Failed ) ;
1928- storedFunction . Exception . ShouldNotBeNull ( ) ;
1929- storedFunction . Exception . ExceptionMessage . ShouldBe ( storedException . ExceptionMessage ) ;
1930- storedFunction . Timestamp . ShouldBe ( timestamp ) ;
1931- storedFunction . OwnerId . ShouldBeNull ( ) ;
1932- }
1933-
1934- public abstract Task SetFunctionSucceedsWithPostponedStatus ( ) ;
1935- protected async Task SetFunctionSucceedsWithPostponedStatus ( Task < IFunctionStore > storeTask )
1936- {
1937- var functionId = TestStoredId . Create ( ) ;
1938-
1939- var store = await storeTask ;
1940- await store . CreateFunction (
1941- functionId ,
1942- "humanInstanceId" ,
1943- param : "test" . ToJson ( ) . ToUtf8Bytes ( ) ,
1944- leaseExpiration : DateTime . UtcNow . Ticks ,
1945- postponeUntil : null ,
1946- timestamp : DateTime . UtcNow . Ticks ,
1947- parent : null ,
1948- owner : ReplicaId . Empty
1949- ) . ShouldNotBeNullAsync ( ) ;
1950-
1951- var postponeUntil = DateTime . UtcNow . AddHours ( 1 ) . Ticks ;
1952- var timestamp = DateTime . UtcNow . Ticks ;
1953-
1954- await store . SetFunction (
1955- functionId ,
1956- result : null ,
1957- status : new FunctionStatus ( Status . Postponed ) ,
1958- postponeUntil : postponeUntil ,
1959- storedException : null ,
1960- timestamp : timestamp ,
1961- expectedReplica : ReplicaId . Empty ,
1962- effects : null ,
1963- messages : null ,
1964- storageSession : null
1965- ) . ShouldBeTrueAsync ( ) ;
1966-
1967- var storedFunction = await store . GetFunction ( functionId ) ;
1968- storedFunction . ShouldNotBeNull ( ) ;
1969- storedFunction . Status . ShouldBe ( Status . Postponed ) ;
1970- storedFunction . Expires . ShouldBe ( postponeUntil ) ;
1971- storedFunction . Timestamp . ShouldBe ( timestamp ) ;
1972- storedFunction . OwnerId . ShouldBeNull ( ) ;
1973- }
1974-
1975- public abstract Task SetFunctionSucceedsWithSuspendedStatus ( ) ;
1976- protected async Task SetFunctionSucceedsWithSuspendedStatus ( Task < IFunctionStore > storeTask )
1977- {
1978- var functionId = TestStoredId . Create ( ) ;
1979-
1980- var store = await storeTask ;
1981- await store . CreateFunction (
1982- functionId ,
1983- "humanInstanceId" ,
1984- param : "test" . ToJson ( ) . ToUtf8Bytes ( ) ,
1985- leaseExpiration : DateTime . UtcNow . Ticks ,
1986- postponeUntil : null ,
1987- timestamp : DateTime . UtcNow . Ticks ,
1988- parent : null ,
1989- owner : ReplicaId . Empty
1990- ) . ShouldNotBeNullAsync ( ) ;
1991-
1992- var timestamp = DateTime . UtcNow . Ticks ;
1993-
1994- await store . SetFunction (
1995- functionId ,
1996- result : null ,
1997- status : new FunctionStatus ( Status . Suspended ) ,
1998- postponeUntil : null ,
1999- storedException : null ,
2000- timestamp : timestamp ,
2001- expectedReplica : ReplicaId . Empty ,
2002- effects : null ,
2003- messages : null ,
2004- storageSession : null
2005- ) . ShouldBeTrueAsync ( ) ;
2006-
2007- var storedFunction = await store . GetFunction ( functionId ) ;
2008- storedFunction . ShouldNotBeNull ( ) ;
2009- storedFunction . Status . ShouldBe ( Status . Suspended ) ;
2010- storedFunction . Timestamp . ShouldBe ( timestamp ) ;
2011- storedFunction . OwnerId . ShouldBeNull ( ) ;
2012- }
2013-
2014- public abstract Task SetFunctionFailsWhenInterruptedForPostponedAndSuspended ( ) ;
2015- protected async Task SetFunctionFailsWhenInterruptedForPostponedAndSuspended ( Task < IFunctionStore > storeTask )
2016- {
2017- var functionId = TestStoredId . Create ( ) ;
2018-
2019- var store = await storeTask ;
2020- await store . CreateFunction (
2021- functionId ,
2022- "humanInstanceId" ,
2023- param : "test" . ToJson ( ) . ToUtf8Bytes ( ) ,
2024- leaseExpiration : DateTime . UtcNow . Ticks ,
2025- postponeUntil : null ,
2026- timestamp : DateTime . UtcNow . Ticks ,
2027- parent : null ,
2028- owner : ReplicaId . Empty
2029- ) . ShouldNotBeNullAsync ( ) ;
2030-
2031- // Interrupt the function
2032- await store . Interrupt ( functionId ) . ShouldBeTrueAsync ( ) ;
2033-
2034- var timestamp = DateTime . UtcNow . Ticks ;
2035-
2036- // SetFunction should fail for Postponed when interrupted
2037- await store . SetFunction (
2038- functionId ,
2039- result : null ,
2040- status : new FunctionStatus ( Status . Postponed ) ,
2041- postponeUntil : DateTime . UtcNow . AddHours ( 1 ) . Ticks ,
2042- storedException : null ,
2043- timestamp : timestamp ,
2044- expectedReplica : ReplicaId . Empty ,
2045- effects : null ,
2046- messages : null ,
2047- storageSession : null
2048- ) . ShouldBeFalseAsync ( ) ;
2049-
2050- var storedFunction = await store . GetFunction ( functionId ) ;
2051- storedFunction . ShouldNotBeNull ( ) ;
2052- storedFunction . Status . ShouldBe ( Status . Executing ) ; // Stays Executing when interrupted from Executing
2053- storedFunction . Interrupted . ShouldBeTrue ( ) ;
2054-
2055- // SetFunction should also fail for Suspended when interrupted
2056- await store . SetFunction (
2057- functionId ,
2058- result : null ,
2059- status : new FunctionStatus ( Status . Suspended ) ,
2060- postponeUntil : null ,
2061- storedException : null ,
2062- timestamp : timestamp ,
2063- expectedReplica : ReplicaId . Empty ,
2064- effects : null ,
2065- messages : null ,
2066- storageSession : null
2067- ) . ShouldBeFalseAsync ( ) ;
2068-
2069- storedFunction = await store . GetFunction ( functionId ) ;
2070- storedFunction . ShouldNotBeNull ( ) ;
2071- storedFunction . Status . ShouldBe ( Status . Executing ) ; // Still in original status
2072- storedFunction . Interrupted . ShouldBeTrue ( ) ;
2073- }
2074-
2075- public abstract Task SetFunctionFailsWhenEpochIsNotAsExpected ( ) ;
2076- protected async Task SetFunctionFailsWhenEpochIsNotAsExpected ( Task < IFunctionStore > storeTask )
2077- {
2078- var functionId = TestStoredId . Create ( ) ;
2079-
2080- var store = await storeTask ;
2081- var owner = ReplicaId . NewId ( ) ;
2082- await store . CreateFunction (
2083- functionId ,
2084- "humanInstanceId" ,
2085- param : "test" . ToJson ( ) . ToUtf8Bytes ( ) ,
2086- leaseExpiration : DateTime . UtcNow . Ticks ,
2087- postponeUntil : null ,
2088- timestamp : DateTime . UtcNow . Ticks ,
2089- parent : null ,
2090- owner : owner
2091- ) . ShouldNotBeNullAsync ( ) ;
2092-
2093- var timestamp = DateTime . UtcNow . Ticks ;
2094- var wrongOwner = ReplicaId . NewId ( ) ;
2095-
2096- // SetFunction should fail because the expected replica is wrong
2097- await store . SetFunction (
2098- functionId ,
2099- result : "success" . ToJson ( ) . ToUtf8Bytes ( ) ,
2100- status : new FunctionStatus ( Status . Succeeded ) ,
2101- postponeUntil : null ,
2102- storedException : null ,
2103- timestamp : timestamp ,
2104- expectedReplica : wrongOwner ,
2105- effects : null ,
2106- messages : null ,
2107- storageSession : null
2108- ) . ShouldBeFalseAsync ( ) ;
2109-
2110- var storedFunction = await store . GetFunction ( functionId ) ;
2111- storedFunction . ShouldNotBeNull ( ) ;
2112- storedFunction . Status . ShouldBe ( Status . Executing ) ; // Still in original status
2113- storedFunction . OwnerId . ShouldBe ( owner ) ; // Owner unchanged
2114- }
2115-
21161847 public abstract Task GetInterruptedFunctionsReturnsOnlyInterruptedFunctions ( ) ;
21171848 protected async Task GetInterruptedFunctionsReturnsOnlyInterruptedFunctions ( Task < IFunctionStore > storeTask )
21181849 {
0 commit comments