Beispiel #1
0
        // ------------------------------------------------------------------------------------
        // Test Execution

        // Start an individual test (called by TestRunner)
        public void StartTest(TestEntry inputTest, RunnerType runnerType)
        {
            Console.Instance.Write(DebugLevel.Logic, MessageLevel.Log, "Starting test " + inputTest.testName);                        // Write to console
            activeTest = SuiteManager.GetTest(inputTest);                                                                             // Get the active test
            TestLogicBase activeTestLogic = GetLogicInstance(SuiteManager.GetSuiteName(inputTest.suiteIndex), activeTest, inputTest); // Get active test logic instance

            StartCoroutine(activeTestLogic.SetupTest(inputTest, runnerType));                                                         // Setup test
        }
Beispiel #2
0
    public Task RunTimerTask(float duration, RunnerType type, System.Action feedback, string name = "default")
    {
        TimerActionTask task = new TimerActionTask(duration, type);

        task.feedback += feedback;
        task.Name      = name;
        taskCollection.Add(task);
        return(task);
    }
Beispiel #3
0
        // ------------------------------------------------------------------------------------
        // Test Execution

        // Set initial information for test at beginning of test run
        public IEnumerator SetupTest(TestEntry inputEntry, RunnerType runType)
        {
            activeTestEntry = inputEntry;                                                                                                    // Store active TestEntry
            activeRunType   = runType;                                                                                                       // Store active RunnerType
            if (!TestRunner.Instance.isAnalytic)                                                                                             // If not analytic
            {
                ProgressScreen.Instance.SetState(true, ProgressType.LocalSave, "Preparing test");                                            // Enable ProgressScreen
                testWasRan = false;                                                                                                          // Reset
                SetSettings();                                                                                                               // Set settings to internal
                yield return(new WaitForEndOfFrame());                                                                                       // Wait for settings

                SetupResultsStructs();                                                                                                       // Setup the results structs to be filled
                CheckForBaseline();                                                                                                          // Check for baselines
                Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, this.GetType().Name + " set up test " + activeTestEntry.testName); // Write to console
            }
            else
            {
                SetSettings();         // Set settings to internal
            }
            ResultsIOData localResult; // Used for certain active run types

            switch (activeRunType)
            {
            case RunnerType.Automation:
                TestPreProcess();     // Start pre-process
                break;

            case RunnerType.Manual:
                localResult = ResultsIO.Instance.RetrieveEntry(suiteName, GetType().ToString().Replace("GraphicsTestFramework.", "").Replace("Logic", ""), activeResultData.common, false, true); // Try get local result
                if (localResult == null)                                                                                                                                                          // If not found
                {
                    TestPreProcess();                                                                                                                                                             // Start pre-process
                }
                else                                                                                                                                                                              // If found
                {
                    UseLocalResult(localResult);                                                                                                                                                  // Use local
                }
                break;

            case RunnerType.Results:
                localResult = ResultsIO.Instance.RetrieveEntry(suiteName, GetType().ToString().Replace("GraphicsTestFramework.", "").Replace("Logic", ""), activeResultData.common, false, true); // Try get local result
                UseLocalResult(localResult);                                                                                                                                                      // Use local
                break;

            case RunnerType.Resolve:
                TestPreProcess();     // Start pre-process
                break;

            case RunnerType.Analytic:
                break;

            case RunnerType.AnalyticComparison:
                StartCoroutine(ProcessAnalyticComparison());
                break;
            }
        }
Beispiel #4
0
        // ------------------------------------------------------------------------------------
        // Initialization

        // Setup the runner after instantiation
        public void SetupRunner(RunnerType runType)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Setting up runner");                              // Write to console
            ProgressScreen.Instance.SetState(true, ProgressType.LocalLoad, "Generating and processing new Test Runner"); // Enable ProgressScreen
            runnerType = runType;                                                                                        // Set runner type
            if (runnerType != RunnerType.Results)                                                                        // If not results
            {
                GenerateTestRunner(TestStructure.Instance.GetStructure());                                               // Generate test runner
            }
        }
