public void AsyncHTTPICmd() { FileStream stream; stream = File.Create(outputFileHTTPAsync); results = new StreamWriter(stream); System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch(); ICmd validICmd = new ICmd(TestGlobals.testServer, TestGlobals.validSerial); Test validTest = new Test(validICmd); validTest.setTestName("ValidSerial"); validTest.setExpectedResult ("200"); validTest.setType ("performance"); List<Test> tests = new List<Test>(); tests.Add(validTest); // Construct started tasks Task<double>[] tasks = new Task<double>[TestGlobals.maxReps]; for (int i = 0; i < TestGlobals.maxReps; i++) { System.Threading.Thread.Sleep(TestGlobals.delay); tasks[i] = new HTTPCalls().runTest(validTest, HTTPOperation.GET); Console.WriteLine("Test starting:" + i.ToString()); } Console.WriteLine("------------------------------------------------------"); Console.WriteLine("All tests initialized, waiting on them to run as async"); Console.WriteLine("------------------------------------------------------"); Task.WaitAll(tasks); foreach (Task<double> nextResult in tasks) { results.WriteLine("Test Time," + nextResult.Result); } results.Close(); }
public void AsyncHTTPDeviceBackup() { FileStream stream; stream = File.Create(outputFileHTTPAsync); results = new StreamWriter(stream); BackupItem[] items = new BackupItem[1]; items[0] = InterceptorTests.DeviceBackupTest.getBackupItem(1); //BackupJSon DeviceBackupJSON json = new DeviceBackupJSON(); json.i = TestGlobals.validSerial; json.s = 4; json.b = items; //BackupOperation DeviceBackup operation = new DeviceBackup(TestGlobals.testServer, json); //Test Test backupTest = new Test(operation); backupTest.setTestName("ValidSingleBackupItem"); backupTest.setExpectedResult ("201"); backupTest.setType ("performance"); // Construct started tasks Task<double>[] tasks = new Task<double>[TestGlobals.maxReps]; for (int i = 0; i < TestGlobals.maxReps; i++) { System.Threading.Thread.Sleep(TestGlobals.delay); tasks[i] = new HTTPCalls().runTest(backupTest, HTTPOperation.POST); Console.WriteLine("Test starting:" + i.ToString()); } Console.WriteLine("------------------------------------------------------"); Console.WriteLine("All tests initialized, waiting on them to run as async"); Console.WriteLine("------------------------------------------------------"); Task.WaitAll(tasks); foreach (Task<double> nextResult in tasks) { results.WriteLine("Test Time," + nextResult.Result); } results.Close(); }
public void AsyncHTTPDeviceScan() { FileStream stream; stream = File.Create(outputFileHTTPAsync); results = new StreamWriter(stream); DeviceScanJSON testJson = new DeviceScanJSON(); testJson.i = TestGlobals.validSerial; testJson.d = "1289472198573"; testJson.b = null; testJson.s = 4; DeviceScan testDScan = new DeviceScan(TestGlobals.testServer, testJson); Test scanTest = new Test(testDScan); scanTest.setTestName("ValidSingleScanSimple"); scanTest.setExpectedResult ("201"); scanTest.setType ("performance"); List<Test> tests = new List<Test>(); tests.Add(scanTest); // Construct started tasks Task<double>[] tasks = new Task<double>[TestGlobals.maxReps]; for (int i = 0; i < TestGlobals.maxReps; i++) { System.Threading.Thread.Sleep(TestGlobals.delay); tasks[i] = new HTTPCalls().runTest(scanTest, HTTPOperation.POST); Console.WriteLine("Test starting:" + i.ToString()); } Console.WriteLine("------------------------------------------------------"); Console.WriteLine("All tests initialized, waiting on them to run as async"); Console.WriteLine("------------------------------------------------------"); Task.WaitAll(tasks); foreach (Task<double> nextResult in tasks) { results.WriteLine("Test Time," + nextResult.Result); } results.Close(); }
public void multiClientICmd() { FileStream stream; stream = File.Create(outputFileMultiClientICmd); results = new StreamWriter(stream); ICmd validICmd1 = new ICmd(TestGlobals.testServer, TestGlobals.validSerial); Test validTest1 = new Test(validICmd1); validTest1.setTestName("ValidSerial"); validTest1.setExpectedResult ("200"); validTest1.setType ("performance"); ICmd validICmd2 = new ICmd(TestGlobals.testServer, TestGlobals.validSerial); Test validTest2 = new Test(validICmd2); validTest2.setTestName("ValidSerial"); validTest2.setExpectedResult ("200"); validTest2.setType ("performance"); // Construct started tasks Task<double>[,] tasks = new Task<double>[TestGlobals.maxReps, 2]; for (int i = 0; i < TestGlobals.maxReps; i++) { System.Threading.Thread.Sleep(TestGlobals.delay); tasks[i, 0] = new HTTPCalls().runTest(validTest1, HTTPOperation.GET); tasks[i, 1] = new HTTPCalls().runTest(validTest2, HTTPOperation.GET); Console.WriteLine("Test starting:" + i.ToString()); Task.WaitAll(tasks[i, 0], tasks[i, 1]); } foreach (Task<double> nextResult in tasks) { results.WriteLine("Test Time," + nextResult.Result); } results.Close(); }
public void AsyncHTTPICmd() { FileStream stream; stream = File.Create(outputFileHTTPAsync); results = new StreamWriter(stream); DateTime started = DateTime.Now; log.WriteLine ("Test Started: AsyncHTTPICmd"); log.WriteLine ("Current Time: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Test Run times: " + TestGlobals.maxReps); log.WriteLine ("Server: " + TestGlobals.testServer); System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch(); ICmd validICmd = new ICmd(TestGlobals.testServer, TestGlobals.validSerial); Test validTest = new Test(validICmd); validTest.setTestName("ValidSerial"); validTest.setExpectedResult ("200"); validTest.setType ("performance"); List<Test> tests = new List<Test>(); tests.Add(validTest); // Construct started tasks Task<double>[] tasks = new Task<double>[TestGlobals.maxReps]; DateTime[] testStarted = new DateTime [TestGlobals.maxReps]; for (int i = 0; i < TestGlobals.maxReps; i++) { System.Threading.Thread.Sleep(TestGlobals.delay); tasks[i] = new HTTPCalls().runTest(validTest, HTTPOperation.GET); testStarted [i] = HTTPCalls.started; Console.WriteLine("Test starting:" + i.ToString()); } Console.WriteLine("------------------------------------------------------"); Console.WriteLine("All tests initialized, waiting on them to run as async"); Console.WriteLine("------------------------------------------------------"); Task.WaitAll(tasks); int seq = 0; foreach (Task<double> nextResult in tasks) { results.WriteLine("Test Time," + nextResult.Result); log.WriteLine ("Test " + seq + " Started at " + testStarted[seq].ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Test Lasted: " + nextResult.Result + "ms"); seq++; if (seq < 99) { log.WriteLine (); } } DateTime ended = DateTime.Now; TimeSpan lasted = ended - started; log.WriteLine ("Test Ended: AsyncHTTPICmd"); log.WriteLine ("Current Time: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Test lasted: " + lasted); log.WriteLine ("\n\n"); results.Close(); }
public void MultiClientICmd() { FileStream stream; stream = File.Create(outputFileMultiClientICmd); results = new StreamWriter(stream); DateTime started = DateTime.Now; log.WriteLine ("Test Started: MultiClientICmd"); log.WriteLine ("Current Time: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Server: " + TestGlobals.testServer); ICmd validICmd1 = new ICmd(TestGlobals.testServer, TestGlobals.validSerial); Test validTest1 = new Test(validICmd1); validTest1.setTestName("ValidSerial"); validTest1.setExpectedResult ("200"); validTest1.setType ("performance"); ICmd validICmd2 = new ICmd(TestGlobals.testServer, TestGlobals.validSerial); Test validTest2 = new Test(validICmd2); validTest2.setTestName("ValidSerial"); validTest2.setExpectedResult ("200"); validTest2.setType ("performance"); // Construct started tasks Task<double>[,] tasks = new Task<double>[TestGlobals.maxReps, 2]; DateTime[] testStarted1 = new DateTime[TestGlobals.maxReps]; DateTime[] testStarted2 = new DateTime[TestGlobals.maxReps]; for (int i = 0; i < TestGlobals.maxReps; i++) { System.Threading.Thread.Sleep(TestGlobals.delay); // client 1 tasks[i, 0] = new HTTPCalls().runTest(validTest1, HTTPOperation.GET); testStarted1[i] = HTTPCalls.started; // client 2 tasks[i, 1] = new HTTPCalls().runTest(validTest2, HTTPOperation.GET); testStarted2[i] = HTTPCalls.started; Console.WriteLine("Test starting:" + i.ToString()); Task.WaitAll(tasks[i, 0], tasks[i, 1]); } log.WriteLine ("Client 1:"); for(int i = 0; i < TestGlobals.maxReps; i++) { results.WriteLine ("Test Time," + tasks[i, 0].Result); log.WriteLine ("Client 1 Test " + i + " Started at " + testStarted1 [i].ToString ("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Test Lasted: " + tasks[i, 0].Result + "ms"); log.WriteLine (); } log.WriteLine ("Client 2:"); for(int i = 0; i < TestGlobals.maxReps; i++) { results.WriteLine ("Test Time," + tasks[i, 1].Result); log.WriteLine ("Client 2 Test " + i + " Started at " + testStarted2 [i].ToString ("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Test Lasted: " + tasks[i, 1].Result + "ms"); if (i < 99) { log.WriteLine (); } } DateTime ended = DateTime.Now; TimeSpan lasted = ended - started; log.WriteLine ("Test Ended: MultiClientICmd"); log.WriteLine ("Current Time: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Test lasted: " + lasted); log.WriteLine ("\n\n"); results.Close(); }
public void MultiClientStatus() { FileStream stream; stream = File.Create(outputFileMultiClientStatus); results = new StreamWriter(stream); DateTime started = DateTime.Now; log.WriteLine ("Test Started: MultiClientDeviceStatus"); log.WriteLine ("Current Time: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Server: " + TestGlobals.testServer); // Construct started tasks Task<double>[,] tasks = new Task<double>[TestGlobals.maxReps, 2]; DateTime[] testStarted1 = new DateTime[TestGlobals.maxReps]; DateTime[] testStarted2 = new DateTime[TestGlobals.maxReps]; JObject[] statusPosted1 = new JObject[TestGlobals.maxReps]; JObject[] statusPosted2 = new JObject[TestGlobals.maxReps]; for (int i = 0; i < TestGlobals.maxReps; i++) { System.Threading.Thread.Sleep(TestGlobals.delay); // client 1 status.seqNum = i.ToString(); DeviceStatus operation1 = new DeviceStatus(TestGlobals.testServer, status); Test statusTest1 = new Test(operation1); statusTest1.setTestName("ValidSerial"); statusTest1.setExpectedResult ("201"); statusTest1.setType ("performance"); tasks[i, 0] = new HTTPCalls().runTest(statusTest1, HTTPOperation.POST); testStarted1[i] = HTTPCalls.started; JObject Json1 = JObject.FromObject(status); statusPosted1[i] = Json1; // client 2 status.seqNum = i.ToString(); DeviceStatus operation2 = new DeviceStatus(TestGlobals.testServer, status); Test statusTest2 = new Test(operation2); statusTest2.setTestName("ValidSerial"); statusTest2.setExpectedResult ("201"); statusTest2.setType ("performance"); tasks[i, 1] = new HTTPCalls().runTest(statusTest2, HTTPOperation.POST); testStarted2[i] = HTTPCalls.started; JObject Json2 = JObject.FromObject(status); statusPosted2[i] = Json2; Console.WriteLine("Test starting:" + i.ToString()); Task.WaitAll(tasks[i, 0], tasks[i, 1]); } log.WriteLine ("Client 1:"); for(int i = 0; i < TestGlobals.maxReps; i++) { results.WriteLine ("Test Time," + tasks[i, 0].Result); log.WriteLine ("Client 1 Test " + i + " Started at " + testStarted1 [i].ToString ("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Json Posted:"); log.WriteLine (statusPosted1 [i].ToString ()); log.WriteLine ("Test Lasted: " + tasks[i, 0].Result + "ms"); log.WriteLine (); } log.WriteLine ("Client 2:"); for(int i = 0; i < TestGlobals.maxReps; i++) { results.WriteLine ("Test Time," + tasks[i, 1].Result); log.WriteLine ("Client 2 Test " + i + " Started at " + testStarted2 [i].ToString ("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Json Posted:"); log.WriteLine (statusPosted2 [i].ToString ()); log.WriteLine ("Test Lasted: " + tasks[i, 1].Result + "ms"); if (i < 99) { log.WriteLine (); } } DateTime ended = DateTime.Now; TimeSpan lasted = ended - started; log.WriteLine ("Test Ended: MultiClientDeviceStatus"); log.WriteLine ("Current Time: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Test lasted: " + lasted); log.WriteLine ("\n\n"); results.Close(); }
public void AsyncHTTPDeviceScan() { FileStream stream; stream = File.Create(outputFileHTTPAsync); results = new StreamWriter(stream); DateTime started = DateTime.Now; log.WriteLine ("Test Started: AsyncHTTPDeviceScan"); log.WriteLine ("Current Time: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Test Run times: " + TestGlobals.maxReps); log.WriteLine ("Server: " + TestGlobals.testServer); // Construct started tasks Task<double>[] tasks = new Task<double>[TestGlobals.maxReps]; DateTime[] testStarted = new DateTime [TestGlobals.maxReps]; JObject[] scanPosted = new JObject[TestGlobals.maxReps]; for (int i = 0; i < TestGlobals.maxReps; i++) { System.Threading.Thread.Sleep(TestGlobals.delay); DeviceScanJSON testJson = new DeviceScanJSON(); testJson.i = TestGlobals.validSerial; testJson.d = "1289472198573"; testJson.b = null; testJson.s = i; DeviceScan testDScan = new DeviceScan(TestGlobals.testServer, testJson); Test scanTest = new Test(testDScan); scanTest.setTestName("ValidSingleScanSimple"); scanTest.setExpectedResult ("201"); scanTest.setType ("performance"); List<Test> tests = new List<Test>(); tests.Add(scanTest); tasks[i] = new HTTPCalls().runTest(scanTest, HTTPOperation.POST); testStarted [i] = HTTPCalls.started; JObject Json = JObject.FromObject(testJson); scanPosted[i] = Json; Console.WriteLine("Test starting:" + i.ToString()); } Console.WriteLine("------------------------------------------------------"); Console.WriteLine("All tests initialized, waiting on them to run as async"); Console.WriteLine("------------------------------------------------------"); Task.WaitAll(tasks); int seq = 0; foreach (Task<double> nextResult in tasks) { results.WriteLine("Test Time," + nextResult.Result); log.WriteLine ("Test " + seq + " Started at " + testStarted[seq].ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Json Posted:"); log.WriteLine (scanPosted[seq].ToString ()); log.WriteLine ("Test Lasted: " + nextResult.Result + "ms"); seq++; if (seq < 99) { log.WriteLine (); } } DateTime ended = DateTime.Now; TimeSpan lasted = ended - started; log.WriteLine ("Test Ended: AsyncHTTPDeviceScan"); log.WriteLine ("Current Time: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Test lasted: " + lasted); log.WriteLine ("\n\n"); results.Close(); }
public void AsyncHTTPDeviceBackup() { FileStream stream; stream = File.Create(outputFileHTTPAsync); results = new StreamWriter(stream); DateTime started = DateTime.Now; log.WriteLine ("Test Started: AsyncHTTPDeviceBackup"); log.WriteLine ("Current Time: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Test Run times: " + TestGlobals.maxReps); log.WriteLine ("Server: " + TestGlobals.testServer); BackupItem[] items = new BackupItem[1]; items[0] = InterceptorTests.DeviceBackupTest.getBackupItem(1); //BackupJSon // Construct started tasks Task<double>[] tasks = new Task<double>[TestGlobals.maxReps]; DateTime[] testStarted = new DateTime [TestGlobals.maxReps]; JObject[] bkPosted = new JObject[TestGlobals.maxReps]; for (int i = 0; i < TestGlobals.maxReps; i++) { DeviceBackupJSON json = new DeviceBackupJSON(); json.i = TestGlobals.validSerial; json.s = i; json.b = items; //BackupOperation DeviceBackup operation = new DeviceBackup(TestGlobals.testServer, json); //Test Test backupTest = new Test(operation); backupTest.setTestName("ValidSingleBackupItem"); backupTest.setExpectedResult ("201"); backupTest.setType ("performance"); System.Threading.Thread.Sleep(TestGlobals.delay); tasks[i] = new HTTPCalls().runTest(backupTest, HTTPOperation.POST); testStarted [i] = HTTPCalls.started; JObject Json = JObject.FromObject(json); bkPosted[i] = Json; Console.WriteLine("Test starting:" + i.ToString()); } Console.WriteLine("------------------------------------------------------"); Console.WriteLine("All tests initialized, waiting on them to run as async"); Console.WriteLine("------------------------------------------------------"); Task.WaitAll(tasks); int seq = 0; foreach (Task<double> nextResult in tasks) { results.WriteLine("Test Time," + nextResult.Result); log.WriteLine ("Test " + seq + " Started at " + testStarted[seq].ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Json Posted:"); log.WriteLine (bkPosted[seq].ToString ()); log.WriteLine ("Test Lasted: " + nextResult.Result + "ms"); seq++; if (seq < 99) { log.WriteLine (); } } DateTime ended = DateTime.Now; TimeSpan lasted = ended - started; log.WriteLine ("Test Ended: AsyncHTTPDeviceBackup"); log.WriteLine ("Current Time: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Test lasted: " + lasted); log.WriteLine ("\n\n"); results.Close(); }
public void MultiClientDeviceBackup() { FileStream stream; stream = File.Create(outputFileMultiClientDeviceBackup); results = new StreamWriter(stream); DateTime started = DateTime.Now; log.WriteLine ("Test Started: MultiClientDeviceBackup"); log.WriteLine ("Current Time: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Server: " + TestGlobals.testServer); BackupItem[] items = new BackupItem[1]; items[0] = InterceptorTests.DeviceBackupTest.getBackupItem(1); BackupItem[] items2 = new BackupItem[1]; items2[0] = InterceptorTests.DeviceBackupTest.getBackupItem(1); // Construct started tasks Task<double>[,] tasks = new Task<double>[TestGlobals.maxReps, 2]; DateTime[] testStarted1 = new DateTime[TestGlobals.maxReps]; DateTime[] testStarted2 = new DateTime[TestGlobals.maxReps]; JObject[] bkPosted1 = new JObject[TestGlobals.maxReps]; JObject[] bkPosted2 = new JObject[TestGlobals.maxReps]; for (int i = 0; i < TestGlobals.maxReps; i++) { System.Threading.Thread.Sleep(TestGlobals.delay); // client 1 DeviceBackupJSON json = new DeviceBackupJSON(); json.i = TestGlobals.validSerial; json.s = i; json.b = items; DeviceBackup operation1 = new DeviceBackup(TestGlobals.testServer, json); Test backupTest1 = new Test(operation1); backupTest1.setTestName("ValidSingleBackupItem"); backupTest1.setExpectedResult ("201"); backupTest1.setType ("performance"); tasks[i, 0] = new HTTPCalls().runTest(backupTest1, HTTPOperation.POST); testStarted1[i] = HTTPCalls.started; JObject Json = JObject.FromObject(json); bkPosted1[i] = Json; // client 2 DeviceBackupJSON json2 = new DeviceBackupJSON(); json2.i = TestGlobals.validSerial; json2.s = i; json2.b = items; DeviceBackup operation2 = new DeviceBackup(TestGlobals.testServer, json); Test backupTest2 = new Test(operation2); backupTest2.setTestName("ValidSingleBackupItem"); backupTest2.setExpectedResult ("201"); backupTest2.setType ("performance"); tasks[i, 1] = new HTTPCalls().runTest(backupTest2, HTTPOperation.POST); Console.WriteLine("Test starting:" + i.ToString()); testStarted2[i] = HTTPCalls.started; JObject Json2 = JObject.FromObject(json2); bkPosted2[i] = Json2; Task.WaitAll(tasks[i, 0], tasks[i, 1]); } log.WriteLine ("Client 1:"); for(int i = 0; i < TestGlobals.maxReps; i++) { results.WriteLine ("Test Time," + tasks[i, 0].Result); log.WriteLine ("Client 1 Test " + i + " Started at " + testStarted1 [i].ToString ("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Json Posted:"); log.WriteLine (bkPosted1 [i].ToString ()); log.WriteLine ("Test Lasted: " + tasks[i, 0].Result + "ms"); log.WriteLine (); } log.WriteLine ("Client 2:"); for(int i = 0; i < TestGlobals.maxReps; i++) { results.WriteLine ("Test Time," + tasks[i, 1].Result); log.WriteLine ("Client 2 Test " + i + " Started at " + testStarted2 [i].ToString ("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Json Posted:"); log.WriteLine (bkPosted2 [i].ToString ()); log.WriteLine ("Test Lasted: " + tasks[i, 1].Result + "ms"); if (i < 99) { log.WriteLine (); } } DateTime ended = DateTime.Now; TimeSpan lasted = ended - started; log.WriteLine ("Test Ended: MultiClientDeviceBackup"); log.WriteLine ("Current Time: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.ffffff")); log.WriteLine ("Test lasted: " + lasted); log.WriteLine ("\n\n"); results.Close(); }
public void multiClientScans() { FileStream stream; stream = File.Create(outputFileMultiClientScans); results = new StreamWriter(stream); DeviceScanJSON testJson1 = new DeviceScanJSON(); testJson1.i = TestGlobals.validSerial; testJson1.d = "1289472198573"; testJson1.b = null; testJson1.s = 4; DeviceScan Scan1 = new DeviceScan(TestGlobals.testServer, testJson1); Test scanTest1 = new Test(Scan1); scanTest1.setTestName("ValidSingleScanSimple"); scanTest1.setExpectedResult ("201"); scanTest1.setType ("performance"); DeviceScanJSON testJson2 = new DeviceScanJSON(); testJson2.i = TestGlobals.validSerial; testJson2.d = "1289472198573"; testJson2.b = null; testJson2.s = 4; DeviceScan Scan2 = new DeviceScan(TestGlobals.testServer, testJson2); Test scanTest2 = new Test(Scan2); scanTest2.setTestName("ValidSingleScanSimple"); scanTest2.setExpectedResult ("201"); scanTest2.setType ("performance"); // Construct started tasks Task<double>[,] tasks = new Task<double>[TestGlobals.maxReps, 2]; for (int i = 0; i < TestGlobals.maxReps; i++) { System.Threading.Thread.Sleep(TestGlobals.delay); tasks[i, 0] = new HTTPCalls().runTest(scanTest1, HTTPOperation.POST); tasks[i, 1] = new HTTPCalls().runTest(scanTest2, HTTPOperation.POST); Console.WriteLine("Test starting:" + i.ToString()); Task.WaitAll(tasks[i, 0], tasks[i, 1]); } foreach (Task<double> nextResult in tasks) { results.WriteLine("Test Time," + nextResult.Result); } results.Close(); }
public void multiClientDeviceBackup() { FileStream stream; stream = File.Create(outputFileMultiClientDeviceBackup); results = new StreamWriter(stream); BackupItem[] items = new BackupItem[1]; items[0] = InterceptorTests.DeviceBackupTest.getBackupItem(1); DeviceBackupJSON json = new DeviceBackupJSON(); json.i = TestGlobals.validSerial; json.s = 4; json.b = items; DeviceBackup operation1 = new DeviceBackup(TestGlobals.testServer, json); Test backupTest1 = new Test(operation1); backupTest1.setTestName("ValidSingleBackupItem"); backupTest1.setExpectedResult ("201"); backupTest1.setType ("performance"); BackupItem[] items2 = new BackupItem[1]; items2[0] = InterceptorTests.DeviceBackupTest.getBackupItem(1); DeviceBackupJSON json2 = new DeviceBackupJSON(); json2.i = TestGlobals.validSerial; json2.s = 4; json2.b = items; DeviceBackup operation2 = new DeviceBackup(TestGlobals.testServer, json); Test backupTest2 = new Test(operation2); backupTest2.setTestName("ValidSingleBackupItem"); backupTest2.setExpectedResult ("201"); backupTest2.setType ("performance"); // Construct started tasks Task<double>[,] tasks = new Task<double>[TestGlobals.maxReps, 2]; for (int i = 0; i < TestGlobals.maxReps; i++) { System.Threading.Thread.Sleep(TestGlobals.delay); tasks[i, 0] = new HTTPCalls().runTest(backupTest1, HTTPOperation.POST); tasks[i, 1] = new HTTPCalls().runTest(backupTest2, HTTPOperation.POST); Console.WriteLine("Test starting:" + i.ToString()); Task.WaitAll(tasks[i, 0], tasks[i, 1]); } foreach (Task<double> nextResult in tasks) { results.WriteLine("Test Time," + nextResult.Result); } results.Close(); }