feat(server): run managed Ollama on Linux and skip CUDA downloads on install (P1.3b)
- Pinned Ollama 0.32.3 (and rollback 0.32.0) Linux x64/arm64 artifacts with their published SHA-256 and sizes; .tar.zst archives are decompressed by Node 22's zstd and unpacked by the system tar. - install.sh sets ONNXRUNTIME_NODE_INSTALL_CUDA=skip: onnxruntime-node otherwise downloads CUDA libraries on every Linux x64 install. - Drop the root sqlite-vec-windows-x64 dependency; the sqlite-vec package already carries per-platform binaries.
This commit is contained in:
62
packages/server/tests/local/managed-ollama-linux.test.ts
Normal file
62
packages/server/tests/local/managed-ollama-linux.test.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import zlib from 'node:zlib';
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
import {
|
||||
extractTarZst,
|
||||
OLLAMA_RUNTIME_ARTIFACTS,
|
||||
resolveOllamaRuntimeArtifact,
|
||||
} from '../../src/local/managed-ollama-runtime.js';
|
||||
|
||||
const dirs: string[] = [];
|
||||
function tempDir(): string {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-ollama-linux-'));
|
||||
dirs.push(dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
for (const dir of dirs.splice(0)) fs.rmSync(dir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
describe('managed Ollama on Linux', () => {
|
||||
it('has a pinned artifact for x64 and arm64', () => {
|
||||
for (const arch of ['x64', 'arm64']) {
|
||||
const artifact = resolveOllamaRuntimeArtifact('linux', arch);
|
||||
expect(artifact).toMatchObject({
|
||||
platform: 'linux',
|
||||
arch,
|
||||
executableName: 'ollama',
|
||||
url: expect.stringMatching(/^https:\/\/github\.com\/ollama\/ollama\/releases\/download\/v[\d.]+\/ollama-linux-(amd64|arm64)\.tar\.zst$/),
|
||||
sha256: expect.stringMatching(/^[0-9a-f]{64}$/),
|
||||
});
|
||||
}
|
||||
expect(resolveOllamaRuntimeArtifact('linux', 'ia32')).toBeNull();
|
||||
});
|
||||
|
||||
it('keeps one rollback artifact per Linux architecture', () => {
|
||||
const linux = OLLAMA_RUNTIME_ARTIFACTS.filter((entry) => entry.platform === 'linux');
|
||||
expect(new Set(linux.map((entry) => `${entry.version}/${entry.arch}`)).size).toBe(linux.length);
|
||||
expect(linux).toHaveLength(4);
|
||||
});
|
||||
|
||||
it.skipIf(process.platform === 'win32' || !('createZstdCompress' in zlib))(
|
||||
'unpacks a zstd-compressed tarball',
|
||||
async () => {
|
||||
const source = tempDir();
|
||||
fs.mkdirSync(path.join(source, 'bin'));
|
||||
fs.writeFileSync(path.join(source, 'bin', 'ollama'), '#!/bin/sh\necho ok\n');
|
||||
const tarball = path.join(tempDir(), 'runtime.tar');
|
||||
execFileSync('tar', ['-cf', tarball, '-C', source, 'bin']);
|
||||
const compress = (zlib as unknown as { zstdCompressSync: (input: Buffer) => Buffer }).zstdCompressSync;
|
||||
const archive = `${tarball}.zst`;
|
||||
fs.writeFileSync(archive, compress(fs.readFileSync(tarball)));
|
||||
|
||||
const destination = tempDir();
|
||||
await extractTarZst(archive, destination);
|
||||
expect(fs.readFileSync(path.join(destination, 'bin', 'ollama'), 'utf8')).toContain('echo ok');
|
||||
},
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user