Commit 6d3831c3 6d3831c387cbb2de5555047cf904c80d8849d4a3 by Christian Gerdes

New option to SetTestParameter plugin: Use_UniqueFiles

1 parent 5425e667
......@@ -154,3 +154,4 @@ $RECYCLE.BIN/
# Mac desktop service store files
.DS_Store
/.vs/LIL_VSTT_Plugins/v15/sqlite3/storage.ide
......
......@@ -177,6 +177,7 @@ namespace LIL_VSTT_Plugins
private string myColNames = "";
private bool myUseRandom = true;
private bool myUseUnique = false;
private bool myUseUniqueFiles = false;
private bool myUseUniqueIteration = false;
private bool myUseUniqueTestIteration = false;
private bool myLogToFile = false;
......@@ -189,10 +190,12 @@ namespace LIL_VSTT_Plugins
private bool stop = false;
private int timeWait = 0;
private int nextAvailableRow = 0;
private StringCollection myParams = new StringCollection();
private Random random = new Random();
private Dictionary<string, int> testIterations = new Dictionary<string, int>();
private Dictionary<int, int> userRow = new Dictionary<int, int>();
private LoadTest m_loadTest;
#region guiparams
......@@ -287,6 +290,15 @@ namespace LIL_VSTT_Plugins
set { myUseUnique = value; }
}
[DisplayName("Välj unikt per VU per Testdatafil?")]
[Description("Ange True om du vill att varje testdatafil (CSV) hanteras separat för varje unik VU. Pluginet kommer då komma ihåg vilka rader som delats ut separat för varje fil.")]
[DefaultValue(false)]
public bool Use_UniqueFiles
{
get { return myUseUniqueFiles; }
set { myUseUniqueFiles = value; }
}
[DisplayName("Välj unikt per Iteration?")]
[Description("Ange True om du vill att varje LoadTest VU ska ha sitt eget unika värde för varje iteration av alla tester, dvs aldrig återanvändas av någon VU i något test. Gäller före unikt per test iteration.")]
[DefaultValue(false)]
......@@ -371,10 +383,12 @@ namespace LIL_VSTT_Plugins
if (myParams.Count > 0)
{
if (myUseUniqueIteration)
m_loadTest.TestStarting += new EventHandler<TestStartingEventArgs>(loadTestStartingUniqueIteration);
else if(myUseUniqueTestIteration)
if (myUseUniqueTestIteration)
m_loadTest.TestStarting += new EventHandler<TestStartingEventArgs>(loadTestStartingUniqueTestIteration);
else if (myUseUniqueIteration)
m_loadTest.TestStarting += new EventHandler<TestStartingEventArgs>(loadTestStartingUniqueIteration);
else if (myUseUniqueFiles)
m_loadTest.TestStarting += new EventHandler<TestStartingEventArgs>(loadTestStartingUniqueFiles);
else if (myUseUnique)
m_loadTest.TestStarting += new EventHandler<TestStartingEventArgs>(loadTestStartingUnique);
else if (myUseRandom)
......@@ -434,6 +448,28 @@ namespace LIL_VSTT_Plugins
setParameters(this.getSeqUser(e.UserContext.CompletedTestCount), e);
}
void loadTestStartingUniqueFiles(object sender, TestStartingEventArgs e)
{
if (shouldRun(e))
{
int row = 0;
// Go single threaded
lock (userRow)
{
// Check if the user already has a row in our file, otherwise get the next one
if (userRow.ContainsKey(e.UserContext.UserId)) row = userRow[e.UserContext.UserId];
else
{
// New user, get the next row and increase the counter
row = nextAvailableRow++;
// Save the row for this user
userRow[e.UserContext.UserId] = row;
}
}
setParameters(this.getSeqUser(row), e);
}
}
void loadTestStartingUnique(object sender, TestStartingEventArgs e)
{
setParameters(this.getSeqUser(e.UserContext.UserId), e);
......