golangci-lint: use exclude-rules instead of skip-files and skip-dirs
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>pull/7573/head
parent
3c704ba1b1
commit
ef04ef6361
|
@ -19,24 +19,12 @@ run:
|
|||
# "/" will be replaced by current OS file path separator to properly work
|
||||
# on Windows.
|
||||
skip-dirs:
|
||||
- test/*
|
||||
- pkg/plugin/generated/*
|
||||
# - autogenerated_by_my_lib
|
||||
|
||||
# default is true. Enables skipping of directories:
|
||||
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
|
||||
skip-dirs-use-default: true
|
||||
|
||||
# which files to skip: they will be analyzed, but issues from them
|
||||
# won't be reported. Default value is empty list, but there is
|
||||
# no need to include all autogenerated files, we confidently recognize
|
||||
# autogenerated files. If it's not please let us know.
|
||||
# "/" will be replaced by current OS file path separator to properly work
|
||||
# on Windows.
|
||||
skip-files:
|
||||
- ".*_test.go$"
|
||||
# - lib/bad.go
|
||||
|
||||
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
|
||||
# If invoked with -mod=readonly, the go command is disallowed from the implicit
|
||||
# automatic updating of go.mod described above. Instead, it fails when any changes
|
||||
|
@ -364,6 +352,35 @@ issues:
|
|||
- linters:
|
||||
- staticcheck
|
||||
text: "DefaultVolumesToRestic" # No need to report deprecate for DefaultVolumesToRestic.
|
||||
- path: ".*_test.go$"
|
||||
linters:
|
||||
- dupword
|
||||
- errcheck
|
||||
- ginkgolinter
|
||||
- goconst
|
||||
- gosec
|
||||
- govet
|
||||
- staticcheck
|
||||
- stylecheck
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
- path: test/
|
||||
linters:
|
||||
- bodyclose
|
||||
- dupword
|
||||
- errcheck
|
||||
- goconst
|
||||
- gosec
|
||||
- gosimple
|
||||
- ginkgolinter
|
||||
- nilerr
|
||||
- noctx
|
||||
- staticcheck
|
||||
- stylecheck
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
|
||||
# The list of ids of default excludes to include or disable. By default it's empty.
|
||||
include:
|
||||
|
|
|
@ -67,7 +67,6 @@ func TestHookTracker_Record(t *testing.T) {
|
|||
|
||||
err = tracker.Record("ns2", "pod2", "container1", HookSourceAnnotation, "h1", PhasePre, true)
|
||||
assert.NotNil(t, err)
|
||||
|
||||
}
|
||||
|
||||
func TestHookTracker_Stat(t *testing.T) {
|
||||
|
|
|
@ -2351,14 +2351,12 @@ func TestBackupHookTracker(t *testing.T) {
|
|||
}
|
||||
}
|
||||
h.HandleHooks(velerotest.NewLogger(), groupResource, pod.item, pod.hooks, test.phase, hookTracker)
|
||||
|
||||
}
|
||||
actualAtemptted, actualFailed := hookTracker.Stat()
|
||||
assert.Equal(t, test.expectedHookAttempted, actualAtemptted)
|
||||
assert.Equal(t, test.expectedHookFailed, actualFailed)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestRestoreHookTrackerAdd(t *testing.T) {
|
||||
|
|
|
@ -710,7 +710,6 @@ func TestWaitExecHandleHooks(t *testing.T) {
|
|||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
source := fcache.NewFakeControllerSource()
|
||||
go func() {
|
||||
// This is the state of the pod that will be seen by the AddFunc handler.
|
||||
|
@ -1251,7 +1250,6 @@ func TestRestoreHookTrackerUpdate(t *testing.T) {
|
|||
|
||||
for _, test := range tests1 {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
source := fcache.NewFakeControllerSource()
|
||||
go func() {
|
||||
// This is the state of the pod that will be seen by the AddFunc handler.
|
||||
|
|
|
@ -428,7 +428,6 @@ func TestGetResourceModifiersFromConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestResourceModifiers_ApplyResourceModifierRules(t *testing.T) {
|
||||
|
||||
pvcStandardSc := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"apiVersion": "v1",
|
||||
|
|
|
@ -86,7 +86,6 @@ func TestCapacityIsInRange(t *testing.T) {
|
|||
actual := test.capacity.isInRange(test.quantity)
|
||||
|
||||
assert.Equal(t, test.isInRange, actual)
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +140,6 @@ func TestStorageClassConditionMatch(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestNFSConditionMatch(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
condition *nfsCondition
|
||||
|
@ -196,7 +194,6 @@ func TestNFSConditionMatch(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCSIConditionMatch(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
condition *csiCondition
|
||||
|
|
|
@ -128,7 +128,6 @@ func testDefaultImage(t *testing.T, defaultImageFn func() string, imageName stri
|
|||
assert.Equal(t, tc.want, defaultImageFn())
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDefaultVeleroImage(t *testing.T) {
|
||||
|
|
|
@ -154,8 +154,8 @@ func TestBackupProgressIsUpdated(t *testing.T) {
|
|||
h.backupper.Backup(h.log, req, backupFile, nil, nil)
|
||||
|
||||
require.NotNil(t, req.Status.Progress)
|
||||
assert.Equal(t, len(req.BackedUpItems), req.Status.Progress.TotalItems)
|
||||
assert.Equal(t, len(req.BackedUpItems), req.Status.Progress.ItemsBackedUp)
|
||||
assert.Len(t, req.BackedUpItems, req.Status.Progress.TotalItems)
|
||||
assert.Len(t, req.BackedUpItems, req.Status.Progress.ItemsBackedUp)
|
||||
}
|
||||
|
||||
// TestBackupResourceFiltering runs backups with different combinations
|
||||
|
|
|
@ -76,5 +76,4 @@ func TestSortOrderedResource(t *testing.T) {
|
|||
}
|
||||
sortedPvResources := sortResourcesByOrder(log, pvResources, pvOrder)
|
||||
assert.Equal(t, sortedPvResources, expectedPvResources)
|
||||
|
||||
}
|
||||
|
|
|
@ -136,7 +136,6 @@ func TestRemapCRDVersionAction(t *testing.T) {
|
|||
// set it back to the default one
|
||||
a.discoveryHelper = fakeDiscoveryHelper()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// TestRemapCRDVersionActionData tests the RemapCRDVersionAction plugin against actual CRD to confirm that the v1beta1 version is returned when the v1 version is passed in to the plugin.
|
||||
|
@ -217,7 +216,6 @@ func TestRemapCRDVersionActionData(t *testing.T) {
|
|||
betaClient.Delete(context.TODO(), crd.Name, metav1.DeleteOptions{})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func fakeDiscoveryHelper() velerodiscovery.Helper {
|
||||
|
|
|
@ -400,7 +400,6 @@ func TestServiceAccountActionExecute(t *testing.T) {
|
|||
assert.Equal(t, test.expectedAdditionalItems, additional)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestServiceAccountActionExecuteOnBeta1(t *testing.T) {
|
||||
|
@ -608,5 +607,4 @@ func TestServiceAccountActionExecuteOnBeta1(t *testing.T) {
|
|||
assert.Equal(t, test.expectedAdditionalItems, additional)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,5 +49,4 @@ func TestFormattedGitSHA(t *testing.T) {
|
|||
assert.Equal(t, FormattedGitSHA(), test.expected)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ func removeConfigfileName() error {
|
|||
return nil
|
||||
}
|
||||
func TestConfigOperations(t *testing.T) {
|
||||
|
||||
preHomeEnv := ""
|
||||
prevEnv := os.Environ()
|
||||
for _, entry := range prevEnv {
|
||||
|
|
|
@ -148,7 +148,6 @@ func TestCreateOptions_OrderedResources(t *testing.T) {
|
|||
"persistentvolumes": "pv1,pv2",
|
||||
}
|
||||
assert.Equal(t, orderedResources, expectedMixedResources)
|
||||
|
||||
}
|
||||
|
||||
func TestCreateCommand(t *testing.T) {
|
||||
|
@ -156,7 +155,6 @@ func TestCreateCommand(t *testing.T) {
|
|||
args := []string{name}
|
||||
|
||||
t.Run("create a backup create command with full options except fromSchedule and wait, then run by create option", func(t *testing.T) {
|
||||
|
||||
// create a factory
|
||||
f := &factorymocks.Factory{}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ func TestNewGetCommand(t *testing.T) {
|
|||
i++
|
||||
}
|
||||
}
|
||||
assert.Equal(t, len(args), i)
|
||||
assert.Len(t, args, i)
|
||||
}
|
||||
|
||||
d := NewGetCommand(f, "velero backup get")
|
||||
|
@ -98,6 +98,6 @@ func TestNewGetCommand(t *testing.T) {
|
|||
i++
|
||||
}
|
||||
}
|
||||
assert.Equal(t, len(args), i)
|
||||
assert.Len(t, args, i)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import (
|
|||
)
|
||||
|
||||
func TestNewDeleteCommand(t *testing.T) {
|
||||
|
||||
// create a factory
|
||||
f := &factorymocks.Factory{}
|
||||
kbclient := velerotest.NewFakeControllerRuntimeClient(t)
|
||||
|
@ -75,7 +74,6 @@ func TestNewDeleteCommand(t *testing.T) {
|
|||
return
|
||||
}
|
||||
t.Fatalf("process ran with err %v, want backups by get()", err)
|
||||
|
||||
}
|
||||
func TestDeleteFunctions(t *testing.T) {
|
||||
//t.Run("create the other create command with fromSchedule option for Run() other branches", func(t *testing.T) {
|
||||
|
|
|
@ -59,7 +59,6 @@ func TestCreateCommand(t *testing.T) {
|
|||
args := []string{name}
|
||||
|
||||
t.Run("create a backup create command with full options except fromSchedule and wait, then run by create option", func(t *testing.T) {
|
||||
|
||||
// create a factory
|
||||
f := &factorymocks.Factory{}
|
||||
|
||||
|
|
|
@ -76,6 +76,6 @@ func TestNewGetCommand(t *testing.T) {
|
|||
i++
|
||||
}
|
||||
}
|
||||
require.Equal(t, len(args), i)
|
||||
require.Len(t, args, i)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,6 @@ func TestSetOfMap(t *testing.T) {
|
|||
assert.EqualValues(t, c.expected, m.Data())
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestStringOfMap(t *testing.T) {
|
||||
|
|
|
@ -618,5 +618,4 @@ func TestDescribeDeleteBackupRequestsInSF(t *testing.T) {
|
|||
assert.True(tt, reflect.DeepEqual(sd.output, tc.expect))
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -435,7 +435,6 @@ func TestDefaultBackupTTL(t *testing.T) {
|
|||
)
|
||||
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
apiServer := velerotest.NewAPIServer(t)
|
||||
discoveryHelper, err := discovery.NewHelper(apiServer.DiscoveryClient, logger)
|
||||
require.NoError(t, err)
|
||||
|
@ -1735,6 +1734,5 @@ func TestPatchResourceWorksWithStatus(t *testing.T) {
|
|||
t.Error(cmp.Diff(fromCluster, tt.args.updated))
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,6 @@ func defaultTestDbr() *velerov1api.DeleteBackupRequest {
|
|||
}
|
||||
|
||||
func setupBackupDeletionControllerTest(t *testing.T, req *velerov1api.DeleteBackupRequest, objects ...runtime.Object) *backupDeletionControllerTestData {
|
||||
|
||||
var (
|
||||
fakeClient = velerotest.NewFakeControllerRuntimeClient(t, append(objects, req)...)
|
||||
volumeSnapshotter = &velerotest.FakeVolumeSnapshotter{SnapshotsTaken: sets.NewString()}
|
||||
|
@ -215,7 +214,6 @@ func TestBackupDeletionControllerReconcile(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("unable to find backup", func(t *testing.T) {
|
||||
|
||||
td := setupBackupDeletionControllerTest(t, defaultTestDbr())
|
||||
|
||||
_, err := td.controller.Reconcile(context.TODO(), td.req)
|
||||
|
@ -261,7 +259,6 @@ func TestBackupDeletionControllerReconcile(t *testing.T) {
|
|||
assert.Equal(t, "cannot delete backup because backup storage location default is currently in read-only mode", res.Status.Errors[0])
|
||||
})
|
||||
t.Run("full delete, no errors", func(t *testing.T) {
|
||||
|
||||
input := defaultTestDbr()
|
||||
|
||||
// Clear out resource labels to make sure the controller adds them and does not
|
||||
|
@ -668,7 +665,6 @@ func TestBackupDeletionControllerReconcile(t *testing.T) {
|
|||
err = td.fakeClient.Get(ctx, td.req.NamespacedName, res)
|
||||
assert.True(t, apierrors.IsNotFound(err), "Expected not found error, but actual value of error: %v", err)
|
||||
td.backupStore.AssertNotCalled(t, "DeleteBackup", mock.Anything)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Expired request will not be deleted if the status is not processed", func(t *testing.T) {
|
||||
|
@ -690,7 +686,6 @@ func TestBackupDeletionControllerReconcile(t *testing.T) {
|
|||
assert.Equal(t, "Processed", string(res.Status.Phase))
|
||||
assert.Len(t, res.Status.Errors, 1)
|
||||
assert.Equal(t, "backup not found", res.Status.Errors[0])
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ func mockBackupRepositoryCR() *velerov1api.BackupRepository {
|
|||
MaintenanceFrequency: metav1.Duration{Duration: testMaintenanceFrequency},
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestPatchBackupRepository(t *testing.T) {
|
||||
|
|
|
@ -526,7 +526,6 @@ func TestOnDataDownloadCompleted(t *testing.T) {
|
|||
ep := exposermockes.NewGenericRestoreExposer(t)
|
||||
if test.rebindVolumeErr {
|
||||
ep.On("RebindVolume", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(errors.New("Error to rebind volume"))
|
||||
|
||||
} else {
|
||||
ep.On("RebindVolume", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
|
||||
}
|
||||
|
@ -813,7 +812,6 @@ func TestTryCancelDataDownload(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateDataDownloadWithRetry(t *testing.T) {
|
||||
|
||||
namespacedName := types.NamespacedName{
|
||||
Name: dataDownloadName,
|
||||
Namespace: "velero",
|
||||
|
@ -1026,7 +1024,7 @@ func TestAttemptDataDownloadResume(t *testing.T) {
|
|||
} else {
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Verify DataDownload marked as Cancelled
|
||||
// Verify DataDownload marked as Canceled
|
||||
for _, duName := range test.cancelledDataDownloads {
|
||||
dataUpload := &velerov2alpha1api.DataDownload{}
|
||||
err := r.client.Get(context.Background(), types.NamespacedName{Namespace: "velero", Name: duName}, dataUpload)
|
||||
|
|
|
@ -885,7 +885,6 @@ func TestTryCancelDataUpload(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUpdateDataUploadWithRetry(t *testing.T) {
|
||||
|
||||
namespacedName := types.NamespacedName{
|
||||
Name: dataUploadName,
|
||||
Namespace: "velero",
|
||||
|
@ -1097,7 +1096,7 @@ func TestAttemptDataUploadResume(t *testing.T) {
|
|||
} else {
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Verify DataUploads marked as Cancelled
|
||||
// Verify DataUploads marked as Canceled
|
||||
for _, duName := range test.cancelledDataUploads {
|
||||
dataUpload := &velerov2alpha1api.DataUpload{}
|
||||
err := r.client.Get(context.Background(), types.NamespacedName{Namespace: "velero", Name: duName}, dataUpload)
|
||||
|
|
|
@ -53,7 +53,6 @@ import (
|
|||
)
|
||||
|
||||
func TestFetchBackupInfo(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
backupName string
|
||||
|
@ -206,7 +205,6 @@ func TestProcessQueueItemSkips(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRestoreReconcile(t *testing.T) {
|
||||
|
||||
defaultStorageLocation := builder.ForBackupStorageLocation("velero", "default").Provider("myCloud").Bucket("bucket").Result()
|
||||
|
||||
now, err := time.Parse(time.RFC1123Z, time.RFC1123Z)
|
||||
|
|
|
@ -178,7 +178,6 @@ func TestRestoreFinalizerReconcile(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestUpdateResult(t *testing.T) {
|
||||
|
@ -453,7 +452,6 @@ func TestPatchDynamicPVWithVolumeInfo(t *testing.T) {
|
|||
assert.Equal(t, expectedPVInfo.ReclaimPolicy, string(pv.Spec.PersistentVolumeReclaimPolicy))
|
||||
assert.Equal(t, expectedPVInfo.Labels, pv.Labels)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -489,5 +487,4 @@ func TestGetRestoredPVCFromRestoredResourceList(t *testing.T) {
|
|||
}
|
||||
actual = getRestoredPVCFromRestoredResourceList(restoredResourceList)
|
||||
assert.Equal(t, expected, actual)
|
||||
|
||||
}
|
||||
|
|
|
@ -440,7 +440,6 @@ func TestExpose(t *testing.T) {
|
|||
} else {
|
||||
assert.EqualError(t, err, test.err)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1142,7 +1142,6 @@ func TestGetBackupVolumeInfos(t *testing.T) {
|
|||
if len(tc.expectedResult) > 0 {
|
||||
require.Equal(t, tc.expectedResult, result)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ func TestNewClientBuilder(t *testing.T) {
|
|||
assert.Equal(t, []string{"run-plugins", "--log-level", "info", "--features", "feature1,feature2"}, cb.commandArgs)
|
||||
// Clear the features list in case other tests run in the same process.
|
||||
features.NewFeatureFlagSet()
|
||||
|
||||
}
|
||||
|
||||
func TestClientConfig(t *testing.T) {
|
||||
|
|
|
@ -197,7 +197,6 @@ func Test_backupper_BackupPodVolumes_log_test(t *testing.T) {
|
|||
b.BackupPodVolumes(tt.args.backup, tt.args.pod, tt.args.volumesToBackup, tt.args.resPolicies, log)
|
||||
fmt.Println(logOutput.String())
|
||||
assert.Contains(t, logOutput.String(), tt.wantLog)
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -495,7 +494,7 @@ func TestBackupPodVolumes(t *testing.T) {
|
|||
bsl: "fake-bsl",
|
||||
},
|
||||
{
|
||||
name: "context cancelled",
|
||||
name: "context canceled",
|
||||
ctx: ctxWithCancel,
|
||||
volumes: []string{
|
||||
"fake-volume-1",
|
||||
|
@ -616,7 +615,6 @@ func TestBackupPodVolumes(t *testing.T) {
|
|||
for _, pvb := range test.retPVBs {
|
||||
bp.(*backupper).results[resultsKey(test.sourcePod.Namespace, test.sourcePod.Name)] <- pvb
|
||||
}
|
||||
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
@ -409,7 +409,6 @@ func TestRestorePodVolumes(t *testing.T) {
|
|||
for _, pvr := range test.retPVRs {
|
||||
rs.(*restorer).results[resultsKey(test.restoredPod.Namespace, test.restoredPod.Name)] <- pvr
|
||||
}
|
||||
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
@ -298,6 +298,5 @@ func TestVolumeHasNonRestorableSource(t *testing.T) {
|
|||
actual := volumeHasNonRestorableSource(tc.volumeName, tc.podVolumes)
|
||||
assert.Equal(t, tc.expected, actual)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1000,7 +1000,7 @@ func TestBatchForget(t *testing.T) {
|
|||
})
|
||||
|
||||
if tc.expectedErr == nil {
|
||||
assert.Equal(t, 0, len(errs))
|
||||
assert.Empty(t, errs)
|
||||
} else {
|
||||
assert.Equal(t, len(tc.expectedErr), len(errs))
|
||||
|
||||
|
|
|
@ -89,7 +89,6 @@ func TestGetSnapshotCommand(t *testing.T) {
|
|||
|
||||
assert.Equal(t, expectedFlags, actualFlags)
|
||||
assert.Equal(t, expectedTags, actualTags)
|
||||
|
||||
}
|
||||
|
||||
func TestInitCommand(t *testing.T) {
|
||||
|
|
|
@ -361,7 +361,6 @@ func TestMergeMaps(t *testing.T) {
|
|||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
||||
result := mergeMaps(tc.destination, tc.source)
|
||||
|
||||
assert.Equal(t, tc.expected, result)
|
||||
|
|
|
@ -1859,7 +1859,6 @@ func TestRestoreWithAsyncOperations(t *testing.T) {
|
|||
UpdatedItem: obj,
|
||||
OperationID: obj.GetName() + "-1",
|
||||
}, nil
|
||||
|
||||
},
|
||||
progressFunc: func(operationID string, restore *velerov1api.Restore) (velero.OperationProgress, error) {
|
||||
return velero.OperationProgress{
|
||||
|
@ -1881,7 +1880,6 @@ func TestRestoreWithAsyncOperations(t *testing.T) {
|
|||
UpdatedItem: obj,
|
||||
OperationID: obj.GetName() + "-1",
|
||||
}, nil
|
||||
|
||||
},
|
||||
progressFunc: func(operationID string, restore *velerov1api.Restore) (velero.OperationProgress, error) {
|
||||
return velero.OperationProgress{
|
||||
|
@ -1902,7 +1900,6 @@ func TestRestoreWithAsyncOperations(t *testing.T) {
|
|||
return &velero.RestoreItemActionExecuteOutput{
|
||||
UpdatedItem: obj,
|
||||
}, nil
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ func svcJSONFromUnstructured(ports ...map[string]interface{}) string {
|
|||
}
|
||||
|
||||
func TestServiceActionExecute(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
obj corev1api.Service
|
||||
|
|
|
@ -79,7 +79,6 @@ func MockFuncs(s *snapshotMockes, args []mockArgs) {
|
|||
}
|
||||
|
||||
func TestSnapshotSource(t *testing.T) {
|
||||
|
||||
ctx := context.TODO()
|
||||
sourceInfo := snapshot.SourceInfo{
|
||||
UserName: "testUserName",
|
||||
|
|
|
@ -228,7 +228,7 @@ func TestCheckContext(t *testing.T) {
|
|||
kp.CheckContext(ctx, tc.finishChan, tc.restoreChan, tc.uploader)
|
||||
|
||||
if tc.expectCancel && tc.uploader != nil {
|
||||
t.Error("Expected the uploader to be cancelled")
|
||||
t.Error("Expected the uploader to be canceled")
|
||||
}
|
||||
|
||||
if tc.expectBackup && tc.uploader == nil && len(tc.restoreChan) > 0 {
|
||||
|
|
|
@ -85,7 +85,6 @@ func TestNewUploaderProvider(t *testing.T) {
|
|||
mockFileGetter := &mocks.FileStore{}
|
||||
mockFileGetter.On("Path", &v1.SecretKeySelector{}).Return("", nil)
|
||||
credGetter.FromFile = mockFileGetter
|
||||
|
||||
}
|
||||
_, err := NewUploaderProvider(ctx, client, testCase.UploaderType, testCase.RequestorType, repoIdentifier, bsl, backupRepo, credGetter, repoKeySelector, log)
|
||||
if testCase.ExpectedError == "" {
|
||||
|
|
|
@ -232,7 +232,6 @@ func TestResticRunRestore(t *testing.T) {
|
|||
require.Equal(t, true, tc.errorHandleFunc(err))
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestClose(t *testing.T) {
|
||||
|
|
|
@ -47,7 +47,6 @@ func TestNewCredential(t *testing.T) {
|
|||
}
|
||||
_, err = NewCredential(creds, options)
|
||||
require.Nil(t, err)
|
||||
|
||||
}
|
||||
|
||||
func Test_newConfigCredential(t *testing.T) {
|
||||
|
|
|
@ -729,7 +729,6 @@ func TestGetScopedResourceIncludesExcludes(t *testing.T) {
|
|||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
||||
logger := logrus.StandardLogger()
|
||||
nsIncludeExclude := NewIncludesExcludes()
|
||||
resources := GetScopeResourceIncludesExcludes(setupDiscoveryClientWithResources(tc.apiResources), logger, tc.namespaceScopedIncludes, tc.namespaceScopedExcludes, tc.clusterScopedIncludes, tc.clusterScopedExcludes, *nsIncludeExclude)
|
||||
|
|
|
@ -25,7 +25,6 @@ import (
|
|||
)
|
||||
|
||||
func TestCSIFeatureNotEnabledAndPluginIsFromCSI(t *testing.T) {
|
||||
|
||||
features.NewFeatureFlagSet("EnableCSI")
|
||||
require.False(t, ShouldSkipAction("abc"))
|
||||
require.False(t, ShouldSkipAction("velero.io/csi-pvc-backupper"))
|
||||
|
|
|
@ -138,7 +138,6 @@ func TestEnsureNamespaceExistsAndIsReady(t *testing.T) {
|
|||
assert.Equal(t, test.expectedCreatedResult, nsCreated)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TestGetVolumeDirectorySuccess tests that the GetVolumeDirectory function
|
||||
|
|
|
@ -58,7 +58,6 @@ func BackupRestoreRetainedPVWithRestic() {
|
|||
}
|
||||
|
||||
func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) {
|
||||
|
||||
var (
|
||||
backupName, restoreName, kibishiiNamespace string
|
||||
err error
|
||||
|
|
|
@ -73,7 +73,6 @@ func BackupsSyncTest() {
|
|||
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace)).To(Succeed())
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
It("Backups in object storage should be synced to a new Velero successfully", func() {
|
||||
|
|
|
@ -51,7 +51,6 @@ func (b *TTL) Init() {
|
|||
b.backupName = "backup-ttl-test-" + UUIDgen.String()
|
||||
b.restoreName = "restore-ttl-test-" + UUIDgen.String()
|
||||
b.ttl = 10 * time.Minute
|
||||
|
||||
}
|
||||
|
||||
func TTLTest() {
|
||||
|
@ -159,7 +158,6 @@ func TTLTest() {
|
|||
veleroCfg.CloudCredentialsFile, veleroCfg.BSLBucket,
|
||||
veleroCfg.BSLPrefix, veleroCfg.BSLConfig, test.restoreName,
|
||||
RestoreObjectsPrefix)).NotTo(HaveOccurred(), "Fail to get restore object")
|
||||
|
||||
})
|
||||
|
||||
By("Check TTL was set correctly", func() {
|
||||
|
@ -198,7 +196,6 @@ func TTLTest() {
|
|||
veleroCfg.CloudCredentialsFile, veleroCfg.BSLBucket,
|
||||
veleroCfg.BSLPrefix, veleroCfg.BSLConfig, test.restoreName,
|
||||
RestoreObjectsPrefix, 5)).NotTo(HaveOccurred(), "Fail to get restore object")
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -91,7 +91,6 @@ func APIExtensionsVersionsTest() {
|
|||
veleroCfg.ClientToInstallVelero = veleroCfg.DefaultClient
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
Context("When EnableAPIGroupVersions flag is set", func() {
|
||||
It("Enable API Group to B/R CRD APIExtensionsVersions", func() {
|
||||
|
|
|
@ -238,7 +238,6 @@ func runEnableAPIGroupVersionsTests(ctx context.Context, client TestClient, grou
|
|||
fmt.Println(errors.Wrapf(err, "failed to delete crd %q", crdName))
|
||||
}
|
||||
}(fmt.Sprintf("rockband%ds.music.example.io.%d", i, i))
|
||||
|
||||
}
|
||||
|
||||
time.Sleep(6 * time.Minute)
|
||||
|
@ -328,7 +327,6 @@ func runEnableAPIGroupVersionsTests(ctx context.Context, client TestClient, grou
|
|||
)
|
||||
return errors.New(msg)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -465,7 +463,6 @@ func resourceInfo(ctx context.Context, g, v, r string, index int) (map[string]ma
|
|||
// are found in the haystack argument values.
|
||||
func containsAll(haystack, needles map[string]string) bool {
|
||||
for nkey, nval := range needles {
|
||||
|
||||
hval, ok := haystack[nkey]
|
||||
if !ok {
|
||||
return false
|
||||
|
|
|
@ -83,7 +83,6 @@ func (s *StorageClasssChanging) CreateResources() error {
|
|||
})
|
||||
|
||||
By(fmt.Sprintf("Create a deployment in namespace %s", s.VeleroCfg.VeleroNamespace), func() {
|
||||
|
||||
pvc, err := CreatePVC(s.Client, s.namespace, s.pvcName, s.srcStorageClass, nil)
|
||||
Expect(err).To(Succeed())
|
||||
vols := CreateVolumes(pvc.Name, []string{s.volume})
|
||||
|
|
|
@ -321,7 +321,6 @@ func BslDeletionTest(useVolumeSnapshots bool) {
|
|||
var snapshotCheckPoint SnapshotCheckPoint
|
||||
snapshotCheckPoint.NamespaceBackedUp = bslDeletionTestNs
|
||||
By(fmt.Sprintf("Snapshot should not be deleted in cloud object store after deleting bsl %s", backupLocation_1), func() {
|
||||
|
||||
snapshotCheckPoint, err = GetSnapshotCheckPoint(*veleroCfg.ClientToInstallVelero, veleroCfg, 1, bslDeletionTestNs, backupName_1, []string{podName_1})
|
||||
Expect(err).NotTo(HaveOccurred(), "Fail to get Azure CSI snapshot checkpoint")
|
||||
Expect(SnapshotsShouldBeCreatedInCloud(veleroCfg.CloudProvider,
|
||||
|
|
|
@ -101,7 +101,6 @@ func init() {
|
|||
flag.StringVar(&VeleroCfg.EKSPolicyARN, "eks-policy-arn", "", "EKS plicy ARN for creating AWS IAM service account.")
|
||||
flag.StringVar(&VeleroCfg.DefaultCLSServiceAccountName, "default-cls-service-account-name", "", "default cluster service account name.")
|
||||
flag.StringVar(&VeleroCfg.StandbyCLSServiceAccountName, "standby-cls-service-account-name", "", "standby cluster service account name.")
|
||||
|
||||
}
|
||||
|
||||
// Add label [SkipVanillaZfs]:
|
||||
|
|
|
@ -108,7 +108,6 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
|
|||
veleroCfg.ClusterToInstallVelero = veleroCfg.DefaultClusterName
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
When("kibishii is the sample workload", func() {
|
||||
It("should be successfully backed up and restored to the default BackupStorageLocation", func() {
|
||||
|
|
|
@ -55,7 +55,6 @@ func (p *PVBackupFiltering) Init() error {
|
|||
// annotation will be ignored, so it's only set for opt-out test
|
||||
if p.annotation == OPT_OUT_ANN {
|
||||
p.BackupArgs = append(p.BackupArgs, "--default-volumes-to-fs-backup")
|
||||
|
||||
}
|
||||
p.RestoreArgs = []string{
|
||||
"create", "--namespace", p.VeleroCfg.VeleroNamespace, "restore", p.RestoreName,
|
||||
|
|
|
@ -90,7 +90,6 @@ func (e *ExcludeNamespaces) Init() error {
|
|||
"create", "--namespace", e.VeleroCfg.VeleroNamespace, "restore", e.RestoreName,
|
||||
"--from-backup", e.BackupName, "--wait",
|
||||
}
|
||||
|
||||
} else {
|
||||
*e.NSIncluded = append(*e.NSIncluded, *e.nsExcluded...)
|
||||
e.BackupArgs = []string{
|
||||
|
|
|
@ -79,7 +79,6 @@ func (i *IncludeNamespaces) Init() error {
|
|||
"create", "--namespace", i.VeleroCfg.VeleroNamespace, "restore", i.RestoreName,
|
||||
"--from-backup", i.BackupName, "--wait",
|
||||
}
|
||||
|
||||
} else {
|
||||
i.BackupName = "backup-" + i.UUIDgen
|
||||
i.RestoreName = "restore-" + i.CaseBaseName
|
||||
|
|
|
@ -177,7 +177,6 @@ func (r *ResourcePoliciesCase) Verify() error {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -200,7 +200,6 @@ func (n *ScheduleBackup) Verify() error {
|
|||
fmt.Printf("Restored configmap is %v\n", configmap)
|
||||
Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("failed to list configmap in namespace: %q\n", ns))
|
||||
}
|
||||
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -123,7 +123,6 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC
|
|||
veleroCfg.GCFrequency = ""
|
||||
By(fmt.Sprintf("Install the expected old version Velero (%s) for upgrade",
|
||||
veleroCLI2Version.VeleroVersion), func() {
|
||||
|
||||
//Set VeleroImage and RestoreHelperImage to blank
|
||||
//VeleroImage and RestoreHelperImage should be the default value in originalCli
|
||||
tmpCfgForOldVeleroInstall := veleroCfg
|
||||
|
@ -230,7 +229,6 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC
|
|||
}
|
||||
|
||||
By(fmt.Sprintf("Upgrade Velero by CLI %s", tmpCfg.VeleroCLI), func() {
|
||||
|
||||
tmpCfg.GCFrequency = ""
|
||||
tmpCfg.UseRestic = false
|
||||
tmpCfg.UseNodeAgent = !useVolumeSnapshots
|
||||
|
|
|
@ -130,7 +130,6 @@ func (c VeleroConfig) Colorized() bool {
|
|||
}
|
||||
|
||||
return colorized
|
||||
|
||||
}
|
||||
|
||||
func (c VeleroConfig) CACertFile() string {
|
||||
|
|
|
@ -114,7 +114,6 @@ func (d *DeploymentBuilder) WithVolume(volumes []*v1.Volume) *DeploymentBuilder
|
|||
MountPath: "/" + v.Name,
|
||||
})
|
||||
d.Spec.Template.Spec.Volumes = append(d.Spec.Template.Spec.Volumes, *v)
|
||||
|
||||
}
|
||||
|
||||
// NOTE here just mount volumes to the first container
|
||||
|
|
|
@ -28,7 +28,6 @@ import (
|
|||
)
|
||||
|
||||
func CreatePersistentVolume(client TestClient, name string) (*corev1.PersistentVolume, error) {
|
||||
|
||||
p := &corev1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
|
|
|
@ -107,7 +107,6 @@ func GetPod(ctx context.Context, client TestClient, namespace string, pod string
|
|||
}
|
||||
|
||||
func AddAnnotationToPod(ctx context.Context, client TestClient, namespace, podName string, ann map[string]string) (*corev1.Pod, error) {
|
||||
|
||||
newPod, err := GetPod(ctx, client, namespace, podName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, fmt.Sprintf("Fail to ge pod %s in namespace %s", podName, namespace))
|
||||
|
|
|
@ -76,7 +76,6 @@ func GetClusterRoleBinding(ctx context.Context, client TestClient, rolebinding s
|
|||
}
|
||||
|
||||
func CleanupClusterRole(ctx context.Context, client TestClient, CaseBaseName string) error {
|
||||
|
||||
clusterroles, err := client.ClientGo.RbacV1().ClusterRoles().List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Could not retrieve clusterroles")
|
||||
|
@ -95,7 +94,6 @@ func CleanupClusterRole(ctx context.Context, client TestClient, CaseBaseName str
|
|||
}
|
||||
|
||||
func CleanupClusterRoleBinding(ctx context.Context, client TestClient, CaseBaseName string) error {
|
||||
|
||||
clusterrolebindings, err := client.ClientGo.RbacV1().ClusterRoleBindings().List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Could not retrieve clusterrolebindings")
|
||||
|
|
|
@ -128,7 +128,6 @@ func newS3Client(cfg aws.Config, url string, forcePathStyle bool) (*s3.Client, e
|
|||
// GetBucketRegion returns the AWS region that a bucket is in, or an error
|
||||
// if the region cannot be determined.
|
||||
func GetBucketRegion(bucket string) (string, error) {
|
||||
|
||||
cfg, err := config.LoadDefaultConfig(context.Background())
|
||||
if err != nil {
|
||||
return "", errors.WithStack(err)
|
||||
|
|
|
@ -270,7 +270,6 @@ func (s AzureStorage) DeleteObjectsInBucket(cloudCredentialsFile, bslBucket, bsl
|
|||
|
||||
marker = listBlob.NextMarker
|
||||
for _, blobInfo := range listBlob.Segment.BlobItems {
|
||||
|
||||
if strings.Contains(blobInfo.Name, bslPrefix+backupObject+"/") {
|
||||
deleteBlob(p, accountName, containerName, blobInfo.Name)
|
||||
if err != nil {
|
||||
|
@ -284,7 +283,6 @@ func (s AzureStorage) DeleteObjectsInBucket(cloudCredentialsFile, bslBucket, bsl
|
|||
}
|
||||
|
||||
func (s AzureStorage) IsSnapshotExisted(cloudCredentialsFile, bslConfig, backupName string, snapshotCheck SnapshotCheckPoint) error {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
if err := loadCredentialsIntoEnv(cloudCredentialsFile); err != nil {
|
||||
|
|
|
@ -173,7 +173,6 @@ func getPluginsByVersion(version, cloudProvider, objectStoreProvider, feature st
|
|||
plugins = append(plugins, pluginsForDatamover...)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return plugins, nil
|
||||
}
|
||||
|
@ -181,7 +180,6 @@ func getPluginsByVersion(version, cloudProvider, objectStoreProvider, feature st
|
|||
// getProviderVeleroInstallOptions returns Velero InstallOptions for the provider.
|
||||
func getProviderVeleroInstallOptions(veleroCfg *VeleroConfig,
|
||||
plugins []string) (*cliinstall.Options, error) {
|
||||
|
||||
if veleroCfg.CloudCredentialsFile == "" && veleroCfg.ServiceAccountNameToInstall == "" {
|
||||
return nil, errors.Errorf("No credentials were supplied to use for E2E tests")
|
||||
}
|
||||
|
@ -1184,7 +1182,6 @@ func DeleteBslResource(ctx context.Context, veleroCLI string, bslName string) er
|
|||
}
|
||||
|
||||
func SnapshotCRsCountShouldBe(ctx context.Context, namespace, backupName string, expectedCount int) error {
|
||||
|
||||
checkSnapshotCmd := exec.CommandContext(ctx, "kubectl",
|
||||
"get", "-n", namespace, "snapshots.backupdriver.cnsdp.vmware.com", "-o=jsonpath='{range .items[*]}{.metadata.labels.velero\\.io\\/backup-name}{\"\\n\"}{end}'")
|
||||
fmt.Printf("checkSnapshotCmd cmd =%v\n", checkSnapshotCmd)
|
||||
|
@ -1603,7 +1600,6 @@ func InstallTestStorageClasses(path string) error {
|
|||
}
|
||||
|
||||
func GetPvName(ctx context.Context, client TestClient, pvcName, namespace string) (string, error) {
|
||||
|
||||
pvcList, err := GetPvcByPVCName(context.Background(), namespace, pvcName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -1622,7 +1618,6 @@ func GetPvName(ctx context.Context, client TestClient, pvcName, namespace string
|
|||
}
|
||||
|
||||
return pvList[0], nil
|
||||
|
||||
}
|
||||
func DeletePVs(ctx context.Context, client TestClient, pvList []string) error {
|
||||
for _, pv := range pvList {
|
||||
|
@ -1637,7 +1632,6 @@ func DeletePVs(ctx context.Context, client TestClient, pvList []string) error {
|
|||
}
|
||||
|
||||
func CleanAllRetainedPV(ctx context.Context, client TestClient) {
|
||||
|
||||
pvNameList, err := GetAllPVNames(ctx, client)
|
||||
if err != nil {
|
||||
fmt.Println("fail to list PV")
|
||||
|
|
Loading…
Reference in New Issue