Skip to content

Commit

Permalink
CLI: print treeID/branchID for eventsV2 branchToken in admin wf desc …
Browse files Browse the repository at this point in the history
…command (uber#1354)

* Decode branchToken in adm desc

* bump cli version

* fix unit test
  • Loading branch information
longquanzheng authored Dec 26, 2018
1 parent 383c699 commit 39f0f40
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
20 changes: 20 additions & 0 deletions tools/cli/adminCommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ package cli
import (
"encoding/json"
"fmt"

"github.com/gocql/gocql"
"github.com/uber-common/bark"
"github.com/uber/cadence/.gen/go/admin"
"github.com/uber/cadence/.gen/go/shared"
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/codec"
"github.com/uber/cadence/common/persistence"
cassp "github.com/uber/cadence/common/persistence/cassandra"
"github.com/uber/cadence/tools/cassandra"
Expand Down Expand Up @@ -130,6 +132,24 @@ func AdminDescribeWorkflow(c *cli.Context) {
}

prettyPrintJSONObject(resp)

if resp != nil {
msStr := resp.GetMutableStateInDatabase()
ms := persistence.WorkflowMutableState{}
err = json.Unmarshal([]byte(msStr), &ms)
if err != nil {
ErrorAndExit("json.Unmarshal err", err)
}
if ms.ExecutionInfo != nil && ms.ExecutionInfo.EventStoreVersion == persistence.EventStoreVersionV2 {
branchInfo := shared.HistoryBranch{}
thriftrwEncoder := codec.NewThriftRWEncoder()
err := thriftrwEncoder.Decode(ms.ExecutionInfo.BranchToken, &branchInfo)
if err != nil {
ErrorAndExit("thriftrwEncoder.Decode err", err)
}
prettyPrintJSONObject(branchInfo)
}
}
}

// AdminDeleteWorkflow describe a new workflow execution for admin
Expand Down
2 changes: 1 addition & 1 deletion tools/cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import "github.com/urfave/cli"
const (
// Version is the controlled version string. It should be updated every time
// before we release a new version.
Version = "0.5.6"
Version = "0.5.7"
)

// NewCliApp instantiates a new instance of the CLI application.
Expand Down
12 changes: 7 additions & 5 deletions tools/cli/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
package cli

import (
"strings"
"testing"
"time"

"github.com/golang/mock/gomock"
"github.com/olekukonko/tablewriter"
"github.com/pborman/uuid"
Expand All @@ -36,9 +40,6 @@ import (
clientFrontend "go.uber.org/cadence/.gen/go/cadence/workflowserviceclient"
clientFrontendTest "go.uber.org/cadence/.gen/go/cadence/workflowservicetest"
"go.uber.org/cadence/.gen/go/shared"
"strings"
"testing"
"time"
)

type cliAppSuite struct {
Expand Down Expand Up @@ -476,8 +477,9 @@ var describeTaskListResponse = &shared.DescribeTaskListResponse{

func (s *cliAppSuite) TestAdminDescribeWorkflow() {
resp := &admin.DescribeWorkflowExecutionResponse{
ShardId: common.StringPtr("test-shard-id"),
HistoryAddr: common.StringPtr("ip:port"),
ShardId: common.StringPtr("test-shard-id"),
HistoryAddr: common.StringPtr("ip:port"),
MutableStateInDatabase: common.StringPtr("{}"),
}

s.serverAdminClient.EXPECT().DescribeWorkflowExecution(gomock.Any(), gomock.Any()).Return(resp, nil)
Expand Down

0 comments on commit 39f0f40

Please sign in to comment.