Skip to content

Commit

Permalink
fix: fix checkstatus post req and resp body (#454)
Browse files Browse the repository at this point in the history
* fix: fix typo DBBackModeFull

* fix: fix checkstatus post req and resp body

* chore: update backup test
  • Loading branch information
mlycore authored Nov 14, 2023
1 parent 202e269 commit 8fcdf3c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pitr/cli/internal/cmd/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var BackupCmd = &cobra.Command{
// convert BackupModeStr to BackupMode
switch BackupModeStr {
case "FULL", "full":
BackupMode = model.BDBackModeFull
BackupMode = model.DBBackModeFull
case "PTRACK", "ptrack":
BackupMode = model.DBBackModePTrack
}
Expand Down
1 change: 1 addition & 0 deletions pitr/cli/internal/cmd/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ var _ = Describe("test backup mock", func() {
BeforeEach(func() {
mockCtrl = gomock.NewController(GinkgoT())
mockIreq = mock_httputils.NewMockIreq(mockCtrl)
mockIreq.EXPECT().Body(gomock.Any()).AnyTimes()

monkey.Patch(httputils.NewRequest, func(ctx context.Context, method, url string) httputils.Ireq {
return mockIreq
Expand Down
10 changes: 9 additions & 1 deletion pitr/cli/internal/pkg/agent-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,21 @@ func NewAgentServer(addr string) IAgentServer {
}
}

type CommonOutResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data any `json:"data"`
}

// CheckStatus check agent server is alive
func (as *agentServer) CheckStatus(in *model.HealthCheckIn) error {
url := fmt.Sprintf("%s%s", as.addr, as._apiHealthCheck)

out := &CommonOutResp{}
r := httputils.NewRequest(context.Background(), http.MethodPost, url)
r.Body(in)

if err := r.Send(in); err != nil {
if err := r.Send(out); err != nil {
return xerr.NewUnknownErr(url, in, nil, err)
}

Expand Down
2 changes: 1 addition & 1 deletion pitr/cli/internal/pkg/model/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ const (
SsBackupStatusCheckError BackupStatus = "CheckError"
SsBackupStatusCanceled BackupStatus = "Canceled"

BDBackModeFull DBBackupMode = "FULL"
DBBackModeFull DBBackupMode = "FULL"
DBBackModePTrack DBBackupMode = "PTRACK"
)

0 comments on commit 8fcdf3c

Please sign in to comment.