mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-11-09 17:06:13 -06:00
This branch is a reliability overhaul of the ESXi/vSphere source side of V2V, plus a scope reduction of the package. The SOAP plumbing is rewritten:
VimClient wraps @vates/node-vsphere-soap in a promise API with one emitter per call (no more cross-talk between concurrent calls, no listener leak) and a pTimeout;
vim25 faults are now parsed (_parseFault.mjs) so callers get a real fault type instead of task execution failed;
the library no longer throws from async callbacks (which killed xo-server) and its beforeExit logout hook is per-client instead of removeAllListeners.
Request specs are built in explicit schema order (soap/specs.mjs) with xsi:type, and property values are normalized (soap/normalize.mjs) so search() and the new #retrieveProperty share one shape.
search() now paginates, cancels the retrieval and destroys the container view.
Datastore HTTP downloads get session-cookie reuse, retry with jittered backoff, a headers-only timeout, and range-honouring validation.
Task waiting polls with backoff and per-operation timeouts (6 h for snapshot consolidation).
nbdkit servers are memoized by a key that includes the export options, the readiness wait races the process death instead of sleeping 2 s
the password file is 0600 and unlinked
the thumbprint is read over TLS in-process instead of two openssl spawns.
The old VHD-over-datastore readers (VhdEsxi*, Datastore*, openDeltaVmdkAsVhd) are deleted, hence the majo, rleaving the vddk/NBD path with a COWD grain-directory parser as data-map fallback.
~1.7k lines of unit tests are added.
62 lines
2.0 KiB
JavaScript
62 lines
2.0 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { describe, it } from 'node:test'
|
|
|
|
import { asArray, normalizeSoapValue } from './normalize.mjs'
|
|
|
|
describe('asArray', function () {
|
|
it('wraps a single element', function () {
|
|
assert.deepEqual(asArray('a'), ['a'])
|
|
assert.deepEqual(asArray({ a: 1 }), [{ a: 1 }])
|
|
})
|
|
|
|
it('keeps an array as is', function () {
|
|
const array = ['a', 'b']
|
|
assert.equal(asArray(array), array)
|
|
})
|
|
|
|
it('returns an empty array for an absent element', function () {
|
|
assert.deepEqual(asArray(undefined), [])
|
|
assert.deepEqual(asArray(null), [])
|
|
})
|
|
})
|
|
|
|
describe('normalizeSoapValue', function () {
|
|
it('unwraps a scalar', function () {
|
|
assert.equal(normalizeSoapValue({ $value: 'poweredOn', attributes: { 'xsi:type': 'string' } }), 'poweredOn')
|
|
})
|
|
|
|
it('unwraps a falsy scalar', function () {
|
|
assert.equal(normalizeSoapValue({ $value: '' }), '')
|
|
assert.equal(normalizeSoapValue({ $value: 0 }), 0)
|
|
assert.equal(normalizeSoapValue({ $value: false }), false)
|
|
})
|
|
|
|
it('unwraps a managed object reference to its value', function () {
|
|
assert.equal(normalizeSoapValue({ attributes: { type: 'Datastore' }, $value: 'datastore-11' }), 'datastore-11')
|
|
})
|
|
|
|
it('drops the attributes of a complex type', function () {
|
|
assert.deepEqual(
|
|
normalizeSoapValue({ attributes: { 'xsi:type': 'VirtualMachineConfigInfo' }, name: 'vm', guestId: 'ubuntu64' }),
|
|
{ name: 'vm', guestId: 'ubuntu64' }
|
|
)
|
|
})
|
|
|
|
it('does not touch a value without attributes', function () {
|
|
const value = { name: 'vm' }
|
|
assert.equal(normalizeSoapValue(value), value)
|
|
})
|
|
|
|
it('leaves the nested values as they are', function () {
|
|
assert.deepEqual(normalizeSoapValue({ attributes: {}, hardware: { memoryMB: '2048' } }), {
|
|
hardware: { memoryMB: '2048' },
|
|
})
|
|
})
|
|
|
|
it('passes primitives and null through', function () {
|
|
assert.equal(normalizeSoapValue('poweredOff'), 'poweredOff')
|
|
assert.equal(normalizeSoapValue(null), null)
|
|
assert.equal(normalizeSoapValue(undefined), undefined)
|
|
})
|
|
})
|