Skip to content

Commit 4adc76e

Browse files
authored
Removed IFunctionStore's SetFunction
1 parent d455237 commit 4adc76e

15 files changed

Lines changed: 0 additions & 634 deletions

File tree

Core/Cleipnir.ResilientFunctions.Tests/InMemoryTests/StoreTests.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -226,30 +226,6 @@ public override Task PostponedSetsOwnerToNull()
226226
public override Task SucceedSetsOwnerToNull()
227227
=> SucceedSetsOwnerToNull(FunctionStoreFactory.Create());
228228

229-
[TestMethod]
230-
public override Task SetFunctionSucceedsWithSucceededStatus()
231-
=> SetFunctionSucceedsWithSucceededStatus(FunctionStoreFactory.Create());
232-
233-
[TestMethod]
234-
public override Task SetFunctionSucceedsWithFailedStatus()
235-
=> SetFunctionSucceedsWithFailedStatus(FunctionStoreFactory.Create());
236-
237-
[TestMethod]
238-
public override Task SetFunctionSucceedsWithPostponedStatus()
239-
=> SetFunctionSucceedsWithPostponedStatus(FunctionStoreFactory.Create());
240-
241-
[TestMethod]
242-
public override Task SetFunctionSucceedsWithSuspendedStatus()
243-
=> SetFunctionSucceedsWithSuspendedStatus(FunctionStoreFactory.Create());
244-
245-
[TestMethod]
246-
public override Task SetFunctionFailsWhenInterruptedForPostponedAndSuspended()
247-
=> SetFunctionFailsWhenInterruptedForPostponedAndSuspended(FunctionStoreFactory.Create());
248-
249-
[TestMethod]
250-
public override Task SetFunctionFailsWhenEpochIsNotAsExpected()
251-
=> SetFunctionFailsWhenEpochIsNotAsExpected(FunctionStoreFactory.Create());
252-
253229
[TestMethod]
254230
public override Task GetInterruptedFunctionsReturnsOnlyInterruptedFunctions()
255231
=> GetInterruptedFunctionsReturnsOnlyInterruptedFunctions(FunctionStoreFactory.Create());

Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/StoreTests.cs

Lines changed: 0 additions & 269 deletions
Original file line numberDiff line numberDiff line change
@@ -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
{

Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/WatchDogsTests/CrashableFunctionStore.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,6 @@ public Task<bool> SetFunctionState(
111111
expectedReplica
112112
);
113113

114-
public Task<bool> SetFunction(
115-
StoredId storedId,
116-
byte[]? result,
117-
FunctionStatus status,
118-
long? postponeUntil,
119-
StoredException? storedException,
120-
long timestamp,
121-
ReplicaId expectedReplica,
122-
IReadOnlyList<StoredEffect>? effects,
123-
IReadOnlyList<StoredMessage>? messages,
124-
IStorageSession? storageSession
125-
) => _crashed
126-
? Task.FromException<bool>(new TimeoutException())
127-
: _inner.SetFunction(storedId, result, status, postponeUntil, storedException, timestamp, expectedReplica, effects, messages, storageSession);
128-
129114
public Task<bool> SucceedFunction(
130115
StoredId storedId,
131116
byte[]? result,

Core/Cleipnir.ResilientFunctions/Storage/IFunctionStore.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,6 @@ Task<bool> SetFunctionState(
5959
ReplicaId? expectedReplica
6060
);
6161

62-
Task<bool> SetFunction(
63-
StoredId storedId,
64-
byte[]? result,
65-
FunctionStatus status,
66-
long? postponeUntil,
67-
StoredException? storedException,
68-
long timestamp,
69-
ReplicaId expectedReplica,
70-
IReadOnlyList<StoredEffect>? effects,
71-
IReadOnlyList<StoredMessage>? messages,
72-
IStorageSession? storageSession
73-
);
74-
7562
Task<bool> SucceedFunction(
7663
StoredId storedId,
7764
byte[]? result,

0 commit comments

Comments
 (0)