mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-05-21 23:06:42 +00:00
cleanup: address golangci 'usetesting' linter issues
When a context.Context is needed in a unit test, t.Context() should be used instead of creating a new one with context.TODO() or context.Background(). Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
parent
be5462cf62
commit
457ffe884a
@ -47,7 +47,7 @@ func TestControllerServer_validateCreateVolumeGroupSnapshotRequest(t *testing.T)
|
|||||||
{
|
{
|
||||||
"valid CreateVolumeGroupSnapshotRequest",
|
"valid CreateVolumeGroupSnapshotRequest",
|
||||||
args{
|
args{
|
||||||
context.Background(), &csi.CreateVolumeGroupSnapshotRequest{
|
t.Context(), &csi.CreateVolumeGroupSnapshotRequest{
|
||||||
Name: "vg-snap-1",
|
Name: "vg-snap-1",
|
||||||
SourceVolumeIds: []string{"vg-1"},
|
SourceVolumeIds: []string{"vg-1"},
|
||||||
Parameters: map[string]string{
|
Parameters: map[string]string{
|
||||||
@ -62,7 +62,7 @@ func TestControllerServer_validateCreateVolumeGroupSnapshotRequest(t *testing.T)
|
|||||||
{
|
{
|
||||||
"empty request name in CreateVolumeGroupSnapshotRequest",
|
"empty request name in CreateVolumeGroupSnapshotRequest",
|
||||||
args{
|
args{
|
||||||
context.Background(), &csi.CreateVolumeGroupSnapshotRequest{
|
t.Context(), &csi.CreateVolumeGroupSnapshotRequest{
|
||||||
SourceVolumeIds: []string{"vg-1"},
|
SourceVolumeIds: []string{"vg-1"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -72,7 +72,7 @@ func TestControllerServer_validateCreateVolumeGroupSnapshotRequest(t *testing.T)
|
|||||||
{
|
{
|
||||||
"empty SourceVolumeIds in CreateVolumeGroupSnapshotRequest",
|
"empty SourceVolumeIds in CreateVolumeGroupSnapshotRequest",
|
||||||
args{
|
args{
|
||||||
context.Background(), &csi.CreateVolumeGroupSnapshotRequest{
|
t.Context(), &csi.CreateVolumeGroupSnapshotRequest{
|
||||||
Name: "vg-snap-1",
|
Name: "vg-snap-1",
|
||||||
SourceVolumeIds: []string{"vg-1"},
|
SourceVolumeIds: []string{"vg-1"},
|
||||||
},
|
},
|
||||||
@ -83,7 +83,7 @@ func TestControllerServer_validateCreateVolumeGroupSnapshotRequest(t *testing.T)
|
|||||||
{
|
{
|
||||||
"empty clusterID in CreateVolumeGroupSnapshotRequest",
|
"empty clusterID in CreateVolumeGroupSnapshotRequest",
|
||||||
args{
|
args{
|
||||||
context.Background(), &csi.CreateVolumeGroupSnapshotRequest{
|
t.Context(), &csi.CreateVolumeGroupSnapshotRequest{
|
||||||
Name: "vg-snap-1",
|
Name: "vg-snap-1",
|
||||||
SourceVolumeIds: []string{"vg-1"},
|
SourceVolumeIds: []string{"vg-1"},
|
||||||
Parameters: map[string]string{"fsName": "value"},
|
Parameters: map[string]string{"fsName": "value"},
|
||||||
@ -95,7 +95,7 @@ func TestControllerServer_validateCreateVolumeGroupSnapshotRequest(t *testing.T)
|
|||||||
{
|
{
|
||||||
"empty fsName in CreateVolumeGroupSnapshotRequest",
|
"empty fsName in CreateVolumeGroupSnapshotRequest",
|
||||||
args{
|
args{
|
||||||
context.Background(), &csi.CreateVolumeGroupSnapshotRequest{
|
t.Context(), &csi.CreateVolumeGroupSnapshotRequest{
|
||||||
Name: "vg-snap-1",
|
Name: "vg-snap-1",
|
||||||
SourceVolumeIds: []string{"vg-1"},
|
SourceVolumeIds: []string{"vg-1"},
|
||||||
Parameters: map[string]string{"clusterID": "value"},
|
Parameters: map[string]string{"clusterID": "value"},
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package cephfs
|
package cephfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/csi-addons/spec/lib/go/fence"
|
"github.com/csi-addons/spec/lib/go/fence"
|
||||||
@ -38,7 +37,7 @@ func TestFenceClusterNetwork(t *testing.T) {
|
|||||||
Cidrs: nil,
|
Cidrs: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := controller.FenceClusterNetwork(context.TODO(), req)
|
_, err := controller.FenceClusterNetwork(t.Context(), req)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +53,6 @@ func TestUnfenceClusterNetwork(t *testing.T) {
|
|||||||
Secrets: nil,
|
Secrets: nil,
|
||||||
Cidrs: nil,
|
Cidrs: nil,
|
||||||
}
|
}
|
||||||
_, err := controller.UnfenceClusterNetwork(context.TODO(), req)
|
_, err := controller.UnfenceClusterNetwork(t.Context(), req)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package networkfence
|
package networkfence
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@ -252,7 +251,7 @@ listed 1 entries`,
|
|||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
result := nf.parseBlocklistForCIDR(context.TODO(), tc.blocklist, tc.cidr)
|
result := nf.parseBlocklistForCIDR(t.Context(), tc.blocklist, tc.cidr)
|
||||||
require.Equal(t, tc.expected, result)
|
require.Equal(t, tc.expected, result)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ limitations under the License.
|
|||||||
package rbd
|
package rbd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/csi-addons/spec/lib/go/fence"
|
"github.com/csi-addons/spec/lib/go/fence"
|
||||||
@ -35,7 +34,7 @@ func TestFenceClusterNetwork(t *testing.T) {
|
|||||||
Cidrs: nil,
|
Cidrs: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := controller.FenceClusterNetwork(context.TODO(), req)
|
_, err := controller.FenceClusterNetwork(t.Context(), req)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +50,6 @@ func TestUnfenceClusterNetwork(t *testing.T) {
|
|||||||
Secrets: nil,
|
Secrets: nil,
|
||||||
Cidrs: nil,
|
Cidrs: nil,
|
||||||
}
|
}
|
||||||
_, err := controller.UnfenceClusterNetwork(context.TODO(), req)
|
_, err := controller.UnfenceClusterNetwork(t.Context(), req)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package rbd
|
package rbd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ceph/ceph-csi/internal/util"
|
"github.com/ceph/ceph-csi/internal/util"
|
||||||
@ -39,7 +38,7 @@ func TestControllerReclaimSpace(t *testing.T) {
|
|||||||
Secrets: nil,
|
Secrets: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := controller.ControllerReclaimSpace(context.TODO(), req)
|
_, err := controller.ControllerReclaimSpace(t.Context(), req)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +57,6 @@ func TestNodeReclaimSpace(t *testing.T) {
|
|||||||
Secrets: nil,
|
Secrets: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := node.NodeReclaimSpace(context.TODO(), req)
|
_, err := node.NodeReclaimSpace(t.Context(), req)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ func TestValidateSchedulingInterval(t *testing.T) {
|
|||||||
|
|
||||||
func TestValidateSchedulingDetails(t *testing.T) {
|
func TestValidateSchedulingDetails(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ctx := context.TODO()
|
ctx := t.Context()
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
parameters map[string]string
|
parameters map[string]string
|
||||||
@ -213,7 +213,7 @@ func TestGetSchedulingDetails(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckVolumeResyncStatus(t *testing.T) {
|
func TestCheckVolumeResyncStatus(t *testing.T) {
|
||||||
ctx := context.TODO()
|
ctx := t.Context()
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -406,7 +406,7 @@ func TestCheckRemoteSiteStatus(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
if ready := checkRemoteSiteStatus(context.TODO(), tt.args.GetAllSitesStatus()); ready != tt.wantReady {
|
if ready := checkRemoteSiteStatus(t.Context(), tt.args.GetAllSitesStatus()); ready != tt.wantReady {
|
||||||
t.Errorf("checkRemoteSiteStatus() ready = %v, expect ready = %v", ready, tt.wantReady)
|
t.Errorf("checkRemoteSiteStatus() ready = %v, expect ready = %v", ready, tt.wantReady)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -546,7 +546,7 @@ func Test_getFlattenMode(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "flattenMode option not set",
|
name: "flattenMode option not set",
|
||||||
args: args{
|
args: args{
|
||||||
ctx: context.TODO(),
|
ctx: t.Context(),
|
||||||
parameters: map[string]string{},
|
parameters: map[string]string{},
|
||||||
},
|
},
|
||||||
want: types.FlattenModeNever,
|
want: types.FlattenModeNever,
|
||||||
@ -554,7 +554,7 @@ func Test_getFlattenMode(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "flattenMode option set to never",
|
name: "flattenMode option set to never",
|
||||||
args: args{
|
args: args{
|
||||||
ctx: context.TODO(),
|
ctx: t.Context(),
|
||||||
parameters: map[string]string{
|
parameters: map[string]string{
|
||||||
flattenModeKey: string(types.FlattenModeNever),
|
flattenModeKey: string(types.FlattenModeNever),
|
||||||
},
|
},
|
||||||
@ -564,7 +564,7 @@ func Test_getFlattenMode(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "flattenMode option set to force",
|
name: "flattenMode option set to force",
|
||||||
args: args{
|
args: args{
|
||||||
ctx: context.TODO(),
|
ctx: t.Context(),
|
||||||
parameters: map[string]string{
|
parameters: map[string]string{
|
||||||
flattenModeKey: string(types.FlattenModeForce),
|
flattenModeKey: string(types.FlattenModeForce),
|
||||||
},
|
},
|
||||||
@ -575,7 +575,7 @@ func Test_getFlattenMode(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "flattenMode option set to invalid value",
|
name: "flattenMode option set to invalid value",
|
||||||
args: args{
|
args: args{
|
||||||
ctx: context.TODO(),
|
ctx: t.Context(),
|
||||||
parameters: map[string]string{
|
parameters: map[string]string{
|
||||||
flattenModeKey: "invalid123",
|
flattenModeKey: "invalid123",
|
||||||
},
|
},
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package csicommon
|
package csicommon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -233,7 +232,7 @@ func TestFilesystemNodeGetVolumeStats(t *testing.T) {
|
|||||||
|
|
||||||
// retry until a mountpoint is found
|
// retry until a mountpoint is found
|
||||||
for {
|
for {
|
||||||
stats, err := FilesystemNodeGetVolumeStats(context.TODO(), mount.New(""), cwd, true)
|
stats, err := FilesystemNodeGetVolumeStats(t.Context(), mount.New(""), cwd, true)
|
||||||
if err != nil && cwd != "/" && strings.HasSuffix(err.Error(), "is not mounted") {
|
if err != nil && cwd != "/" && strings.HasSuffix(err.Error(), "is not mounted") {
|
||||||
// try again with the parent directory
|
// try again with the parent directory
|
||||||
cwd = filepath.Dir(cwd)
|
cwd = filepath.Dir(cwd)
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package kms
|
package kms
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@ -93,7 +92,7 @@ func TestWorkflowSecretsMetadataKMS(t *testing.T) {
|
|||||||
// plainDEK is the (LUKS) passphrase for the volume
|
// plainDEK is the (LUKS) passphrase for the volume
|
||||||
plainDEK := "usually created with generateNewEncryptionPassphrase()"
|
plainDEK := "usually created with generateNewEncryptionPassphrase()"
|
||||||
|
|
||||||
ctx := context.TODO()
|
ctx := t.Context()
|
||||||
|
|
||||||
// with missing encryptionPassphraseKey, encrypting should fail
|
// with missing encryptionPassphraseKey, encrypting should fail
|
||||||
_, err = kms.EncryptDEK(ctx, volumeID, plainDEK)
|
_, err = kms.EncryptDEK(ctx, volumeID, plainDEK)
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package rbd
|
package rbd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -160,7 +159,7 @@ func TestToCSIVolume(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
if _, err := tt.rv.ToCSI(context.TODO()); (err != nil) != tt.wantErr {
|
if _, err := tt.rv.ToCSI(t.Context()); (err != nil) != tt.wantErr {
|
||||||
t.Errorf("ToCSI() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("ToCSI() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package rbd
|
package rbd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -84,7 +83,7 @@ func TestMakeVolumeGroupID(t *testing.T) {
|
|||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
ctx := context.TODO()
|
ctx := t.Context()
|
||||||
mgr := NewManager("rbd.example.org", tt.parameters, nil)
|
mgr := NewManager("rbd.example.org", tt.parameters, nil)
|
||||||
defer mgr.Destroy(ctx)
|
defer mgr.Destroy(ctx)
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package rbd
|
package rbd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ import (
|
|||||||
|
|
||||||
func TestValidateLastSyncInfo(t *testing.T) {
|
func TestValidateLastSyncInfo(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ctx := context.TODO()
|
|
||||||
duration := int64(56743)
|
duration := int64(56743)
|
||||||
zero := int64(0)
|
zero := int64(0)
|
||||||
|
|
||||||
@ -124,7 +122,7 @@ func TestValidateLastSyncInfo(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
teststruct, err := newSyncInfo(ctx, tt.description)
|
teststruct, err := newSyncInfo(t.Context(), tt.description)
|
||||||
if err != nil && !strings.Contains(err.Error(), tt.expectedErr) {
|
if err != nil && !strings.Contains(err.Error(), tt.expectedErr) {
|
||||||
// returned error
|
// returned error
|
||||||
t.Errorf("newSyncInfo() returned error, expected: %v, got: %v",
|
t.Errorf("newSyncInfo() returned error, expected: %v, got: %v",
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package rbd
|
package rbd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
@ -67,7 +66,7 @@ func TestGetStagingPath(t *testing.T) {
|
|||||||
|
|
||||||
func TestParseBoolOption(t *testing.T) {
|
func TestParseBoolOption(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ctx := context.TODO()
|
ctx := t.Context()
|
||||||
optionName := "myOption"
|
optionName := "myOption"
|
||||||
defaultValue := false
|
defaultValue := false
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package rbd
|
package rbd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ func checkQOS(
|
|||||||
|
|
||||||
func TestSetQOS(t *testing.T) {
|
func TestSetQOS(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ctx := context.TODO()
|
ctx := t.Context()
|
||||||
|
|
||||||
tests := map[string]string{
|
tests := map[string]string{
|
||||||
baseReadIops: "2000",
|
baseReadIops: "2000",
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package rbd
|
package rbd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@ -249,7 +248,7 @@ func TestGetCephClientLogFileName(t *testing.T) {
|
|||||||
|
|
||||||
func TestStrategicActionOnLogFile(t *testing.T) {
|
func TestStrategicActionOnLogFile(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ctx := context.TODO()
|
ctx := t.Context()
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
var logFile [3]string
|
var logFile [3]string
|
||||||
@ -320,7 +319,7 @@ func TestStrategicActionOnLogFile(t *testing.T) {
|
|||||||
|
|
||||||
func TestIsKrbdFeatureSupported(t *testing.T) {
|
func TestIsKrbdFeatureSupported(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ctx := context.TODO()
|
ctx := t.Context()
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package rbd
|
package rbd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -78,7 +77,7 @@ func TestToCSISnapshot(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
if _, err := tt.rs.ToCSI(context.TODO()); (err != nil) != tt.wantErr {
|
if _, err := tt.rs.ToCSI(t.Context()); (err != nil) != tt.wantErr {
|
||||||
t.Errorf("ToCSI() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("ToCSI() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -41,7 +41,7 @@ func TestExecCommandWithTimeout(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "echo hello",
|
name: "echo hello",
|
||||||
args: args{
|
args: args{
|
||||||
ctx: context.TODO(),
|
ctx: t.Context(),
|
||||||
program: "echo",
|
program: "echo",
|
||||||
timeout: time.Second,
|
timeout: time.Second,
|
||||||
args: []string{"hello"},
|
args: []string{"hello"},
|
||||||
@ -53,7 +53,7 @@ func TestExecCommandWithTimeout(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "sleep with timeout",
|
name: "sleep with timeout",
|
||||||
args: args{
|
args: args{
|
||||||
ctx: context.TODO(),
|
ctx: t.Context(),
|
||||||
program: "sleep",
|
program: "sleep",
|
||||||
timeout: time.Second,
|
timeout: time.Second,
|
||||||
args: []string{"3"},
|
args: []string{"3"},
|
||||||
|
@ -295,7 +295,7 @@ func TestGetMappedID(t *testing.T) {
|
|||||||
|
|
||||||
func TestFetchMappedClusterIDAndMons(t *testing.T) {
|
func TestFetchMappedClusterIDAndMons(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ctx := context.TODO()
|
ctx := t.Context()
|
||||||
type args struct {
|
type args struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
clusterID string
|
clusterID string
|
||||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -56,7 +55,7 @@ func TestKMSWorkflow(t *testing.T) {
|
|||||||
require.Equal(t, kms.DefaultKMSType, ve.GetID())
|
require.Equal(t, kms.DefaultKMSType, ve.GetID())
|
||||||
|
|
||||||
volumeID := "volume-id"
|
volumeID := "volume-id"
|
||||||
ctx := context.TODO()
|
ctx := t.Context()
|
||||||
|
|
||||||
err = ve.StoreNewCryptoPassphrase(ctx, volumeID, defaultEncryptionPassphraseSize)
|
err = ve.StoreNewCryptoPassphrase(ctx, volumeID, defaultEncryptionPassphraseSize)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -14,7 +14,6 @@ limitations under the License.
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ func TestGetPassphraseFromKMS(t *testing.T) {
|
|||||||
|
|
||||||
volEnc, err := NewVolumeEncryption(provider.UniqueID, kms)
|
volEnc, err := NewVolumeEncryption(provider.UniqueID, kms)
|
||||||
if errors.Is(err, ErrDEKStoreNeeded) {
|
if errors.Is(err, ErrDEKStoreNeeded) {
|
||||||
_, err = volEnc.KMS.GetSecret(context.TODO(), "")
|
_, err = volEnc.KMS.GetSecret(t.Context(), "")
|
||||||
if errors.Is(err, kmsapi.ErrGetSecretUnsupported) {
|
if errors.Is(err, kmsapi.ErrGetSecretUnsupported) {
|
||||||
continue // currently unsupported by fscrypt integration
|
continue // currently unsupported by fscrypt integration
|
||||||
}
|
}
|
||||||
@ -46,7 +45,7 @@ func TestGetPassphraseFromKMS(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
secret, err := kms.GetSecret(context.TODO(), "")
|
secret, err := kms.GetSecret(t.Context(), "")
|
||||||
require.NoError(t, err, provider.UniqueID)
|
require.NoError(t, err, provider.UniqueID)
|
||||||
require.NotEmpty(t, secret, provider.UniqueID)
|
require.NotEmpty(t, secret, provider.UniqueID)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user