2
2
3
3
import { describe } from 'mocha' ;
4
4
5
+ import * as semver from 'semver' ;
5
6
import { Flags } from '../../../src/commands/flags.js' ;
6
- import { getTestCacheDirectory , getTestCluster } from '../../test-utility.js' ;
7
+ import { getTestCacheDirectory , getTestCluster , HEDERA_PLATFORM_VERSION_TAG } from '../../test-utility.js' ;
7
8
import { main } from '../../../src/index.js' ;
8
9
import { resetForTest } from '../../test-container.js' ;
9
10
import {
@@ -73,6 +74,9 @@ describe('Dual Cluster Full E2E Test', async function dualClusterFullEndToEndTes
73
74
const testCacheDirectory : string = getTestCacheDirectory ( testName ) ;
74
75
let testLogger : SoloWinstonLogger ;
75
76
const createdAccountIds : string [ ] = [ ] ;
77
+ const enableLocalBuildPathTesting : boolean = process . env . SOLO_LOCAL_BUILD_PATH_TESTING ?. toLowerCase ( ) === 'true' ;
78
+ const localBuildPath : string = process . env . SOLO_LOCAL_BUILD_PATH || '../hiero-consensus-node/hedera-node/data' ;
79
+ const localBuildReleaseTag : string = process . env . SOLO_LOCAL_BUILD_RELEASE_TAG || HEDERA_PLATFORM_VERSION_TAG ;
76
80
77
81
// TODO the kube config context causes issues if it isn't one of the selected clusters we are deploying to
78
82
before ( async ( ) : Promise < void > => {
@@ -157,7 +161,7 @@ describe('Dual Cluster Full E2E Test', async function dualClusterFullEndToEndTes
157
161
} ) ;
158
162
159
163
it ( `${ testName } : network deploy` , async ( ) : Promise < void > => {
160
- await main ( soloNetworkDeployArgv ( deployment ) ) ;
164
+ await main ( soloNetworkDeployArgv ( deployment , enableLocalBuildPathTesting , localBuildReleaseTag ) ) ;
161
165
const k8Factory : K8Factory = container . resolve < K8Factory > ( InjectTokens . K8Factory ) ;
162
166
for ( const [ index , context_ ] of contexts . entries ( ) ) {
163
167
const k8 : K8 = k8Factory . getK8 ( context_ ) ;
@@ -171,7 +175,7 @@ describe('Dual Cluster Full E2E Test', async function dualClusterFullEndToEndTes
171
175
172
176
// TODO node setup still list --node-aliases
173
177
it ( `${ testName } : node setup` , async ( ) : Promise < void > => {
174
- await main ( soloNodeSetupArgv ( deployment ) ) ;
178
+ await main ( soloNodeSetupArgv ( deployment , enableLocalBuildPathTesting , localBuildPath , localBuildReleaseTag ) ) ;
175
179
const k8Factory : K8Factory = container . resolve < K8Factory > ( InjectTokens . K8Factory ) ;
176
180
for ( const context_ of contexts ) {
177
181
const k8 : K8 = k8Factory . getK8 ( context_ ) ;
@@ -181,10 +185,12 @@ describe('Dual Cluster Full E2E Test', async function dualClusterFullEndToEndTes
181
185
PodReference . of ( namespace , pods [ 0 ] . podReference . name ) ,
182
186
ROOT_CONTAINER ,
183
187
) ;
184
- expect (
185
- await k8 . containers ( ) . readByRef ( rootContainer ) . hasFile ( `${ HEDERA_USER_HOME_DIR } /extract-platform.sh` ) ,
186
- 'expect extract-platform.sh to be present on the pods' ,
187
- ) . to . be . true ;
188
+ if ( ! enableLocalBuildPathTesting ) {
189
+ expect (
190
+ await k8 . containers ( ) . readByRef ( rootContainer ) . hasFile ( `${ HEDERA_USER_HOME_DIR } /extract-platform.sh` ) ,
191
+ 'expect extract-platform.sh to be present on the pods' ,
192
+ ) . to . be . true ;
193
+ }
188
194
expect ( await k8 . containers ( ) . readByRef ( rootContainer ) . hasFile ( `${ HEDERA_HAPI_PATH } /data/apps/HederaNode.jar` ) ) . to
189
195
. be . true ;
190
196
expect (
@@ -230,8 +236,14 @@ describe('Dual Cluster Full E2E Test', async function dualClusterFullEndToEndTes
230
236
231
237
it ( `${ testName } : mirror node deploy` , async ( ) : Promise < void > => {
232
238
await main ( soloMirrorNodeDeployArgv ( deployment , testClusterArray [ 1 ] ) ) ;
233
- await verifyMirrorNodeDeployWasSuccessful ( contexts , namespace , testLogger , createdAccountIds ) ;
234
- // TODO validate the new accounts are showing up with the mirror node rest url
239
+ await verifyMirrorNodeDeployWasSuccessful (
240
+ contexts ,
241
+ namespace ,
242
+ testLogger ,
243
+ createdAccountIds ,
244
+ enableLocalBuildPathTesting ,
245
+ localBuildReleaseTag ,
246
+ ) ;
235
247
} ) . timeout ( Duration . ofMinutes ( 10 ) . toMillis ( ) ) ;
236
248
237
249
it ( `${ testName } : explorer deploy` , async ( ) : Promise < void > => {
@@ -336,7 +348,11 @@ function soloNodeKeysArgv(deployment: DeploymentName): string[] {
336
348
return argv ;
337
349
}
338
350
339
- function soloNetworkDeployArgv ( deployment : DeploymentName ) : string [ ] {
351
+ function soloNetworkDeployArgv (
352
+ deployment : DeploymentName ,
353
+ enableLocalBuildPathTesting : boolean ,
354
+ localBuildReleaseTag : string ,
355
+ ) : string [ ] {
340
356
const argv : string [ ] = newArgv ( ) ;
341
357
argv . push (
342
358
'network' ,
@@ -345,13 +361,29 @@ function soloNetworkDeployArgv(deployment: DeploymentName): string[] {
345
361
deployment ,
346
362
optionFromFlag ( Flags . loadBalancerEnabled ) ,
347
363
) ; // have to enable load balancer to resolve cross cluster in multi-cluster
364
+ if ( enableLocalBuildPathTesting ) {
365
+ argv . push ( optionFromFlag ( Flags . releaseTag ) , localBuildReleaseTag ) ;
366
+ }
348
367
argvPushGlobalFlags ( argv , true , true ) ;
349
368
return argv ;
350
369
}
351
370
352
- function soloNodeSetupArgv ( deployment : DeploymentName ) : string [ ] {
371
+ function soloNodeSetupArgv (
372
+ deployment : DeploymentName ,
373
+ enableLocalBuildPathTesting : boolean ,
374
+ localBuildPath : string ,
375
+ localBuildReleaseTag : string ,
376
+ ) : string [ ] {
353
377
const argv : string [ ] = newArgv ( ) ;
354
378
argv . push ( 'node' , 'setup' , optionFromFlag ( Flags . deployment ) , deployment ) ;
379
+ if ( enableLocalBuildPathTesting ) {
380
+ argv . push (
381
+ optionFromFlag ( Flags . localBuildPath ) ,
382
+ localBuildPath ,
383
+ optionFromFlag ( Flags . releaseTag ) ,
384
+ localBuildReleaseTag ,
385
+ ) ;
386
+ }
355
387
argvPushGlobalFlags ( argv , true ) ;
356
388
return argv ;
357
389
}
@@ -421,6 +453,8 @@ async function verifyMirrorNodeDeployWasSuccessful(
421
453
namespace : NamespaceName ,
422
454
testLogger : SoloWinstonLogger ,
423
455
createdAccountIds : string [ ] ,
456
+ enableLocalBuildPathTesting : boolean ,
457
+ localBuildReleaseTag : string ,
424
458
) : Promise < void > {
425
459
const k8Factory : K8Factory = container . resolve < K8Factory > ( InjectTokens . K8Factory ) ;
426
460
const k8 : K8 = k8Factory . getK8 ( contexts [ 1 ] ) ;
@@ -432,11 +466,13 @@ async function verifyMirrorNodeDeployWasSuccessful(
432
466
'app.kubernetes.io/component=rest' ,
433
467
] ) ;
434
468
expect ( mirrorNodeRestPods ) . to . have . lengthOf ( 1 ) ;
469
+
435
470
let portForwarder : ExtendedNetServer ;
436
471
try {
437
472
portForwarder = await k8 . pods ( ) . readByReference ( mirrorNodeRestPods [ 0 ] . podReference ) . portForward ( 5551 , 5551 ) ;
438
473
await sleep ( Duration . ofSeconds ( 2 ) ) ;
439
474
const queryUrl : string = 'http://localhost:5551/api/v1/network/nodes' ;
475
+
440
476
let received : boolean = false ;
441
477
// wait until the transaction reached consensus and retrievable from the mirror node API
442
478
while ( ! received ) {
@@ -445,30 +481,41 @@ async function verifyMirrorNodeDeployWasSuccessful(
445
481
{ method : 'GET' , timeout : 100 , headers : { Connection : 'close' } } ,
446
482
( response : http . IncomingMessage ) : void => {
447
483
response . setEncoding ( 'utf8' ) ;
484
+
448
485
response . on ( 'data' , ( chunk ) : void => {
449
486
// convert chunk to json object
450
- const object : { nodes : unknown [ ] } = JSON . parse ( chunk ) ;
487
+ const object : { nodes : { service_endpoints : unknown [ ] } [ ] } = JSON . parse ( chunk ) ;
451
488
expect (
452
489
object . nodes ?. length ,
453
490
"expect there to be two nodes in the mirror node's copy of the address book" ,
454
491
) . to . equal ( 2 ) ;
455
- // TODO need to enable this, but looks like mirror node currently is getting no service endpoints, hopefully they will be in v0.60+
456
- // expect(
457
- // obj.nodes[0].service_endpoints?.length,
458
- // 'expect there to be at least one service endpoint',
459
- // ).to.be.greaterThan(0);
492
+
493
+ if (
494
+ ( enableLocalBuildPathTesting && semver . gte ( localBuildReleaseTag . slice ( 1 ) , '0.62.0' ) ) ||
495
+ semver . gte ( HEDERA_PLATFORM_VERSION_TAG , '0.62.0' )
496
+ ) {
497
+ expect (
498
+ object . nodes [ 0 ] . service_endpoints ?. length ,
499
+ 'expect there to be at least one service endpoint' ,
500
+ ) . to . be . greaterThan ( 0 ) ;
501
+ }
502
+
460
503
received = true ;
461
504
} ) ;
462
505
} ,
463
506
) ;
507
+
464
508
request . on ( 'error' , ( error : Error ) : void => {
465
509
testLogger . debug ( `problem with request: ${ error . message } ` , error ) ;
466
510
} ) ;
511
+
467
512
request . end ( ) ; // make the request
468
513
await sleep ( Duration . ofSeconds ( 2 ) ) ;
469
514
}
515
+
470
516
for ( const accountId of createdAccountIds ) {
471
517
const accountQueryUrl : string = `http://localhost:5551/api/v1/accounts/${ accountId } ` ;
518
+
472
519
received = false ;
473
520
// wait until the transaction reached consensus and retrievable from the mirror node API
474
521
while ( ! received ) {
@@ -477,27 +524,34 @@ async function verifyMirrorNodeDeployWasSuccessful(
477
524
{ method : 'GET' , timeout : 100 , headers : { Connection : 'close' } } ,
478
525
( response : http . IncomingMessage ) : void => {
479
526
response . setEncoding ( 'utf8' ) ;
527
+
480
528
response . on ( 'data' , ( chunk ) : void => {
481
529
// convert chunk to json object
482
530
const object : { account : string } = JSON . parse ( chunk ) ;
531
+
483
532
expect (
484
533
object . account ,
485
534
'expect the created account to exist in the mirror nodes copy of the accounts' ,
486
535
) . to . equal ( accountId ) ;
536
+
487
537
received = true ;
488
538
} ) ;
489
539
} ,
490
540
) ;
541
+
491
542
request . on ( 'error' , ( error : Error ) : void => {
492
543
testLogger . debug ( `problem with request: ${ error . message } ` , error ) ;
493
544
} ) ;
545
+
494
546
request . end ( ) ; // make the request
495
547
await sleep ( Duration . ofSeconds ( 2 ) ) ;
496
548
}
549
+
497
550
await sleep ( Duration . ofSeconds ( 1 ) ) ;
498
551
}
499
552
} finally {
500
553
if ( portForwarder ) {
554
+ // eslint-disable-next-line unicorn/no-null
501
555
await k8 . pods ( ) . readByReference ( null ) . stopPortForward ( portForwarder ) ;
502
556
}
503
557
}
@@ -540,6 +594,7 @@ async function verifyExplorerDeployWasSuccessful(
540
594
const queryUrl : string = 'http://127.0.0.1:8080/api/v1/accounts?limit=15&order=desc' ;
541
595
const packageDownloader : PackageDownloader = container . resolve < PackageDownloader > ( InjectTokens . PackageDownloader ) ;
542
596
expect ( await packageDownloader . urlExists ( queryUrl ) , 'the hedera explorer Accounts URL should exist' ) . to . be . true ;
597
+
543
598
let received : boolean = false ;
544
599
// wait until the transaction reached consensus and retrievable from the mirror node API
545
600
while ( ! received ) {
@@ -548,31 +603,37 @@ async function verifyExplorerDeployWasSuccessful(
548
603
{ method : 'GET' , timeout : 100 , headers : { Connection : 'close' } } ,
549
604
( response : http . IncomingMessage ) : void => {
550
605
response . setEncoding ( 'utf8' ) ;
606
+
551
607
response . on ( 'data' , ( chunk ) : void => {
552
608
// convert chunk to json object
553
609
const object : { accounts : { account : string } [ ] } = JSON . parse ( chunk ) ;
554
610
expect (
555
611
object . accounts ?. length ,
556
612
"expect there to be more than one account in the hedera explorer's call to mirror node" ,
557
613
) . to . be . greaterThan ( 1 ) ;
614
+
558
615
for ( const accountId of createdAccountIds ) {
559
616
expect (
560
617
object . accounts . some ( ( account : { account : string } ) : boolean => account . account === accountId ) ,
561
618
`expect ${ accountId } to be in the response` ,
562
619
) . to . be . true ;
563
620
}
621
+
564
622
received = true ;
565
623
} ) ;
566
624
} ,
567
625
) ;
626
+
568
627
request . on ( 'error' , ( error : Error ) : void => {
569
628
testLogger . debug ( `problem with request: ${ error . message } ` , error ) ;
570
629
} ) ;
630
+
571
631
request . end ( ) ; // make the request
572
632
await sleep ( Duration . ofSeconds ( 2 ) ) ;
573
633
}
574
634
} finally {
575
635
if ( portForwarder ) {
636
+ // eslint-disable-next-line unicorn/no-null
576
637
await k8 . pods ( ) . readByReference ( null ) . stopPortForward ( portForwarder ) ;
577
638
}
578
639
}
0 commit comments