Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit committed Nov 19, 2024
1 parent f4e2661 commit b04800c
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions pkg/spdk/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,51 @@ func (s *TestSuite) TestIsNewEngine(c *C) {

func (s *TestSuite) TestReleaseTargetAndStandbyTargetPorts(c *C) {
testCases := []struct {
name string
engine *Engine
expectedTargetPortRequired bool
expectedStandbyPortRequired bool
expectedError error
name string
engine *Engine
expectedTargetPort int32
expectedStandbyTargetPort int32
expectedError error
}{
{
name: "Release both target and standby target ports",
engine: &Engine{
TargetPort: 2000,
StandbyTargetPort: 2005,
},
expectedError: nil,
expectedTargetPort: 0,
expectedStandbyTargetPort: 0,
expectedError: nil,
},
{
name: "Release target port only but standby target port is not set",
engine: &Engine{
TargetPort: 2000,
StandbyTargetPort: 0,
},
expectedTargetPort: 0,
expectedStandbyTargetPort: 0,
expectedError: nil,
},
{
name: "Release target port only but standby target port is not set",
engine: &Engine{
TargetPort: 2000,
StandbyTargetPort: 2000,
},
expectedTargetPort: 0,
expectedStandbyTargetPort: 0,
expectedError: nil,
},
{
name: "Release snapshot target port only",
engine: &Engine{
TargetPort: 0,
StandbyTargetPort: 2000,
},
expectedTargetPort: 0,
expectedStandbyTargetPort: 0,
expectedError: nil,
},
}

Expand All @@ -195,5 +227,7 @@ func (s *TestSuite) TestReleaseTargetAndStandbyTargetPorts(c *C) {

err = testCase.engine.releaseTargetAndStandbyTargetPorts(bitmap)
c.Assert(err, DeepEquals, testCase.expectedError, Commentf("Test case '%s': unexpected error result", testCase.name))
c.Assert(testCase.engine.TargetPort, Equals, testCase.expectedTargetPort, Commentf("Test case '%s': unexpected target port", testCase.name))
c.Assert(testCase.engine.StandbyTargetPort, Equals, testCase.expectedStandbyTargetPort, Commentf("Test case '%s': unexpected standby target port", testCase.name))
}
}

0 comments on commit b04800c

Please sign in to comment.