I have a VBScript test that manually processes 100 users performing one action, then processes 10 users performing a second action all within one iteration. The latter 10 require inputs from the first 100 so I handle the users myself via for loops. The problem I'm encountering is that I can't get my threads to execute in a staggered fashion. They still group up and run in lock-step (and they step all over each other). I've tried putting in random delays (very similar to the code that has been posted in this forum previously) but I'm finding that many threads get the same values for delays even after I use Randomize. I've also tried to have the using a global variable as a counter and staggering the users based on that. As it turns out many threads can get the same value for the global variable and this is not effective. I tried using a file as a semaphore but several threads can open the file at the same time even when I specify opening the file for writing.
Is there any way to get at ACT's thread number/counter? Each entry in the act.trace file has this thread identifier and that's exactly what I need to manage my test run.
Any other thoughts or advice would be greatly appreciated.
Random Delay Code I've been using:
</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
'iMaxWait is specified in minutes - convert to msec
iMaxWait = iMaxWait * 60 * 100
To do it more mathmatically, get the user number, and use that to multiply against a set number.
In my case, the script runs multiple times rather than looping inside the script, so I set a global variable to keep track. The global gets turned on when the first user finishes, and I tune the delay so that the first user finishes after the last user has started, so no "user" gets delayed more than once.
I let the user names get automatically assigned when I use this method, but if you set them yourself, you should be able to work with it by having a number value to work with in the user name.
Dim oUser, lUserNumber, lLength, strUser, lNapTime
iBeenUsed = Test.GetGlobalVariable ("iBeenUsed")
lStaggerAmount = 2000
If (iBeenUsed <> 1) Then
Set oUser = Test.GetCurrentUser
lLength = Len(oUser.Name)
lPosition = lLength - 8
lUserNumber = Mid(oUser.Name, 9, lLength) + 1
If (lUserNumber <= lUsers or iBeenUsed <> "iBeenUsed") Then
lNapTime = (lUserNumber - 1) * lStaggerAmount
Test.Trace("User " & lUserNumber & " went to sleep for " & (lNapTime / 1000) & " Seconds. ")
iBeenUsed = lUserNumber + 1
I prefer 'maliciously mischevious'.
TDAdmin of Evil