Skip to content

Commit

Permalink
fix: stabilize the upgrade tests and disable the node add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Klick <[email protected]>
  • Loading branch information
nathanklick committed Nov 21, 2024
1 parent f6c9acd commit ed3576a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/flow-pull-request-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ jobs:
- { name: "Node PEM Kill", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-pem-kill-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-pem-kill-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-pem-kill-coverage-report }}" }
- { name: "Node Local Hedera", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-local-hedera-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-local-hedera-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-local-hedera-coverage-report }}" }
- { name: "Node Local PTT", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-local-ptt-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-local-ptt-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-local-ptt-coverage-report }}" }
- { name: "Node Add", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-add-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-add-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-add-coverage-report }}" }
- { name: "Node Add Local", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-add-local-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-add-local-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-add-local-coverage-report }}" }
- { name: "Node Add - Separate commands", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-add-separate-commands-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-add-separate-commands-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-add-separate-commands-coverage-report }}" }
# Node Add tests are disabled and are not viable for the amount of memory available. The teacher crashes during
# the reconnect attempt.
#- { name: "Node Add", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-add-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-add-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-add-coverage-report }}" }
#- { name: "Node Add Local", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-add-local-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-add-local-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-add-local-coverage-report }}" }
#- { name: "Node Add - Separate commands", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-add-separate-commands-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-add-separate-commands-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-add-separate-commands-coverage-report }}" }
- { name: "Node Update", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-update-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-update-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-update-coverage-report }}" }
- { name: "Node Update - Separate commands", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-update-separate-commands-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-update-separate-commands-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-update-separate-commands-coverage-report }}" }
- { name: "Node Delete", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-delete-coverage-report }}" }
Expand Down
6 changes: 3 additions & 3 deletions src/commands/node/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,15 @@ export class NodeCommandTasks {
const { upgradeZipHash } = ctx
const { nodeClient, freezeAdminPrivateKey } = ctx.config
try {
// transfer some tiny amount to the freeze admin account
// await this.accountManager.transferAmount(constants.TREASURY_ACCOUNT_ID, FREEZE_ADMIN_ACCOUNT, 100000)

// query the balance
const balance = await new AccountBalanceQuery()
.setAccountId(FREEZE_ADMIN_ACCOUNT)
.execute(nodeClient)
this.logger.debug(`Freeze admin account balance: ${balance.hbars}`)

// transfer some tiny amount to the freeze admin account
await this.accountManager.transferAmount(constants.TREASURY_ACCOUNT_ID, FREEZE_ADMIN_ACCOUNT, 100000)

// set operator of freeze transaction as freeze admin account
nodeClient.setOperator(FREEZE_ADMIN_ACCOUNT, freezeAdminPrivateKey)

Expand Down
37 changes: 24 additions & 13 deletions src/core/account_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,25 +214,19 @@ export class AccountManager {
* @returns a node client that can be used to call transactions
*/
async _getNodeClient (namespace: string, networkNodeServicesMap: Map<string, NetworkNodeServices>, operatorId: string,
operatorKey: string) {
const nodes = {}
operatorKey: string, useFirstNodeOnly = true) {
let nodes = {}
try {
let localPort = constants.LOCAL_NODE_START_PORT

for (const networkNodeService of networkNodeServicesMap.values()) {
const usePortForward = this.shouldUseLocalHostPortForward(networkNodeService)
const host = usePortForward ? '127.0.0.1' : networkNodeService.haProxyLoadBalancerIp as string
const port = +networkNodeService.haProxyGrpcPort
const targetPort = usePortForward ? localPort : port
const addlNode = await this.configureNodeAccess(networkNodeService, localPort, networkNodeServicesMap.size)
nodes = { ...nodes, ...addlNode }
localPort++

if (usePortForward && this._portForwards.length < networkNodeServicesMap.size) {
this._portForwards.push(await this.k8.portForward(networkNodeService.haProxyPodName, localPort, port))
if (useFirstNodeOnly) {
break
}

// @ts-ignore
nodes[`${host}:${targetPort}`] = AccountId.fromString((networkNodeService.accountId as string))
await this.k8.testConnection(host, targetPort)
localPort++
}

this.logger.debug(`creating client from network configuration: ${JSON.stringify(nodes)}`)
Expand All @@ -250,6 +244,23 @@ export class AccountManager {
}
}

private async configureNodeAccess (networkNodeService: NetworkNodeServices, localPort: number, totalNodes: number) {
const obj = {}
const usePortForward = this.shouldUseLocalHostPortForward(networkNodeService)
const host = usePortForward ? '127.0.0.1' : networkNodeService.haProxyLoadBalancerIp as string
const port = +networkNodeService.haProxyGrpcPort
const targetPort = usePortForward ? localPort : port

if (usePortForward && this._portForwards.length < totalNodes) {
this._portForwards.push(await this.k8.portForward(networkNodeService.haProxyPodName, localPort, port))
}

await this.k8.testConnection(host, targetPort)
obj[`${host}:${targetPort}`] = AccountId.fromString((networkNodeService.accountId as string))

return obj
}

/**
* Gets a Map of the Hedera node services and the attributes needed
* @param namespace - the namespace of the solo network deployment
Expand Down

0 comments on commit ed3576a

Please sign in to comment.