mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* fix(sandbox-control): read the orgRole claim that Orca Cloud auth mints (#29) Auth mints the live org role as orgRole on sandbox tokens (same claim as billing tokens, stablyai/orca-cloud#695); the verifier read org_role, so admins would never have been recognized. * wip(cloud): environment builds control plane * wip(cloud): environment build boot path, staleness, routes * wip(cloud): env build tests, anonymous staleness fallback * wip(cloud): migration 0008 (claimed), quieter recovered clone errors * fix(cloud): env build review: interrupted-snapshot recovery, bounded log reads, secret redaction, activation guard, hook/prelude fixes * fix(cloud): wait briefly for the build exit code after its log ends; print the base image and package manager * wip(desktop): org environments client, IPC, CLI, settings UI, orcad disk usage + low-disk banner * perf(cloud): smoke-boot each environment build before activating it; skip the redundant prelude fetch * fix(cloud): a GitHub token error fails the build as github_unavailable instead of cloning anonymously * perf(cloud): warm pool VMs per hot environment build, so a create from an org environment skips the provider boot * wip(desktop): cloud environment UI round-3 fixes * fix(cloud): pool-per-build review: smoke race safety, provider hiccups skip smoke, usage-based hot builds with caps, bounded boots, index * fix(desktop): Configure with an agent hands the prompt over at launch (trust dialog swallowed the pasted Enter); CLI builds table widths * polish(desktop): W10 P2s — InlineError action slot, shared focus-ring, copy * feat(cloud): build event stream heartbeat every 20 s * fix(desktop): FE review — stable virtualizer, shadow-buffer replays, heartbeat-aware build watch, CLI follower restarts, repo import path checks, poll races
68 lines
2.4 KiB
TypeScript
68 lines
2.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
lowDiskLevelForVolume,
|
|
OrcadDiskUsageResultSchema,
|
|
worstLowDiskVolume,
|
|
type OrcadDiskVolumeUsage
|
|
} from './orcad-disk-usage'
|
|
|
|
const MIB = 1024 ** 2
|
|
const GIB = 1024 ** 3
|
|
|
|
function volume(path: string, totalBytes: number, availableBytes: number): OrcadDiskVolumeUsage {
|
|
return { path, totalBytes, freeBytes: availableBytes, availableBytes, usedPercent: 0 }
|
|
}
|
|
|
|
describe('lowDiskLevelForVolume', () => {
|
|
it.each([
|
|
['plenty on a 32 GiB disk', 32 * GIB, 10 * GIB, 'ok'],
|
|
['just above 10% of 32 GiB', 32 * GIB, 3.3 * GIB, 'ok'],
|
|
['under 10% of 32 GiB', 32 * GIB, 3.1 * GIB, 'warning'],
|
|
['under 2 GiB on a huge disk', 1024 * GIB, 1.9 * GIB, 'warning'],
|
|
['10% of a huge disk but above 2 GiB', 1024 * GIB, 100 * GIB, 'warning'],
|
|
['exactly 500 MiB', 32 * GIB, 500 * MIB, 'warning'],
|
|
['under 500 MiB', 32 * GIB, 499 * MIB, 'critical'],
|
|
['full', 32 * GIB, 0, 'critical'],
|
|
['a zero-size filesystem', 0, 0, 'ok']
|
|
] as const)('%s', (_label, total, available, expected) => {
|
|
expect(lowDiskLevelForVolume({ totalBytes: total, availableBytes: available })).toBe(expected)
|
|
})
|
|
|
|
it('treats a small disk above 2 GiB and 10% as ok', () => {
|
|
expect(lowDiskLevelForVolume({ totalBytes: 8 * GIB, availableBytes: 2.5 * GIB })).toBe('ok')
|
|
})
|
|
})
|
|
|
|
describe('worstLowDiskVolume', () => {
|
|
it('returns null when every volume is fine', () => {
|
|
expect(worstLowDiskVolume([volume('/', 32 * GIB, 20 * GIB)])).toBeNull()
|
|
expect(worstLowDiskVolume([])).toBeNull()
|
|
})
|
|
|
|
it('prefers critical over warning, then the least available', () => {
|
|
const warning = volume('/home', 32 * GIB, 1.5 * GIB)
|
|
const warningLower = volume('/data', 32 * GIB, 1 * GIB)
|
|
const critical = volume('/vercel/sandbox', 32 * GIB, 100 * MIB)
|
|
expect(worstLowDiskVolume([warning, critical, warningLower])).toEqual({
|
|
level: 'critical',
|
|
volume: critical
|
|
})
|
|
expect(worstLowDiskVolume([warning, warningLower])).toEqual({
|
|
level: 'warning',
|
|
volume: warningLower
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('OrcadDiskUsageResultSchema', () => {
|
|
it('rejects a malformed reply instead of rendering garbage', () => {
|
|
expect(OrcadDiskUsageResultSchema.safeParse({ volumes: [{ path: '/' }] }).success).toBe(false)
|
|
expect(
|
|
OrcadDiskUsageResultSchema.safeParse({
|
|
checkedAt: 1,
|
|
volumes: [volume('/', 1, 1)]
|
|
}).success
|
|
).toBe(true)
|
|
})
|
|
})
|