Skip to content

Commit

Permalink
chore(tests): fix bootstrap network issues when we switched to Mocha (#…
Browse files Browse the repository at this point in the history
…708)

Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
jeromy-cannon authored Oct 18, 2024
1 parent 124f842 commit af73379
Show file tree
Hide file tree
Showing 20 changed files with 1,178 additions and 1,206 deletions.
459 changes: 230 additions & 229 deletions test/e2e/commands/account.test.ts

Large diffs are not rendered by default.

374 changes: 187 additions & 187 deletions test/e2e/commands/mirror_node.test.ts

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test/e2e/commands/network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @mocha-environment steps
*/
import { it, describe, after, before } from 'mocha'
import { expect } from 'chai'
Expand Down
9 changes: 2 additions & 7 deletions test/e2e/commands/node_add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @mocha-environment steps
*/
import { describe } from 'mocha'

import { testNodeAdd } from '../../test_add.ts'
import { MINUTES } from '../../../src/core/constants.ts'

describe('Node add with released hedera', () => {
const localBuildPath = ''
testNodeAdd(localBuildPath)
}).timeout(3 * MINUTES)
const localBuildPath = ''
testNodeAdd(localBuildPath, 'Node add with released hedera', 3 * MINUTES)
1 change: 0 additions & 1 deletion test/e2e/commands/node_add_local.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @mocha-environment steps
*/
import { describe } from 'mocha'

Expand Down
105 changes: 51 additions & 54 deletions test/e2e/commands/node_delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @mocha-environment steps
*/
import { it, describe, after } from 'mocha'
import { expect } from 'chai'
Expand All @@ -22,7 +21,7 @@ import { flags } from '../../../src/commands/index.ts'
import {
accountCreationShouldSucceed,
balanceQueryShouldSucceed,
bootstrapNetwork,
e2eTestSuite,
getDefaultArgv,
HEDERA_PLATFORM_VERSION_TAG
} from '../../test_util.ts'
Expand All @@ -32,63 +31,61 @@ import { HEDERA_HAPI_PATH, MINUTES, ROOT_CONTAINER } from '../../../src/core/con
import fs from 'fs'
import type { PodName } from '../../../src/types/aliases.ts'

