2023-09-10 11:29:35 -07:00
|
|
|
import child_process from "child_process";
|
|
|
|
import fs from "fs";
|
|
|
|
|
Streaming in-place WACZ creation + CDXJ indexing (#673)
Fixes #674
This PR supersedes #505, and instead of using js-wacz for optimized WACZ
creation:
- generates an 'in-place' or 'streaming' WACZ in the crawler, without
having to copy the data again.
- WACZ contents are streamed to remote upload (or to disk) from existing
files on disk
- CDXJ indices per-WARC are first written to 'warc-cdx' directory, then merged using the linux 'sort' command, and compressed to ZipNum if >50K (or always if using --generateCDX)
- All data in the WARCs is written and read only once
- Should result in significant speed / disk usage improvements:
previously WARC was written once, then read again (for CDXJ indexing),
read again (for adding to new WACZ ZIP), written to disk (into new WACZ
ZIP), read again (if upload to remote endpoint). Now, WARCs are written
once, along with the per-WARC CDXJ, the CDXJ only is reread, sorted and merged on-disk, and all
data is read once to either generate WACZ on disk or upload to remote.
---------
Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
2024-08-29 13:21:20 -07:00
|
|
|
const doValidate = process.argv.filter((x) => x.startsWith('-validate'))[0];
|
|
|
|
const testIf = (condition, ...args) => condition ? test(...args) : test.skip(...args);
|
|
|
|
|
2023-09-10 11:29:35 -07:00
|
|
|
test("ensure multi url crawl run with docker run passes", async () => {
|
2023-11-09 19:11:11 -05:00
|
|
|
child_process.execSync(
|
2024-10-31 10:24:58 -07:00
|
|
|
'docker run -v $PWD/test-crawls:/crawls webrecorder/browsertrix-crawler crawl --url https://www.iana.org/ --url https://old.webrecorder.net/ --generateWACZ --text --collection advanced --combineWARC --rolloverSize 10000 --workers 2 --title "test title" --description "test description" --pages 2 --limit 2 --exclude community',
|
2023-11-09 19:11:11 -05:00
|
|
|
);
|
Streaming in-place WACZ creation + CDXJ indexing (#673)
Fixes #674
This PR supersedes #505, and instead of using js-wacz for optimized WACZ
creation:
- generates an 'in-place' or 'streaming' WACZ in the crawler, without
having to copy the data again.
- WACZ contents are streamed to remote upload (or to disk) from existing
files on disk
- CDXJ indices per-WARC are first written to 'warc-cdx' directory, then merged using the linux 'sort' command, and compressed to ZipNum if >50K (or always if using --generateCDX)
- All data in the WARCs is written and read only once
- Should result in significant speed / disk usage improvements:
previously WARC was written once, then read again (for CDXJ indexing),
read again (for adding to new WACZ ZIP), written to disk (into new WACZ
ZIP), read again (if upload to remote endpoint). Now, WARCs are written
once, along with the per-WARC CDXJ, the CDXJ only is reread, sorted and merged on-disk, and all
data is read once to either generate WACZ on disk or upload to remote.
---------
Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
2024-08-29 13:21:20 -07:00
|
|
|
});
|
2023-09-10 11:29:35 -07:00
|
|
|
|
Streaming in-place WACZ creation + CDXJ indexing (#673)
Fixes #674
This PR supersedes #505, and instead of using js-wacz for optimized WACZ
creation:
- generates an 'in-place' or 'streaming' WACZ in the crawler, without
having to copy the data again.
- WACZ contents are streamed to remote upload (or to disk) from existing
files on disk
- CDXJ indices per-WARC are first written to 'warc-cdx' directory, then merged using the linux 'sort' command, and compressed to ZipNum if >50K (or always if using --generateCDX)
- All data in the WARCs is written and read only once
- Should result in significant speed / disk usage improvements:
previously WARC was written once, then read again (for CDXJ indexing),
read again (for adding to new WACZ ZIP), written to disk (into new WACZ
ZIP), read again (if upload to remote endpoint). Now, WARCs are written
once, along with the per-WARC CDXJ, the CDXJ only is reread, sorted and merged on-disk, and all
data is read once to either generate WACZ on disk or upload to remote.
---------
Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
2024-08-29 13:21:20 -07:00
|
|
|
testIf(doValidate, "validate multi url crawl wacz", () => {
|
2023-11-09 19:11:11 -05:00
|
|
|
child_process.execSync(
|
Streaming in-place WACZ creation + CDXJ indexing (#673)
Fixes #674
This PR supersedes #505, and instead of using js-wacz for optimized WACZ
creation:
- generates an 'in-place' or 'streaming' WACZ in the crawler, without
having to copy the data again.
- WACZ contents are streamed to remote upload (or to disk) from existing
files on disk
- CDXJ indices per-WARC are first written to 'warc-cdx' directory, then merged using the linux 'sort' command, and compressed to ZipNum if >50K (or always if using --generateCDX)
- All data in the WARCs is written and read only once
- Should result in significant speed / disk usage improvements:
previously WARC was written once, then read again (for CDXJ indexing),
read again (for adding to new WACZ ZIP), written to disk (into new WACZ
ZIP), read again (if upload to remote endpoint). Now, WARCs are written
once, along with the per-WARC CDXJ, the CDXJ only is reread, sorted and merged on-disk, and all
data is read once to either generate WACZ on disk or upload to remote.
---------
Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
2024-08-29 13:21:20 -07:00
|
|
|
"wacz validate --file ./test-crawls/collections/advanced/advanced.wacz",
|
2023-11-09 19:11:11 -05:00
|
|
|
);
|
2023-09-10 11:29:35 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
test("check that the favicon made it into the pages jsonl file", () => {
|
2023-11-09 19:11:11 -05:00
|
|
|
expect(
|
|
|
|
fs.existsSync("test-crawls/collections/advanced/pages/pages.jsonl"),
|
|
|
|
).toBe(true);
|
2023-09-10 11:29:35 -07:00
|
|
|
|
2023-11-09 19:11:11 -05:00
|
|
|
const data1 = JSON.parse(
|
|
|
|
fs
|
|
|
|
.readFileSync(
|
|
|
|
"test-crawls/collections/advanced/pages/pages.jsonl",
|
|
|
|
"utf8",
|
|
|
|
)
|
|
|
|
.split("\n")[1],
|
|
|
|
);
|
|
|
|
const data2 = JSON.parse(
|
|
|
|
fs
|
|
|
|
.readFileSync(
|
|
|
|
"test-crawls/collections/advanced/pages/pages.jsonl",
|
|
|
|
"utf8",
|
|
|
|
)
|
|
|
|
.split("\n")[2],
|
|
|
|
);
|
|
|
|
const data = [data1, data2];
|
2023-09-10 11:29:35 -07:00
|
|
|
for (const d of data) {
|
2024-10-31 10:24:58 -07:00
|
|
|
if (d.url === "https://old.webrecorder.net/") {
|
2023-11-09 19:11:11 -05:00
|
|
|
expect(d.favIconUrl).toEqual(
|
2024-10-31 10:24:58 -07:00
|
|
|
"https://old.webrecorder.net/assets/favicon.ico",
|
2023-11-09 19:11:11 -05:00
|
|
|
);
|
2023-09-10 11:29:35 -07:00
|
|
|
}
|
|
|
|
if (d.url === "https://iana.org/") {
|
2023-11-09 19:11:11 -05:00
|
|
|
expect(d.favIconUrl).toEqual(
|
|
|
|
"https://www.iana.org/_img/bookmark_icon.ico",
|
|
|
|
);
|
2023-09-10 11:29:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|