mirror of
https://github.com/logos-storage/codex-factory.git
synced 2026-01-02 13:03:07 +00:00
test: output client logs on test failure
This commit is contained in:
parent
ca6aaa2687
commit
86d331dae5
@ -6,11 +6,11 @@ import { AllStatus } from './docker.js'
|
||||
import { TimeoutError } from './error.js'
|
||||
import { sleep } from './index.js'
|
||||
|
||||
const AWAIT_SLEEP = 3000
|
||||
const AWAIT_SLEEP = 1000
|
||||
|
||||
const BLOCKCHAIN_BODY_REQUEST = JSON.stringify({ id: 1, jsonrpc: '2.0', method: 'eth_chainId' })
|
||||
const EXPECTED_CHAIN_ID = '0x7a69'
|
||||
const ALLOWED_ERRORS = ['ECONNREFUSED', 'ECONNRESET', 'UND_ERR_SOCKET']
|
||||
const ALLOWED_ERRORS = ['ECONNREFUSED', 'ECONNRESET', 'UND_ERR_SOCKET', 502] as string[]
|
||||
|
||||
function isAllowedError(e: FetchError): boolean {
|
||||
if (e.cause) {
|
||||
@ -22,8 +22,6 @@ function isAllowedError(e: FetchError): boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
// Errors from Bee-js does not have the `FetchError` structure (eq. `code` property)
|
||||
// so we assert message itself.
|
||||
if (e.message.includes('socket hang up')) {
|
||||
return true
|
||||
}
|
||||
@ -42,7 +40,7 @@ function extractIpFromMultiaddr(multiaddr: string): string {
|
||||
|
||||
}
|
||||
|
||||
export async function waitForBlockchain(waitingIterations = 30): Promise<void> {
|
||||
export async function waitForBlockchain(waitingIterations = 90): Promise<void> {
|
||||
for (let i = 0; i < waitingIterations; i++) {
|
||||
try {
|
||||
const request = await fetch('http://127.0.0.1:8545', {
|
||||
@ -69,7 +67,7 @@ export async function waitForBlockchain(waitingIterations = 30): Promise<void> {
|
||||
|
||||
export async function waitForClient(
|
||||
verifyClientIsUp: () => Promise<boolean>,
|
||||
waitingIterations = 120,
|
||||
waitingIterations = 300,
|
||||
): Promise<string> {
|
||||
const codex = new Codex('http://127.0.0.1:8080')
|
||||
|
||||
@ -107,7 +105,7 @@ export async function waitForClient(
|
||||
export async function waitForHosts(
|
||||
hostCount: number,
|
||||
getStatus: () => Promise<AllStatus>,
|
||||
waitingIterations = 120,
|
||||
waitingIterations = 300,
|
||||
): Promise<void> {
|
||||
const codex = new Codex('http://127.0.0.1:8080')
|
||||
|
||||
|
||||
@ -12,12 +12,13 @@ import { deleteNetwork, findContainer } from '../utils/docker'
|
||||
chaiUse(chaiAsPromised)
|
||||
let testFailed = false
|
||||
|
||||
async function runCommand(args: string): Promise<ReturnType<typeof runCommandRaw>> {
|
||||
async function runCommand (args: string): Promise<ReturnType<typeof runCommandRaw>> {
|
||||
const result = await runCommandRaw(args)
|
||||
|
||||
if (result.error) {
|
||||
console.log(result.stdout)
|
||||
console.error(result.stderr)
|
||||
console.log('============\n=> ERROR:', result.error)
|
||||
console.log('============\n=> STDOUT:', result.stdout)
|
||||
console.error('============\n=> STDERR:', result.stderr)
|
||||
}
|
||||
|
||||
return result
|
||||
@ -72,7 +73,9 @@ describe('start command', () => {
|
||||
const containers = await docker.listContainers()
|
||||
for (const c of containers) console.log(` - ${c.Names.join(', ')}`)
|
||||
|
||||
await runCommand('logs client')
|
||||
const { stdout } = await runCommand('logs client')
|
||||
console.log('Client logs:\n', stdout)
|
||||
|
||||
}
|
||||
|
||||
await runCommand('stop')
|
||||
|
||||
@ -13,8 +13,9 @@ async function runCommand(args: string): Promise<ReturnType<typeof runCommandRaw
|
||||
const result = await runCommandRaw(args)
|
||||
|
||||
if (result.error) {
|
||||
console.log(result.stdout)
|
||||
console.error(result.stderr)
|
||||
console.log('============\n=> ERROR:', result.error)
|
||||
console.log('============\n=> STDOUT:', result.stdout)
|
||||
console.error('============\n=> STDERR:', result.stderr)
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user