Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert to sleep and remove jest.runAllTicks from e2e test #255

Merged
merged 5 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/commands/mirror_node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export class MirrorNodeCommand extends BaseCommand {
ctx.config = {
namespace: self.configManager.getFlag(flags.namespace),
chartDir: self.configManager.getFlag(flags.chartDirectory),
deployHederaExplorer: self.configManager.getFlag(flags.deployHederaExplorer)
deployHederaExplorer: self.configManager.getFlag(flags.deployHederaExplorer),
fstChartVersion: this.configManager.getFlag(flags.fstChartVersion)
}

ctx.config.chartPath = await self.prepareChartPath(ctx.config.chartDir,
Expand Down Expand Up @@ -104,7 +105,8 @@ export class MirrorNodeCommand extends BaseCommand {
ctx.config.namespace,
constants.FULLSTACK_DEPLOYMENT_CHART,
ctx.config.chartPath,
ctx.config.valuesArg
ctx.config.valuesArg,
ctx.config.fstChartVersion
)
}
}
Expand Down Expand Up @@ -214,7 +216,8 @@ export class MirrorNodeCommand extends BaseCommand {

ctx.config = {
namespace: self.configManager.getFlag(flags.namespace),
chartDir: self.configManager.getFlag(flags.chartDirectory)
chartDir: self.configManager.getFlag(flags.chartDirectory),
fstChartVersion: this.configManager.getFlag(flags.fstChartVersion)
}

ctx.config.chartPath = await self.prepareChartPath(ctx.config.chartDir,
Expand All @@ -238,7 +241,8 @@ export class MirrorNodeCommand extends BaseCommand {
ctx.config.namespace,
constants.FULLSTACK_DEPLOYMENT_CHART,
ctx.config.chartPath,
ctx.config.valuesArg
ctx.config.valuesArg,
ctx.config.fstChartVersion
)
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/commands/network.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ export class NetworkCommand extends BaseCommand {
ctx.config.namespace,
constants.FULLSTACK_DEPLOYMENT_CHART,
ctx.config.chartPath,
ctx.config.valuesArg
ctx.config.valuesArg,
ctx.config.fstChartVersion
)
}
},
Expand Down
14 changes: 11 additions & 3 deletions src/commands/node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class NodeCommand extends BaseCommand {
* @returns {Promise<void>}
*/
async close () {
this.accountManager.close()
if (this._portForwards) {
for (const srv of this._portForwards) {
await this.k8.stopPortForward(srv)
Expand Down Expand Up @@ -1113,7 +1114,8 @@ export class NodeCommand extends BaseCommand {
keyFormat: self.configManager.getFlag(flags.keyFormat),
devMode: self.configManager.getFlag(flags.devMode),
chartDir: self.configManager.getFlag(flags.chartDirectory),
curDate: new Date()
curDate: new Date(),
fstChartVersion: self.configManager.getFlag(flags.fstChartVersion)
}

await self.initializeSetup(config, self.configManager, self.k8)
Expand All @@ -1124,6 +1126,9 @@ export class NodeCommand extends BaseCommand {
ctx.config.chartPath = await self.prepareChartPath(ctx.config.chartDir,
constants.FULLSTACK_TESTING_CHART, constants.FULLSTACK_DEPLOYMENT_CHART)

// initialize Node Client with existing network nodes prior to adding the new node which isn't functioning, yet
await this.accountManager.loadNodeClient(ctx.config.namespace)

self.logger.debug('Initialized config', { config })
}
},
Expand Down Expand Up @@ -1163,15 +1168,16 @@ export class NodeCommand extends BaseCommand {
let valuesArg = ''
let index = 0
for (const node of values.hedera.nodes) {
valuesArg += `--set hedera.nodes[${index}].name=${node.name} --set hedera.nodes[${index}].accountId=${node.accountId} `
valuesArg += ` --set "hedera.nodes[${index}].accountId=${node.accountId}" --set "hedera.nodes[${index}].name=${node.name}"`
index++
}

await self.chartManager.upgrade(
ctx.config.namespace,
constants.FULLSTACK_DEPLOYMENT_CHART,
ctx.config.chartPath,
valuesArg
valuesArg,
ctx.config.fstChartVersion
)
ctx.config.allNodeIds = [...ctx.config.existingNodeIds, ...ctx.config.nodeIds]
}
Expand Down Expand Up @@ -1423,6 +1429,8 @@ export class NodeCommand extends BaseCommand {
await tasks.run()
} catch (e) {
throw new FullstackTestingError(`Error in setting up nodes: ${e.message}`, e)
} finally {
await self.close()
}

return true
Expand Down
9 changes: 7 additions & 2 deletions src/core/chart_manager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,15 @@ export class ChartManager {
return true
}

async upgrade (namespaceName, chartReleaseName, chartPath, valuesArg = '') {
async upgrade (namespaceName, chartReleaseName, chartPath, valuesArg = '', version = '') {
let versionArg = ''
if (version) {
versionArg = `--version ${version}`
}

try {
this.logger.debug(chalk.cyan('> upgrading chart:'), chalk.yellow(`${chartReleaseName}`))
await this.helm.upgrade(`-n ${namespaceName} ${chartReleaseName} ${chartPath} --reuse-values ${valuesArg}`)
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)
Expand Down
4 changes: 2 additions & 2 deletions src/core/k8.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -712,11 +712,11 @@ export class K8 {
await new Promise((resolve, reject) => {
server.close((e) => {
if (e) {
if (e.message.contains('Server is not running')) {
if (e.message?.includes('Server is not running')) {
this.logger.debug(`Server not running, port-forwarder [${server.info}]`)
resolve()
} else {
this.logger.debug(`Failed to stop port-forwarder [${server.info}]: ${e.message}`)
this.logger.debug(`Failed to stop port-forwarder [${server.info}]: ${e.message}`, e)
reject(e)
}
} else {
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/commands/mirror_node.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('MirrorNodeCommand', () => {

afterAll(async () => {
await k8.deleteNamespace(namespace)
await accountManager.close()
})

afterEach(async () => {
Expand All @@ -74,7 +75,7 @@ describe('MirrorNodeCommand', () => {
mirrorNodeCmd.logger.showUserError(e)
expect(e).toBeNull()
}
}, 360000)
}, 480000)

it('mirror node api and hedera explorer should success', async () => {
await accountManager.loadNodeClient(namespace)
Expand Down
7 changes: 3 additions & 4 deletions test/e2e/commands/node.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import {
beforeAll,
describe,
expect,
it,
jest
it
} from '@jest/globals'
import { flags } from '../../../src/commands/index.mjs'
import {
Expand Down Expand Up @@ -70,7 +69,7 @@ describe.each([
}, 120000)

afterAll(async () => {
// await k8.deleteNamespace(namespace)
await k8.deleteNamespace(namespace)
}, 120000)

describe(`Node should have started successfully [mode ${input.mode}, release ${input.releaseTag}, keyFormat: ${input.keyFormat}]`, () => {
Expand Down Expand Up @@ -230,7 +229,7 @@ function balanceQueryShouldSucceed (accountManager, nodeCmd, namespace) {
nodeCmd.logger.showUserError(e)
expect(e).toBeNull()
}
jest.runAllTicks()
await sleep(1000)
}, 120000)
}

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/commands/relay.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ describe('RelayCommand', () => {
relayCmd.logger.showUserError(e)
expect(e).toBeNull()
}
}, 60000)
}, 120000)
})