-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent interop timeouts with fast fixture loading (#73)
* deps: update ipfsd-ctl and kubo-rpc-client * chore: apply suggestions from code review * tmp: get some debug logs from CI jobs * fix: disable delegated routing in vfetch-interop tests * fix: test:node on windows * Revert "tmp: get some debug logs from CI jobs" This reverts commit 3654a28.
- Loading branch information
Showing
10 changed files
with
70 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,30 @@ | ||
import getPort from 'aegir/get-port' | ||
import { createServer } from 'ipfsd-ctl' | ||
import * as kuboRpcClient from 'kubo-rpc-client' | ||
import { resolve } from 'node:path' | ||
import { tmpdir } from 'node:os' | ||
|
||
const IPFS_PATH = resolve(tmpdir(), 'verified-fetch-interop-ipfs-repo') | ||
|
||
/** @type {import('aegir').PartialOptions} */ | ||
export default { | ||
test: { | ||
files: './dist/src/*.spec.js', | ||
before: async (options) => { | ||
if (options.runner !== 'node') { | ||
const ipfsdPort = await getPort() | ||
const ipfsdServer = await createServer({ | ||
host: '127.0.0.1', | ||
port: ipfsdPort | ||
}, { | ||
ipfsBin: (await import('kubo')).default.path(), | ||
kuboRpcModule: kuboRpcClient, | ||
ipfsOptions: { | ||
config: { | ||
Addresses: { | ||
Swarm: [ | ||
"/ip4/0.0.0.0/tcp/0", | ||
"/ip4/0.0.0.0/tcp/0/ws" | ||
] | ||
} | ||
} | ||
} | ||
}).start() | ||
before: async () => { | ||
|
||
return { | ||
env: { | ||
IPFSD_SERVER: `http://127.0.0.1:${ipfsdPort}` | ||
}, | ||
ipfsdServer | ||
} | ||
} | ||
const { createKuboNode } = await import('./dist/src/fixtures/create-kubo.js') | ||
const kuboNode = await createKuboNode(IPFS_PATH) | ||
|
||
return {} | ||
}, | ||
after: async (options, beforeResult) => { | ||
if (options.runner !== 'node') { | ||
await beforeResult.ipfsdServer.stop() | ||
await kuboNode.start() | ||
|
||
// requires aegir build to be run first, which it will by default. | ||
const { loadFixtures } = await import('./dist/src/fixtures/load-fixtures.js') | ||
|
||
await loadFixtures(IPFS_PATH) | ||
|
||
return { | ||
kuboNode | ||
} | ||
}, | ||
after: async (_options, beforeResult) => { | ||
await beforeResult.kuboNode.stop() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { $ } from 'execa' | ||
import fg from 'fast-glob' | ||
import { path as kuboPath } from 'kubo' | ||
|
||
/** | ||
* Only callable from node (intended to be consumed by .aegir.js) | ||
* but the fixtures loaded by this function are also used by browser tests. | ||
*/ | ||
export async function loadFixtures (IPFS_PATH = undefined): Promise<void> { | ||
const kuboBinary = process.env.KUBO_BINARY ?? kuboPath() | ||
/** | ||
* fast-glob does not like windows paths, see https://github.com/mrmlnc/fast-glob/issues/237 | ||
* fast-glob performs search from process.cwd() by default, which will be: | ||
* 1. the root of the monorepo when running tests in CI | ||
* 2. the package root when running tests in the package directory | ||
*/ | ||
let globRoot = process.cwd().replace(/\\/g, '/') | ||
if (!globRoot.includes('packages/interop')) { | ||
// we only want car files from the interop package | ||
globRoot = [...globRoot.split('/'), 'packages/interop'].join('/') | ||
} | ||
for (const carFile of await fg.glob('src/fixtures/data/*.car', { cwd: globRoot })) { | ||
await $({ env: { IPFS_PATH } })`${kuboBinary} dag import --pin-roots=false --offline ${carFile}` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters