sufeng1894 (v0.1.4248) added Qoder China and QwenWork providers (both served by the Qoder plugin): their models were green in the provider's Test, and every request through Routing failed with 503. A Qoder/QwenWork plan queues a model (code 10605, e.g. "this plan's queue: p4"). The test sends x-magpie-fallback, the plugin answers the queue's 503 at once, and probe counts it OK with Result.Queued (d3aecfe95). The GUI drew that as a green dot and "answered", while routing gives way from a queued member at once (503 busy) and the last member's wait ends in the queue's 503 (4 minutes unstreamed; a frozen queue after 5 minutes with qoder 0.2.71, v0.1.4321). So Test said the opposite of what Routing does. Now a queued result is its own state: an amber dot, its title "Queued at its vendor, not answered: <queue>", and Test models' and Test this model's status say the same and are not "ok". Working only still keeps a queued model, as the test's OK says (a queue clears). renderEndpoints is not a sibling: it is drawn only when no address is plugin://, and only plugins report queued. core_budget_test.go: +135 for it, the reason in the comment; one string (queuedSaid) shared by all three places. Run (mica-run/mote-run, at origin/main8608ce024): - models-queued.test.cjs (chromium, webkit): 4/4 ok; with the old app.js 4/4 red ("a queued model's dot isn't green", and the single test's status timed out waiting for the queued dot). - go test -run Budget ./internal/gui: ok. - every models-*, model-*, provider*, i18n-* and test-* GUI file: 2430 tests, 2323 ok, 107 red (mote). The same 107 in the same 11 files are red at untouched origin/main8608ce024(146 run, 107 red), all filed: i18n-keys (#6877), models-works-only (#4391), model-chip-steady (#4388), model-copy-id (#4621), model-api-preset (#5838), provider-max-output and provider-many-keys (#6209), provider-fetch-again, provider-models-rest, provider-picks-stay and provider-typed (#6532). A first run on mica died of ENOSPC (its disk is full) and tested nothing. - Rebased onto07f7e0b45(nothing under internal/gui changed since8608ce024): the budget test and models-queued + model-test-one (8/8) ran again there, ok. Not tried: a real Qoder China or QwenWork account; the reporter's 503 body, so which queue (or another cause) their 503s carry is not confirmed.
101 lines
6.2 KiB
JavaScript
101 lines
6.2 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
|
// A plugin's model its vendor has queued (Qoder's "queued the request for
|
|
// ...", Mr7Faith on X) is no failed test: Working only keeps it picked. But
|
|
// it didn't answer either, and routing gives way at once or ends with the
|
|
// queue's 503, so its dot is the queued one, not green, and the status
|
|
// says the queue, not "answered" (@sufeng1894 on X).
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("node:fs/promises");
|
|
const path = require("node:path");
|
|
const { test } = require("node:test");
|
|
const { chromium, webkit } = require("playwright");
|
|
|
|
const assets = path.resolve(__dirname, "../assets");
|
|
const fetched = new Date(Date.now() - 3600e3).toISOString();
|
|
const m = (id, i) => ({ id, name: id, on: i < 4 });
|
|
const ids = ["glm-5", "kimi-k3", "qwen4-max", "deepseek-v4", "minimax-m3", "gpt-oss-200b"];
|
|
const relay = {
|
|
id: "mixed", name: "Mixed Relay", icon: "generic", host: "mixed.example.com", chat: "https://mixed.example.com/v1", responses: "", anthropic: "", catalog: "",
|
|
models: ids.map(m), chosen: ids.slice(0, 4), fetched, agents: [], fallback: [], headers: {},
|
|
key: { set: true, masked: "sk-…one" }, keyList: [], balanceToken: { takes: false, set: false }, proxy: "",
|
|
};
|
|
// what the vendor answered: two of the four picks fail
|
|
const answers = {
|
|
"glm-5": { ok: true, ms: 410, protocol: "openai", queued: "Qoder queued the request for glm-5 (this plan's queue: p4, 1 ahead); try again in 60s" },
|
|
"kimi-k3": { ok: false, status: 404, error: "model not found", protocol: "openai" },
|
|
"qwen4-max": { ok: true, ms: 380, protocol: "openai" },
|
|
"deepseek-v4": { ok: false, status: 503, error: "no available channel", protocol: "openai" },
|
|
};
|
|
const KEPT = ["glm-5", "qwen4-max"];
|
|
|
|
function serve(lang, posts) {
|
|
const providers = { providers: [relay], presets: [], excluded: [], gateway: { running: true, window: true } };
|
|
const state = { agents: [], profiles: [], settings: { lang, theme: "light" } };
|
|
return async (route) => {
|
|
const req = route.request(), url = new URL(req.url());
|
|
const json = (data) => route.fulfill({ json: data });
|
|
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
|
|
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
|
if (req.method() === "POST" && url.pathname.startsWith("/api/")) posts.push({ path: url.pathname, body: req.postDataJSON() || {} });
|
|
if (url.pathname === "/api/state") return json(state);
|
|
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
|
if (url.pathname === "/api/providers") return json(providers);
|
|
if (url.pathname === "/api/groups") return json({ groups: [] });
|
|
if (url.pathname === "/api/provider/test") {
|
|
const body = req.postDataJSON();
|
|
return json({ results: body.test.map((model) => ({ model, ...answers[model] })) });
|
|
}
|
|
if (url.pathname.startsWith("/api/")) return json({});
|
|
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
|
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
|
await route.fulfill({ body: await fs.readFile(file), contentType });
|
|
};
|
|
}
|
|
|
|
|
|
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
|
test(`${engine}: a queued model's test says the queue, not green`, async (t) => {
|
|
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
|
t.after(() => browser.close());
|
|
const page = await (await browser.newContext({ viewport: { width: 900, height: 700 }, reducedMotion: "reduce" })).newPage();
|
|
page.setDefaultTimeout(5000);
|
|
page.setDefaultNavigationTimeout(60000);
|
|
const posts = [];
|
|
await page.route("**/*", serve("en", posts));
|
|
await page.goto("http://magpie.test/?view=providers");
|
|
const editor = page.locator("#modal:not([hidden]) .editor");
|
|
await page.locator(".row.provider", { hasText: "Mixed Relay" }).click();
|
|
await editor.locator(".mchips .mchip").first().waitFor();
|
|
await editor.getByRole("button", { name: "Test models", exact: true }).click();
|
|
await editor.locator(".mchips .tdot.ok").first().waitFor();
|
|
const chip = editor.locator(".mchips .mchip", { hasText: "glm-5" });
|
|
assert.equal(await chip.locator(".tdot.ok").count(), 0, "a queued model's dot isn't green");
|
|
assert.equal(await chip.locator(".tdot.queued").count(), 1);
|
|
assert.match(await chip.getAttribute("title"), /^Queued at its vendor, not answered: Qoder queued the request for glm-5/);
|
|
// Working only unpicks the two that failed and keeps the queued one
|
|
await editor.locator(".works-only").click();
|
|
for (const id of KEPT) assert.equal(await editor.locator(".mchips .mchip.on", { hasText: id }).count(), 1, id + " stays picked");
|
|
assert.equal(await editor.locator(".mchips .mchip.on", { hasText: "kimi-k3" }).count(), 0, "a failed one is unpicked");
|
|
});
|
|
|
|
test(`${engine}: a queued model's single test isn't "answered"`, async (t) => {
|
|
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
|
t.after(() => browser.close());
|
|
const page = await (await browser.newContext({ viewport: { width: 900, height: 700 }, reducedMotion: "reduce" })).newPage();
|
|
page.setDefaultTimeout(5000);
|
|
page.setDefaultNavigationTimeout(60000);
|
|
await page.route("**/*", serve("en", []));
|
|
await page.goto("http://magpie.test/?view=providers");
|
|
const editor = page.locator("#modal:not([hidden]) .editor");
|
|
await page.locator(".row.provider", { hasText: "Mixed Relay" }).click();
|
|
const chip = editor.locator(".mchips .mchip", { hasText: "glm-5" });
|
|
await chip.waitFor();
|
|
await chip.click({ button: "right" });
|
|
await page.getByRole("menuitem", { name: "Test this model" }).click();
|
|
await chip.locator(".tdot.queued").waitFor();
|
|
const said = await page.locator("#status").textContent();
|
|
assert.match(said, /^glm-5: Queued at its vendor, not answered: Qoder queued/);
|
|
assert.doesNotMatch(said, /answered in/);
|
|
});
|
|
}
|