Beispiel #5
0
        private RunnerType GetRunnerType()
        {
            bool continuousIntegrationMode = _options.ContinuousIntegrationMode;
            bool useTeamCity        = _options.OutputForTeamCity;
            bool startWebServerOnly = _options.StartWebServerOnly;
            bool useRemoteTestPage  = _options.UseRemoteTestPage;

            RunnerType runnerType = DetermineRunnerType(continuousIntegrationMode, useTeamCity, startWebServerOnly, useRemoteTestPage);

            return(runnerType);
        }
        public TestReportCollection Run()
        {
            RunnerType runnerType = DetermineRunnerType(_inputOptions.ContinuousIntegrationMode, _inputOptions.OutputForTeamCity, _inputOptions.StartWebServerOnly, _inputOptions.UseRemoteTestPage);

            _logger.Debug("RunnerType = {0}".FormatWith(runnerType));

            TestReportCollection testReports = GetTestReports(runnerType);

            WriteXmlReport(testReports, _inputOptions.ReportOutputPath, _inputOptions.ReportOutputFileType);

            return(testReports);
        }
Beispiel #7
0
 public TimerActionTask(float duration, RunnerType type)
 {
     //if (duration < Time.deltaTime)
     //{
     //    Debug.LogError("Time set error:Please set duration unless deltaTime");
     //}
     OriginTime      = Time.time;
     this.duration   = duration;
     this.type       = type;
     CompletePercent = 0;
     calcZeroTime    = 0;
 }
        public static CodeRunner CreateRunner(RunnerType type, IVariableRetriever v)
        {
            return new CSharpRunner(v);  

            //switch (type)
            //{
            //    case RunnerType.CSharp:
            //        return new CSharpRunner(v);                
            //    default:
            //        return new CSharpRunner(v);                
            //}
        }
Beispiel #9
0
 private TestReport DoTheRun(RunnerType runnerType, StatLightConfiguration statLightConfiguration)
 {
     using (IRunner runner = GetRunner(
                _logger,
                runnerType,
                statLightConfiguration,
                _statLightRunnerFactory))
     {
         _logger.Debug("IRunner typeof({0})".FormatWith(runner.GetType().Name));
         return(_runnerFunc(runner));
     }
 }
Beispiel #10
0
        // ------------------------------------------------------------------------------------
        // Execution

        // Generate and execute a new test runner
        public void GenerateTestRunner(RunnerType type)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Generating a test runner"); // Write to console
            TestRunner newRunner;                                                                  // Store a reference to call on

            if (!Master.Instance.gameObject.GetComponent <TestRunner>())                           // If no test runner
            {
                newRunner = Master.Instance.gameObject.AddComponent <TestRunner>();                // Generate one
            }
            else
            {
                newRunner = Master.Instance.gameObject.GetComponent <TestRunner>(); // Get current
            }
            newRunner.SetupRunner(type);                                            // Setup the runner
        }
Beispiel #11
0
        public void SendTestGenMessage(int session, string sequenceData)
        {
            // TODO 暂时不配置Host信息
            RunnerType runnerType = (session == Constants.TestProjectSessionId)
                ? RunnerType.TestProject
                : RunnerType.SequenceGroup;
            RmtGenMessage rmtGenMessage = new RmtGenMessage(MessageNames.DownRmtGenMsgName, session, runnerType,
                                                            sequenceData);

            rmtGenMessage.Params.Add("MsgType", "Generation");
            _globalInfo.MessageTransceiver.Send(rmtGenMessage);
            // 发送生成事件
            TestGenEventInfo testGenEventInfo = new TestGenEventInfo(rmtGenMessage, TestGenState.StartGeneration);

            _globalInfo.EventQueue.Enqueue(testGenEventInfo);
        }
Beispiel #12
0
        // ------------------------------------------------------------------------------------
        // Test Execution

        // Start an individual test (called by TestRunner)
        public void StartTest(TestEntry inputTest, RunnerType runnerType)
        {
            Console.Instance.Write(DebugLevel.Logic, MessageLevel.Log, "Starting test " + inputTest.testName); // Write to console
            TestLogicBase activeTestLogic = null;

            if (!isAnalytic)                                                                                    // If not analytic mode
            {
                activeTest      = SuiteManager.GetTest(inputTest);                                              // Get the active test from suite manager
                activeTestLogic = GetLogicInstance(SuiteManager.GetSuiteName(inputTest.suiteIndex), inputTest); // Get active test logic instance
            }
            else
            {
                activeTest      = Common.GenerateTestFromTestEntry(inputTest);                                                     // Get the active test from structure
                activeTestLogic = GetLogicInstance(TestStructure.Instance.GetSuiteNameFromIndex(inputTest.suiteIndex), inputTest); // Get active test logic instance
            }
            StartCoroutine(activeTestLogic.SetupTest(inputTest, runnerType));                                                      // Setup test
        }
