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 5d51017 commit 4469b89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/spdk/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (e *Engine) checkInitiatorAndTargetCreationRequirements(podIP, initiatorIP,
targetCreationRequired = true
}
} else {
err = fmt.Errorf("invalid initiator and target address for engine %s creation", e.Name)
err = fmt.Errorf("invalid initiator and target addresses for engine %s creation with initiator address %v and target address %v", e.Name, initiatorIP, targetIP)
}

Check warning on line 130 in pkg/spdk/engine.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/engine.go#L128-L130

Added lines #L128 - L130 were not covered by tests
} else if podIP == initiatorIP {
e.log.Info("Creating an initiator instance")
Expand All @@ -135,7 +135,7 @@ func (e *Engine) checkInitiatorAndTargetCreationRequirements(podIP, initiatorIP,
e.log.Info("Creating a target instance")
targetCreationRequired = true
} else {
err = fmt.Errorf("invalid initiator and target address for engine %s creation", e.Name)
err = fmt.Errorf("invalid initiator and target addresses for engine %s creation with initiator address %v and target address %v", e.Name, initiatorIP, targetIP)
}

return initiatorCreationRequired, targetCreationRequired, err
Expand Down
13 changes: 8 additions & 5 deletions pkg/spdk/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *TestSuite) TestCheckInitiatorAndTargetCreationRequirements(c *C) {
expectedError: nil,
},
{
name: "Invalid initiator and target address",
name: "Invalid initiator and target addresses",
podIP: "192.168.1.1",
initiatorIP: "192.168.1.2",
targetIP: "192.168.1.3",
Expand All @@ -79,7 +79,7 @@ func (s *TestSuite) TestCheckInitiatorAndTargetCreationRequirements(c *C) {
standbyTargetPort: 0,
expectedInitiatorCreationRequired: false,
expectedTargetCreationRequired: false,
expectedError: fmt.Errorf("invalid initiator and target address for engine %s creation", "test-engine"),
expectedError: fmt.Errorf("invalid initiator and target addresses for engine test-engine creation with initiator address 192.168.1.2 and target address 192.168.1.3"),
},
{
name: "Standby target instance is already created",
Expand Down Expand Up @@ -107,8 +107,11 @@ func (s *TestSuite) TestCheckInitiatorAndTargetCreationRequirements(c *C) {

initiatorCreationRequired, targetCreationRequired, err := engine.checkInitiatorAndTargetCreationRequirements(testCase.podIP, testCase.initiatorIP, testCase.targetIP)

c.Assert(initiatorCreationRequired, Equals, testCase.expectedInitiatorCreationRequired)
c.Assert(targetCreationRequired, Equals, testCase.expectedTargetCreationRequired)
c.Assert(err, DeepEquals, testCase.expectedError)
c.Assert(initiatorCreationRequired, Equals, testCase.expectedInitiatorCreationRequired,
Commentf("Test case '%s': unexpected initiator creation requirement", testCase.name))
c.Assert(targetCreationRequired, Equals, testCase.expectedTargetCreationRequired,
Commentf("Test case '%s': unexpected target creation requirement", testCase.name))
c.Assert(err, DeepEquals, testCase.expectedError,
Commentf("Test case '%s': unexpected error result", testCase.name))
}
}

0 comments on commit 4469b89

Please sign in to comment.