mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-03 11:45:20 +00:00
add various scenarios to queue controller unit tests
Signed-off-by: Scott Seago <sseago@redhat.com>
This commit is contained in:
@@ -23,13 +23,15 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
//metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
||||
//"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
||||
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
"github.com/vmware-tanzu/velero/pkg/builder"
|
||||
velerotest "github.com/vmware-tanzu/velero/pkg/test"
|
||||
)
|
||||
|
||||
func TestBackupQueueReconciler(t *testing.T) {
|
||||
@@ -58,7 +60,7 @@ func TestBackupQueueReconciler(t *testing.T) {
|
||||
expectPhase: velerov1api.BackupPhaseInProgress,
|
||||
},
|
||||
{
|
||||
name: "Second New Backup gets queued with queuePosition 2",
|
||||
name: "Second New Backup gets queued with queuePosition 2",
|
||||
priorBackups: []*velerov1api.Backup{
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseQueued).QueuePosition(1).Result(),
|
||||
},
|
||||
@@ -72,7 +74,7 @@ func TestBackupQueueReconciler(t *testing.T) {
|
||||
expectPhase: velerov1api.BackupPhaseReadyToStart,
|
||||
},
|
||||
{
|
||||
name: "Queued Backup remains queued if no spaces available",
|
||||
name: "Queued Backup remains queued if no spaces available",
|
||||
priorBackups: []*velerov1api.Backup{
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).Result(),
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-12").Phase(velerov1api.BackupPhaseInProgress).Result(),
|
||||
@@ -83,7 +85,7 @@ func TestBackupQueueReconciler(t *testing.T) {
|
||||
expectQueuePosition: 1,
|
||||
},
|
||||
{
|
||||
name: "Queued Backup remains queued if no spaces available including ReadyToStart",
|
||||
name: "Queued Backup remains queued if no spaces available including ReadyToStart",
|
||||
priorBackups: []*velerov1api.Backup{
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).Result(),
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-12").Phase(velerov1api.BackupPhaseReadyToStart).Result(),
|
||||
@@ -94,7 +96,7 @@ func TestBackupQueueReconciler(t *testing.T) {
|
||||
expectQueuePosition: 1,
|
||||
},
|
||||
{
|
||||
name: "Queued Backup remains queued if earlier runnable backup is also queued",
|
||||
name: "Queued Backup remains queued if earlier runnable backup is also queued",
|
||||
priorBackups: []*velerov1api.Backup{
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).Result(),
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-12").Phase(velerov1api.BackupPhaseQueued).QueuePosition(1).Result(),
|
||||
@@ -105,7 +107,7 @@ func TestBackupQueueReconciler(t *testing.T) {
|
||||
expectQueuePosition: 2,
|
||||
},
|
||||
{
|
||||
name: "Queued Backup remains queued if in conflict with running backup",
|
||||
name: "Queued Backup remains queued if in conflict with running backup",
|
||||
priorBackups: []*velerov1api.Backup{
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).IncludedNamespaces("foo").Result(),
|
||||
},
|
||||
@@ -116,7 +118,7 @@ func TestBackupQueueReconciler(t *testing.T) {
|
||||
expectQueuePosition: 1,
|
||||
},
|
||||
{
|
||||
name: "Queued Backup remains queued if in conflict with ReadyToStart backup",
|
||||
name: "Queued Backup remains queued if in conflict with ReadyToStart backup",
|
||||
priorBackups: []*velerov1api.Backup{
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseReadyToStart).IncludedNamespaces("foo").Result(),
|
||||
},
|
||||
@@ -127,7 +129,7 @@ func TestBackupQueueReconciler(t *testing.T) {
|
||||
expectQueuePosition: 1,
|
||||
},
|
||||
{
|
||||
name: "Queued Backup remains queued if in conflict with earlier queued backup",
|
||||
name: "Queued Backup remains queued if in conflict with earlier queued backup",
|
||||
priorBackups: []*velerov1api.Backup{
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseQueued).QueuePosition(1).IncludedNamespaces("foo").Result(),
|
||||
},
|
||||
@@ -138,7 +140,7 @@ func TestBackupQueueReconciler(t *testing.T) {
|
||||
expectQueuePosition: 2,
|
||||
},
|
||||
{
|
||||
name: "Queued Backup remains queued if earlier non-ns-conflict backup exists",
|
||||
name: "Queued Backup remains queued if earlier non-ns-conflict backup exists",
|
||||
priorBackups: []*velerov1api.Backup{
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).IncludedNamespaces("bar").Result(),
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-12").Phase(velerov1api.BackupPhaseQueued).QueuePosition(1).IncludedNamespaces("foo").Result(),
|
||||
@@ -150,7 +152,7 @@ func TestBackupQueueReconciler(t *testing.T) {
|
||||
expectQueuePosition: 2,
|
||||
},
|
||||
{
|
||||
name: "Running all-namespace backup conflicts with queued one-namespace backup ",
|
||||
name: "Running all-namespace backup conflicts with queued one-namespace backup ",
|
||||
priorBackups: []*velerov1api.Backup{
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).IncludedNamespaces("*").Result(),
|
||||
},
|
||||
@@ -161,7 +163,7 @@ func TestBackupQueueReconciler(t *testing.T) {
|
||||
expectQueuePosition: 1,
|
||||
},
|
||||
{
|
||||
name: "Running one-namespace backup conflicts with queued all-namespace backup ",
|
||||
name: "Running one-namespace backup conflicts with queued all-namespace backup ",
|
||||
priorBackups: []*velerov1api.Backup{
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).IncludedNamespaces("bar").Result(),
|
||||
},
|
||||
@@ -172,7 +174,7 @@ func TestBackupQueueReconciler(t *testing.T) {
|
||||
expectQueuePosition: 1,
|
||||
},
|
||||
{
|
||||
name: "Queued Backup moves to ReadyToStart if running count < concurrentBackups",
|
||||
name: "Queued Backup moves to ReadyToStart if running count < concurrentBackups",
|
||||
priorBackups: []*velerov1api.Backup{
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).Result(),
|
||||
builder.ForBackup(velerov1api.DefaultNamespace, "backup-12").Phase(velerov1api.BackupPhaseInProgress).Result(),
|
||||
|
||||
Reference in New Issue
Block a user