@@ -77,9 +77,34 @@ export const reducer = combineReducersAsync<StressOperations, LocalServerStressS
7777 orderSequentially : orderSequentiallyReducer ,
7878} ) ;
7979
80+ /**
81+ * Number of operations in the "creation phase" before attach.
82+ * During this phase, we prioritize creating datastores and channels.
83+ */
84+ const creationPhaseOps = 7 ;
85+
8086export function makeGenerator < T extends BaseOperation > (
8187 additional : DynamicAsyncWeights < T , LocalServerStressState > = [ ] ,
8288) : AsyncGenerator < StressOperations | T , LocalServerStressState > {
89+ // Track operation count for phasing during detached state
90+ let detachedOpCount = 0 ;
91+
92+ /**
93+ * Returns true if we're in the "creation phase" (prioritize creating datastores/channels).
94+ * This is the first few operations while detached.
95+ */
96+ const isCreationPhase = ( state : LocalServerStressState ) : boolean =>
97+ state . client . container . attachState === AttachState . Detached &&
98+ detachedOpCount < creationPhaseOps ;
99+
100+ /**
101+ * Returns true if we're in the "DDS ops phase" (prioritize DDS operations).
102+ * This is after the creation phase but still detached.
103+ */
104+ const isDdsOpsPhase = ( state : LocalServerStressState ) : boolean =>
105+ state . client . container . attachState === AttachState . Detached &&
106+ detachedOpCount >= creationPhaseOps ;
107+
83108 const asyncGenerator = createWeightedAsyncGeneratorWithDynamicWeights <
84109 StressOperations | T ,
85110 LocalServerStressState
@@ -91,7 +116,8 @@ export function makeGenerator<T extends BaseOperation>(
91116 asChild : state . random . bool ( ) ,
92117 tag : state . tag ( "datastore" ) ,
93118 } ) ,
94- 1 ,
119+ // High weight during creation phase, low weight otherwise
120+ ( state ) => ( isCreationPhase ( state ) ? 20 : 1 ) ,
95121 ] ,
96122 [
97123 async ( state ) => ( {
@@ -108,7 +134,8 @@ export function makeGenerator<T extends BaseOperation>(
108134 channelType : state . random . pick ( [ ...ddsModelMap . keys ( ) ] ) ,
109135 tag : state . tag ( "channel" ) ,
110136 } ) ,
111- 5 ,
137+ // High weight during creation phase, low weight otherwise
138+ ( state ) => ( isCreationPhase ( state ) ? 20 : 5 ) ,
112139 ] ,
113140 [
114141 async ( ) => ( {
@@ -129,7 +156,19 @@ export function makeGenerator<T extends BaseOperation>(
129156 state . client . entryPoint . inStagingMode ( ) &&
130157 state . client . container . attachState !== AttachState . Detached ,
131158 ] ,
132- [ DDSModelOpGenerator , 100 ] ,
159+ [
160+ DDSModelOpGenerator ,
161+ // Low weight during creation phase, high weight during DDS ops phase
162+ ( state ) => {
163+ if ( isCreationPhase ( state ) ) {
164+ return 10 ;
165+ }
166+ if ( isDdsOpsPhase ( state ) ) {
167+ return 150 ;
168+ }
169+ return 100 ;
170+ } ,
171+ ] ,
133172 [
134173 async ( state ) => {
135174 const operations : DDSModelOp [ ] = [ ] ;
@@ -154,7 +193,13 @@ export function makeGenerator<T extends BaseOperation>(
154193 ] ,
155194 ] ) ;
156195
157- return async ( state ) => asyncGenerator ( state ) ;
196+ return async ( state ) => {
197+ // Track detached operation count for phasing
198+ if ( state . client . container . attachState === AttachState . Detached ) {
199+ detachedOpCount ++ ;
200+ }
201+ return asyncGenerator ( state ) ;
202+ } ;
158203}
159204export const saveFailures = { directory : path . join ( _dirname , "../src/test/results" ) } ;
160205export const saveSuccesses = { directory : path . join ( _dirname , "../src/test/results" ) } ;
0 commit comments