Export artifact bytes explicitly
This commit is contained in:
parent
2a86900e57
commit
22fa4fc675
9 changed files with 346 additions and 15 deletions
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
const assert = require("assert");
|
||||
const cp = require("child_process");
|
||||
const fs = require("fs");
|
||||
const net = require("net");
|
||||
const os = require("os");
|
||||
const path = require("path");
|
||||
|
||||
const repo = path.resolve(__dirname, "..");
|
||||
|
|
@ -111,6 +113,20 @@ function nodeCapabilities() {
|
|||
};
|
||||
}
|
||||
|
||||
function runJson(command, args, options = {}) {
|
||||
const result = cp.spawnSync(command, args, {
|
||||
cwd: repo,
|
||||
encoding: "utf8",
|
||||
...options,
|
||||
});
|
||||
if (result.status !== 0) {
|
||||
throw new Error(
|
||||
`${command} ${args.join(" ")} failed with code ${result.status}\n${result.stderr}\n${result.stdout}`
|
||||
);
|
||||
}
|
||||
return JSON.parse(result.stdout);
|
||||
}
|
||||
|
||||
async function reportNode(addr, node, { directConnectivity = true, online = true } = {}) {
|
||||
const response = await send(addr, {
|
||||
type: "report_node_capabilities",
|
||||
|
|
@ -192,6 +208,41 @@ async function reportNode(addr, node, { directConnectivity = true, online = true
|
|||
assert.strictEqual(exportPlan.plan.coordinator_assisted_rendezvous, true);
|
||||
assert.strictEqual(exportPlan.plan.coordinator_bulk_relay_allowed, false);
|
||||
assert.match(exportPlan.plan.authorization_digest, /^sha256:[0-9a-f]{64}$/);
|
||||
assert.strictEqual(exportPlan.artifact_size_bytes, produced.stdout_bytes);
|
||||
|
||||
const temp = fs.mkdtempSync(path.join(os.tmpdir(), "disasmer-artifact-export-"));
|
||||
const exportPath = path.join(temp, "export-output.txt");
|
||||
const cliExport = runJson("cargo", [
|
||||
"run",
|
||||
"-q",
|
||||
"-p",
|
||||
"disasmer-cli",
|
||||
"--bin",
|
||||
"disasmer",
|
||||
"--",
|
||||
"artifact",
|
||||
"export",
|
||||
"--coordinator",
|
||||
`${addr.host}:${addr.port}`,
|
||||
"--tenant",
|
||||
"tenant",
|
||||
"--project-id",
|
||||
"project",
|
||||
"--user",
|
||||
"user",
|
||||
"--json",
|
||||
"export-output.txt",
|
||||
"--receiver-node",
|
||||
"node-export-receiver",
|
||||
"--to",
|
||||
exportPath,
|
||||
]);
|
||||
assert.strictEqual(cliExport.command, "artifact export");
|
||||
assert.strictEqual(cliExport.export_plan.local_bytes_written_by_cli, true);
|
||||
assert.strictEqual(cliExport.export_plan.local_export_status, "local_bytes_written");
|
||||
assert.strictEqual(cliExport.export_plan.bytes_written, produced.stdout_bytes);
|
||||
assert.strictEqual(cliExport.local_export.stream.content_material_returned_in_report, false);
|
||||
assert.strictEqual(fs.readFileSync(exportPath, "utf8"), produced.stdout_tail);
|
||||
|
||||
const crossTenant = await send(addr, {
|
||||
type: "export_artifact_to_node",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue