@@ -5,9 +5,9 @@ function getIngressConnectionEstablishmentRatePerSec(mongo) {
55 . ingressConnectionEstablishmentRatePerSec ;
66}
77
8- function getIngressConnectionEstablishmentBurstSize ( mongo ) {
9- return mongo . adminCommand ( { getParameter : 1 , ingressConnectionEstablishmentBurstSize : 1 } )
10- . ingressConnectionEstablishmentBurstSize ;
8+ function getingressConnectionEstablishmentBurstCapacitySecs ( mongo ) {
9+ return mongo . adminCommand ( { getParameter : 1 , ingressConnectionEstablishmentBurstCapacitySecs : 1 } )
10+ . ingressConnectionEstablishmentBurstCapacitySecs ;
1111}
1212
1313function getIngressConnectionEstablishmentMaxQueueDepthDefault ( mongo ) {
@@ -23,9 +23,14 @@ let ingressConnectionEstablishmentRatePerSecDefault =
2323 getIngressConnectionEstablishmentRatePerSec ( mongo ) ;
2424assert . eq ( ingressConnectionEstablishmentRatePerSecDefault , maxInt32 ) ;
2525
26- let ingressConnectionEstablishmentBurstSizeDefault =
27- getIngressConnectionEstablishmentBurstSize ( mongo ) ;
28- assert . eq ( ingressConnectionEstablishmentBurstSizeDefault , maxInt32 ) ;
26+ let ingressConnectionEstablishmentBurstCapacitySecsDefault =
27+ getingressConnectionEstablishmentBurstCapacitySecs ( mongo ) ;
28+ assert . eq ( ingressConnectionEstablishmentBurstCapacitySecsDefault , Number . MAX_VALUE ) ;
29+
30+ // There are infinite tokens available by default.
31+ let availableTokens =
32+ mongo . adminCommand ( { serverStatus : 1 } ) . queues . ingressSessionEstablishment . totalAvailableTokens ;
33+ assert . eq ( availableTokens , Infinity ) ;
2934
3035let ingressConnectionEstablishmentMaxQueueDepthDefault =
3136 getIngressConnectionEstablishmentMaxQueueDepthDefault ( mongo ) ;
@@ -36,7 +41,7 @@ const runtimeSetValue = 10;
3641assert . commandWorked ( mongo . adminCommand ( {
3742 setParameter : 1 ,
3843 ingressConnectionEstablishmentRatePerSec : runtimeSetValue ,
39- ingressConnectionEstablishmentBurstSize : runtimeSetValue ,
44+ ingressConnectionEstablishmentBurstCapacitySecs : runtimeSetValue ,
4045 ingressConnectionEstablishmentMaxQueueDepth : runtimeSetValue
4146} ) ) ;
4247
@@ -45,9 +50,11 @@ assert.neq(ingressConnectionEstablishmentRatePerSec,
4550 ingressConnectionEstablishmentMaxQueueDepthDefault ) ;
4651assert . eq ( ingressConnectionEstablishmentRatePerSec , runtimeSetValue ) ;
4752
48- let ingressConnectionEstablishmentBurstSize = getIngressConnectionEstablishmentBurstSize ( mongo ) ;
49- assert . neq ( ingressConnectionEstablishmentBurstSize , ingressConnectionEstablishmentBurstSizeDefault ) ;
50- assert . eq ( ingressConnectionEstablishmentBurstSize , runtimeSetValue ) ;
53+ let ingressConnectionEstablishmentBurstCapacitySecs =
54+ getingressConnectionEstablishmentBurstCapacitySecs ( mongo ) ;
55+ assert . neq ( ingressConnectionEstablishmentBurstCapacitySecs ,
56+ ingressConnectionEstablishmentBurstCapacitySecsDefault ) ;
57+ assert . eq ( ingressConnectionEstablishmentBurstCapacitySecs , runtimeSetValue ) ;
5158
5259let ingressConnectionEstablishmentMaxQueueDepth =
5360 mongo . adminCommand ( { getParameter : 1 , ingressConnectionEstablishmentMaxQueueDepth : 1 } )
@@ -61,16 +68,17 @@ const startupSetValue = 50;
6168mongo = MongoRunner . runMongod ( {
6269 setParameter : {
6370 ingressConnectionEstablishmentRatePerSec : startupSetValue ,
64- ingressConnectionEstablishmentBurstSize : startupSetValue ,
71+ ingressConnectionEstablishmentBurstCapacitySecs : startupSetValue ,
6572 ingressConnectionEstablishmentMaxQueueDepth : startupSetValue
6673 }
6774} ) ;
6875
6976ingressConnectionEstablishmentRatePerSec = getIngressConnectionEstablishmentRatePerSec ( mongo ) ;
7077assert . eq ( ingressConnectionEstablishmentRatePerSec , startupSetValue ) ;
7178
72- ingressConnectionEstablishmentBurstSize = getIngressConnectionEstablishmentBurstSize ( mongo ) ;
73- assert . eq ( ingressConnectionEstablishmentBurstSize , startupSetValue ) ;
79+ ingressConnectionEstablishmentBurstCapacitySecs =
80+ getingressConnectionEstablishmentBurstCapacitySecs ( mongo ) ;
81+ assert . eq ( ingressConnectionEstablishmentBurstCapacitySecs , startupSetValue ) ;
7482
7583ingressConnectionEstablishmentMaxQueueDepth =
7684 mongo . adminCommand ( { getParameter : 1 , ingressConnectionEstablishmentMaxQueueDepth : 1 } )
@@ -89,9 +97,10 @@ assert.eq(ingressConnectionEstablishmentRatePerSec, stringSetValue);
8997MongoRunner . stopMongod ( mongo ) ;
9098
9199mongo = MongoRunner . runMongod (
92- { setParameter : 'ingressConnectionEstablishmentBurstSize=' + stringSetValue } ) ;
93- ingressConnectionEstablishmentBurstSize = getIngressConnectionEstablishmentBurstSize ( mongo ) ;
94- assert . eq ( ingressConnectionEstablishmentBurstSize , stringSetValue ) ;
100+ { setParameter : 'ingressConnectionEstablishmentBurstCapacitySecs=' + stringSetValue } ) ;
101+ ingressConnectionEstablishmentBurstCapacitySecs =
102+ getingressConnectionEstablishmentBurstCapacitySecs ( mongo ) ;
103+ assert . eq ( ingressConnectionEstablishmentBurstCapacitySecs , stringSetValue ) ;
95104MongoRunner . stopMongod ( mongo ) ;
96105
97106mongo = MongoRunner . runMongod (
@@ -101,3 +110,32 @@ ingressConnectionEstablishmentMaxQueueDepth =
101110 . ingressConnectionEstablishmentMaxQueueDepth ;
102111assert . eq ( ingressConnectionEstablishmentMaxQueueDepth , stringSetValue ) ;
103112MongoRunner . stopMongod ( mongo ) ;
113+
114+ // Make sure that increasing the burstSize results in increasing the available tokens in the bucket
115+ const marginOfError = 5 ; // +/- 5 tokens just in case there is rounding errors/clock skew
116+ const refreshRate = 10000 ;
117+ const initialBurstCapacitySecs = 0.5 ;
118+ mongo = MongoRunner . runMongod ( {
119+ setParameter : {
120+ ingressConnectionEstablishmentRatePerSec : refreshRate ,
121+ ingressConnectionEstablishmentBurstCapacitySecs : initialBurstCapacitySecs ,
122+ }
123+ } ) ;
124+ let initialTokens =
125+ mongo . adminCommand ( { serverStatus : 1 } ) . queues . ingressSessionEstablishment . totalAvailableTokens ;
126+ const targetTokens = refreshRate * initialBurstCapacitySecs ;
127+ assert . between ( targetTokens - marginOfError , initialTokens , targetTokens + marginOfError ) ;
128+
129+ const newBurstCapacitySecs = 2 ;
130+ const newTargetTokens = refreshRate * newBurstCapacitySecs ;
131+ assert . commandWorked ( mongo . adminCommand (
132+ { setParameter : 1 , ingressConnectionEstablishmentBurstCapacitySecs : newBurstCapacitySecs } ) ) ;
133+ assert . soon ( ( ) => {
134+ const newTokens = mongo . adminCommand ( { serverStatus : 1 } )
135+ . queues . ingressSessionEstablishment . totalAvailableTokens ;
136+ jsTestLog ( "New tokens: " + newTokens ) ;
137+ return newTargetTokens - marginOfError <= newTokens &&
138+ newTokens <= newTargetTokens + marginOfError ;
139+ } ) ;
140+
141+ MongoRunner . stopMongod ( mongo ) ;
0 commit comments