From d436f4201c9a3b0ab034228d32aaaf618b65a101 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Wed, 18 Sep 2024 16:21:36 -0500 Subject: [PATCH] chore: rename to SoloError Signed-off-by: Jeffrey Tang --- src/commands/account.mjs | 24 +++---- src/commands/cluster.mjs | 8 +-- src/commands/init.mjs | 6 +- src/commands/mirror_node.mjs | 12 ++-- src/commands/network.mjs | 8 +-- src/commands/node.mjs | 72 +++++++++---------- src/commands/prompts.mjs | 20 +++--- src/commands/relay.mjs | 8 +-- src/core/account_manager.mjs | 12 ++-- src/core/chart_manager.mjs | 10 +-- src/core/config_manager.mjs | 10 +-- .../dependency_manager.mjs | 4 +- .../keytool_dependency_manager.mjs | 4 +- src/core/errors.mjs | 10 +-- src/core/helpers.mjs | 12 ++-- src/core/k8.mjs | 62 ++++++++-------- src/core/key_manager.mjs | 14 ++-- src/core/package_downloader.mjs | 10 +-- src/core/platform_installer.mjs | 18 ++--- src/core/profile_manager.mjs | 8 +-- src/core/templates.mjs | 4 +- src/core/zippy.mjs | 10 +-- test/e2e/core/k8_e2e.test.mjs | 8 +-- .../dependency_manager.test.mjs | 4 +- test/unit/core/errors.test.mjs | 16 ++--- test/unit/core/zippy.test.mjs | 10 +-- 26 files changed, 192 insertions(+), 192 deletions(-) diff --git a/src/commands/account.mjs b/src/commands/account.mjs index 711e45bb2..a5d7c7971 100644 --- a/src/commands/account.mjs +++ b/src/commands/account.mjs @@ -17,7 +17,7 @@ 'use strict' import chalk from 'chalk' import { BaseCommand } from './base.mjs' -import { FullstackTestingError, IllegalArgumentError } from '../core/errors.mjs' +import { SoloError, IllegalArgumentError } from '../core/errors.mjs' import { flags } from './index.mjs' import { Listr } from 'listr2' import * as prompts from './prompts.mjs' @@ -112,7 +112,7 @@ export class AccountCommand extends BaseCommand { const hbarAmount = Number.parseFloat(amount) if (amount && isNaN(hbarAmount)) { - throw new FullstackTestingError(`The HBAR amount was invalid: ${amount}`) + throw new SoloError(`The HBAR amount was invalid: ${amount}`) } if (hbarAmount > 0) { @@ -155,7 +155,7 @@ export class AccountCommand extends BaseCommand { } if (!await this.k8.hasNamespace(config.namespace)) { - throw new FullstackTestingError(`namespace ${config.namespace} does not exist`) + throw new SoloError(`namespace ${config.namespace} does not exist`) } // set config in the context for later tasks to use @@ -227,7 +227,7 @@ export class AccountCommand extends BaseCommand { } self.logger.showUser(chalk.gray('Waiting for sockets to be closed....')) if (ctx.resultTracker.rejectedCount > 0) { - throw new FullstackTestingError(`Account keys updates failed for ${ctx.resultTracker.rejectedCount} accounts.`) + throw new SoloError(`Account keys updates failed for ${ctx.resultTracker.rejectedCount} accounts.`) } } } @@ -247,7 +247,7 @@ export class AccountCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError(`Error in creating account: ${e.message}`, e) + throw new SoloError(`Error in creating account: ${e.message}`, e) } finally { await this.closeConnections() } @@ -284,7 +284,7 @@ export class AccountCommand extends BaseCommand { } if (!await this.k8.hasNamespace(config.namespace)) { - throw new FullstackTestingError(`namespace ${config.namespace} does not exist`) + throw new SoloError(`namespace ${config.namespace} does not exist`) } // set config in the context for later tasks to use @@ -313,7 +313,7 @@ export class AccountCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError(`Error in creating account: ${e.message}`, e) + throw new SoloError(`Error in creating account: ${e.message}`, e) } finally { await this.closeConnections() } @@ -346,7 +346,7 @@ export class AccountCommand extends BaseCommand { } if (!await this.k8.hasNamespace(config.namespace)) { - throw new FullstackTestingError(`namespace ${config.namespace} does not exist`) + throw new SoloError(`namespace ${config.namespace} does not exist`) } // set config in the context for later tasks to use @@ -367,7 +367,7 @@ export class AccountCommand extends BaseCommand { title: 'update the account', task: async (ctx, task) => { if (!(await self.updateAccountInfo(ctx))) { - throw new FullstackTestingError(`An error occurred updating account ${ctx.accountInfo.accountId}`) + throw new SoloError(`An error occurred updating account ${ctx.accountInfo.accountId}`) } } }, @@ -386,7 +386,7 @@ export class AccountCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError(`Error in updating account: ${e.message}`, e) + throw new SoloError(`Error in updating account: ${e.message}`, e) } finally { await this.closeConnections() } @@ -417,7 +417,7 @@ export class AccountCommand extends BaseCommand { } if (!await this.k8.hasNamespace(config.namespace)) { - throw new FullstackTestingError(`namespace ${config.namespace} does not exist`) + throw new SoloError(`namespace ${config.namespace} does not exist`) } // set config in the context for later tasks to use @@ -443,7 +443,7 @@ export class AccountCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError(`Error in getting account info: ${e.message}`, e) + throw new SoloError(`Error in getting account info: ${e.message}`, e) } finally { await this.closeConnections() } diff --git a/src/commands/cluster.mjs b/src/commands/cluster.mjs index 95540147e..0d6ea41f7 100644 --- a/src/commands/cluster.mjs +++ b/src/commands/cluster.mjs @@ -17,7 +17,7 @@ 'use strict' import { ListrEnquirerPromptAdapter } from '@listr2/prompt-adapter-enquirer' import { Listr } from 'listr2' -import { FullstackTestingError, IllegalArgumentError } from '../core/errors.mjs' +import { SoloError, IllegalArgumentError } from '../core/errors.mjs' import * as flags from './flags.mjs' import { BaseCommand } from './base.mjs' import chalk from 'chalk' @@ -151,7 +151,7 @@ export class ClusterCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError('Error on cluster setup', e) + throw new SoloError('Error on cluster setup', e) } return true @@ -191,7 +191,7 @@ export class ClusterCommand extends BaseCommand { ctx.isChartInstalled = await this.chartManager.isChartInstalled(ctx.config.clusterSetupNamespace, constants.FULLSTACK_CLUSTER_SETUP_CHART) if (!ctx.isChartInstalled) { - throw new FullstackTestingError('No chart found for the cluster') + throw new SoloError('No chart found for the cluster') } } }, @@ -214,7 +214,7 @@ export class ClusterCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError('Error on cluster reset', e) + throw new SoloError('Error on cluster reset', e) } return true diff --git a/src/commands/init.mjs b/src/commands/init.mjs index e52d12215..ca210abfd 100644 --- a/src/commands/init.mjs +++ b/src/commands/init.mjs @@ -21,7 +21,7 @@ import { BaseCommand } from './base.mjs' import * as core from '../core/index.mjs' import { constants } from '../core/index.mjs' import * as fs from 'fs' -import { FullstackTestingError, IllegalArgumentError } from '../core/errors.mjs' +import { SoloError, IllegalArgumentError } from '../core/errors.mjs' import * as flags from './flags.mjs' import chalk from 'chalk' @@ -51,7 +51,7 @@ export class InitCommand extends BaseCommand { }) } catch (e) { this.logger.error(e) - throw new FullstackTestingError(`failed to create directory: ${e.message}`, e) + throw new SoloError(`failed to create directory: ${e.message}`, e) } return dirs @@ -136,7 +136,7 @@ export class InitCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError('Error running init', e) + throw new SoloError('Error running init', e) } return true diff --git a/src/commands/mirror_node.mjs b/src/commands/mirror_node.mjs index b4063f68b..f0f30dd79 100644 --- a/src/commands/mirror_node.mjs +++ b/src/commands/mirror_node.mjs @@ -16,7 +16,7 @@ */ import { ListrEnquirerPromptAdapter } from '@listr2/prompt-adapter-enquirer' import { Listr } from 'listr2' -import { FullstackTestingError, IllegalArgumentError, MissingArgumentError } from '../core/errors.mjs' +import { SoloError, IllegalArgumentError, MissingArgumentError } from '../core/errors.mjs' import { constants } from '../core/index.mjs' import { BaseCommand } from './base.mjs' import * as flags from './flags.mjs' @@ -136,7 +136,7 @@ export class MirrorNodeCommand extends BaseCommand { ) if (!await self.k8.hasNamespace(ctx.config.namespace)) { - throw new FullstackTestingError(`namespace ${ctx.config.namespace} does not exist`) + throw new SoloError(`namespace ${ctx.config.namespace} does not exist`) } await self.accountManager.loadNodeClient(ctx.config.namespace) @@ -252,7 +252,7 @@ export class MirrorNodeCommand extends BaseCommand { const pods = await this.k8.getPodsByLabel(['app.kubernetes.io/name=postgres']) if (pods.length === 0) { - throw new FullstackTestingError('postgres pod not found') + throw new SoloError('postgres pod not found') } const postgresPodName = pods[0].metadata.name const postgresContainerName = 'postgresql' @@ -287,7 +287,7 @@ export class MirrorNodeCommand extends BaseCommand { await tasks.run() self.logger.debug('node start has completed') } catch (e) { - throw new FullstackTestingError(`Error starting node: ${e.message}`, e) + throw new SoloError(`Error starting node: ${e.message}`, e) } finally { await self.accountManager.close() } @@ -335,7 +335,7 @@ export class MirrorNodeCommand extends BaseCommand { ctx.config.valuesArg = ' --set hedera-mirror-node.enabled=false --set hedera-explorer.enabled=false' if (!await self.k8.hasNamespace(ctx.config.namespace)) { - throw new FullstackTestingError(`namespace ${ctx.config.namespace} does not exist`) + throw new SoloError(`namespace ${ctx.config.namespace} does not exist`) } await self.accountManager.loadNodeClient(ctx.config.namespace) @@ -378,7 +378,7 @@ export class MirrorNodeCommand extends BaseCommand { await tasks.run() self.logger.debug('node start has completed') } catch (e) { - throw new FullstackTestingError(`Error starting node: ${e.message}`, e) + throw new SoloError(`Error starting node: ${e.message}`, e) } finally { await self.accountManager.close() } diff --git a/src/commands/network.mjs b/src/commands/network.mjs index 4f53da150..9651d7d5a 100644 --- a/src/commands/network.mjs +++ b/src/commands/network.mjs @@ -18,7 +18,7 @@ import { ListrEnquirerPromptAdapter } from '@listr2/prompt-adapter-enquirer' import chalk from 'chalk' import { Listr } from 'listr2' -import { FullstackTestingError, IllegalArgumentError, MissingArgumentError } from '../core/errors.mjs' +import { SoloError, IllegalArgumentError, MissingArgumentError } from '../core/errors.mjs' import { BaseCommand } from './base.mjs' import * as flags from './flags.mjs' import { constants, Templates } from '../core/index.mjs' @@ -463,7 +463,7 @@ export class NetworkCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError(`Error installing chart ${constants.FULLSTACK_DEPLOYMENT_CHART}`, e) + throw new SoloError(`Error installing chart ${constants.FULLSTACK_DEPLOYMENT_CHART}`, e) } return true @@ -547,7 +547,7 @@ export class NetworkCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError('Error destroying network', e) + throw new SoloError('Error destroying network', e) } return true @@ -597,7 +597,7 @@ export class NetworkCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError(`Error upgrading chart ${constants.FULLSTACK_DEPLOYMENT_CHART}`, e) + throw new SoloError(`Error upgrading chart ${constants.FULLSTACK_DEPLOYMENT_CHART}`, e) } return true diff --git a/src/commands/node.mjs b/src/commands/node.mjs index b65e15d47..1a496822e 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -20,7 +20,7 @@ import chalk from 'chalk' import * as fs from 'fs' import { Listr } from 'listr2' import path from 'path' -import { FullstackTestingError, IllegalArgumentError } from '../core/errors.mjs' +import { SoloError, IllegalArgumentError } from '../core/errors.mjs' import * as helpers from '../core/helpers.mjs' import { addDebugOptions, @@ -333,7 +333,7 @@ export class NodeCommand extends BaseCommand { const transactionStatus = receipt.status this.logger.debug(`The transaction consensus status is ${transactionStatus.toString()}`) } catch (e) { - throw new FullstackTestingError(`Error in adding stake: ${e.message}`, e) + throw new SoloError(`Error in adding stake: ${e.message}`, e) } } @@ -357,7 +357,7 @@ export class NodeCommand extends BaseCommand { return podName } catch (e) { - throw new FullstackTestingError(`no pod found for nodeId: ${nodeId}`, e) + throw new SoloError(`no pod found for nodeId: ${nodeId}`, e) } } @@ -438,7 +438,7 @@ export class NodeCommand extends BaseCommand { await this.k8.stopPortForward(srv) if (!success) { - throw new FullstackTestingError(`node '${nodeId}' is not ${NodeStatusEnums[status]}` + + throw new SoloError(`node '${nodeId}' is not ${NodeStatusEnums[status]}` + `[ attempt = ${chalk.blueBright(`${attempt}/${maxAttempts}`)} ]`) } @@ -798,7 +798,7 @@ export class NodeCommand extends BaseCommand { config.stagingKeysDir = path.join(validatePath(config.stagingDir), 'keys') if (!await k8.hasNamespace(config.namespace)) { - throw new FullstackTestingError(`namespace ${config.namespace} does not exist`) + throw new SoloError(`namespace ${config.namespace} does not exist`) } // prepare staging keys directory @@ -847,7 +847,7 @@ export class NodeCommand extends BaseCommand { } if (!fs.existsSync(localDataLibBuildPath)) { - throw new FullstackTestingError(`local build path does not exist: ${localDataLibBuildPath}`) + throw new SoloError(`local build path does not exist: ${localDataLibBuildPath}`) } subTasks.push({ @@ -920,7 +920,7 @@ export class NodeCommand extends BaseCommand { const certPem = fs.readFileSync(certFullPath).toString() const decodedDers = x509.PemConverter.decode(certPem) if (!decodedDers || decodedDers.length === 0) { - throw new FullstackTestingError('unable to load perm key: ' + certFullPath) + throw new SoloError('unable to load perm key: ' + certFullPath) } return (new Uint8Array(decodedDers[0])) } @@ -993,7 +993,7 @@ export class NodeCommand extends BaseCommand { return zipHash } catch (e) { - throw new FullstackTestingError(`failed to upload build.zip file: ${e.message}`, e) + throw new SoloError(`failed to upload build.zip file: ${e.message}`, e) } } @@ -1017,7 +1017,7 @@ export class NodeCommand extends BaseCommand { } else if (parts.length === 1) { url = parts[0] } else { - throw new FullstackTestingError(`incorrect endpoint format. expected url:port, found ${endpoint}`) + throw new SoloError(`incorrect endpoint format. expected url:port, found ${endpoint}`) } if (endpointType.toUpperCase() === constants.ENDPOINT_TYPE_IP) { @@ -1125,7 +1125,7 @@ export class NodeCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError(`Error in setting up nodes: ${e.message}`, e) + throw new SoloError(`Error in setting up nodes: ${e.message}`, e) } return true @@ -1162,7 +1162,7 @@ export class NodeCommand extends BaseCommand { ) if (!await self.k8.hasNamespace(ctx.config.namespace)) { - throw new FullstackTestingError(`namespace ${ctx.config.namespace} does not exist`) + throw new SoloError(`namespace ${ctx.config.namespace} does not exist`) } } }, @@ -1231,7 +1231,7 @@ export class NodeCommand extends BaseCommand { await tasks.run() self.logger.debug('node start has completed') } catch (e) { - throw new FullstackTestingError(`Error starting node: ${e.message}`, e) + throw new SoloError(`Error starting node: ${e.message}`, e) } finally { await self.close() } @@ -1262,7 +1262,7 @@ export class NodeCommand extends BaseCommand { } if (!await self.k8.hasNamespace(ctx.config.namespace)) { - throw new FullstackTestingError(`namespace ${ctx.config.namespace} does not exist`) + throw new SoloError(`namespace ${ctx.config.namespace} does not exist`) } } }, @@ -1300,7 +1300,7 @@ export class NodeCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError('Error stopping node', e) + throw new SoloError('Error stopping node', e) } return true @@ -1410,7 +1410,7 @@ export class NodeCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError(`Error generating keys: ${e.message}`, e) + throw new SoloError(`Error generating keys: ${e.message}`, e) } return true @@ -1542,7 +1542,7 @@ export class NodeCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError(`Error in refreshing nodes: ${e.message}`, e) + throw new SoloError(`Error in refreshing nodes: ${e.message}`, e) } return true @@ -1584,7 +1584,7 @@ export class NodeCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError(`Error in downloading log from nodes: ${e.message}`, e) + throw new SoloError(`Error in downloading log from nodes: ${e.message}`, e) } finally { await self.close() } @@ -1684,7 +1684,7 @@ export class NodeCommand extends BaseCommand { config.existingNodeIds = [] if (config.keyFormat !== constants.KEY_FORMAT_PEM) { - throw new FullstackTestingError('key type cannot be PFX') + throw new SoloError('key type cannot be PFX') } await self.initializeSetup(config, self.k8) @@ -1732,7 +1732,7 @@ export class NodeCommand extends BaseCommand { title: 'Check that PVCs are enabled', task: async (ctx, task) => { if (!self.configManager.getFlag(flags.persistentVolumeClaims)) { - throw new FullstackTestingError('PVCs are not enabled. Please enable PVCs before adding a node') + throw new SoloError('PVCs are not enabled. Please enable PVCs before adding a node') } } }, @@ -1830,7 +1830,7 @@ export class NodeCommand extends BaseCommand { let endpoints = [] if (!config.gossipEndpoints) { if (config.endpointType !== constants.ENDPOINT_TYPE_FQDN) { - throw new FullstackTestingError(`--gossip-endpoints must be set if --endpoint-type is: ${constants.ENDPOINT_TYPE_IP}`) + throw new SoloError(`--gossip-endpoints must be set if --endpoint-type is: ${constants.ENDPOINT_TYPE_IP}`) } endpoints = [ @@ -1852,7 +1852,7 @@ export class NodeCommand extends BaseCommand { if (!config.grpcEndpoints) { if (config.endpointType !== constants.ENDPOINT_TYPE_FQDN) { - throw new FullstackTestingError(`--grpc-endpoints must be set if --endpoint-type is: ${constants.ENDPOINT_TYPE_IP}`) + throw new SoloError(`--grpc-endpoints must be set if --endpoint-type is: ${constants.ENDPOINT_TYPE_IP}`) } endpoints = [ @@ -1890,7 +1890,7 @@ export class NodeCommand extends BaseCommand { const config = /** @type {NodeAddConfigClass} **/ ctx.config const outputDir = argv[flags.outputDir.name] if (!outputDir) { - throw new FullstackTestingError(`Path to export context data not specified. Please set a value for --${flags.outputDir.name}`) + throw new SoloError(`Path to export context data not specified. Please set a value for --${flags.outputDir.name}`) } if (!fs.existsSync(outputDir)) { @@ -1926,7 +1926,7 @@ export class NodeCommand extends BaseCommand { const config = /** @type {NodeAddConfigClass} **/ ctx.config const inputDir = argv[flags.inputDir.name] if (!inputDir) { - throw new FullstackTestingError(`Path to context data not specified. Please set a value for --${flags.inputDir.name}`) + throw new SoloError(`Path to context data not specified. Please set a value for --${flags.inputDir.name}`) } const ctxData = JSON.parse(fs.readFileSync(path.join(inputDir, 'ctx.json'))) @@ -1974,7 +1974,7 @@ export class NodeCommand extends BaseCommand { this.logger.debug(`NodeCreateReceipt: ${nodeCreateReceipt.toString()}`) } catch (e) { this.logger.error(`Error adding node to network: ${e.message}`, e) - throw new FullstackTestingError(`Error adding node to network: ${e.message}`, e) + throw new SoloError(`Error adding node to network: ${e.message}`, e) } } }, @@ -2169,7 +2169,7 @@ export class NodeCommand extends BaseCommand { await tasks.run() } catch (e) { self.logger.error(`Error in setting up nodes: ${e.message}`, e) - throw new FullstackTestingError(`Error in setting up nodes: ${e.message}`, e) + throw new SoloError(`Error in setting up nodes: ${e.message}`, e) } finally { await self.close() } @@ -2195,7 +2195,7 @@ export class NodeCommand extends BaseCommand { await tasks.run() } catch (e) { self.logger.error(`Error in submitting transactions to node: ${e.message}`, e) - throw new FullstackTestingError(`Error in submitting transactions to up node: ${e.message}`, e) + throw new SoloError(`Error in submitting transactions to up node: ${e.message}`, e) } finally { await self.close() } @@ -2222,7 +2222,7 @@ export class NodeCommand extends BaseCommand { await tasks.run() } catch (e) { self.logger.error(`Error in starting up nodes: ${e.message}`, e) - throw new FullstackTestingError(`Error in setting up nodes: ${e.message}`, e) + throw new SoloError(`Error in setting up nodes: ${e.message}`, e) } finally { await self.close() } @@ -2253,7 +2253,7 @@ export class NodeCommand extends BaseCommand { await tasks.run() } catch (e) { self.logger.error(`Error in adding nodes: ${e.message}`, e) - throw new FullstackTestingError(`Error in adding nodes: ${e.message}`, e) + throw new SoloError(`Error in adding nodes: ${e.message}`, e) } finally { await self.close() } @@ -2296,7 +2296,7 @@ export class NodeCommand extends BaseCommand { ) } catch (e) { this.logger.error(`Error in prepare upgrade: ${e.message}`, e) - throw new FullstackTestingError(`Error in prepare upgrade: ${e.message}`, e) + throw new SoloError(`Error in prepare upgrade: ${e.message}`, e) } } @@ -2328,7 +2328,7 @@ export class NodeCommand extends BaseCommand { freezeUpgradeReceipt.status.toString()) } catch (e) { this.logger.error(`Error in freeze upgrade: ${e.message}`, e) - throw new FullstackTestingError(`Error in freeze upgrade: ${e.message}`, e) + throw new SoloError(`Error in freeze upgrade: ${e.message}`, e) } } @@ -2716,7 +2716,7 @@ export class NodeCommand extends BaseCommand { let endpoints = [] if (!config.gossipEndpoints) { if (config.endpointType !== constants.ENDPOINT_TYPE_FQDN) { - throw new FullstackTestingError(`--gossip-endpoints must be set if --endpoint-type is: ${constants.ENDPOINT_TYPE_IP}`) + throw new SoloError(`--gossip-endpoints must be set if --endpoint-type is: ${constants.ENDPOINT_TYPE_IP}`) } endpoints = [ @@ -2738,7 +2738,7 @@ export class NodeCommand extends BaseCommand { if (!config.grpcEndpoints) { if (config.endpointType !== constants.ENDPOINT_TYPE_FQDN) { - throw new FullstackTestingError(`--grpc-endpoints must be set if --endpoint-type is: ${constants.ENDPOINT_TYPE_IP}`) + throw new SoloError(`--grpc-endpoints must be set if --endpoint-type is: ${constants.ENDPOINT_TYPE_IP}`) } endpoints = [ @@ -2831,7 +2831,7 @@ export class NodeCommand extends BaseCommand { } catch (e) { this.logger.error(`Error updating node to network: ${e.message}`, e) this.logger.error(e.stack) - throw new FullstackTestingError(`Error updating node to network: ${e.message}`, e) + throw new SoloError(`Error updating node to network: ${e.message}`, e) } } }, @@ -2987,7 +2987,7 @@ export class NodeCommand extends BaseCommand { } catch (e) { self.logger.error(`Error in updating nodes: ${e.message}`, e) this.logger.error(e.stack) - throw new FullstackTestingError(`Error in updating nodes: ${e.message}`, e) + throw new SoloError(`Error in updating nodes: ${e.message}`, e) } finally { await self.close() } @@ -3143,7 +3143,7 @@ export class NodeCommand extends BaseCommand { this.logger.debug(`NodeUpdateReceipt: ${nodeUpdateReceipt.toString()}`) } catch (e) { this.logger.error(`Error deleting node from network: ${e.message}`, e) - throw new FullstackTestingError(`Error deleting node from network: ${e.message}`, e) + throw new SoloError(`Error deleting node from network: ${e.message}`, e) } } }, @@ -3292,7 +3292,7 @@ export class NodeCommand extends BaseCommand { await tasks.run() } catch (e) { self.logger.error(`Error in deleting nodes: ${e.message}`, e) - throw new FullstackTestingError(`Error in deleting nodes: ${e.message}`, e) + throw new SoloError(`Error in deleting nodes: ${e.message}`, e) } finally { await self.close() } diff --git a/src/commands/prompts.mjs b/src/commands/prompts.mjs index 80507e10b..608a8685a 100644 --- a/src/commands/prompts.mjs +++ b/src/commands/prompts.mjs @@ -17,7 +17,7 @@ 'use strict' import { ListrEnquirerPromptAdapter } from '@listr2/prompt-adapter-enquirer' import fs from 'fs' -import { FullstackTestingError, IllegalArgumentError } from '../core/errors.mjs' +import { SoloError, IllegalArgumentError } from '../core/errors.mjs' import { ConfigManager, constants } from '../core/index.mjs' import * as flags from './flags.mjs' import * as helpers from '../core/helpers.mjs' @@ -37,12 +37,12 @@ async function prompt (type, task, input, defaultValue, promptMessage, emptyChec } if (emptyCheckMessage && !input) { - throw new FullstackTestingError(emptyCheckMessage) + throw new SoloError(emptyCheckMessage) } return input } catch (e) { - throw new FullstackTestingError(`input failed: ${flagName}: ${e.message}`, e) + throw new SoloError(`input failed: ${flagName}: ${e.message}`, e) } } @@ -138,7 +138,7 @@ export async function promptChartDir (task, input) { return input } catch (e) { - throw new FullstackTestingError(`input failed: ${flags.chartDirectory.name}`, e) + throw new SoloError(`input failed: ${flags.chartDirectory.name}`, e) } } @@ -158,7 +158,7 @@ export async function promptValuesFile (task, input) { return input } catch (e) { - throw new FullstackTestingError(`input failed: ${flags.valuesFile.name}`, e) + throw new SoloError(`input failed: ${flags.valuesFile.name}`, e) } } @@ -189,7 +189,7 @@ export async function promptProfile (task, input, choices = constants.ALL_PROFIL }) if (!input) { - throw new FullstackTestingError('key-format cannot be empty') + throw new SoloError('key-format cannot be empty') } return input @@ -197,7 +197,7 @@ export async function promptProfile (task, input, choices = constants.ALL_PROFIL return input } catch (e) { - throw new FullstackTestingError(`input failed: ${flags.profileName.name}`, e) + throw new SoloError(`input failed: ${flags.profileName.name}`, e) } } @@ -268,12 +268,12 @@ export async function promptTlsClusterIssuerType (task, input) { } if (!input || !['acme-staging', 'acme-prod', 'self-signed'].includes(input)) { - throw new FullstackTestingError('must be one of: "acme-staging", "acme-prod", or "self-signed"') + throw new SoloError('must be one of: "acme-staging", "acme-prod", or "self-signed"') } return input } catch (e) { - throw new FullstackTestingError(`input failed: ${flags.tlsClusterIssuerType.name}`, e) + throw new SoloError(`input failed: ${flags.tlsClusterIssuerType.name}`, e) } } @@ -494,7 +494,7 @@ export async function execute (task, configManager, flagList = []) { } if (!prompts.has(flag.name)) { - throw new FullstackTestingError(`No prompt available for flag: ${flag.name}`) + throw new SoloError(`No prompt available for flag: ${flag.name}`) } const prompt = prompts.get(flag.name) diff --git a/src/commands/relay.mjs b/src/commands/relay.mjs index 39464cc8f..e78704649 100644 --- a/src/commands/relay.mjs +++ b/src/commands/relay.mjs @@ -16,7 +16,7 @@ */ 'use strict' import { Listr } from 'listr2' -import { FullstackTestingError, MissingArgumentError } from '../core/errors.mjs' +import { SoloError, MissingArgumentError } from '../core/errors.mjs' import * as helpers from '../core/helpers.mjs' import { constants } from '../core/index.mjs' import { BaseCommand } from './base.mjs' @@ -266,7 +266,7 @@ export class RelayCommand extends BaseCommand { `app.kubernetes.io/instance=${config.releaseName}` ], 1, 100, 2000) } catch (e) { - throw new FullstackTestingError(`Relay ${config.releaseName} is not ready: ${e.message}`, e) + throw new SoloError(`Relay ${config.releaseName} is not ready: ${e.message}`, e) } } } @@ -278,7 +278,7 @@ export class RelayCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError('Error installing relays', e) + throw new SoloError('Error installing relays', e) } return true @@ -341,7 +341,7 @@ export class RelayCommand extends BaseCommand { try { await tasks.run() } catch (e) { - throw new FullstackTestingError('Error uninstalling relays', e) + throw new SoloError('Error uninstalling relays', e) } return true diff --git a/src/core/account_manager.mjs b/src/core/account_manager.mjs index 728dd48e9..34436add8 100644 --- a/src/core/account_manager.mjs +++ b/src/core/account_manager.mjs @@ -34,7 +34,7 @@ import { Status, TransferTransaction } from '@hashgraph/sdk' -import { FullstackTestingError, MissingArgumentError } from './errors.mjs' +import { SoloError, MissingArgumentError } from './errors.mjs' import { Templates } from './templates.mjs' import ip from 'ip' import { NetworkNodeServicesBuilder } from './network_node_services.mjs' @@ -260,7 +260,7 @@ export class AccountManager { this._nodeClient.setRequestTimeout(constants.NODE_CLIENT_REQUEST_TIMEOUT) return this._nodeClient } catch (e) { - throw new FullstackTestingError(`failed to setup node client: ${e.message}`, e) + throw new SoloError(`failed to setup node client: ${e.message}`, e) } } @@ -598,13 +598,13 @@ export class AccountManager { if (!(accountSecretCreated)) { this.logger.error(`new account created [accountId=${accountInfo.accountId}, amount=${amount} HBAR, publicKey=${accountInfo.publicKey}, privateKey=${accountInfo.privateKey}] but failed to create secret in Kubernetes`) - throw new FullstackTestingError(`failed to create secret for accountId ${accountInfo.accountId.toString()}, keys were sent to log file`) + throw new SoloError(`failed to create secret for accountId ${accountInfo.accountId.toString()}, keys were sent to log file`) } } catch (e) { - if (e instanceof FullstackTestingError) { + if (e instanceof SoloError) { throw e } - throw new FullstackTestingError(`failed to create secret for accountId ${accountInfo.accountId.toString()}, e: ${e.toString()}`, e) + throw new SoloError(`failed to create secret for accountId ${accountInfo.accountId.toString()}, e: ${e.toString()}`, e) } return accountInfo @@ -633,7 +633,7 @@ export class AccountManager { } catch (e) { const errorMessage = `transfer amount failed with an error: ${e.toString()}` this.logger.error(errorMessage) - throw new FullstackTestingError(errorMessage, e) + throw new SoloError(errorMessage, e) } } diff --git a/src/core/chart_manager.mjs b/src/core/chart_manager.mjs index f97c8bb20..f927b9258 100644 --- a/src/core/chart_manager.mjs +++ b/src/core/chart_manager.mjs @@ -17,7 +17,7 @@ 'use strict' import { constants } from './index.mjs' import chalk from 'chalk' -import { FullstackTestingError } from './errors.mjs' +import { SoloError } from './errors.mjs' export class ChartManager { /** @@ -57,7 +57,7 @@ export class ChartManager { return urls } catch (e) { - throw new FullstackTestingError(`failed to setup chart repositories: ${e.message}`, e) + throw new SoloError(`failed to setup chart repositories: ${e.message}`, e) } } @@ -105,7 +105,7 @@ export class ChartManager { this.logger.debug(`OK: chart is already installed:${chartReleaseName} (${chartPath})`) } } catch (e) { - throw new FullstackTestingError(`failed to install chart ${chartReleaseName}: ${e.message}`, e) + throw new SoloError(`failed to install chart ${chartReleaseName}: ${e.message}`, e) } return true @@ -144,7 +144,7 @@ export class ChartManager { this.logger.debug(`OK: chart release is already uninstalled: ${chartReleaseName}`) } } catch (e) { - throw new FullstackTestingError(`failed to uninstall chart ${chartReleaseName}: ${e.message}`, e) + throw new SoloError(`failed to uninstall chart ${chartReleaseName}: ${e.message}`, e) } return true @@ -169,7 +169,7 @@ export class ChartManager { await this.helm.upgrade(`-n ${namespaceName} ${chartReleaseName} ${chartPath} ${versionArg} --reuse-values ${valuesArg}`) this.logger.debug(chalk.green('OK'), `chart '${chartReleaseName}' is upgraded`) } catch (e) { - throw new FullstackTestingError(`failed to upgrade chart ${chartReleaseName}: ${e.message}`, e) + throw new SoloError(`failed to upgrade chart ${chartReleaseName}: ${e.message}`, e) } return true diff --git a/src/core/config_manager.mjs b/src/core/config_manager.mjs index 0ca5ce130..93c71e523 100644 --- a/src/core/config_manager.mjs +++ b/src/core/config_manager.mjs @@ -16,7 +16,7 @@ */ 'use strict' import fs from 'fs' -import { FullstackTestingError, MissingArgumentError } from './errors.mjs' +import { SoloError, MissingArgumentError } from './errors.mjs' import { constants } from './index.mjs' import { Logger } from './logging.mjs' import * as flags from '../commands/flags.mjs' @@ -54,7 +54,7 @@ export class ConfigManager { this.config = yamlToObject(this.cachedConfigFile) } } catch (e) { - throw new FullstackTestingError(`failed to initialize config manager: ${e.message}`, e) + throw new SoloError(`failed to initialize config manager: ${e.message}`, e) } } @@ -137,7 +137,7 @@ export class ConfigManager { this.config.flags[flag.name] = Number.parseFloat(val) } } catch (e) { - throw new FullstackTestingError(`invalid number value '${val}': ${e.message}`, e) + throw new SoloError(`invalid number value '${val}': ${e.message}`, e) } break @@ -147,7 +147,7 @@ export class ConfigManager { break default: - throw new FullstackTestingError(`Unsupported field type for flag '${flag.name}': ${flag.definition.type}`) + throw new SoloError(`Unsupported field type for flag '${flag.name}': ${flag.definition.type}`) } } } @@ -176,7 +176,7 @@ export class ConfigManager { // refresh config with the file contents this.load() } catch (e) { - throw new FullstackTestingError(`failed to persis config: ${e.message}`, e) + throw new SoloError(`failed to persis config: ${e.message}`, e) } } diff --git a/src/core/dependency_managers/dependency_manager.mjs b/src/core/dependency_managers/dependency_manager.mjs index 465158829..cca460c11 100644 --- a/src/core/dependency_managers/dependency_manager.mjs +++ b/src/core/dependency_managers/dependency_manager.mjs @@ -16,7 +16,7 @@ */ 'use strict' import os from 'os' -import { FullstackTestingError, MissingArgumentError } from '../errors.mjs' +import { SoloError, MissingArgumentError } from '../errors.mjs' import { ShellRunner } from '../shell_runner.mjs' export class DependencyManager extends ShellRunner { @@ -47,7 +47,7 @@ export class DependencyManager extends ShellRunner { } if (!status) { - throw new FullstackTestingError(`Dependency '${dep}' is not found`) + throw new SoloError(`Dependency '${dep}' is not found`) } this.logger.debug(`Dependency '${dep}' is found`) diff --git a/src/core/dependency_managers/keytool_dependency_manager.mjs b/src/core/dependency_managers/keytool_dependency_manager.mjs index 8a71b41d8..3f65f4f2a 100644 --- a/src/core/dependency_managers/keytool_dependency_manager.mjs +++ b/src/core/dependency_managers/keytool_dependency_manager.mjs @@ -20,7 +20,7 @@ import os from 'os' import path from 'path' import * as semver from 'semver' import * as util from 'util' -import { MissingArgumentError, FullstackTestingError, IllegalArgumentError } from '../errors.mjs' +import { MissingArgumentError, SoloError, IllegalArgumentError } from '../errors.mjs' import * as helpers from '../helpers.mjs' import { constants, Keytool, Templates } from '../index.mjs' import * as version from '../../../version.mjs' @@ -77,7 +77,7 @@ export class KeytoolDependencyManager extends ShellRunner { this.osArch = 'aarch64' break default: - throw new FullstackTestingError(`unsupported os arch: ${osArch}`) + throw new SoloError(`unsupported os arch: ${osArch}`) } this.javaVersion = semver.parse(javaVersion, { includePrerelease: true }) diff --git a/src/core/errors.mjs b/src/core/errors.mjs index e8e41a5c2..11e29123d 100644 --- a/src/core/errors.mjs +++ b/src/core/errors.mjs @@ -16,7 +16,7 @@ */ 'use strict' -export class FullstackTestingError extends Error { +export class SoloError extends Error { /** * Create a custom error object * @@ -39,7 +39,7 @@ export class FullstackTestingError extends Error { } } -export class ResourceNotFoundError extends FullstackTestingError { +export class ResourceNotFoundError extends SoloError { /** * Create a custom error for resource not found scenario * @@ -54,7 +54,7 @@ export class ResourceNotFoundError extends FullstackTestingError { } } -export class MissingArgumentError extends FullstackTestingError { +export class MissingArgumentError extends SoloError { /** * Create a custom error for missing argument scenario * @@ -66,7 +66,7 @@ export class MissingArgumentError extends FullstackTestingError { } } -export class IllegalArgumentError extends FullstackTestingError { +export class IllegalArgumentError extends SoloError { /** * Create a custom error for illegal argument scenario * @@ -81,7 +81,7 @@ export class IllegalArgumentError extends FullstackTestingError { } } -export class DataValidationError extends FullstackTestingError { +export class DataValidationError extends SoloError { /** * Create a custom error for data validation error scenario * diff --git a/src/core/helpers.mjs b/src/core/helpers.mjs index 9dc8bdf5d..a80f7d939 100644 --- a/src/core/helpers.mjs +++ b/src/core/helpers.mjs @@ -19,7 +19,7 @@ import fs from 'fs' import os from 'os' import path from 'path' import util from 'util' -import { FullstackTestingError } from './errors.mjs' +import { SoloError } from './errors.mjs' import * as paths from 'path' import { fileURLToPath } from 'url' import * as semver from 'semver' @@ -68,7 +68,7 @@ export function splitFlagInput (input, separator = ',') { return items } - throw new FullstackTestingError('input is not a comma separated string') + throw new SoloError('input is not a comma separated string') } /** @@ -89,7 +89,7 @@ export function loadPackageJSON () { const raw = fs.readFileSync(path.join(CUR_FILE_DIR, '..', '..', 'package.json')) return JSON.parse(raw.toString()) } catch (e) { - throw new FullstackTestingError('failed to load package.json', e) + throw new SoloError('failed to load package.json', e) } } @@ -222,7 +222,7 @@ export function isNumeric (str) { */ export function validatePath (input) { if (input.indexOf('\0') !== -1) { - throw new FullstackTestingError(`access denied for path: ${input}`) + throw new SoloError(`access denied for path: ${input}`) } return input } @@ -334,7 +334,7 @@ export function renameAndCopyFile (srcFilePath, expectedBaseName, destDir) { fs.copyFile(path.join(srcDir, expectedBaseName), path.join(destDir, expectedBaseName), (err) => { if (err) { self.logger.error(`Error copying file: ${err.message}`) - throw new FullstackTestingError(`Error copying file: ${err.message}`) + throw new SoloError(`Error copying file: ${err.message}`) } }) } @@ -373,6 +373,6 @@ export function yamlToObject (yamlFile) { return configMap } } catch (e) { - throw new FullstackTestingError(`failed to convert yaml file ${yamlFile} to object: ${e.message}`, e) + throw new SoloError(`failed to convert yaml file ${yamlFile} to object: ${e.message}`, e) } } diff --git a/src/core/k8.mjs b/src/core/k8.mjs index 07ad6a5c9..0db4ac53e 100644 --- a/src/core/k8.mjs +++ b/src/core/k8.mjs @@ -21,7 +21,7 @@ import net from 'net' import os from 'os' import path from 'path' import { flags } from '../commands/index.mjs' -import { FullstackTestingError, IllegalArgumentError, MissingArgumentError } from './errors.mjs' +import { SoloError, IllegalArgumentError, MissingArgumentError } from './errors.mjs' import * as sb from 'stream-buffers' import * as tar from 'tar' import { v4 as uuid4 } from 'uuid' @@ -79,12 +79,12 @@ export class K8 { this.kubeConfig.loadFromDefault() if (!this.kubeConfig.getCurrentCluster()) { - throw new FullstackTestingError('No active kubernetes cluster found. ' + + throw new SoloError('No active kubernetes cluster found. ' + 'Please create a cluster and set current context.') } if (!this.kubeConfig.getCurrentContext()) { - throw new FullstackTestingError('No active kubernetes context found. ' + + throw new SoloError('No active kubernetes context found. ' + 'Please set current kubernetes context.') } @@ -133,7 +133,7 @@ export class K8 { */ filterItem (items, filters = {}) { const filtered = this.applyMetadataFilter(items, filters) - if (filtered.length > 1) throw new FullstackTestingError('multiple items found with filters', { filters }) + if (filtered.length > 1) throw new SoloError('multiple items found with filters', { filters }) return filtered[0] } @@ -178,7 +178,7 @@ export class K8 { return namespaces } - throw new FullstackTestingError('incorrect response received from kubernetes API. Unable to list namespaces') + throw new SoloError('incorrect response received from kubernetes API. Unable to list namespaces') } /** @@ -263,7 +263,7 @@ export class K8 { } this.logger.debug(`Unable to find pod IP for ${podNameName}`) - throw new FullstackTestingError(`unable to find host IP of podName: ${podNameName}`) + throw new SoloError(`unable to find host IP of podName: ${podNameName}`) } /** @@ -296,7 +296,7 @@ export class K8 { return svc.spec.clusterIP } - throw new FullstackTestingError(`unable to find cluster IP for svc: ${svcName}`) + throw new SoloError(`unable to find cluster IP for svc: ${svcName}`) } /** @@ -382,7 +382,7 @@ export class K8 { return items } catch (e) { - throw new FullstackTestingError(`unable to check path in '${podName}':${containerName}' - ${destPath}: ${e.message}`, e) + throw new SoloError(`unable to check path in '${podName}':${containerName}' - ${destPath}: ${e.message}`, e) } } @@ -423,7 +423,7 @@ export class K8 { } } } catch (e) { - const error = new FullstackTestingError(`unable to check file in '${podName}':${containerName}' - ${destPath}: ${e.message}`, e) + const error = new SoloError(`unable to check file in '${podName}':${containerName}' - ${destPath}: ${e.message}`, e) this.logger.error(error.message, error) throw error } @@ -475,11 +475,11 @@ export class K8 { const namespace = this._getNamespace() if (!await this.hasDir(podName, containerName, destDir)) { - throw new FullstackTestingError(`invalid destination path: ${destDir}`) + throw new SoloError(`invalid destination path: ${destDir}`) } if (!fs.existsSync(srcPath)) { - throw new FullstackTestingError(`invalid source path: ${srcPath}`) + throw new SoloError(`invalid source path: ${srcPath}`) } try { @@ -509,7 +509,7 @@ export class K8 { }).then(conn => { conn.on('close', async (code, reason) => { if (code !== 1000) { // code 1000 is the success code - return reject(new FullstackTestingError(`failed to copy because of error (${code}): ${reason}`)) + return reject(new SoloError(`failed to copy because of error (${code}): ${reason}`)) } return resolve(true) @@ -517,12 +517,12 @@ export class K8 { conn.on('error', (e) => { self._deleteTempFile(tmpFile) - return reject(new FullstackTestingError(`failed to copy file ${destPath} because of connection error: ${e.message}`, e)) + return reject(new SoloError(`failed to copy file ${destPath} because of connection error: ${e.message}`, e)) }) }) }) } catch (e) { - throw new FullstackTestingError(`failed to copy file to ${podName}:${containerName} [${srcPath} -> ${destDir}]: ${e.message}`, e) + throw new SoloError(`failed to copy file to ${podName}:${containerName} [${srcPath} -> ${destDir}]: ${e.message}`, e) } } @@ -543,20 +543,20 @@ export class K8 { // get stat for source file in the container let entries = await this.listDir(podName, containerName, srcPath) if (entries.length !== 1) { - throw new FullstackTestingError(`invalid source path: ${srcPath}`) + throw new SoloError(`invalid source path: ${srcPath}`) } // handle symbolic link if (entries[0].name.indexOf(' -> ') > -1) { const redirectSrcPath = path.join(path.dirname(srcPath), entries[0].name.substring(entries[0].name.indexOf(' -> ') + 4)) entries = await this.listDir(podName, containerName, redirectSrcPath) if (entries.length !== 1) { - throw new FullstackTestingError(`invalid source path: ${redirectSrcPath}`) + throw new SoloError(`invalid source path: ${redirectSrcPath}`) } } const srcFileDesc = entries[0] // cache for later comparison after copy if (!fs.existsSync(destDir)) { - throw new FullstackTestingError(`invalid destination path: ${destDir}`) + throw new SoloError(`invalid destination path: ${destDir}`) } try { @@ -610,14 +610,14 @@ export class K8 { self._deleteTempFile(tmpFile) const errorMessage = `tar command failed with status Failure while copying from ${podName}:${srcDir}/${srcFile} to ${destPath}` this.logger.error(errorMessage) - return reject(new FullstackTestingError(errorMessage)) + return reject(new SoloError(errorMessage)) } this.logger.debug(`copyFrom.callback(status)=${status}`) }) .then(conn => { conn.on('error', (e) => { self._deleteTempFile(tmpFile) - return reject(new FullstackTestingError( + return reject(new SoloError( `failed copying from ${podName}:${srcDir}/${srcFile} to ${destPath} because of connection error: ${e.message}`, e)) }) @@ -626,7 +626,7 @@ export class K8 { if (code !== 1000) { // code 1000 is the success code const errorMessage = `failed copying from ${podName}:${srcDir}/${srcFile} to ${destPath} because of error (${code}): ${reason}` this.logger.error(errorMessage) - return reject(new FullstackTestingError(errorMessage)) + return reject(new SoloError(errorMessage)) } outputFileStream.end() @@ -654,14 +654,14 @@ export class K8 { if (rejection) { const errorMessage = `failed copying from ${podName}:${srcDir}/${srcFile} to ${destPath} to download file completely: ${destPath}${additionalErrorMessageDetail}` this.logger.error(errorMessage) - return reject(new FullstackTestingError(errorMessage)) + return reject(new SoloError(errorMessage)) } else { return resolve(true) } } catch (e) { const errorMessage = `failed to complete copying from ${podName}:${srcDir}/${srcFile} to ${destPath} to extract file: ${destPath}` this.logger.error(errorMessage, e) - return reject(new FullstackTestingError(errorMessage, e)) + return reject(new SoloError(errorMessage, e)) } }) }) @@ -670,7 +670,7 @@ export class K8 { errStream.on('data', (data) => { const errorMessage = `error encountered copying from ${podName}:${srcDir}/${srcFile} to ${destPath}, error: ${data.toString()}` this.logger.error(errorMessage) - return reject(new FullstackTestingError(errorMessage)) + return reject(new SoloError(errorMessage)) }) outputFileStream.on('close', () => { @@ -680,7 +680,7 @@ export class K8 { outputFileStream.on('error', (err) => { const errorMessage = `writerStream error encountered copying from ${podName}:${srcDir}/${srcFile} to ${destPath}, err: ${err.toString()}` this.logger.error(errorMessage, err) - return reject(new FullstackTestingError(errorMessage, err)) + return reject(new SoloError(errorMessage, err)) }) outputFileStream.on('end', () => { @@ -702,7 +702,7 @@ export class K8 { } catch (e) { const errorMessage = `failed to download file from ${podName}:${containerName} [${srcPath} -> ${destDir}]: ${e.message}` this.logger.error(errorMessage, e) - throw new FullstackTestingError(errorMessage, e) + throw new SoloError(errorMessage, e) } } @@ -742,7 +742,7 @@ export class K8 { false, ({ status }) => { if (status === 'Failure' || errStream.size()) { - reject(new FullstackTestingError(`Exec error: + reject(new SoloError(`Exec error: [exec ${podName} -c ${containerName} -- ${command.join(' ')}'] - error details: ${errStream.getContentsAsString()}`)) return @@ -795,7 +795,7 @@ export class K8 { const s = new net.Socket() s.on('error', (e) => { s.destroy() - reject(new FullstackTestingError(`failed to connect to '${host}:${port}': ${e.message}`, e)) + reject(new SoloError(`failed to connect to '${host}:${port}': ${e.message}`, e)) }) s.connect(port, host, () => { @@ -876,7 +876,7 @@ export class K8 { await sleep(timeout) } if (attempts >= maxAttempts) { - throw new FullstackTestingError(`failed to stop port-forwarder [${server.info}]`) + throw new SoloError(`failed to stop port-forwarder [${server.info}]`) } } @@ -936,7 +936,7 @@ export class K8 { if (++attempts < maxAttempts) { setTimeout(() => check(resolve, reject), delay) } else { - return reject(new FullstackTestingError(`Expected number of pod (${podCount}) not found for labels: ${labelSelector}, phases: ${phases.join(',')} [attempts = ${attempts}/${maxAttempts}]`)) + return reject(new SoloError(`Expected number of pod (${podCount}) not found for labels: ${labelSelector}, phases: ${phases.join(',')} [attempts = ${attempts}/${maxAttempts}]`)) } } @@ -956,7 +956,7 @@ export class K8 { try { return await this.waitForPodConditions(K8.PodReadyCondition, labels, podCount, maxAttempts, delay) } catch (e) { - throw new FullstackTestingError(`Pod not ready [maxAttempts = ${maxAttempts}]`, e) + throw new SoloError(`Pod not ready [maxAttempts = ${maxAttempts}]`, e) } } @@ -1116,7 +1116,7 @@ export class K8 { return resp.response.statusCode === 201 } catch (e) { - throw new FullstackTestingError(`failed to create secret ${name} in namespace ${namespace}: ${e.message}, ${e?.body?.message}`, e) + throw new SoloError(`failed to create secret ${name} in namespace ${namespace}: ${e.message}, ${e?.body?.message}`, e) } } diff --git a/src/core/key_manager.mjs b/src/core/key_manager.mjs index ef7bd4c06..15bae91d7 100644 --- a/src/core/key_manager.mjs +++ b/src/core/key_manager.mjs @@ -19,7 +19,7 @@ import * as x509 from '@peculiar/x509' import crypto from 'crypto' import fs from 'fs' import path from 'path' -import { FullstackTestingError, IllegalArgumentError, MissingArgumentError } from './errors.mjs' +import { SoloError, IllegalArgumentError, MissingArgumentError } from './errors.mjs' import { constants } from './index.mjs' import { Logger } from './logging.mjs' import { Templates } from './templates.mjs' @@ -322,7 +322,7 @@ export class KeyManager { certificateChain: certChain } } catch (e) { - throw new FullstackTestingError(`failed to generate signing key: ${e.message}`, e) + throw new SoloError(`failed to generate signing key: ${e.message}`, e) } } @@ -390,7 +390,7 @@ export class KeyManager { publicKey: signingKey.certificate.publicKey, signatureOnly: true })) { - throw new FullstackTestingError(`failed to verify generated certificate for '${friendlyName}'`) + throw new SoloError(`failed to verify generated certificate for '${friendlyName}'`) } const certChain = await new x509.X509ChainBuilder({ certificates: [signingKey.certificate] }).build(cert) @@ -402,7 +402,7 @@ export class KeyManager { certificateChain: certChain } } catch (e) { - throw new FullstackTestingError(`failed to generate ${keyPrefix}-key: ${e.message}`, e) + throw new SoloError(`failed to generate ${keyPrefix}-key: ${e.message}`, e) } } @@ -457,7 +457,7 @@ export class KeyManager { certificateChain: certChain } } catch (e) { - throw new FullstackTestingError(`failed to generate gRPC TLS key: ${e.message}`, e) + throw new SoloError(`failed to generate gRPC TLS key: ${e.message}`, e) } } @@ -487,7 +487,7 @@ export class KeyManager { async copyNodeKeysToStaging (nodeKey, destDir) { for (const keyFile of [nodeKey.privateKeyFile, nodeKey.certificateFile]) { if (!fs.existsSync(keyFile)) { - throw new FullstackTestingError(`file (${keyFile}) is missing`) + throw new SoloError(`file (${keyFile}) is missing`) } const fileName = path.basename(keyFile) @@ -557,7 +557,7 @@ export class KeyManager { taskGenerateTLSKeys (nodeIds, keysDir, curDate = new Date()) { // check if nodeIds is an array of strings if (!Array.isArray(nodeIds) || !nodeIds.every((nodeId) => typeof nodeId === 'string')) { - throw new FullstackTestingError('nodeIds must be an array of strings') + throw new SoloError('nodeIds must be an array of strings') } const self = this const nodeKeyFiles = new Map() diff --git a/src/core/package_downloader.mjs b/src/core/package_downloader.mjs index 40c164baa..01f0a95a1 100644 --- a/src/core/package_downloader.mjs +++ b/src/core/package_downloader.mjs @@ -22,7 +22,7 @@ import got from 'got' import path from 'path' import { DataValidationError, - FullstackTestingError, + SoloError, IllegalArgumentError, MissingArgumentError, ResourceNotFoundError @@ -140,7 +140,7 @@ export class PackageDownloader { return destPath } catch (e) { - throw new FullstackTestingError(`Error fetching file ${url}: ${e.message}`, e) + throw new SoloError(`Error fetching file ${url}: ${e.message}`, e) } } @@ -172,7 +172,7 @@ export class PackageDownloader { reject(e) }) } catch (e) { - reject(new FullstackTestingError('failed to compute checksum', e, { filePath, algo })) + reject(new SoloError('failed to compute checksum', e, { filePath, algo })) } }) } @@ -222,7 +222,7 @@ export class PackageDownloader { await this.fetchFile(checksumURL, checksumFile) const checksumData = fs.readFileSync(checksumFile).toString() - if (!checksumData) throw new FullstackTestingError(`unable to read checksum file: ${checksumFile}`) + if (!checksumData) throw new SoloError(`unable to read checksum file: ${checksumFile}`) const checksum = checksumData.split(' ')[0] await this.fetchFile(packageURL, packageFile) await this.verifyChecksum(packageFile, checksum, algo) @@ -236,7 +236,7 @@ export class PackageDownloader { fs.rmSync(packageFile) } - throw new FullstackTestingError(e.message, e) + throw new SoloError(e.message, e) } } diff --git a/src/core/platform_installer.mjs b/src/core/platform_installer.mjs index 3b29fb0d2..ee711bb81 100644 --- a/src/core/platform_installer.mjs +++ b/src/core/platform_installer.mjs @@ -18,7 +18,7 @@ import * as fs from 'fs' import { Listr } from 'listr2' import * as path from 'path' -import { FullstackTestingError, IllegalArgumentError, MissingArgumentError } from './errors.mjs' +import { SoloError, IllegalArgumentError, MissingArgumentError } from './errors.mjs' import { constants } from './index.mjs' import { Templates } from './templates.mjs' import { flags } from '../commands/index.mjs' @@ -112,7 +112,7 @@ export class PlatformInstaller { await this.k8.execContainer(podName, constants.ROOT_CONTAINER, [extractScript, tag]) return true } catch (e) { - throw new FullstackTestingError(`failed to extract platform code in this pod '${podName}': ${e.message}`, e) + throw new SoloError(`failed to extract platform code in this pod '${podName}': ${e.message}`, e) } } @@ -132,7 +132,7 @@ export class PlatformInstaller { // prepare the file mapping for (const srcPath of srcFiles) { if (!fs.existsSync(srcPath)) { - throw new FullstackTestingError(`file does not exist: ${srcPath}`) + throw new SoloError(`file does not exist: ${srcPath}`) } if (!await this.k8.hasDir(podName, container, destDir)) { @@ -148,7 +148,7 @@ export class PlatformInstaller { return copiedFiles } catch (e) { - throw new FullstackTestingError(`failed to copy files to pod '${podName}': ${e.message}`, e) + throw new SoloError(`failed to copy files to pod '${podName}': ${e.message}`, e) } } @@ -179,11 +179,11 @@ export class PlatformInstaller { Templates.renderGossipKeySecretName(nodeId), this._getNamespace(), 'Opaque', data, Templates.renderGossipKeySecretLabelObject(nodeId), true)) { - throw new FullstackTestingError(`failed to create secret for gossip keys for node '${nodeId}'`) + throw new SoloError(`failed to create secret for gossip keys for node '${nodeId}'`) } } catch (e) { this.logger.error(`failed to copy gossip keys to secret '${Templates.renderGossipKeySecretName(nodeId)}': ${e.message}`, e) - throw new FullstackTestingError(`failed to copy gossip keys to secret '${Templates.renderGossipKeySecretName(nodeId)}': ${e.message}`, e) + throw new SoloError(`failed to copy gossip keys to secret '${Templates.renderGossipKeySecretName(nodeId)}': ${e.message}`, e) } } @@ -209,11 +209,11 @@ export class PlatformInstaller { 'network-node-hapi-app-secrets', this._getNamespace(), 'Opaque', data, undefined, true)) { - throw new FullstackTestingError('failed to create secret for TLS keys') + throw new SoloError('failed to create secret for TLS keys') } } catch (e) { this.logger.error('failed to copy TLS keys to secret', e) - throw new FullstackTestingError('failed to copy TLS keys to secret', e) + throw new SoloError('failed to copy TLS keys to secret', e) } } @@ -263,7 +263,7 @@ export class PlatformInstaller { return true } catch (e) { - throw new FullstackTestingError(`failed to set permission in '${podName}'`, e) + throw new SoloError(`failed to set permission in '${podName}'`, e) } } diff --git a/src/core/profile_manager.mjs b/src/core/profile_manager.mjs index 5e7b6b634..a15a3e663 100644 --- a/src/core/profile_manager.mjs +++ b/src/core/profile_manager.mjs @@ -17,7 +17,7 @@ 'use strict' import fs from 'fs' import path from 'path' -import { FullstackTestingError, IllegalArgumentError, MissingArgumentError } from './errors.mjs' +import { SoloError, IllegalArgumentError, MissingArgumentError } from './errors.mjs' import * as yaml from 'js-yaml' import { flags } from '../commands/index.mjs' import { constants, helpers, Templates } from './index.mjs' @@ -196,7 +196,7 @@ export class ProfileManager { for (const flag of flags.nodeConfigFileFlags.values()) { const filePath = this.configManager.getFlag(flag) if (!filePath) { - throw new FullstackTestingError(`Configuration file path is missing for: ${flag.name}`) + throw new SoloError(`Configuration file path is missing for: ${flag.name}`) } const fileName = path.basename(filePath) @@ -296,7 +296,7 @@ export class ProfileManager { const profile = this.getProfile(profileName) const nodeIds = helpers.parseNodeIds(this.configManager.getFlag(flags.nodeIDs)) - if (!nodeIds) throw new FullstackTestingError('Node IDs are not set in the config') + if (!nodeIds) throw new SoloError('Node IDs are not set in the config') // generate the yaml const yamlRoot = {} @@ -494,7 +494,7 @@ export class ProfileManager { return configFilePath } catch (e) { - throw new FullstackTestingError('failed to generate config.txt', e) + throw new SoloError('failed to generate config.txt', e) } } } diff --git a/src/core/templates.mjs b/src/core/templates.mjs index 21214e46d..6d76b5f29 100644 --- a/src/core/templates.mjs +++ b/src/core/templates.mjs @@ -18,7 +18,7 @@ import * as x509 from '@peculiar/x509' import os from 'os' import path from 'path' -import { DataValidationError, FullstackTestingError, IllegalArgumentError, MissingArgumentError } from './errors.mjs' +import { DataValidationError, SoloError, IllegalArgumentError, MissingArgumentError } from './errors.mjs' import { constants } from './index.mjs' export class Templates { @@ -218,7 +218,7 @@ export class Templates { return path.join(installationDir, 'jre', 'bin', dep) default: - throw new FullstackTestingError(`unknown dep: ${dep}`) + throw new SoloError(`unknown dep: ${dep}`) } } diff --git a/src/core/zippy.mjs b/src/core/zippy.mjs index 512d9bb08..1003bb6fb 100644 --- a/src/core/zippy.mjs +++ b/src/core/zippy.mjs @@ -15,7 +15,7 @@ * */ 'use strict' -import { FullstackTestingError, IllegalArgumentError, MissingArgumentError } from './errors.mjs' +import { SoloError, IllegalArgumentError, MissingArgumentError } from './errors.mjs' import fs from 'fs' import AdmZip from 'adm-zip' import * as tar from 'tar' @@ -57,7 +57,7 @@ export class Zippy { return destPath } catch (e) { - throw new FullstackTestingError(`failed to unzip ${srcPath}: ${e.message}`, e) + throw new SoloError(`failed to unzip ${srcPath}: ${e.message}`, e) } } @@ -94,7 +94,7 @@ export class Zippy { return destPath } catch (e) { - throw new FullstackTestingError(`failed to unzip ${srcPath}: ${e.message}`, e) + throw new SoloError(`failed to unzip ${srcPath}: ${e.message}`, e) } } @@ -118,7 +118,7 @@ export class Zippy { }, [srcPath]) return destPath } catch (e) { - throw new FullstackTestingError(`failed to tar ${srcPath}: ${e.message}`, e) + throw new SoloError(`failed to tar ${srcPath}: ${e.message}`, e) } } @@ -144,7 +144,7 @@ export class Zippy { }) return destPath } catch (e) { - throw new FullstackTestingError(`failed to untar ${srcPath}: ${e.message}`, e) + throw new SoloError(`failed to untar ${srcPath}: ${e.message}`, e) } } } diff --git a/test/e2e/core/k8_e2e.test.mjs b/test/e2e/core/k8_e2e.test.mjs index 0622dc6fd..b346722ad 100644 --- a/test/e2e/core/k8_e2e.test.mjs +++ b/test/e2e/core/k8_e2e.test.mjs @@ -19,7 +19,7 @@ import net from 'net' import os from 'os' import path from 'path' import { v4 as uuid4 } from 'uuid' -import { FullstackTestingError } from '../../../src/core/errors.mjs' +import { SoloError } from '../../../src/core/errors.mjs' import { ConfigManager, constants, logging, Templates } from '../../../src/core/index.mjs' import { K8 } from '../../../src/core/k8.mjs' import { flags } from '../../../src/commands/index.mjs' @@ -159,12 +159,12 @@ describe('K8', () => { const pods = await k8.getPodsByLabel([`app=${podLabelValue}`]) const podName = pods[0].metadata.name await expect(k8.getPodIP(podName)).resolves.not.toBeNull() - await expect(k8.getPodIP('INVALID')).rejects.toThrow(FullstackTestingError) + await expect(k8.getPodIP('INVALID')).rejects.toThrow(SoloError) }, defaultTimeout) it('should be able to detect cluster IP', async () => { await expect(k8.getClusterIP(serviceName)).resolves.not.toBeNull() - await expect(k8.getClusterIP('INVALID')).rejects.toThrow(FullstackTestingError) + await expect(k8.getClusterIP('INVALID')).rejects.toThrow(SoloError) }, defaultTimeout) it('should be able to check if a path is directory inside a container', async () => { @@ -226,7 +226,7 @@ describe('K8', () => { s.on('error', async (e) => { s.destroy() await k8.stopPortForward(server) - done(new FullstackTestingError(`could not connect to local port '${localPort}': ${e.message}`, e)) + done(new SoloError(`could not connect to local port '${localPort}': ${e.message}`, e)) }) s.connect(localPort) diff --git a/test/unit/core/dependency_managers/dependency_manager.test.mjs b/test/unit/core/dependency_managers/dependency_manager.test.mjs index a42160162..bc225c769 100644 --- a/test/unit/core/dependency_managers/dependency_manager.test.mjs +++ b/test/unit/core/dependency_managers/dependency_manager.test.mjs @@ -17,7 +17,7 @@ import { describe, expect, it } from '@jest/globals' import { DependencyManager, HelmDependencyManager } from '../../../../src/core/dependency_managers/index.mjs' import { logging, constants, PackageDownloader, Zippy } from '../../../../src/core/index.mjs' -import { FullstackTestingError } from '../../../../src/core/errors.mjs' +import { SoloError } from '../../../../src/core/errors.mjs' const testLogger = logging.NewLogger('debug', true) describe('DependencyManager', () => { @@ -31,7 +31,7 @@ describe('DependencyManager', () => { describe('checkDependency', () => { it('should fail during invalid dependency check', async () => { - await expect(depManager.checkDependency('INVALID_PROGRAM')).rejects.toThrowError(new FullstackTestingError("Dependency 'INVALID_PROGRAM' is not found")) + await expect(depManager.checkDependency('INVALID_PROGRAM')).rejects.toThrowError(new SoloError("Dependency 'INVALID_PROGRAM' is not found")) }) it('should succeed during helm dependency check', async () => { diff --git a/test/unit/core/errors.test.mjs b/test/unit/core/errors.test.mjs index 518f1e9e0..ded248690 100644 --- a/test/unit/core/errors.test.mjs +++ b/test/unit/core/errors.test.mjs @@ -16,7 +16,7 @@ */ import { describe, expect, it } from '@jest/globals' import { - FullstackTestingError, + SoloError, ResourceNotFoundError, MissingArgumentError, IllegalArgumentError, @@ -27,10 +27,10 @@ describe('Errors', () => { const message = 'errorMessage' const cause = new Error('cause') - it('should construct correct FullstackTestingError', () => { - const error = new FullstackTestingError(message, cause) + it('should construct correct SoloError', () => { + const error = new SoloError(message, cause) expect(error).toBeInstanceOf(Error) - expect(error.name).toBe('FullstackTestingError') + expect(error.name).toBe('SoloError') expect(error.message).toBe(message) expect(error.cause).toBe(cause) expect(error.meta).toStrictEqual({}) @@ -39,7 +39,7 @@ describe('Errors', () => { it('should construct correct ResourceNotFoundError', () => { const resource = 'resource' const error = new ResourceNotFoundError(message, resource) - expect(error).toBeInstanceOf(FullstackTestingError) + expect(error).toBeInstanceOf(SoloError) expect(error.name).toBe('ResourceNotFoundError') expect(error.message).toBe(message) expect(error.cause).toStrictEqual({}) @@ -48,7 +48,7 @@ describe('Errors', () => { it('should construct correct MissingArgumentError', () => { const error = new MissingArgumentError(message) - expect(error).toBeInstanceOf(FullstackTestingError) + expect(error).toBeInstanceOf(SoloError) expect(error.name).toBe('MissingArgumentError') expect(error.message).toBe(message) expect(error.cause).toStrictEqual({}) @@ -58,7 +58,7 @@ describe('Errors', () => { it('should construct correct IllegalArgumentError', () => { const value = 'invalid argument' const error = new IllegalArgumentError(message, value) - expect(error).toBeInstanceOf(FullstackTestingError) + expect(error).toBeInstanceOf(SoloError) expect(error.name).toBe('IllegalArgumentError') expect(error.message).toBe(message) expect(error.cause).toStrictEqual({}) @@ -69,7 +69,7 @@ describe('Errors', () => { const expected = 'expected' const found = 'found' const error = new DataValidationError(message, expected, found) - expect(error).toBeInstanceOf(FullstackTestingError) + expect(error).toBeInstanceOf(SoloError) expect(error.name).toBe('DataValidationError') expect(error.message).toBe(message) expect(error.cause).toStrictEqual({}) diff --git a/test/unit/core/zippy.test.mjs b/test/unit/core/zippy.test.mjs index 1377236d7..23932cdce 100644 --- a/test/unit/core/zippy.test.mjs +++ b/test/unit/core/zippy.test.mjs @@ -16,7 +16,7 @@ */ import { describe, expect, it } from '@jest/globals' import * as core from '../../../src/core/index.mjs' -import { FullstackTestingError, IllegalArgumentError, MissingArgumentError } from '../../../src/core/errors.mjs' +import { SoloError, IllegalArgumentError, MissingArgumentError } from '../../../src/core/errors.mjs' import os from 'os' import fs from 'fs' import path from 'path' @@ -43,12 +43,12 @@ describe('Zippy', () => { it('should fail for a directory', async () => { expect.assertions(1) - await expect(zippy.unzip('test/data', os.tmpdir())).rejects.toThrow(FullstackTestingError) + await expect(zippy.unzip('test/data', os.tmpdir())).rejects.toThrow(SoloError) }) it('should fail for a non-zip file', async () => { expect.assertions(1) - await expect(zippy.unzip('test/data/test.txt', os.tmpdir())).rejects.toThrow(FullstackTestingError) + await expect(zippy.unzip('test/data/test.txt', os.tmpdir())).rejects.toThrow(SoloError) }) it('should succeed for valid inputs', async () => { @@ -79,12 +79,12 @@ describe('Zippy', () => { it('should fail for a directory', async () => { expect.assertions(1) - await expect(zippy.untar('test/data', os.tmpdir())).rejects.toThrow(FullstackTestingError) + await expect(zippy.untar('test/data', os.tmpdir())).rejects.toThrow(SoloError) }) it('should fail for a non-tar file', async () => { expect.assertions(1) - await expect(zippy.untar('test/data/test.txt', os.tmpdir())).rejects.toThrow(FullstackTestingError) + await expect(zippy.untar('test/data/test.txt', os.tmpdir())).rejects.toThrow(SoloError) }) it('should succeed for valid inputs', async () => {