Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@xen-orchestra/backups): tests #6597

Merged
merged 2 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions @xen-orchestra/backups/_cleanVm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ test('it merges delta of non destroyed chain', async () => {
loggued.push(message)
}
await adapter.cleanVm(rootPath, { remove: true, logInfo, logWarn: logInfo, lock: false })
assert.equal(loggued[0], `incorrect backup size in metadata`)
assert.equal(loggued[0], `unexpected number of entries in backup cache`)

loggued = []
await adapter.cleanVm(rootPath, { remove: true, merge: true, logInfo, logWarn: () => {}, lock: false })
Expand Down Expand Up @@ -378,7 +378,19 @@ describe('tests multiple combination ', () => {
],
})
)

if (!useAlias && vhdMode === 'directory') {
try {
await adapter.cleanVm(rootPath, { remove: true, merge: true, logWarn: () => {}, lock: false })
} catch (err) {
assert.strictEqual(
err.code,
'NOT_SUPPORTED',
'Merging directory without alias should raise a not supported error'
)
return
}
assert.strictEqual(true, false, 'Merging directory without alias should raise an error')
}
await adapter.cleanVm(rootPath, { remove: true, merge: true, logWarn: () => {}, lock: false })

const metadata = JSON.parse(await handler.readFile(`${rootPath}/metadata.json`))
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
<!--packages-start-->

- @xen-orchestra/backups patch
- vhd-lib patch
- xo-server patch
julien-f marked this conversation as resolved.
Show resolved Hide resolved
julien-f marked this conversation as resolved.
Show resolved Hide resolved

<!--packages-end-->
7 changes: 7 additions & 0 deletions packages/vhd-lib/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ class Merger {

// merging vhdFile must not be concurrently with the potential block reordering after a change
this.#mergeBlockConcurrency = parentIsVhdDirectory && childIsVhdDirectory ? this.#mergeBlockConcurrency : 1

if (parentIsVhdDirectory && !isVhdAlias(this.#parentPath)) {
const error = new Error("can't merge vhd directories without using alias")
error.code = 'NOT_SUPPORTED'
throw error
}

julien-f marked this conversation as resolved.
Show resolved Hide resolved
if (this.#state === undefined) {
// merge should be along a vhd chain
assert.strictEqual(UUID.stringify(childVhd.header.parentUuid), UUID.stringify(parentVhd.footer.uuid))
Expand Down