Skip to content

Commit

Permalink
remove todos
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <jeromy@swirldslabs.com>
  • Loading branch information
jeromy-cannon committed Sep 4, 2024
1 parent 12e3a62 commit aa9e4ce
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 71 deletions.
142 changes: 75 additions & 67 deletions src/commands/node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export class NodeCommand extends BaseCommand {
flags.appConfig,
flags.cacheDir,
flags.devMode,
flags.hederaImage,
flags.localBuildPath,
flags.namespace,
flags.nodeIDs,
Expand Down Expand Up @@ -143,6 +144,7 @@ export class NodeCommand extends BaseCommand {
flags.app,
flags.cacheDir,
flags.devMode,
flags.hederaImage,
flags.localBuildPath,
flags.namespace,
flags.nodeIDs,
Expand Down Expand Up @@ -173,6 +175,7 @@ export class NodeCommand extends BaseCommand {
flags.generateTlsKeys,
flags.gossipEndpoints,
flags.grpcEndpoints,
flags.hederaImage,
flags.keyFormat,
flags.localBuildPath,
flags.namespace,
Expand Down Expand Up @@ -694,6 +697,7 @@ export class NodeCommand extends BaseCommand {
* @property {string} appConfig
* @property {string} cacheDir
* @property {boolean} devMode
* @property {boolean} hederaImage
* @property {string} localBuildPath
* @property {string} namespace
* @property {string} nodeIDs
Expand Down Expand Up @@ -730,15 +734,15 @@ export class NodeCommand extends BaseCommand {
title: 'Identify network pods',
task: (ctx, task) => self.taskCheckNetworkNodePods(ctx, task, ctx.config.nodeIds)
},
// TODO: deterministic flag switch
// {
// title: 'Fetch platform software into network nodes',
// task:
// async (ctx, task) => {
// const config = /** @type {NodeSetupConfigClass} **/ ctx.config
// return self.fetchLocalOrReleasedPlatformSoftware(config.nodeIds, config.podNames, config.releaseTag, task, config.localBuildPath)
// }
// },
{
title: 'Fetch platform software into network nodes',
task:
async (ctx, task) => {
const config = /** @type {NodeSetupConfigClass} **/ ctx.config
return self.fetchLocalOrReleasedPlatformSoftware(config.nodeIds, config.podNames, config.releaseTag, task, config.localBuildPath)
},
skip: (ctx, _) => self.configManager.getFlag(flags.hederaImage)
},
{
title: 'Setup network nodes',
task: async (ctx, parentTask) => {
Expand Down Expand Up @@ -811,23 +815,23 @@ export class NodeCommand extends BaseCommand {
title: 'Identify network pods',
task: (ctx, task) => self.taskCheckNetworkNodePods(ctx, task, ctx.config.nodeIds)
},
// TODO: deterministic flag switch
// {
// title: 'Starting nodes',
// task: (ctx, task) => {
// const subTasks = []
// self.startNodes(ctx.config.podNames, ctx.config.nodeIds, subTasks)
//
// // set up the sub-tasks
// return task.newListr(subTasks, {
// concurrent: true,
// rendererOptions: {
// collapseSubtasks: false,
// timer: constants.LISTR_DEFAULT_RENDERER_TIMER_OPTION
// }
// })
// }
// },
{
title: 'Starting nodes',
task: (ctx, task) => {
const subTasks = []
self.startNodes(ctx.config.podNames, ctx.config.nodeIds, subTasks)

// set up the sub-tasks
return task.newListr(subTasks, {
concurrent: true,
rendererOptions: {
collapseSubtasks: false,
timer: constants.LISTR_DEFAULT_RENDERER_TIMER_OPTION
}
})
},
skip: (ctx, _) => self.configManager.getFlag(flags.hederaImage)
},
{
title: 'Check nodes are ACTIVE',
task: (ctx, task) => {
Expand Down Expand Up @@ -1123,6 +1127,7 @@ export class NodeCommand extends BaseCommand {
* @property {string} app
* @property {string} cacheDir
* @property {boolean} devMode
* @property {boolean} hederaImage
* @property {string} localBuildPath
* @property {string} namespace
* @property {string} nodeIDs
Expand Down Expand Up @@ -1180,15 +1185,15 @@ export class NodeCommand extends BaseCommand {
})
}
},
// TODO: deterministic flag switch
// {
// title: 'Fetch platform software into network nodes',
// task:
// async (ctx, task) => {
// const config = /** @type {NodeRefreshConfigClass} **/ ctx.config
// return self.fetchLocalOrReleasedPlatformSoftware(config.nodeIds, config.podNames, config.releaseTag, task, config.localBuildPath)
// }
// },
{
title: 'Fetch platform software into network nodes',
task:
async (ctx, task) => {
const config = /** @type {NodeRefreshConfigClass} **/ ctx.config
return self.fetchLocalOrReleasedPlatformSoftware(config.nodeIds, config.podNames, config.releaseTag, task, config.localBuildPath)
},
skip: (ctx, _) => self.configManager.getFlag(flags.hederaImage)
},
{
title: 'Setup network nodes',
task: async (ctx, parentTask) => {
Expand Down Expand Up @@ -1381,6 +1386,7 @@ export class NodeCommand extends BaseCommand {
* @property {boolean} generateTlsKeys
* @property {string} gossipEndpoints
* @property {string} grpcEndpoints
* @property {boolean} hederaImage
* @property {string} keyFormat
* @property {string} localBuildPath
* @property {string} namespace
Expand Down Expand Up @@ -1575,7 +1581,7 @@ export class NodeCommand extends BaseCommand {
endpoints = helpers.splitFlagInput(config.gossipEndpoints)
}

ctx.gossipEndpoints = this.prepareEndpoints(config.endpointType, endpoints, constants.HEDERA_NODE_INTERNAL_GOSSIP_PORT)
ctx.gossipEndpoints = this.prepareEndpoints(config.endpointType, endpoints, Number.parseInt(constants.HEDERA_NODE_INTERNAL_GOSSIP_PORT))
}
},
{
Expand All @@ -1596,7 +1602,7 @@ export class NodeCommand extends BaseCommand {
endpoints = helpers.splitFlagInput(config.grpcEndpoints)
}

ctx.grpcServiceEndpoints = this.prepareEndpoints(config.endpointType, endpoints, constants.HEDERA_NODE_EXTERNAL_GOSSIP_PORT)
ctx.grpcServiceEndpoints = this.prepareEndpoints(config.endpointType, endpoints, Number.parseInt(constants.HEDERA_NODE_EXTERNAL_GOSSIP_PORT))
}
},
{
Expand Down Expand Up @@ -1826,8 +1832,9 @@ export class NodeCommand extends BaseCommand {
config.podNames[config.nodeId] = config.serviceMap.get(
config.nodeId).nodePodName

// TODO: deterministic flag switch
// return self.fetchLocalOrReleasedPlatformSoftware(config.allNodeIds, config.podNames, config.releaseTag, task, config.localBuildPath)
if (!config.hederaImage) {
return self.fetchLocalOrReleasedPlatformSoftware(config.allNodeIds, config.podNames, config.releaseTag, task, config.localBuildPath)
}
}
},
{
Expand Down Expand Up @@ -1879,31 +1886,31 @@ export class NodeCommand extends BaseCommand {
})
}
},
// TODO: deterministic flag switch
// {
// title: 'Start network nodes',
// task: async (ctx, task) => {
// const config = /** @type {NodeAddConfigClass} **/ ctx.config
// const subTasks = []
// self.startNodes(config.podNames, config.allNodeIds, subTasks)
//
// // set up the sub-tasks
// return task.newListr(subTasks, {
// concurrent: true,
// rendererOptions: {
// collapseSubtasks: false,
// timer: constants.LISTR_DEFAULT_RENDERER_TIMER_OPTION
// }
// })
// }
// },
// TODO: deterministic flag switch
{
title: 'Start network nodes',
task: async (ctx, task) => {
const config = /** @type {NodeAddConfigClass} **/ ctx.config
const subTasks = []
self.startNodes(config.podNames, config.allNodeIds, subTasks)

// set up the sub-tasks
return task.newListr(subTasks, {
concurrent: true,
rendererOptions: {
collapseSubtasks: false,
timer: constants.LISTR_DEFAULT_RENDERER_TIMER_OPTION
}
})
},
skip: (ctx, _) => self.configManager.getFlag(flags.hederaImage)
},
{
title: 'Kill new node to pick up updated state',
task: async (ctx, task) => {
const config = /** @type {NodeAddConfigClass} **/ ctx.config
await self.k8.kubeClient.deleteNamespacedPod(Templates.renderNetworkPodName(config.nodeId), config.namespace, undefined, undefined, 1)
}
},
skip: (ctx, _) => !self.configManager.getFlag(flags.hederaImage)
},
{
title: 'Check all nodes are ACTIVE',
Expand All @@ -1912,13 +1919,14 @@ export class NodeCommand extends BaseCommand {
const subTasks = []
// sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string
await sleep(30000)
// TODO: deterministic flag switch
// for (const nodeId of ctx.config.allNodeIds) {
// subTasks.push({
// title: `Check node: ${chalk.yellow(nodeId)}`,
// task: () => self.checkNetworkNodeState(nodeId, 200)
// })
// }
if (!config.hederaImage) {
for (const nodeId of ctx.config.allNodeIds) {
subTasks.push({
title: `Check node: ${chalk.yellow(nodeId)}`,
task: () => self.checkNetworkNodeState(nodeId, 200)
})
}
}
subTasks.push({
title: `Check node: ${chalk.yellow(config.nodeId)}`,
task: () => self.checkNetworkNodeState(config.nodeId, 200)
Expand Down Expand Up @@ -2079,7 +2087,7 @@ export class NodeCommand extends BaseCommand {

/**
* @param {Object} podNames
* @param {string} nodeIds
* @param {string[]} nodeIds
* @param {{title: string, task: () => Promise<void>}[]} subTasks
*/
startNodes (podNames, nodeIds, subTasks) {
Expand Down
11 changes: 7 additions & 4 deletions test/test_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,14 @@ export function bootstrapNetwork (testName, argv,
// cache this, because `solo node setup.finalize()` will reset it to false
try {
await expect(nodeCmd.setup(argv)).resolves.toBeTruthy()
expect(nodeCmd.getUnusedConfigs(NodeCommand.SETUP_CONFIGS_NAME)).toEqual([
const expectedUnusedConfigs = [

Check warning on line 260 in test/test_util.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

test/test_util.js#L260

Avoid using global variables
flags.appConfig.constName,
flags.devMode.constName,
flags.localBuildPath.constName // TODO: deterministic flag switch
])
flags.devMode.constName
]
if (bootstrapResp.opts.configManager.getFlag(flags.hederaImage)) {
expectedUnusedConfigs.push(flags.hederaImage.constName)
}
expect(nodeCmd.getUnusedConfigs(NodeCommand.SETUP_CONFIGS_NAME)).toEqual(expectedUnusedConfigs)
} catch (e) {
nodeCmd.logger.showUserError(e)
expect(e).toBeNull()
Expand Down

0 comments on commit aa9e4ce

Please sign in to comment.