File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
main-workshop/load-generator/src Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 88import http from 'k6/http' ;
99import { check , sleep } from 'k6' ;
1010import { Counter , Trend } from 'k6/metrics' ;
11+ import { randomBytes } from 'k6/crypto' ;
1112import { generateUUID } from './aws-utils.js' ;
1213
1314// Helper: cryptographically secure [0,1)
1415function secureRandom ( ) {
15- // Uint32 can store values 0 - 2^32-1, so scale appropriately
16- const array = new Uint32Array ( 1 ) ;
17- crypto . getRandomValues ( array ) ;
18- return array [ 0 ] / 4294967296 ; // 2^32
16+ // Get 4 random bytes and convert to Uint32
17+ const bytes = randomBytes ( 4 ) ;
18+ const view = new DataView ( bytes ) ;
19+ const value = view . getUint32 ( 0 , false ) ;
20+ return value / 4294967296 ; // 2^32
1921}
2022
2123// Custom metrics
@@ -117,7 +119,7 @@ export function generateErrorRequests() {
117119
118120 if ( success ) {
119121 errorRequests . add ( 1 ) ;
120- console . log ( `❌ Error request (status ${ response . status } ) - ${ duration } ms [${ correlationId } ]` ) ;
122+ console . log ( `✅ Error request (status ${ response . status } ) - ${ duration } ms [${ correlationId } ]` ) ;
121123 } else {
122124 console . log ( `⚠️ Error request got unexpected status ${ response . status } - ${ duration } ms [${ correlationId } ]` ) ;
123125 }
You can’t perform that action at this time.
0 commit comments