@@ -31,6 +31,7 @@ import {
31
31
getTestConfigManager ,
32
32
TEST_CLUSTER
33
33
} from '../../test_util.js'
34
+ import { sleep } from '../../../src/core/helpers.mjs'
34
35
35
36
describe . each ( [
36
37
// { releaseTag: 'v0.47.0-alpha.0', keyFormat: constants.KEY_FORMAT_PFX, testName: 'node-cmd-e2e-pfx' },
@@ -42,10 +43,11 @@ describe.each([
42
43
argv [ flags . namespace . name ] = namespace
43
44
argv [ flags . releaseTag . name ] = input . releaseTag
44
45
argv [ flags . keyFormat . name ] = input . keyFormat
45
- argv [ flags . nodeIDs . name ] = 'node0,node1,node2'
46
+ argv [ flags . nodeIDs . name ] = 'node0,node1,node2,node3 '
46
47
argv [ flags . generateGossipKeys . name ] = true
47
48
argv [ flags . generateTlsKeys . name ] = true
48
49
argv [ flags . clusterName . name ] = TEST_CLUSTER
50
+ argv [ flags . chartDirectory . name ] = 'charts' // TODO remove before pushing
49
51
const bootstrapResp = bootstrapNetwork ( testName , argv )
50
52
const accountManager = bootstrapResp . opts . accountManager
51
53
const k8 = bootstrapResp . opts . k8
@@ -113,7 +115,7 @@ describe.each([
113
115
} , 20000 )
114
116
} )
115
117
116
- describe ( `Node should refresh successfully [release ${ input . releaseTag } , keyFormat: ${ input . keyFormat } ]` , ( ) => {
118
+ describe ( `Killed node should refresh successfully [release ${ input . releaseTag } , keyFormat: ${ input . keyFormat } ]` , ( ) => {
117
119
let podName = ''
118
120
beforeAll ( async ( ) => {
119
121
argv [ flags . nodeIDs . name ] = 'node0'
@@ -126,11 +128,96 @@ describe.each([
126
128
podName = podArray [ 0 ] . metadata . name
127
129
const resp = await k8 . kubeClient . deleteNamespacedPod ( podName , namespace )
128
130
expect ( resp . response . statusCode ) . toEqual ( 200 )
131
+ await sleep ( 20000 ) // sleep to wait for pod to finish terminating
129
132
} else {
130
133
throw new Error ( 'pod for node0 not found' )
131
134
}
135
+ } , 30000 )
136
+
137
+ it ( 'Node0 should be running' , async ( ) => {
138
+ expect ( podName ) . toContain ( 'node0' )
139
+ try {
140
+ await expect ( nodeCmd . checkNetworkNodePod ( namespace , 'node0' ) ) . resolves . toBeTruthy ( )
141
+ } catch ( e ) {
142
+ nodeCmd . logger . showUserError ( e )
143
+ expect ( e ) . toBeNull ( )
144
+ } finally {
145
+ await nodeCmd . close ( )
146
+ }
147
+ } , 20000 )
148
+
149
+ it ( 'Node0 should not be ACTIVE' , async ( ) => {
150
+ expect ( 3 )
151
+ expect ( podName ) . toContain ( 'node0' )
152
+ try {
153
+ await expect ( nodeCmd . checkNetworkNodeStarted ( 'node0' , 5 ) ) . rejects . toThrowError ( )
154
+ } catch ( e ) {
155
+ nodeCmd . logger . showUserError ( e )
156
+ expect ( e ) . not . toBeNull ( )
157
+ } finally {
158
+ await nodeCmd . close ( )
159
+ }
132
160
} , 20000 )
133
161
162
+ it ( 'Node0 refresh should succeed' , async ( ) => {
163
+ await expect ( nodeCmd . refresh ( argv ) ) . resolves . toBeTruthy ( )
164
+ } , 1200000 )
165
+ // TODO need to test with PVCs
166
+ // TODO will have changes when configMap/secrets are implemented
167
+ it ( 'Balance query and account create should succeed' , async ( ) => {
168
+ expect . assertions ( 3 )
169
+
170
+ try {
171
+ await accountManager . loadNodeClient ( namespace )
172
+ expect ( accountManager . _nodeClient ) . not . toBeNull ( )
173
+
174
+ const balance = await new AccountBalanceQuery ( )
175
+ . setAccountId ( accountManager . _nodeClient . getOperator ( ) . accountId )
176
+ . execute ( accountManager . _nodeClient )
177
+
178
+ expect ( balance . hbars ) . not . toBeNull ( )
179
+
180
+ const accountKey = PrivateKey . generate ( )
181
+
182
+ let transaction = await new AccountCreateTransaction ( )
183
+ . setNodeAccountIds ( [ constants . HEDERA_NODE_ACCOUNT_ID_START ] )
184
+ . setInitialBalance ( new Hbar ( 0 ) )
185
+ . setKey ( accountKey . publicKey )
186
+ . freezeWith ( accountManager . _nodeClient )
187
+
188
+ transaction = await transaction . sign ( accountKey )
189
+ const response = await transaction . execute ( accountManager . _nodeClient )
190
+ const receipt = await response . getReceipt ( accountManager . _nodeClient )
191
+
192
+ expect ( receipt . accountId ) . not . toBeNull ( )
193
+ } catch ( e ) {
194
+ nodeCmd . logger . showUserError ( e )
195
+ expect ( e ) . toBeNull ( )
196
+ } finally {
197
+ await nodeCmd . close ( )
198
+ }
199
+ } , 120000 )
200
+ } )
201
+
202
+ describe ( `Stopped node should refresh successfully [release ${ input . releaseTag } , keyFormat: ${ input . keyFormat } ]` , ( ) => {
203
+ let podName = ''
204
+ beforeAll ( async ( ) => {
205
+ argv [ flags . nodeIDs . name ] = 'node0'
206
+ const configManager = getTestConfigManager ( `${ testName } -solo.config` )
207
+ configManager . update ( argv , true )
208
+
209
+ const podArray = await k8 . getPodsByLabel ( [ 'app=network-node0' , 'fullstack.hedera.com/type=network-node' ] )
210
+
211
+ if ( podArray . length > 0 ) {
212
+ podName = podArray [ 0 ] . metadata . name
213
+ const resp = await k8 . kubeClient . deleteNamespacedPod ( podName , namespace )
214
+ expect ( resp . response . statusCode ) . toEqual ( 200 )
215
+ await sleep ( 20000 ) // sleep to wait for pod to finish terminating
216
+ } else {
217
+ throw new Error ( 'pod for node0 not found' )
218
+ }
219
+ } , 30000 )
220
+
134
221
it ( 'Node0 should be running' , async ( ) => {
135
222
expect ( podName ) . toContain ( 'node0' )
136
223
try {
@@ -147,7 +234,6 @@ describe.each([
147
234
expect ( 3 )
148
235
expect ( podName ) . toContain ( 'node0' )
149
236
try {
150
- await expect ( nodeCmd . stop ( argv ) ) . resolves . toBeTruthy ( )
151
237
await expect ( nodeCmd . checkNetworkNodeStarted ( 'node0' , 5 ) ) . rejects . toThrowError ( )
152
238
} catch ( e ) {
153
239
nodeCmd . logger . showUserError ( e )
@@ -162,5 +248,38 @@ describe.each([
162
248
} , 1200000 )
163
249
// TODO need to test with PVCs
164
250
// TODO will have changes when configMap/secrets are implemented
251
+ it ( 'Balance query and account create should succeed' , async ( ) => {
252
+ expect . assertions ( 3 )
253
+
254
+ try {
255
+ await accountManager . loadNodeClient ( namespace )
256
+ expect ( accountManager . _nodeClient ) . not . toBeNull ( )
257
+
258
+ const balance = await new AccountBalanceQuery ( )
259
+ . setAccountId ( accountManager . _nodeClient . getOperator ( ) . accountId )
260
+ . execute ( accountManager . _nodeClient )
261
+
262
+ expect ( balance . hbars ) . not . toBeNull ( )
263
+
264
+ const accountKey = PrivateKey . generate ( )
265
+
266
+ let transaction = await new AccountCreateTransaction ( )
267
+ . setNodeAccountIds ( [ constants . HEDERA_NODE_ACCOUNT_ID_START ] )
268
+ . setInitialBalance ( new Hbar ( 0 ) )
269
+ . setKey ( accountKey . publicKey )
270
+ . freezeWith ( accountManager . _nodeClient )
271
+
272
+ transaction = await transaction . sign ( accountKey )
273
+ const response = await transaction . execute ( accountManager . _nodeClient )
274
+ const receipt = await response . getReceipt ( accountManager . _nodeClient )
275
+
276
+ expect ( receipt . accountId ) . not . toBeNull ( )
277
+ } catch ( e ) {
278
+ nodeCmd . logger . showUserError ( e )
279
+ expect ( e ) . toBeNull ( )
280
+ } finally {
281
+ await nodeCmd . close ( )
282
+ }
283
+ } , 120000 )
165
284
} )
166
285
} )
0 commit comments