@@ -1908,6 +1908,10 @@ def my_signal(self, value: str) -> None:
1908
1908
self ._last_signal = value
1909
1909
workflow .logger .info (f"Signal: { value } " )
1910
1910
1911
+ @workflow .update
1912
+ def my_update (self , value : str ) -> None :
1913
+ workflow .logger .info (f"Update: { value } " )
1914
+
1911
1915
@workflow .query
1912
1916
def last_signal (self ) -> str :
1913
1917
return self ._last_signal
@@ -1955,14 +1959,22 @@ async def test_workflow_logging(client: Client, env: WorkflowEnvironment):
1955
1959
id = f"workflow-{ uuid .uuid4 ()} " ,
1956
1960
task_queue = worker .task_queue ,
1957
1961
)
1958
- # Send a couple signals
1962
+ # Send some signals and updates
1959
1963
await handle .signal (LoggingWorkflow .my_signal , "signal 1" )
1960
1964
await handle .signal (LoggingWorkflow .my_signal , "signal 2" )
1965
+ await handle .execute_update (
1966
+ LoggingWorkflow .my_update , "update 1" , id = "update-1"
1967
+ )
1968
+ await handle .execute_update (
1969
+ LoggingWorkflow .my_update , "update 2" , id = "update-2"
1970
+ )
1961
1971
assert "signal 2" == await handle .query (LoggingWorkflow .last_signal )
1962
1972
1963
- # Confirm two logs happened
1973
+ # Confirm logs were produced
1964
1974
assert capturer .find_log ("Signal: signal 1 ({'attempt':" )
1965
1975
assert capturer .find_log ("Signal: signal 2" )
1976
+ assert capturer .find_log ("Update: update 1" )
1977
+ assert capturer .find_log ("Update: update 2" )
1966
1978
assert not capturer .find_log ("Signal: signal 3" )
1967
1979
# Also make sure it has some workflow info and correct funcName
1968
1980
record = capturer .find_log ("Signal: signal 1" )
@@ -1974,6 +1986,15 @@ async def test_workflow_logging(client: Client, env: WorkflowEnvironment):
1974
1986
)
1975
1987
# Since we enabled full info, make sure it's there
1976
1988
assert isinstance (record .__dict__ ["workflow_info" ], workflow .Info )
1989
+ # Check the log emitted by the update execution.
1990
+ record = capturer .find_log ("Update: update 1" )
1991
+ assert (
1992
+ record
1993
+ and record .__dict__ ["temporal_workflow" ]["update_id" ] == "update-1"
1994
+ and record .__dict__ ["temporal_workflow" ]["update_name" ] == "my_update"
1995
+ and "'update_id': 'update-1'" in record .message
1996
+ and "'update_name': 'my_update'" in record .message
1997
+ )
1977
1998
1978
1999
# Clear queue and start a new one with more signals
1979
2000
capturer .log_queue .queue .clear ()
@@ -1983,7 +2004,7 @@ async def test_workflow_logging(client: Client, env: WorkflowEnvironment):
1983
2004
task_queue = worker .task_queue ,
1984
2005
max_cached_workflows = 0 ,
1985
2006
) as worker :
1986
- # Send a couple signals
2007
+ # Send signals and updates
1987
2008
await handle .signal (LoggingWorkflow .my_signal , "signal 3" )
1988
2009
await handle .signal (LoggingWorkflow .my_signal , "finish" )
1989
2010
await handle .result ()
0 commit comments