Skip to content

Commit

Permalink
Add unit tests for isolated iSCSI code for attaching volumes (#1727)
Browse files Browse the repository at this point in the history
  • Loading branch information
vivintw authored Sep 26, 2024
1 parent 77449b3 commit e648ed2
Show file tree
Hide file tree
Showing 13 changed files with 5,485 additions and 425 deletions.
2 changes: 1 addition & 1 deletion frontend/csi/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

"github.com/netapp/trident/config"
mockControllerAPI "github.com/netapp/trident/mocks/mock_frontend/mock_csi/mock_controller_api"
"github.com/netapp/trident/mocks/mock_utils/mock_iscsi"
"github.com/netapp/trident/mocks/mock_utils/mock_models/mock_luks"
mock_iscsi "github.com/netapp/trident/mocks/mock_utils/mock_reconcile_utils"
"github.com/netapp/trident/utils"
"github.com/netapp/trident/utils/errors"
"github.com/netapp/trident/utils/models"
Expand Down
2 changes: 1 addition & 1 deletion frontend/csi/volume_publish_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"go.uber.org/mock/gomock"

"github.com/netapp/trident/config"
"github.com/netapp/trident/mocks/mock_utils/mock_iscsi"
"github.com/netapp/trident/mocks/mock_utils/mock_models"
mock_iscsi "github.com/netapp/trident/mocks/mock_utils/mock_reconcile_utils"
"github.com/netapp/trident/utils"
"github.com/netapp/trident/utils/errors"
"github.com/netapp/trident/utils/models"
Expand Down
144 changes: 144 additions & 0 deletions mocks/mock_utils/mock_iscsi/mock_iscsi_devices_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions mocks/mock_utils/mock_iscsi/mock_iscsi_filesystem_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions mocks/mock_utils/mock_iscsi/mock_iscsi_mount_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions mocks/mock_utils/mock_iscsi/mock_iscsi_os_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion utils/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -1193,5 +1193,5 @@ func findMultipathDeviceForDevice(ctx context.Context, device string) string {
}

func getLunSerial(ctx context.Context, path string) (string, error) {
return iscsi.GetLunSerial(ctx, path)
return iscsiClient.GetLunSerial(ctx, path)
}
6 changes: 4 additions & 2 deletions utils/iscsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"strings"
"time"

"github.com/spf13/afero"

"github.com/netapp/trident/config"
"github.com/netapp/trident/internal/fiji"
. "github.com/netapp/trident/logging"
Expand All @@ -36,7 +38,7 @@ const (
var (
IscsiUtils = iscsi.NewReconcileUtils(chrootPathPrefix, NewOSClient())
iscsiClient = iscsi.NewDetailed(chrootPathPrefix, command, iscsi.DefaultSelfHealingExclusion, NewOSClient(),
NewDevicesClient(), NewFilesystemClient(), NewMountClient(), IscsiUtils)
NewDevicesClient(), NewFilesystemClient(), NewMountClient(), IscsiUtils, afero.Afero{Fs: afero.NewOsFs()})

// Non-persistent map to maintain flush delays/errors if any, for device path(s).
iSCSIVolumeFlushExceptions = make(map[string]time.Time)
Expand Down Expand Up @@ -996,7 +998,7 @@ func execIscsiadmCommand(ctx context.Context, args ...string) ([]byte, error) {
}

func listAllISCSIDevices(ctx context.Context) {
iscsi.ListAllDevices(ctx)
iscsiClient.ListAllDevices(ctx)
}

func getISCSISessionInfo(ctx context.Context) ([]iscsi.SessionInfo, error) {
Expand Down
Loading

0 comments on commit e648ed2

Please sign in to comment.