@@ -1871,6 +1871,96 @@ func (ts *IntegrationTestSuite) TestCancelChildAndExecuteActivityRace() {
1871
1871
ts .NoError (err )
1872
1872
}
1873
1873
1874
+ func (ts * IntegrationTestSuite ) TestQueryWorkflowRejectNotOpen () {
1875
+ ctx , cancel := context .WithCancel (context .Background ())
1876
+ defer cancel ()
1877
+
1878
+ // Start workflow
1879
+ run , err := ts .client .ExecuteWorkflow (ctx , ts .startWorkflowOptions ("test-workflow-query-reject-not-open" ),
1880
+ ts .workflows .QueryTestWorkflow )
1881
+ ts .NoError (err )
1882
+
1883
+ // Query when the workflow is running
1884
+ queryVal , err := ts .client .QueryWorkflowWithOptions (ctx , & client.QueryWorkflowWithOptionsRequest {
1885
+ WorkflowID : run .GetID (),
1886
+ RunID : run .GetRunID (),
1887
+ QueryType : "query" ,
1888
+ QueryRejectCondition : enumspb .QUERY_REJECT_CONDITION_NONE ,
1889
+ })
1890
+ ts .NoError (err )
1891
+ var queryRes string
1892
+ ts .NoError (queryVal .QueryResult .Get (& queryRes ))
1893
+ ts .Equal ("running" , queryRes )
1894
+
1895
+ ts .NoError (ts .client .SignalWorkflow (ctx , run .GetID (), run .GetRunID (), "signal" , false ))
1896
+ ts .NoError (run .Get (ctx , nil ))
1897
+
1898
+ // Query when the workflow is completed
1899
+ queryVal , err = ts .client .QueryWorkflowWithOptions (ctx , & client.QueryWorkflowWithOptionsRequest {
1900
+ WorkflowID : run .GetID (),
1901
+ RunID : run .GetRunID (),
1902
+ QueryType : "query" ,
1903
+ QueryRejectCondition : enumspb .QUERY_REJECT_CONDITION_NOT_COMPLETED_CLEANLY ,
1904
+ })
1905
+ ts .NoError (err )
1906
+ queryRes = ""
1907
+ ts .NoError (queryVal .QueryResult .Get (& queryRes ))
1908
+ ts .Equal ("completed" , queryRes )
1909
+
1910
+ queryVal , err = ts .client .QueryWorkflowWithOptions (ctx , & client.QueryWorkflowWithOptionsRequest {
1911
+ WorkflowID : run .GetID (),
1912
+ RunID : run .GetRunID (),
1913
+ QueryType : "query" ,
1914
+ QueryRejectCondition : enumspb .QUERY_REJECT_CONDITION_NOT_OPEN ,
1915
+ })
1916
+ ts .NoError (err )
1917
+ ts .Equal (enumspb .WORKFLOW_EXECUTION_STATUS_COMPLETED , queryVal .QueryRejected .Status )
1918
+ }
1919
+
1920
+ func (ts * IntegrationTestSuite ) TestQueryWorkflowRejectNotCompleteCleanly () {
1921
+ ctx , cancel := context .WithCancel (context .Background ())
1922
+ defer cancel ()
1923
+
1924
+ // Start workflow
1925
+ run , err := ts .client .ExecuteWorkflow (ctx , ts .startWorkflowOptions ("test-workflow-query-not-complete-cleanly" ),
1926
+ ts .workflows .QueryTestWorkflow )
1927
+ ts .NoError (err )
1928
+
1929
+ // Query when the workflow is running
1930
+ queryVal , err := ts .client .QueryWorkflowWithOptions (ctx , & client.QueryWorkflowWithOptionsRequest {
1931
+ WorkflowID : run .GetID (),
1932
+ RunID : run .GetRunID (),
1933
+ QueryType : "query" ,
1934
+ QueryRejectCondition : enumspb .QUERY_REJECT_CONDITION_NONE ,
1935
+ })
1936
+ ts .NoError (err )
1937
+ var queryRes string
1938
+ ts .NoError (queryVal .QueryResult .Get (& queryRes ))
1939
+ ts .Equal ("running" , queryRes )
1940
+
1941
+ ts .NoError (ts .client .SignalWorkflow (ctx , run .GetID (), run .GetRunID (), "signal" , true ))
1942
+ ts .Error (run .Get (ctx , nil ))
1943
+
1944
+ // Query when the workflow is failed
1945
+ queryVal , err = ts .client .QueryWorkflowWithOptions (ctx , & client.QueryWorkflowWithOptionsRequest {
1946
+ WorkflowID : run .GetID (),
1947
+ RunID : run .GetRunID (),
1948
+ QueryType : "query" ,
1949
+ QueryRejectCondition : enumspb .QUERY_REJECT_CONDITION_NOT_OPEN ,
1950
+ })
1951
+ ts .NoError (err )
1952
+ ts .Equal (enumspb .WORKFLOW_EXECUTION_STATUS_FAILED , queryVal .QueryRejected .Status )
1953
+
1954
+ queryVal , err = ts .client .QueryWorkflowWithOptions (ctx , & client.QueryWorkflowWithOptionsRequest {
1955
+ WorkflowID : run .GetID (),
1956
+ RunID : run .GetRunID (),
1957
+ QueryType : "query" ,
1958
+ QueryRejectCondition : enumspb .QUERY_REJECT_CONDITION_NOT_COMPLETED_CLEANLY ,
1959
+ })
1960
+ ts .NoError (err )
1961
+ ts .Equal (enumspb .WORKFLOW_EXECUTION_STATUS_FAILED , queryVal .QueryRejected .Status )
1962
+ }
1963
+
1874
1964
func (ts * IntegrationTestSuite ) TestInterceptorCalls () {
1875
1965
ctx , cancel := context .WithCancel (context .Background ())
1876
1966
defer cancel ()
0 commit comments