Skip to content

Commit

Permalink
[issue-1198] adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
katarzynakulpa committed Jul 9, 2024
1 parent 1891d5c commit 34c4b3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,6 @@ func (s *CSINodeService) processFakeAttachInNodeStageVolume(
if isFakeAttachNeeded {
if volumeCR.Annotations[fakeAttachVolumeAnnotation] != fakeAttachVolumeKey {
volumeCR.Annotations[fakeAttachVolumeAnnotation] = fakeAttachVolumeKey
if volumeCR.Spec.OperationalStatus == apiV1.OperationalStatusOperative {
if err := s.crHelper.UpdateVolumeOpStatus(ctx, volumeCR, apiV1.OperationalStatusMissing); err != nil {
ll.Errorf("unable to change volume operational status to MISSING with error: %v", err)
}
}
ll.Warningf("Adding fake-attach annotation to the volume with ID %s", volumeID)
if !isFakeAttachDR {
s.VolumeManager.recorder.Eventf(volumeCR, eventing.FakeAttachInvolved,
Expand All @@ -190,6 +185,9 @@ func (s *CSINodeService) processFakeAttachInNodeStageVolume(
return status.Error(codes.Internal, fmt.Sprintf("failed to mount device in stage volume: %s", err.Error()))
}
}
if volumeCR.Spec.OperationalStatus != apiV1.OperationalStatusMissing {
volumeCR.Spec.OperationalStatus = apiV1.OperationalStatusMissing
}
} else if volumeCR.Annotations[fakeAttachVolumeAnnotation] == fakeAttachVolumeKey {
delete(volumeCR.Annotations, fakeAttachVolumeAnnotation)
ll.Warningf("Removing fake-attach annotation for volume %s", volumeID)
Expand Down Expand Up @@ -401,6 +399,8 @@ func (s *CSINodeService) NodeStageVolume(ctx context.Context, req *csi.NodeStage
volumeCR.Annotations[wbtChangedVolumeAnnotation] = wbtChangedVolumeKey
}
}
ll.Errorf("raz dwa")
ll.Error(volumeCR)

if currStatus != apiV1.VolumeReady {
volumeCR.Spec.CSIStatus = newStatus
Expand Down
1 change: 1 addition & 0 deletions pkg/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ var _ = Describe("CSINodeService Fake-Attach", func() {
err = node.k8sClient.ReadCR(testCtx, testV1ID, "", vol1)
Expect(err).To(BeNil())
Expect(vol1.Spec.CSIStatus).To(Equal(apiV1.VolumeReady))
Expect(vol1.Spec.OperationalStatus).To(Equal(apiV1.OperationalStatusMissing))
Expect(vol1.Annotations[fakeDeviceVolumeAnnotation]).To(Equal(newFakeDevice))
})
It("Should publish unhealthy fs-mode volume with fake-attach annotation", func() {
Expand Down

0 comments on commit 34c4b3d

Please sign in to comment.