Beispiel #13
0
        public virtual IRunner Create(RunnerType runnerType, Computer computer)
        {
            IRunner runner;

            switch (runnerType)
            {
                case RunnerType.PsExec:
                    runner = new PsExecRunner(computer);
                    break;
                case RunnerType.Powershell:
                    runner = new PowershellRunner(computer);
                    break;
                default:
                    throw new InvalidOperationException(string.Format("Unknown runner type {0}", runnerType));
            }

            return runner;
        }
        private TestReportCollection GetTestReports(RunnerType runnerType)
        {
            var testReports = new TestReportCollection();

            IEnumerable <StatLightConfiguration> statLightConfigurations = _currentStatLightConfiguration.ToList();

            if (runnerType == RunnerType.ContinuousTest)
            {
                IRunner continuousTestRunner = _statLightRunnerFactory.CreateContinuousTestRunner(statLightConfigurations);
                continuousTestRunner.Run();
            }
            else
            {
                Stopwatch totalTime = Stopwatch.StartNew();

                do
                {
                    using (IRunner runner = GetRunner(
                               _logger,
                               runnerType,
                               _currentStatLightConfiguration.Current,
                               _statLightRunnerFactory))
                    {
                        _logger.Debug("IRunner typeof({0})".FormatWith(runner.GetType().Name));
                        Stopwatch  stopwatch  = Stopwatch.StartNew();
                        TestReport testReport = runner.Run();
                        stopwatch.Stop();
                        testReports.Add(testReport);
                        _eventPublisher.SendMessage(new TestReportGeneratedServerEvent(testReport, stopwatch.Elapsed,
                                                                                       statLightConfigurations.Count() >
                                                                                       1));
                    }
                } while (_currentStatLightConfiguration.MoveNext());

                totalTime.Stop();

                _eventPublisher.SendMessage(new TestReportCollectionGeneratedServerEvent(testReports, totalTime.Elapsed));
            }

            return(testReports);
        }
Beispiel #15
0
        private static IRunner GetRunner(ILogger logger, RunnerType runnerType,
                                         StatLightConfiguration statLightConfiguration, IStatLightRunnerFactory statLightRunnerFactory)
        {
            switch (runnerType)
            {
            case RunnerType.TeamCity:
                logger.LogChatterLevel = LogChatterLevels.None;
                return(statLightRunnerFactory.CreateTeamCityRunner(statLightConfiguration));

            case RunnerType.ContinuousTest:
                return(statLightRunnerFactory.CreateContinuousTestRunner(statLightConfiguration));

            case RunnerType.WebServerOnly:
                return(statLightRunnerFactory.CreateWebServerOnlyRunner(statLightConfiguration));

            case RunnerType.RemoteRun:
                return(statLightRunnerFactory.CreateRemotelyHostedRunner(statLightConfiguration));

            default:
                return(statLightRunnerFactory.CreateOnetimeConsoleRunner(statLightConfiguration));
            }
        }
Beispiel #16
0
        internal JobContext GetNextJobContext(RunnerType runnerType)
        {
            lock (_syncRoot)
            {
                var node = _jobs.First;
                while (node != null)
                {
                    var context = node.Value;
                    var due     = context.Job.Due.Seconds;
                    if (DateTime.UtcNow >= context.UtcNextExecution &&
                        (runnerType == RunnerType.RealTime && due < RealTimeDuration ||
                         runnerType == RunnerType.LongRunning))
                    {
                        _jobs.Remove(node);
                        return(context);
                    }

                    node = node.Next;
                }
                return(null);
            }
        }
Beispiel #17
0
        public void CanCallFactoryForTest(string runnerTypeParameter, RunnerType actualRunnerType)
        {
            // given
            Mock<IRunner> runner = new Mock<IRunner>(MockBehavior.Strict);
            runner
                .Setup(r => r.ExecuteCommand(@"c:\temp", "systeminfo", string.Empty));

            Mock<RunnerFactory> mockRunnerFactory = new Mock<RunnerFactory>(MockBehavior.Strict);
            mockRunnerFactory
                .Setup(mrf => mrf.Create(
                    actualRunnerType,
                    It.Is<Computer>(c =>
                        (c.Name == "mycomputer")
                        && (c.NetworkCredential.Password == "foobah")
                        && (c.NetworkCredential.UserName == "Administrator"))))
                .Returns(runner.Object);

            // when
            Check check = new Check(mockRunnerFactory.Object);

            StringWriter output = new StringWriter();
            ConsoleCommandDispatcher.DispatchCommand(
                check,
                new[]
                {
                    "-runnertype", runnerTypeParameter,
                    "-computername", "mycomputer",
                    "-adminpassword", "foobah"
                },
                output);

            int result = check.Run(new string[] { });
            Assert.That(result, Is.EqualTo(0));

            runner.VerifyAll();
            mockRunnerFactory.VerifyAll();
        }
