Compare commits
3 Commits
main
...
backup-fie
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
333cd58f79 | ||
|
|
eaf1429d19 | ||
|
|
2d627d832a |
@ -371,7 +371,7 @@ func (suite *BackupCleanupUnitSuite) TestCleanupOrphanedData() {
|
|||||||
|
|
||||||
backupWithLegacyResource := func(protectedResource string, b *backup.Backup) *backup.Backup {
|
backupWithLegacyResource := func(protectedResource string, b *backup.Backup) *backup.Backup {
|
||||||
res := *b
|
res := *b
|
||||||
res.ResourceOwnerID = protectedResource
|
res.ProtectedResourceID = protectedResource
|
||||||
|
|
||||||
return &res
|
return &res
|
||||||
}
|
}
|
||||||
@ -706,14 +706,48 @@ func (suite *BackupCleanupUnitSuite) TestCleanupOrphanedData() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Test that an assist base that has the same Reasons as a newer merge
|
// Test that an assist base that has the same Reasons as a newer merge
|
||||||
// base but the merge base is from an older version of corso for some
|
// base but the merge base is missing the protected resource ID for some
|
||||||
// reason doesn't cause the assist base to be garbage collected. This is
|
// reason doesn't cause the assist base to be garbage collected. This is
|
||||||
// not ideal, but some older versions of corso didn't even populate the
|
// not ideal, but at least we're not accidentally removing assist bases
|
||||||
// resource owner ID.
|
// that could be useful later on.
|
||||||
//
|
//
|
||||||
// Worst case, the assist base will be cleaned up when the user upgrades
|
// Worst case, the assist base will be cleaned up when there's a merge
|
||||||
// corso and generates either a new assist base or merge base with the
|
// base that does populated the protected resource ID field.
|
||||||
// same reason.
|
name: "AssistAndMergeMissingResourceIDBases NotYoungest Noops",
|
||||||
|
snapshots: []*manifest.EntryMetadata{
|
||||||
|
manifestWithReasons(
|
||||||
|
manifestWithTime(baseTime, snapCurrent()),
|
||||||
|
"tenant1",
|
||||||
|
NewReason("", "ro", path.ExchangeService, path.EmailCategory)),
|
||||||
|
manifestWithTime(baseTime, deetsCurrent()),
|
||||||
|
|
||||||
|
manifestWithReasons(
|
||||||
|
manifestWithTime(baseTime.Add(time.Second), snapCurrent2()),
|
||||||
|
"tenant1",
|
||||||
|
NewReason("", "ro", path.ExchangeService, path.EmailCategory)),
|
||||||
|
manifestWithTime(baseTime.Add(time.Second), deetsCurrent2()),
|
||||||
|
},
|
||||||
|
backups: []backupRes{
|
||||||
|
{bup: backupWithResource("ro", true, backupWithTime(baseTime, bupCurrent()))},
|
||||||
|
{bup: func() *backup.Backup {
|
||||||
|
res := backupWithResource(
|
||||||
|
"ro",
|
||||||
|
false,
|
||||||
|
backupWithTime(baseTime.Add(time.Second), bupCurrent2()))
|
||||||
|
res.ProtectedResourceID = ""
|
||||||
|
|
||||||
|
return res
|
||||||
|
}()},
|
||||||
|
},
|
||||||
|
time: baseTime.Add(48 * time.Hour),
|
||||||
|
buffer: 24 * time.Hour,
|
||||||
|
expectErr: assert.NoError,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Test that an assist base that has the same Reasons as a newer merge
|
||||||
|
// base but the merge base is from an older version of corso that doesn't
|
||||||
|
// add merge or assist base tags for some reason causes the assist base to
|
||||||
|
// be garbage collected.
|
||||||
name: "AssistAndLegacyMergeBases NotYoungest Noops",
|
name: "AssistAndLegacyMergeBases NotYoungest Noops",
|
||||||
snapshots: []*manifest.EntryMetadata{
|
snapshots: []*manifest.EntryMetadata{
|
||||||
manifestWithReasons(
|
manifestWithReasons(
|
||||||
@ -732,8 +766,13 @@ func (suite *BackupCleanupUnitSuite) TestCleanupOrphanedData() {
|
|||||||
{bup: backupWithResource("ro", true, backupWithTime(baseTime, bupCurrent()))},
|
{bup: backupWithResource("ro", true, backupWithTime(baseTime, bupCurrent()))},
|
||||||
{bup: backupWithLegacyResource("ro", backupWithTime(baseTime.Add(time.Second), bupCurrent2()))},
|
{bup: backupWithLegacyResource("ro", backupWithTime(baseTime.Add(time.Second), bupCurrent2()))},
|
||||||
},
|
},
|
||||||
time: baseTime.Add(48 * time.Hour),
|
time: baseTime.Add(48 * time.Hour),
|
||||||
buffer: 24 * time.Hour,
|
buffer: 24 * time.Hour,
|
||||||
|
expectDeleteIDs: []manifest.ID{
|
||||||
|
snapCurrent().ID,
|
||||||
|
deetsCurrent().ID,
|
||||||
|
manifest.ID(bupCurrent().ModelStoreID),
|
||||||
|
},
|
||||||
expectErr: assert.NoError,
|
expectErr: assert.NoError,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -36,10 +36,12 @@ type Backup struct {
|
|||||||
// Selector used in this operation
|
// Selector used in this operation
|
||||||
Selector selectors.Selector `json:"selectors"`
|
Selector selectors.Selector `json:"selectors"`
|
||||||
|
|
||||||
// TODO: in process of gaining support, most cases will still use
|
// ** DO NOT CHANGE JSON TAG NAMES **
|
||||||
// ResourceOwner and ResourceOwnerName.
|
// These are in-memory only variable renames of previously persisted fields.
|
||||||
ProtectedResourceID string `json:"protectedResourceID,omitempty"`
|
// ** CHANGING THE JSON TAGS WILL BREAK THINGS BECAUSE THE MODEL WON'T **
|
||||||
ProtectedResourceName string `json:"protectedResourceName,omitempty"`
|
// ** DESERIALIZE PROPERLY **
|
||||||
|
ProtectedResourceID string `json:"resourceOwnerID,omitempty"`
|
||||||
|
ProtectedResourceName string `json:"resourceOwnerName,omitempty"`
|
||||||
|
|
||||||
// Version represents the version of the backup format
|
// Version represents the version of the backup format
|
||||||
Version int `json:"version"`
|
Version int `json:"version"`
|
||||||
@ -61,10 +63,6 @@ type Backup struct {
|
|||||||
// Reference to the backup details storage location.
|
// Reference to the backup details storage location.
|
||||||
// Used to read backup.Details from the streamstore.
|
// Used to read backup.Details from the streamstore.
|
||||||
DetailsID string `json:"detailsID"`
|
DetailsID string `json:"detailsID"`
|
||||||
|
|
||||||
// prefer protectedResource
|
|
||||||
ResourceOwnerID string `json:"resourceOwnerID,omitempty"`
|
|
||||||
ResourceOwnerName string `json:"resourceOwnerName,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// interface compliance checks
|
// interface compliance checks
|
||||||
@ -115,8 +113,8 @@ func New(
|
|||||||
Tags: tags,
|
Tags: tags,
|
||||||
},
|
},
|
||||||
|
|
||||||
ResourceOwnerID: ownerID,
|
ProtectedResourceID: ownerID,
|
||||||
ResourceOwnerName: ownerName,
|
ProtectedResourceName: ownerName,
|
||||||
|
|
||||||
Version: version,
|
Version: version,
|
||||||
SnapshotID: snapshotID,
|
SnapshotID: snapshotID,
|
||||||
@ -253,9 +251,7 @@ func (b Backup) Values() []string {
|
|||||||
|
|
||||||
name := str.First(
|
name := str.First(
|
||||||
b.ProtectedResourceName,
|
b.ProtectedResourceName,
|
||||||
b.ResourceOwnerName,
|
|
||||||
b.ProtectedResourceID,
|
b.ProtectedResourceID,
|
||||||
b.ResourceOwnerID,
|
|
||||||
b.Selector.Name())
|
b.Selector.Name())
|
||||||
|
|
||||||
bs := b.toStats()
|
bs := b.toStats()
|
||||||
|
|||||||
@ -40,10 +40,8 @@ func stubBackup(t time.Time, ownerID, ownerName string) backup.Backup {
|
|||||||
CreationTime: t,
|
CreationTime: t,
|
||||||
SnapshotID: "snapshot",
|
SnapshotID: "snapshot",
|
||||||
DetailsID: "details",
|
DetailsID: "details",
|
||||||
ProtectedResourceID: ownerID + "-pr",
|
ProtectedResourceID: ownerID + "-ro",
|
||||||
ProtectedResourceName: ownerName + "-pr",
|
ProtectedResourceName: ownerName + "-ro",
|
||||||
ResourceOwnerID: ownerID + "-ro",
|
|
||||||
ResourceOwnerName: ownerName + "-ro",
|
|
||||||
Status: "status",
|
Status: "status",
|
||||||
Selector: sel.Selector,
|
Selector: sel.Selector,
|
||||||
ErrorCount: 2,
|
ErrorCount: 2,
|
||||||
@ -86,7 +84,7 @@ func (suite *BackupUnitSuite) TestBackup_HeadersValues() {
|
|||||||
nowFmt,
|
nowFmt,
|
||||||
"1m0s",
|
"1m0s",
|
||||||
"status (2 errors, 1 skipped: 1 malware)",
|
"status (2 errors, 1 skipped: 1 malware)",
|
||||||
"name-pr",
|
"name-ro",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -123,9 +121,6 @@ func (suite *BackupUnitSuite) TestBackup_HeadersValues_onlyResourceOwners() {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
b.ProtectedResourceID = ""
|
|
||||||
b.ProtectedResourceName = ""
|
|
||||||
|
|
||||||
b.StartAndEndTime.CompletedAt = later
|
b.StartAndEndTime.CompletedAt = later
|
||||||
|
|
||||||
// single skipped malware
|
// single skipped malware
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user