Exemplo n.º 1
0
        static void Main(string[] args)
        {
            if (!ParseArgs(args))
            {
                return;
            }

            string logFileName = "KuduStressLog_" + DateTime.Now.ToString("mm-dd-yyyy_HH-mm-ss") + ".log";
            string logFilePath = Path.Combine(Environment.CurrentDirectory, logFileName);

            StreamWriter streamWriter = new StreamWriter(logFilePath);
            StressTextWriterTraceListener traceListener = new StressTextWriterTraceListener(streamWriter, true);
            System.Diagnostics.Trace.Listeners.Add(traceListener); 
            System.Diagnostics.Trace.Listeners.Add(new StressConsoleTraceListener(true));

            // load apps list
            Dictionary<string, GitApplication> appsList = ReadGitAppsList();
            if (!appsList.ContainsKey(appName))
            {
                Console.WriteLine ("Unable to continue. Invalid appname '" + appName + "' specified.");
                return;
            }

            StressTestCases testCases = new StressTestCases();
            testCases.TestApplication = appsList[appName];
            
            startTime = DateTime.Now;

            Trace.WriteLine(string.Format("Stress Starting Run.  Start time: {0},  Scenario Name: {1}, App Name: {2},  Duration: {3} secs", startTime, scenarioName, appName, testDuration));
            Console.WriteLine("The log file for this run is:   " + logFilePath);

            TimeSpan duration =TimeSpan.FromSeconds(testDuration);
            int iterationCount = 0;
            int testsPassed = 0 ;
            int testsFailed= 0; 
            while (DateTime.Now - startTime < duration)
            {
                iterationCount++;
                try
                {
                    switch (scenarioName)
                    {
                        case "GitPushScenario":
                            testCases.StressGitPushScenario();
                            LogIterationResult(true, scenarioName, iterationCount, "test passed");
                            break;
                        case "GitRedeployScenario":
                            testCases.StressGitRedeployScenario();
                            LogIterationResult(true, scenarioName, iterationCount, "test passed");
                            break;
                        default:
                            Console.WriteLine ("Unable to continue. Invalid scenario name specified:  " + scenarioName);
                            Environment.Exit(1);
                            break;
                    }
                    testsPassed ++;
                }
                catch (Exception ex)
                {
                    LogIterationResult(false, scenarioName, iterationCount, ex.ToString());
                    testsFailed++;
                }
                finally
                {
                    Trace.Flush();
                }
            }
            string msg = string.Format ("Test run complete. Total Iterations:  {0} , Passed: {1} , Failed: {2} ", iterationCount, testsPassed, testsFailed) ;
            Trace.WriteLine (msg);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (!ParseArgs(args))
            {
                return;
            }

            string logFileName = "KuduStressLog_" + DateTime.Now.ToString("mm-dd-yyyy_HH-mm-ss") + ".log";
            string logFilePath = Path.Combine(Environment.CurrentDirectory, logFileName);

            StreamWriter streamWriter = new StreamWriter(logFilePath);
            StressTextWriterTraceListener traceListener = new StressTextWriterTraceListener(streamWriter, true);

            System.Diagnostics.Trace.Listeners.Add(traceListener);
            System.Diagnostics.Trace.Listeners.Add(new StressConsoleTraceListener(true));

            // load apps list
            Dictionary <string, GitApplication> appsList = ReadGitAppsList();

            if (!appsList.ContainsKey(appName))
            {
                Console.WriteLine("Unable to continue. Invalid appname '" + appName + "' specified.");
                return;
            }

            StressTestCases testCases = new StressTestCases();

            testCases.TestApplication = appsList[appName];

            startTime = DateTime.Now;

            Trace.WriteLine(string.Format("Stress Starting Run.  Start time: {0},  Scenario Name: {1}, App Name: {2},  Duration: {3} secs", startTime, scenarioName, appName, testDuration));
            Console.WriteLine("The log file for this run is:   " + logFilePath);

            TimeSpan duration       = TimeSpan.FromSeconds(testDuration);
            int      iterationCount = 0;
            int      testsPassed    = 0;
            int      testsFailed    = 0;

            while (DateTime.Now - startTime < duration)
            {
                iterationCount++;
                try
                {
                    switch (scenarioName)
                    {
                    case "GitPushScenario":
                        testCases.StressGitPushScenario();
                        LogIterationResult(true, scenarioName, iterationCount, "test passed");
                        break;

                    case "GitRedeployScenario":
                        testCases.StressGitRedeployScenario();
                        LogIterationResult(true, scenarioName, iterationCount, "test passed");
                        break;

                    default:
                        Console.WriteLine("Unable to continue. Invalid scenario name specified:  " + scenarioName);
                        Environment.Exit(1);
                        break;
                    }
                    testsPassed++;
                }
                catch (Exception ex)
                {
                    LogIterationResult(false, scenarioName, iterationCount, ex.ToString());
                    testsFailed++;
                }
                finally
                {
                    Trace.Flush();
                }
            }
            string msg = string.Format("Test run complete. Total Iterations:  {0} , Passed: {1} , Failed: {2} ", iterationCount, testsPassed, testsFailed);

            Trace.WriteLine(msg);
        }