Forum Discussion
max80
14 years agoOccasional Contributor
It looks like I made some progress, but still not there yet...
Initialization script (groovy test step):
Updating variable script (groovy test step):
Property is defined as follows:
Problem with this solution is that even for 5 threads I observe a race condition, sometimes values in the requests are duplicated. I guess it has something to do with updating variable outside of LoadTestContext, but if I move update code inside initialization script property returns null value.
Initialization script (groovy test step):
if( context.LoadTestContext ) {
synchronized( context.LoadTestContext ) {
if( !context.LoadTestContext['init'] ) {
context.LoadTestContext['init'] = true
context.LoadTestContext['counter'] = '5'
}
}
}Updating variable script (groovy test step):
def mycounter = context.LoadTestContext['counter'].toInteger()
mycounter++
context.LoadTestContext['counter'] = mycounter
Property is defined as follows:
${=(context.LoadTestContext['counter'])}Problem with this solution is that even for 5 threads I observe a race condition, sometimes values in the requests are duplicated. I guess it has something to do with updating variable outside of LoadTestContext, but if I move update code inside initialization script property returns null value.