11// SPDX-License-Identifier: Apache-2.0
22
3- import { after , afterEach , describe } from 'mocha' ;
3+ import { after , describe } from 'mocha' ;
44import { expect } from 'chai' ;
55import each from 'mocha-each' ;
66
77import { Flags as flags } from '../../../src/commands/flags.js' ;
8- import { endToEndTestSuite , getTestCluster , HEDERA_PLATFORM_VERSION_TAG } from '../../test-utility.js' ;
8+ import {
9+ type BootstrapResponse ,
10+ endToEndTestSuite ,
11+ getTestCluster ,
12+ HEDERA_PLATFORM_VERSION_TAG ,
13+ } from '../../test-utility.js' ;
914import * as version from '../../../version.js' ;
1015import { sleep } from '../../../src/core/helpers.js' ;
1116import { RelayCommand } from '../../../src/commands/relay.js' ;
@@ -15,10 +20,12 @@ import {type NetworkNodes} from '../../../src/core/network-nodes.js';
1520import { container } from 'tsyringe-neo' ;
1621import { InjectTokens } from '../../../src/core/dependency-injection/inject-tokens.js' ;
1722import { Argv } from '../../helpers/argv-wrapper.js' ;
23+ import { type ArgvStruct } from '../../../src/types/aliases.js' ;
24+ import { type SoloLogger } from '../../../src/core/logging/solo-logger.js' ;
1825
19- const testName = 'relay-cmd-e2e' ;
20- const namespace = NamespaceName . of ( testName ) ;
21- const argv = Argv . getDefaultArgv ( namespace ) ;
26+ const testName : string = 'relay-cmd-e2e' ;
27+ const namespace : NamespaceName = NamespaceName . of ( testName ) ;
28+ const argv : Argv = Argv . getDefaultArgv ( namespace ) ;
2229argv . setArg ( flags . namespace , namespace . name ) ;
2330argv . setArg ( flags . releaseTag , HEDERA_PLATFORM_VERSION_TAG ) ;
2431argv . setArg ( flags . nodeAliasesUnparsed , 'node1,node2' ) ;
@@ -29,54 +36,65 @@ argv.setArg(flags.soloChartVersion, version.SOLO_CHART_VERSION);
2936argv . setArg ( flags . force , true ) ;
3037argv . setArg ( flags . relayReleaseTag , flags . relayReleaseTag . definition . defaultValue ) ;
3138
32- endToEndTestSuite ( testName , argv , { } , bootstrapResp => {
39+ endToEndTestSuite ( testName , argv , { } , ( bootstrapResp : BootstrapResponse ) : void => {
3340 const {
3441 opts : { k8Factory, logger, commandInvoker} ,
3542 } = bootstrapResp ;
3643
37- describe ( 'RelayCommand' , async ( ) => {
38- const relayCmd = new RelayCommand ( bootstrapResp . opts ) ;
44+ describe ( 'RelayCommand' , async ( ) : Promise < void > => {
45+ const relayCmd : RelayCommand = new RelayCommand ( bootstrapResp . opts ) ;
46+ const testLogger : SoloLogger = container . resolve ( InjectTokens . SoloLogger ) ;
3947
40- after ( async function ( ) {
48+ afterEach ( async ( ) : Promise < void > => {
49+ // wait for k8s to finish destroying containers from relay destroy
50+ await sleep ( Duration . ofMillis ( 5 ) ) ;
51+ } ) ;
52+
53+ after ( async function ( ) : Promise < void > {
4154 this . timeout ( Duration . ofMinutes ( 5 ) . toMillis ( ) ) ;
4255 await container . resolve < NetworkNodes > ( InjectTokens . NetworkNodes ) . getLogs ( namespace ) ;
4356 await k8Factory . default ( ) . namespaces ( ) . delete ( namespace ) ;
4457 } ) ;
4558
46- afterEach ( async ( ) => await sleep ( Duration . ofMillis ( 5 ) ) ) ;
47-
48- each ( [ 'node1' , 'node1,node2' ] ) . it ( 'relay deploy and destroy should work with $value' , async function ( relayNodes ) {
49- this . timeout ( Duration . ofMinutes ( 5 ) . toMillis ( ) ) ;
59+ each ( [ 'node1' , 'node1,node2' ] ) . describe (
60+ 'relay and deploy and destroy for each' ,
61+ async ( relayNodes : string ) : Promise < void > => {
62+ it ( `relay deploy and destroy should work with ${ relayNodes } ` , async function ( ) : Promise < void > {
63+ testLogger . info ( `#### Running relay deploy for: ${ relayNodes } ####` ) ;
64+ this . timeout ( Duration . ofMinutes ( 5 ) . toMillis ( ) ) ;
5065
51- argv . setArg ( flags . nodeAliasesUnparsed , relayNodes ) ;
66+ argv . setArg ( flags . nodeAliasesUnparsed , relayNodes ) ;
5267
53- try {
54- await commandInvoker . invoke ( {
55- argv : argv ,
56- command : RelayCommand . COMMAND_NAME ,
57- subcommand : 'deploy' ,
58- // @ts -expect-error to access private property
59- callback : async argv => relayCmd . deploy ( argv ) ,
60- } ) ;
61- } catch ( error ) {
62- logger . showUserError ( error ) ;
63- expect . fail ( ) ;
64- }
65- await sleep ( Duration . ofMillis ( 500 ) ) ;
68+ try {
69+ await commandInvoker . invoke ( {
70+ argv : argv ,
71+ command : RelayCommand . COMMAND_NAME ,
72+ subcommand : 'deploy' ,
73+ // @ts -expect-error to access private property
74+ callback : async ( argv : ArgvStruct ) : Promise < boolean > => relayCmd . deploy ( argv ) ,
75+ } ) ;
76+ } catch ( error ) {
77+ logger . showUserError ( error ) ;
78+ expect . fail ( ) ;
79+ }
80+ await sleep ( Duration . ofMillis ( 500 ) ) ;
6681
67- // test relay destroy
68- try {
69- await commandInvoker . invoke ( {
70- argv : argv ,
71- command : RelayCommand . COMMAND_NAME ,
72- subcommand : 'destroy' ,
73- // @ts -expect-error to access private modifier
74- callback : async argv => relayCmd . destroy ( argv ) ,
82+ testLogger . info ( `#### Running relay destroy for: ${ relayNodes } ####` ) ;
83+ try {
84+ await commandInvoker . invoke ( {
85+ argv : argv ,
86+ command : RelayCommand . COMMAND_NAME ,
87+ subcommand : 'destroy' ,
88+ // @ts -expect-error to access private modifier
89+ callback : async ( argv : ArgvStruct ) : Promise < boolean > => relayCmd . destroy ( argv ) ,
90+ } ) ;
91+ } catch ( error ) {
92+ logger . showUserError ( error ) ;
93+ expect . fail ( ) ;
94+ }
95+ testLogger . info ( `#### Finished relay deploy and destroy for: ${ relayNodes } ####` ) ;
7596 } ) ;
76- } catch ( error ) {
77- logger . showUserError ( error ) ;
78- expect . fail ( ) ;
79- }
80- } ) ;
97+ } ,
98+ ) ;
8199 } ) ;
82100} ) ;
0 commit comments