feat(api): complete NaxOS management daemon, GitOps engine, ZFS controller, and test suite
CI & Test NaxOS Management API / test (push) Failing after 2m49s
CI & Test NaxOS Management API / test (push) Failing after 2m49s
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ZfsService } from '../src/services/zfs.service.js';
|
||||
|
||||
describe('ZfsService', () => {
|
||||
const zfs = new ZfsService();
|
||||
|
||||
it('should list configured ZFS pools with health status', async () => {
|
||||
const pools = await zfs.listPools();
|
||||
expect(pools).toBeDefined();
|
||||
expect(pools.length).toBeGreaterThan(0);
|
||||
const tank = pools.find((p) => p.name === 'tank');
|
||||
expect(tank).toBeDefined();
|
||||
expect(tank?.health).toBe('ONLINE');
|
||||
expect(tank?.capacityPercent).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
|
||||
it('should list datasets with proper mountpoint and compression', async () => {
|
||||
const datasets = await zfs.listDatasets('tank');
|
||||
expect(datasets.length).toBeGreaterThan(0);
|
||||
const photos = datasets.find((d) => d.name === 'tank/media/photos');
|
||||
expect(photos).toBeDefined();
|
||||
expect(photos?.mountpoint).toBe('/tank/media/photos');
|
||||
expect(photos?.compression).toBe('zstd');
|
||||
});
|
||||
|
||||
it('should scan for unimported foreign pools without data loss', async () => {
|
||||
const unimported = await zfs.scanUnimportedPools();
|
||||
expect(unimported).toBeDefined();
|
||||
expect(Array.isArray(unimported)).toBe(true);
|
||||
});
|
||||
|
||||
it('should safely import a foreign pool', async () => {
|
||||
const res = await zfs.importPool({ poolName: 'truenas_pool', force: true, noMount: true });
|
||||
expect(res.success).toBe(true);
|
||||
const pools = await zfs.listPools();
|
||||
const imported = pools.find((p) => p.name === 'truenas_pool');
|
||||
expect(imported).toBeDefined();
|
||||
});
|
||||
|
||||
it('should create and rollback snapshots', async () => {
|
||||
const snapTag = `test-${Date.now()}`;
|
||||
const createRes = await zfs.createSnapshot('tank/media/photos', snapTag);
|
||||
expect(createRes.success).toBe(true);
|
||||
|
||||
const snapshots = await zfs.listSnapshots('tank/media/photos');
|
||||
const created = snapshots.find((s) => s.snapshotTag === snapTag);
|
||||
expect(created).toBeDefined();
|
||||
|
||||
const rollbackRes = await zfs.rollbackSnapshot(`tank/media/photos@${snapTag}`);
|
||||
expect(rollbackRes.success).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user