From 33c04015dd90564ca71516c079ffcb7083234d1e Mon Sep 17 00:00:00 2001 From: Ivo Yankov Date: Mon, 6 Jan 2025 17:21:36 +0200 Subject: [PATCH] fix: issues in e2e tests Signed-off-by: Ivo Yankov --- src/commands/cluster/handlers.ts | 14 ++++++++++++-- src/commands/cluster/tasks.ts | 6 +++--- test/e2e/commands/cluster.test.ts | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/commands/cluster/handlers.ts b/src/commands/cluster/handlers.ts index 0730c1e8a..0564e2985 100644 --- a/src/commands/cluster/handlers.ts +++ b/src/commands/cluster/handlers.ts @@ -22,6 +22,7 @@ import * as ContextFlags from './flags.js'; import {RemoteConfigTasks} from '../../core/config/remote/remote_config_tasks.js'; import type {RemoteConfigManager} from '../../core/config/remote/remote_config_manager.js'; import {connectConfigBuilder, resetConfigBuilder, setupConfigBuilder} from './configs.js'; +import {SoloError} from "../../core/errors.js"; export class ClusterCommandHandlers implements CommandHandlers { readonly parent: BaseCommand; @@ -110,7 +111,12 @@ export class ClusterCommandHandlers implements CommandHandlers { null, ); - await action(argv, this); + try { + await action(argv, this); + } catch (e: Error | any) { + throw new SoloError('Error on cluster setup', e); + } + return true; } @@ -131,7 +137,11 @@ export class ClusterCommandHandlers implements CommandHandlers { null, ); - await action(argv, this); + try { + await action(argv, this); + } catch (e: Error | any) { + throw new SoloError('Error on cluster reset', e); + } return true; } } diff --git a/src/commands/cluster/tasks.ts b/src/commands/cluster/tasks.ts index e5455b58b..1ca458b27 100644 --- a/src/commands/cluster/tasks.ts +++ b/src/commands/cluster/tasks.ts @@ -310,10 +310,10 @@ export class ClusterCommandTasks { ); } - async acquireNewLease(argv) { - const lease = await this.parent.getLeaseManager().create(); + acquireNewLease(argv) { return new Task('Acquire new lease', async (ctx: any, task: ListrTaskWrapper) => { - ListrLease.newAcquireLeaseTask(lease, task); + const lease = await this.parent.getLeaseManager().create(); + return ListrLease.newAcquireLeaseTask(lease, task); }); } diff --git a/test/e2e/commands/cluster.test.ts b/test/e2e/commands/cluster.test.ts index 38ba20aa4..d0bd6e6b3 100644 --- a/test/e2e/commands/cluster.test.ts +++ b/test/e2e/commands/cluster.test.ts @@ -111,7 +111,7 @@ describe('ClusterCommand', () => { it('function showInstalledChartList should return right true', async () => { // @ts-ignore - await expect(clusterCmd.showInstalledChartList()).to.eventually.be.undefined; + await expect(clusterCmd.handlers.tasks.showInstalledChartList()).to.eventually.be.undefined; }).timeout(Duration.ofMinutes(1).toMillis()); // helm list would return an empty list if given invalid namespace