describe('Node delete', async () => {
const namespace = 'node-delete'
const nodeAlias = 'node1'
const argv = getDefaultArgv()
argv[flags.nodeAliasesUnparsed.name] = 'node1,node2,node3,node4'
argv[flags.nodeAlias.name] = nodeAlias
argv[flags.generateGossipKeys.name] = true
argv[flags.generateTlsKeys.name] = true
argv[flags.persistentVolumeClaims.name] = true
// set the env variable SOLO_CHARTS_DIR if developer wants to use local Solo charts
argv[flags.chartDirectory.name] = process.env.SOLO_CHARTS_DIR ?? undefined
argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG
argv[flags.namespace.name] = namespace
argv[flags.quiet.name] = true
const bootstrapResp = await bootstrapNetwork(namespace, argv)
const nodeCmd = bootstrapResp.cmd.nodeCmd
const accountCmd = bootstrapResp.cmd.accountCmd
const k8 = bootstrapResp.opts.k8
const namespace = 'node-delete'
const nodeAlias = 'node1'
const argv = getDefaultArgv()
argv[flags.nodeAliasesUnparsed.name] = 'node1,node2,node3,node4'
argv[flags.nodeAlias.name] = nodeAlias
argv[flags.generateGossipKeys.name] = true
argv[flags.generateTlsKeys.name] = true
argv[flags.persistentVolumeClaims.name] = true
// set the env variable SOLO_CHARTS_DIR if developer wants to use local Solo charts
argv[flags.chartDirectory.name] = process.env.SOLO_CHARTS_DIR ?? undefined
argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG
argv[flags.namespace.name] = namespace
argv[flags.quiet.name] = true
e2eTestSuite(namespace, argv, undefined, undefined, undefined, undefined, undefined, undefined, true, (bootstrapResp) => {
describe('Node delete', async () => {
const nodeCmd = bootstrapResp.cmd.nodeCmd
const accountCmd = bootstrapResp.cmd.accountCmd
const k8 = bootstrapResp.opts.k8

after(async function () {
this.timeout(10 * MINUTES)
await getNodeLogs(k8, namespace)
await k8.deleteNamespace(namespace)
})
after(async function () {
this.timeout(10 * MINUTES)
await getNodeLogs(k8, namespace)
await k8.deleteNamespace(namespace)
})

it('should succeed with init command', async () => {
const status = await accountCmd.init(argv)
expect(status).to.be.ok
}).timeout(8 * MINUTES)
it('should succeed with init command', async () => {
const status = await accountCmd.init(argv)
expect(status).to.be.ok
}).timeout(8 * MINUTES)

it('should delete a node from the network successfully', async () => {
await nodeCmd.delete(argv)
expect(nodeCmd.getUnusedConfigs(NodeCommand.DELETE_CONFIGS_NAME)).to.deep.equal([
flags.app.constName,
flags.devMode.constName,
flags.endpointType.constName,
flags.quiet.constName
])
it('should delete a node from the network successfully', async () => {
await nodeCmd.delete(argv)
expect(nodeCmd.getUnusedConfigs(NodeCommand.DELETE_CONFIGS_NAME)).to.deep.equal([
flags.app.constName,
flags.devMode.constName,
flags.endpointType.constName,
flags.quiet.constName
])

// @ts-ignore in order to access the private member
await nodeCmd.accountManager.close()
}).timeout(10 * MINUTES)
await bootstrapResp.opts.accountManager.close()
}).timeout(10 * MINUTES)

// @ts-ignore in order to access the private member
balanceQueryShouldSucceed(nodeCmd.accountManager, nodeCmd, namespace)
balanceQueryShouldSucceed(bootstrapResp.opts.accountManager, nodeCmd, namespace)

// @ts-ignore in order to access the private member
accountCreationShouldSucceed(nodeCmd.accountManager, nodeCmd, namespace)
accountCreationShouldSucceed(bootstrapResp.opts.accountManager, nodeCmd, namespace)

it('config.txt should no longer contain removed node alias name', async () => {
// read config.txt file from first node, read config.txt line by line, it should not contain value of nodeAlias
const pods = await k8.getPodsByLabel(['solo.hedera.com/type=network-node'])
const podName = pods[0].metadata.name as PodName
const tmpDir = getTmpDir()
await k8.copyFrom(podName, ROOT_CONTAINER, `${HEDERA_HAPI_PATH}/config.txt`, tmpDir)
const configTxt = fs.readFileSync(`${tmpDir}/config.txt`, 'utf8')
console.log('config.txt:', configTxt)
expect(configTxt).not.to.contain(nodeAlias)
}).timeout(10 * MINUTES)
it('config.txt should no longer contain removed node alias name', async () => {
// read config.txt file from first node, read config.txt line by line, it should not contain value of nodeAlias
const pods = await k8.getPodsByLabel(['solo.hedera.com/type=network-node'])
const podName = pods[0].metadata.name as PodName
const tmpDir = getTmpDir()
await k8.copyFrom(podName, ROOT_CONTAINER, `${HEDERA_HAPI_PATH}/config.txt`, tmpDir)
const configTxt = fs.readFileSync(`${tmpDir}/config.txt`, 'utf8')
console.log('config.txt:', configTxt)
expect(configTxt).not.to.contain(nodeAlias)
}).timeout(10 * MINUTES)
})
})
45 changes: 22 additions & 23 deletions test/e2e/commands/node_local_hedera.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,40 @@
* limitations under the License.
*
*/
import { describe, after } from 'mocha'
import { describe } from 'mocha'

import { flags } from '../../../src/commands/index.ts'
import {
bootstrapNetwork,
e2eTestSuite,
getDefaultArgv,
TEST_CLUSTER
} from '../../test_util.ts'
import { getNodeLogs } from '../../../src/core/helpers.ts'
import { MINUTES } from '../../../src/core/constants.ts'
import type { K8 } from '../../../src/core/index.ts'

describe('Node local build', () => {
const LOCAL_HEDERA = 'local-hedera-app'
const argv = getDefaultArgv()
argv[flags.nodeAliasesUnparsed.name] = 'node1,node2,node3'
argv[flags.generateGossipKeys.name] = true
argv[flags.generateTlsKeys.name] = true
argv[flags.clusterName.name] = TEST_CLUSTER
// set the env variable SOLO_CHARTS_DIR if developer wants to use local Solo charts
argv[flags.chartDirectory.name] = process.env.SOLO_CHARTS_DIR ?? undefined
argv[flags.quiet.name] = true
const LOCAL_HEDERA = 'local-hedera-app'
const argv = getDefaultArgv()
argv[flags.nodeAliasesUnparsed.name] = 'node1,node2,node3'
argv[flags.generateGossipKeys.name] = true
argv[flags.generateTlsKeys.name] = true
argv[flags.clusterName.name] = TEST_CLUSTER
// set the env variable SOLO_CHARTS_DIR if developer wants to use local Solo charts
argv[flags.chartDirectory.name] = process.env.SOLO_CHARTS_DIR ?? undefined
argv[flags.quiet.name] = true

let hederaK8: K8
after(async function () {
this.timeout(10 * MINUTES)
await getNodeLogs(hederaK8, LOCAL_HEDERA)
await hederaK8.deleteNamespace(LOCAL_HEDERA)
})
let hederaK8: K8
console.log('Starting local build for Hedera app')
argv[flags.localBuildPath.name] = 'node1=../hedera-services/hedera-node/data/,../hedera-services/hedera-node/data,node3=../hedera-services/hedera-node/data'
argv[flags.namespace.name] = LOCAL_HEDERA

describe('Node for hedera app should start successfully', async () => {
console.log('Starting local build for Hedera app')
argv[flags.localBuildPath.name] = 'node1=../hedera-services/hedera-node/data/,../hedera-services/hedera-node/data,node3=../hedera-services/hedera-node/data'
argv[flags.namespace.name] = LOCAL_HEDERA
const bootstrapResp = await bootstrapNetwork(LOCAL_HEDERA, argv)
e2eTestSuite(LOCAL_HEDERA, argv, undefined, undefined, undefined, undefined, undefined, undefined, true, (bootstrapResp) => {
describe('Node for hedera app should have started successfully', () => {
hederaK8 = bootstrapResp.opts.k8

it('get the logs and delete the namespace', async function () {
await getNodeLogs(hederaK8, LOCAL_HEDERA)
await hederaK8.deleteNamespace(LOCAL_HEDERA)
}).timeout(10 * MINUTES)
})
})
52 changes: 23 additions & 29 deletions test/e2e/commands/node_local_ptt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,36 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @mocha-environment steps
*/
import { describe, after } from 'mocha'
import { describe, } from 'mocha'

import { flags } from '../../../src/commands/index.ts'
import { bootstrapNetwork, getDefaultArgv, TEST_CLUSTER } from '../../test_util.ts'
import { e2eTestSuite, getDefaultArgv, TEST_CLUSTER } from '../../test_util.ts'
import { getNodeLogs } from '../../../src/core/helpers.ts'
import { MINUTES } from '../../../src/core/constants.ts'
import type { K8 } from '../../../src/core/index.ts'

describe('Node local build', () => {
const LOCAL_PTT = 'local-ptt-app'
const argv = getDefaultArgv()
argv[flags.nodeAliasesUnparsed.name] = 'node1,node2,node3'
argv[flags.generateGossipKeys.name] = true
argv[flags.generateTlsKeys.name] = true
argv[flags.clusterName.name] = TEST_CLUSTER
// set the env variable SOLO_CHARTS_DIR if developer wants to use local Solo charts
argv[flags.chartDirectory.name] = process.env.SOLO_CHARTS_DIR ?? undefined
argv[flags.quiet.name] = true
const LOCAL_PTT = 'local-ptt-app'
const argv = getDefaultArgv()
argv[flags.nodeAliasesUnparsed.name] = 'node1,node2,node3'
argv[flags.generateGossipKeys.name] = true
argv[flags.generateTlsKeys.name] = true
argv[flags.clusterName.name] = TEST_CLUSTER
// set the env variable SOLO_CHARTS_DIR if developer wants to use local Solo charts
argv[flags.chartDirectory.name] = process.env.SOLO_CHARTS_DIR ?? undefined
argv[flags.quiet.name] = true
console.log('Starting local build for Platform app')
argv[flags.localBuildPath.name] = '../hedera-services/platform-sdk/sdk/data,node1=../hedera-services/platform-sdk/sdk/data,node2=../hedera-services/platform-sdk/sdk/data'
argv[flags.app.name] = 'PlatformTestingTool.jar'
argv[flags.appConfig.name] = '../hedera-services/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/resources/FCMFCQ-Basic-2.5k-5m.json'
argv[flags.namespace.name] = LOCAL_PTT

let pttK8: K8
after(async function () {
this.timeout(2 * MINUTES)
e2eTestSuite(LOCAL_PTT, argv, undefined, undefined, undefined, undefined, undefined, undefined, true, (bootstrapResp) => {
describe('Node for platform app should start successfully', () => {
const pttK8 = bootstrapResp.opts.k8

await getNodeLogs(pttK8, LOCAL_PTT)
await pttK8.deleteNamespace(LOCAL_PTT)
})

describe('Node for platform app should start successfully', async () => {
console.log('Starting local build for Platform app')
argv[flags.localBuildPath.name] = '../hedera-services/platform-sdk/sdk/data,node1=../hedera-services/platform-sdk/sdk/data,node2=../hedera-services/platform-sdk/sdk/data'
argv[flags.app.name] = 'PlatformTestingTool.jar'
argv[flags.appConfig.name] = '../hedera-services/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/resources/FCMFCQ-Basic-2.5k-5m.json'
argv[flags.namespace.name] = LOCAL_PTT
const bootstrapResp = await bootstrapNetwork(LOCAL_PTT, argv)
pttK8 = bootstrapResp.opts.k8
it('get the logs and delete the namespace',async function () {
await getNodeLogs(pttK8, LOCAL_PTT)
await pttK8.deleteNamespace(LOCAL_PTT)
}).timeout(2 * MINUTES)
})
})
7 changes: 1 addition & 6 deletions test/e2e/commands/node_pem_kill.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @mocha-environment steps
*/
import { describe } from 'mocha'

import { e2eNodeKeyRefreshTest } from '../e2e_node_util.ts'

describe('NodeCommand', () => {
e2eNodeKeyRefreshTest('node-cmd-e2e-pem-kill', 'kill')
})
e2eNodeKeyRefreshTest('node-cmd-e2e-pem-kill', 'kill')
7 changes: 1 addition & 6 deletions test/e2e/commands/node_pem_stop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @mocha-environment steps
*/
import { describe } from 'mocha'

import { e2eNodeKeyRefreshTest } from '../e2e_node_util.ts'

describe('NodeCommand', () => {
e2eNodeKeyRefreshTest('node-cmd-e2e-pem-stop', 'stop')
})
e2eNodeKeyRefreshTest('node-cmd-e2e-pem-stop', 'stop')
Loading

0 comments on commit af73379

Please sign in to comment.