Repository navigation
DAOS-17832 control: Add dmg system rebuild start|stop cmds #16664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9558126
1fe4cd9
1589977
63a8007
cbc17b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -387,6 +387,43 @@ func TestDmg_SystemCommands(t *testing.T) { | |
| "", | ||
| errors.New("not provided"), | ||
| }, | ||
| { | ||
| "system rebuild start", | ||
| "system rebuild start", | ||
| strings.Join([]string{ | ||
| printRequest(t, &control.SystemRebuildManageReq{ | ||
| OpCode: control.PoolRebuildOpCodeStart, | ||
| }), | ||
| }, " "), | ||
| nil, | ||
| }, | ||
| { | ||
| "system rebuild start with force", | ||
| "system rebuild start --force", | ||
| "", | ||
| errors.New("unknown flag"), | ||
| }, | ||
| { | ||
| "system rebuild stop", | ||
| "system rebuild stop", | ||
| strings.Join([]string{ | ||
| printRequest(t, &control.SystemRebuildManageReq{ | ||
| OpCode: control.PoolRebuildOpCodeStop, | ||
| }), | ||
| }, " "), | ||
| nil, | ||
| }, | ||
| { | ||
| "system rebuild stop with force", | ||
| "system rebuild stop --force", | ||
| strings.Join([]string{ | ||
| printRequest(t, &control.SystemRebuildManageReq{ | ||
| OpCode: control.PoolRebuildOpCodeStop, | ||
| Force: true, | ||
| }), | ||
| }, " "), | ||
| nil, | ||
| }, | ||
| { | ||
| "leader query", | ||
| "system leader-query", | ||
|
|
@@ -555,3 +592,116 @@ func TestDmg_systemStartCmd(t *testing.T) { | |
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestDmg_systemRebuildOpCmd_execute(t *testing.T) { | ||
| for name, tc := range map[string]struct { | ||
| ctlCfg *control.Config | ||
| opCode control.PoolRebuildOpCode | ||
| force bool | ||
| verbose bool | ||
| resp *mgmtpb.SystemRebuildManageResp | ||
| msErr error | ||
| expErr error | ||
| expInfo string | ||
| }{ | ||
| "no config": { | ||
| opCode: control.PoolRebuildOpCodeStop, | ||
| expErr: errors.New("system rebuild stop failed: no configuration loaded"), | ||
| }, | ||
| "ms failures": { | ||
| ctlCfg: &control.Config{}, | ||
| resp: &mgmtpb.SystemRebuildManageResp{}, | ||
| msErr: errors.New("failed"), | ||
| expErr: errors.New("failed"), | ||
| }, | ||
| "no pools": { | ||
| ctlCfg: &control.Config{}, | ||
| opCode: control.PoolRebuildOpCodeStop, | ||
| resp: &mgmtpb.SystemRebuildManageResp{}, | ||
| expInfo: "System-rebuild stop request succeeded on 0 pools", | ||
| }, | ||
| "no pools; verbose": { | ||
| ctlCfg: &control.Config{}, | ||
| opCode: control.PoolRebuildOpCodeStart, | ||
| verbose: true, | ||
| resp: &mgmtpb.SystemRebuildManageResp{}, | ||
| expInfo: "System-rebuild start request succeeded on pools []", | ||
| }, | ||
| "pool stop failed": { | ||
| ctlCfg: &control.Config{}, | ||
| opCode: control.PoolRebuildOpCodeStop, | ||
| resp: &mgmtpb.SystemRebuildManageResp{ | ||
| Results: []*mgmtpb.PoolRebuildManageResult{ | ||
| { | ||
| Errored: true, | ||
| Msg: "failed", | ||
| Id: "foo", | ||
| OpCode: uint32(control.PoolRebuildOpCodeStop), | ||
| }, | ||
| { | ||
| Errored: true, | ||
| Msg: "failed", | ||
| Id: "bar", | ||
| OpCode: uint32(control.PoolRebuildOpCodeStop), | ||
| }, | ||
| { | ||
| Id: "baz", | ||
| OpCode: uint32(control.PoolRebuildOpCodeStop), | ||
| }, | ||
| }, | ||
| }, | ||
| expErr: errors.New("failed on pool foo: failed, pool-rebuild stop failed on pool bar"), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no change requested, just not understanding why the ": failed" (Msg) would not be expected to be seen for the failure associated with pool 'bar'. And not sure where "pool-rebuild stop" comes from for the pool 'bar' but does not show up for the pool 'foo' portion of the expected errors.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is just a subset of the Error string expected, validates that the substring is contained in the error message |
||
| expInfo: "System-rebuild stop request succeeded on 1 pool", | ||
| }, | ||
| "pool start succeeded; verbose": { | ||
| ctlCfg: &control.Config{}, | ||
| opCode: control.PoolRebuildOpCodeStart, | ||
| verbose: true, | ||
| resp: &mgmtpb.SystemRebuildManageResp{ | ||
| Results: []*mgmtpb.PoolRebuildManageResult{ | ||
| { | ||
| Id: "foo", | ||
| OpCode: uint32(control.PoolRebuildOpCodeStop), | ||
| }, | ||
| { | ||
| Id: "bar", | ||
| OpCode: uint32(control.PoolRebuildOpCodeStop), | ||
| }, | ||
| { | ||
| Id: "baz", | ||
| OpCode: uint32(control.PoolRebuildOpCodeStop), | ||
| }, | ||
| }, | ||
| }, | ||
| expInfo: "System-rebuild start request succeeded on pools [foo bar baz]", | ||
| }, | ||
| } { | ||
| t.Run(name, func(t *testing.T) { | ||
| log, buf := logging.NewTestLogger(t.Name()) | ||
| defer test.ShowBufferOnFailure(t, buf) | ||
|
|
||
| mi := control.NewMockInvoker(log, &control.MockInvokerConfig{ | ||
| UnaryResponse: control.MockMSResponse("10.0.0.1:10001", | ||
| tc.msErr, tc.resp), | ||
| }) | ||
|
|
||
| rbldCmd := new(systemRebuildOpCmd) | ||
| rbldCmd.setInvoker(mi) | ||
| rbldCmd.SetLog(log) | ||
| rbldCmd.setConfig(tc.ctlCfg) | ||
| rbldCmd.Verbose = tc.verbose | ||
|
|
||
| gotErr := rbldCmd.execute(tc.opCode, tc.force) | ||
| test.CmpErr(t, tc.expErr, gotErr) | ||
|
|
||
| if !strings.Contains(buf.String(), tc.expInfo) { | ||
| t.Fatalf("expected info log output to contain %s, got %s\n", | ||
| tc.expInfo, buf.String()) | ||
| } | ||
| if tc.expInfo == "" && strings.Contains(buf.String(), "INFO") { | ||
| t.Fatalf("unexpected info log output printed, got %s\n", | ||
| buf.String()) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor suggestion (change only if need to change something else in the PR I suppose): Suggest still printing out the number of pools in addition to the list of pool identifiers. Useful to the admin reading the output if the system has many 10s of pools and doesn't want to manually count or otherwise process the command output to derive the number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will address either on repush or on subsequent PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix applied in #16875