Beispiel #18
0
 public Runner(Scheduler scheduler, RunnerType runnerType)
 {
     _scheduler = scheduler;
     RunnerType = runnerType;
     ID = Interlocked.Increment(ref _id);
 }
Beispiel #19
0
 private TestReport DoTheRun(RunnerType runnerType, StatLightConfiguration statLightConfiguration)
 {
     using (IRunner runner = GetRunner(
         _logger,
         runnerType,
         statLightConfiguration,
         _statLightRunnerFactory))
     {
         _logger.Debug("IRunner typeof({0})".FormatWith(runner.GetType().Name));
         return _runnerFunc(runner);
     }
 }
Beispiel #20
0
        private static IRunner GetRunner(ILogger logger, RunnerType runnerType,
            StatLightConfiguration statLightConfiguration, IStatLightRunnerFactory statLightRunnerFactory)
        {
            switch (runnerType)
            {
                case RunnerType.TeamCity:
                    logger.LogChatterLevel = LogChatterLevels.None;
                    return statLightRunnerFactory.CreateTeamCityRunner(statLightConfiguration);

                case RunnerType.ContinuousTest:
                    return statLightRunnerFactory.CreateContinuousTestRunner(statLightConfiguration);

                case RunnerType.WebServerOnly:
                    return statLightRunnerFactory.CreateWebServerOnlyRunner(statLightConfiguration);

                case RunnerType.RemoteRun:
                    return statLightRunnerFactory.CreateRemotelyHostedRunner(statLightConfiguration);

                default:
                    return statLightRunnerFactory.CreateOnetimeConsoleRunner(statLightConfiguration);
            }
        }
Beispiel #21
0
        internal JobContext GetNextJobContext(RunnerType runnerType)
        {
            lock (_syncRoot)
            {
                var node = _jobs.First;
                while (node != null)
                {
                    var context = node.Value;
                    var due = context.Job.Due.Seconds;
                    if (DateTime.UtcNow >= context.UtcNextExecution
                        && (runnerType == RunnerType.RealTime && due < RealTimeDuration
                            || runnerType == RunnerType.LongRunning))
                    {
                        _jobs.Remove(node);
                        return context;
                    }

                    node = node.Next;
                }
                return null;
            }
        }
Beispiel #22
0
 public RmtGenMessage(string name, int id, RunnerType type) : base(name, id, MessageType.RmtGen)
 {
     this.SequenceType = type;
     this.Sequence     = null;
     this.Params       = new Dictionary <string, string>(CoreConstants.DefaultRuntimeSize);
 }
Beispiel #23
0
 public Result(IRunnerArgs args, RunnerType type, string disposition) : this(args, type)
 {
     Disposition = disposition;
 }
        private TestReportCollection GetTestReports(RunnerType runnerType)
        {
            var testReports = new TestReportCollection();

            IEnumerable<StatLightConfiguration> statLightConfigurations = _currentStatLightConfiguration.ToList();

            if (runnerType == RunnerType.ContinuousTest)
            {
                IRunner continuousTestRunner = _statLightRunnerFactory.CreateContinuousTestRunner(statLightConfigurations);
                continuousTestRunner.Run();
            }
            else
            {

                Stopwatch totalTime = Stopwatch.StartNew();

                do
                {
                    using (IRunner runner = GetRunner(
                        _logger,
                        runnerType,
                        _currentStatLightConfiguration.Current,
                        _statLightRunnerFactory))
                    {
                        _logger.Debug("IRunner typeof({0})".FormatWith(runner.GetType().Name));
                        Stopwatch stopwatch = Stopwatch.StartNew();
                        TestReport testReport = runner.Run();
                        stopwatch.Stop();
                        testReports.Add(testReport);
                        _eventPublisher.SendMessage(new TestReportGeneratedServerEvent(testReport, stopwatch.Elapsed,
                                                                                       statLightConfigurations.Count() >
                                                                                       1));
                    }

                } while (_currentStatLightConfiguration.MoveNext());

                totalTime.Stop();

                _eventPublisher.SendMessage(new TestReportCollectionGeneratedServerEvent(testReports, totalTime.Elapsed));
            }

            return testReports;
        }
Beispiel #25
0
 public Result(IRunnerArgs args, RunnerType type) : this(args)
 {
     RunnerType = type;
 }
Beispiel #26
0
 public Runner(Scheduler scheduler, RunnerType runnerType)
 {
     _scheduler = scheduler;
     RunnerType = runnerType;
     ID         = Interlocked.Increment(ref _id);
 }