mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-13 11:34:54 +00:00
* Add MustIncludeAdditionalItemPVCs structure in backup. It's used to track PVCs returned by BIA with mustIncluded annotaion and PVC is excluded from backup by global filter. * Modfiy the volumeHelper interface to add a parameter function for ShouldPerformFSBackup. * Modify to support fine-grained backup filters. * Modify according to comments. Use a read-only interface to replace the parameter function. Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
/*
|
|
Copyright the Velero contributors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package backup
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/vmware-tanzu/velero/pkg/kuberesource"
|
|
)
|
|
|
|
func TestPVCMustInclusionTracker_IsPVCIncluded(t *testing.T) {
|
|
mustIncludeMap := NewBackedUpItemsMap()
|
|
|
|
tracker := NewPVCMustInclusionTracker(mustIncludeMap)
|
|
|
|
pvcKey1 := itemKey{
|
|
resource: kuberesource.PersistentVolumeClaims.String(),
|
|
namespace: "ns-1",
|
|
name: "pvc-1",
|
|
}
|
|
|
|
// Initially neither PVC is included
|
|
assert.False(t, tracker.IsPVCIncluded("ns-1", "pvc-1"))
|
|
|
|
// Add pvc-1 to mustInclude map
|
|
mustIncludeMap.AddItem(pvcKey1)
|
|
assert.True(t, tracker.IsPVCIncluded("ns-1", "pvc-1"))
|
|
|
|
// Check a PVC not in any map
|
|
assert.False(t, tracker.IsPVCIncluded("ns-1", "pvc-2"))
|
|
}
|