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: flag check of node logs command and incorrect download source #848

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/commands/node/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ export const logsConfigBuilder = function (argv, ctx, task) {
/** @type {{namespace: string, nodeAliases: NodeAliases}} */
const config = {
namespace: this.configManager.getFlag(flags.namespace),
nodeAliases: helpers.parseNodeAliases(this.configManager.getFlag(flags.nodeAliasesUnparsed))
nodeAliases: helpers.parseNodeAliases(this.configManager.getFlag(flags.nodeAliasesUnparsed)),
nodeAliasesUnparsed: this.configManager.getFlag(flags.nodeAliasesUnparsed)
}
ctx.config = config
return config
Expand Down
2 changes: 1 addition & 1 deletion src/commands/node/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const ADD_EXECUTE_FLAGS = {
}

export const LOGS_FLAGS = {
requiredFlags: [flags.nodeAliasesUnparsed],
requiredFlags: [flags.namespace, flags.nodeAliasesUnparsed],
requiredFlagsWithDisabledPrompt: [],
optionalFlags: []
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ async function getNodeLog (pod: V1Pod, namespace: string, timeString: string, k8
await k8.copyTo(podName, ROOT_CONTAINER, sourcePath, `${HEDERA_HAPI_PATH}`)
await k8.execContainer(podName, ROOT_CONTAINER, `chmod 0755 ${HEDERA_HAPI_PATH}/${scriptName}`)
await k8.execContainer(podName, ROOT_CONTAINER, `${HEDERA_HAPI_PATH}/${scriptName}`)
await k8.copyFrom(podName, ROOT_CONTAINER, `${HEDERA_HAPI_PATH}/${podName}.zip`, targetDir)
await k8.copyFrom(podName, ROOT_CONTAINER, `${HEDERA_HAPI_PATH}/data/${podName}.zip`, targetDir)
} catch (e: Error | any) {
// not throw error here, so we can continue to finish downloading logs from other pods
// and also delete namespace in the end
Expand Down
16 changes: 15 additions & 1 deletion test/test_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
AccountCreateTransaction, Hbar, HbarUnit,
PrivateKey
} from '@hashgraph/sdk'
import { MINUTES, ROOT_CONTAINER, SECONDS } from '../src/core/constants.ts'
import { MINUTES, ROOT_CONTAINER, SECONDS, SOLO_LOGS_DIR } from '../src/core/constants.ts'
import crypto from 'crypto'
import { AccountCommand } from '../src/commands/account.ts'
import { SoloError } from '../src/core/errors.ts'
Expand Down Expand Up @@ -292,6 +292,20 @@
expect.fail()
}
}).timeout(30 * MINUTES)

it('node log command should work', async () => {
try {
await expect(nodeCmd.handlers.logs(argv)).to.eventually.be.ok

const soloLogPath = path.join(SOLO_LOGS_DIR, 'solo.log')
const soloLog = fs.readFileSync(soloLogPath, 'utf8')

Check warning on line 301 in test/test_util.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

test/test_util.ts#L301

The application dynamically constructs file or path information.

expect(soloLog).to.not.contain('failed to download logs')
} catch (e) {
nodeCmd.logger.showUserError(e)
expect.fail()
}
}).timeout(30 * MINUTES)
}
})

Expand Down
Loading