@@ -993,3 +993,64 @@ func (s *SharedServerSuite) TestWorkflow_Describe_WorkflowMetadata() {
993993 s .NotNil (jsonOut .ExecutionConfig .UserMetadata .Summary )
994994 s .NotNil (jsonOut .ExecutionConfig .UserMetadata .Details )
995995}
996+
997+ func (s * SharedServerSuite ) TestWorkflow_Describe_RootWorkflow () {
998+ s .Worker ().OnDevWorkflow (func (ctx workflow.Context , input any ) (any , error ) {
999+ if input .(string ) == "child" {
1000+ return "done" , nil
1001+ }
1002+ ctx = workflow .WithActivityOptions (ctx , workflow.ActivityOptions {
1003+ StartToCloseTimeout : 10 * time .Second ,
1004+ })
1005+ childHandle := workflow .ExecuteChildWorkflow (ctx , DevWorkflow , "child" )
1006+ var childWE workflow.Execution
1007+ err := childHandle .GetChildWorkflowExecution ().Get (ctx , & childWE )
1008+ if err != nil {
1009+ return nil , err
1010+ }
1011+ err = childHandle .Get (ctx , nil )
1012+ if err != nil {
1013+ return nil , err
1014+ }
1015+ return childWE .ID , err
1016+ })
1017+
1018+ run , err := s .Client .ExecuteWorkflow (
1019+ s .Context ,
1020+ client.StartWorkflowOptions {TaskQueue : s .Worker ().Options .TaskQueue },
1021+ DevWorkflow ,
1022+ "ignored" ,
1023+ )
1024+ s .NoError (err )
1025+ var wfRes string
1026+ err = run .Get (s .Context , & wfRes )
1027+ s .NoError (err )
1028+
1029+ // Text
1030+ res := s .Execute (
1031+ "workflow" , "describe" ,
1032+ "--address" , s .Address (),
1033+ "-w" , wfRes ,
1034+ )
1035+ s .NoError (res .Err )
1036+ out := res .Stdout .String ()
1037+ s .ContainsOnSameLine (out , "ParentWorkflowId" , run .GetID ())
1038+ s .ContainsOnSameLine (out , "ParentRunId" , run .GetRunID ())
1039+ s .ContainsOnSameLine (out , "RootWorkflowId" , run .GetID ())
1040+ s .ContainsOnSameLine (out , "RootRunId" , run .GetRunID ())
1041+
1042+ // JSON
1043+ res = s .Execute (
1044+ "workflow" , "describe" ,
1045+ "-o" , "json" ,
1046+ "--address" , s .Address (),
1047+ "-w" , wfRes ,
1048+ )
1049+ s .NoError (res .Err )
1050+ var jsonOut workflowservice.DescribeWorkflowExecutionResponse
1051+ s .NoError (temporalcli .UnmarshalProtoJSONWithOptions (res .Stdout .Bytes (), & jsonOut , true ))
1052+ s .Equal (run .GetID (), jsonOut .WorkflowExecutionInfo .ParentExecution .GetWorkflowId ())
1053+ s .Equal (run .GetRunID (), jsonOut .WorkflowExecutionInfo .ParentExecution .GetRunId ())
1054+ s .Equal (run .GetID (), jsonOut .WorkflowExecutionInfo .RootExecution .GetWorkflowId ())
1055+ s .Equal (run .GetRunID (), jsonOut .WorkflowExecutionInfo .RootExecution .GetRunId ())
1056+ }
0 commit comments