1
1
// SPDX-License-Identifier: Apache-2.0
2
2
3
- import { after , afterEach , describe } from 'mocha' ;
3
+ import { after , describe } from 'mocha' ;
4
4
import { expect } from 'chai' ;
5
5
import each from 'mocha-each' ;
6
6
7
7
import { 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' ;
9
14
import * as version from '../../../version.js' ;
10
15
import { sleep } from '../../../src/core/helpers.js' ;
11
16
import { RelayCommand } from '../../../src/commands/relay.js' ;
@@ -15,10 +20,12 @@ import {type NetworkNodes} from '../../../src/core/network-nodes.js';
15
20
import { container } from 'tsyringe-neo' ;
16
21
import { InjectTokens } from '../../../src/core/dependency-injection/inject-tokens.js' ;
17
22
import { 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' ;
18
25
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 ) ;
22
29
argv . setArg ( flags . namespace , namespace . name ) ;
23
30
argv . setArg ( flags . releaseTag , HEDERA_PLATFORM_VERSION_TAG ) ;
24
31
argv . setArg ( flags . nodeAliasesUnparsed , 'node1,node2' ) ;
@@ -29,54 +36,65 @@ argv.setArg(flags.soloChartVersion, version.SOLO_CHART_VERSION);
29
36
argv . setArg ( flags . force , true ) ;
30
37
argv . setArg ( flags . relayReleaseTag , flags . relayReleaseTag . definition . defaultValue ) ;
31
38
32
- endToEndTestSuite ( testName , argv , { } , bootstrapResp => {
39
+ endToEndTestSuite ( testName , argv , { } , ( bootstrapResp : BootstrapResponse ) : void => {
33
40
const {
34
41
opts : { k8Factory, logger, commandInvoker} ,
35
42
} = bootstrapResp ;
36
43
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 ) ;
39
47
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 > {
41
54
this . timeout ( Duration . ofMinutes ( 5 ) . toMillis ( ) ) ;
42
55
await container . resolve < NetworkNodes > ( InjectTokens . NetworkNodes ) . getLogs ( namespace ) ;
43
56
await k8Factory . default ( ) . namespaces ( ) . delete ( namespace ) ;
44
57
} ) ;
45
58
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 ( ) ) ;
50
65
51
- argv . setArg ( flags . nodeAliasesUnparsed , relayNodes ) ;
66
+ argv . setArg ( flags . nodeAliasesUnparsed , relayNodes ) ;
52
67
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 ) ) ;
66
81
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 } ####` ) ;
75
96
} ) ;
76
- } catch ( error ) {
77
- logger . showUserError ( error ) ;
78
- expect . fail ( ) ;
79
- }
80
- } ) ;
97
+ } ,
98
+ ) ;
81
99
} ) ;
82
100
} ) ;
0 commit comments