public void AsyncHTTPSICmd() { FileStream stream; stream = File.Create(outputFileHTTPSAsync); 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 HTTPSCalls().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 AsyncHTTPSICmd() { FileStream stream; stream = File.Create(outputFileHTTPSAsync); results = new StreamWriter(stream); DateTime started = DateTime.Now; DateTime[] testStarted = new DateTime [TestGlobals.maxReps]; log.WriteLine ("Test Started: AsyncHTTPSICmd"); 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]; for (int i = 0; i < TestGlobals.maxReps; i++) { System.Threading.Thread.Sleep(TestGlobals.delay); tasks[i] = new HTTPSCalls().runTest(validTest, HTTPOperation.GET); testStarted [i] = HTTPSCalls.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: AsyncHTTPSICmd"); 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 AsyncHTTPSDeviceScan() { FileStream stream; stream = File.Create(outputFileHTTPSAsync); results = new StreamWriter(stream); DateTime started = DateTime.Now; DateTime[] testStarted = new DateTime [TestGlobals.maxReps]; JObject[] scanPosted = new JObject[TestGlobals.maxReps]; log.WriteLine ("Test Started: AsyncHTTPSDeviceScan"); 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]; for (int i = 0; i < TestGlobals.maxReps; i++) { // thread sleep? 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 HTTPSCalls().runTest(scanTest, HTTPOperation.POST); testStarted [i] = HTTPSCalls.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: AsyncHTTPSDeviceScan"); 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 AsyncHTTPSDeviceBackup() { FileStream stream; stream = File.Create(outputFileHTTPSAsync); results = new StreamWriter(stream); DateTime started = DateTime.Now; DateTime[] testStarted = new DateTime [TestGlobals.maxReps]; JObject[] bkPosted = new JObject[TestGlobals.maxReps]; log.WriteLine ("Test Started: AsyncHTTPSDeviceBackup"); 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); // 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); DeviceBackupJSON json = new DeviceBackupJSON(); json.i = TestGlobals.validSerial; json.b = items; json.s = i; DeviceBackup operation = new DeviceBackup(TestGlobals.testServer, json); Test backupTest = new Test(operation); backupTest.setTestName("ValidSingleBackupItem"); backupTest.setExpectedResult ("201"); backupTest.setType ("performance"); tasks[i] = new HTTPSCalls().runTest(backupTest, HTTPOperation.POST); testStarted [i] = HTTPSCalls.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: AsyncHTTPSDeviceBackup"); 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 AsyncHTTPSDeviceScan() { FileStream stream; stream = File.Create(outputFileHTTPSAsync); 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++) { // thread sleep? System.Threading.Thread.Sleep(TestGlobals.delay); tasks[i] = new HTTPSCalls().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 AsyncHTTPSDeviceBackup() { FileStream stream; stream = File.Create(outputFileHTTPSAsync); 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 HTTPSCalls().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(); }