예제 #1
0
        public void RunSingleExperimentOn2Threads()
        {
            IExperimentRepo repo = new MockExperimentRepo();
            IExperimentFactory factory = new MockExperimentFactory("Instance0",
                (i) =>
                {
                    Thread.Sleep(TimeSpan.FromSeconds(1));
                    return 3.5;
                });

            ExperimentRequest request = repo.GetPendingRequests().First();
            Assert.AreEqual(request.CurrentState, ExperimentRequest.State.Queued);
            Assert.AreEqual(2, request.NumberOfThreads);

            ExperimentRunner runner = new ExperimentRunner("Instance0", repo, factory);
            runner.Start();
            Assert.IsTrue(runner.IsRunning);
            Thread.Sleep(TimeSpan.FromSeconds(10 + request.RequestedIterations * 6));
            runner.Cancel();
            bool hasFinished = runner.WaitForCompletion(TimeSpan.FromSeconds(10));
            Assert.IsTrue(hasFinished, "unexpected tiemout waiting for runner to finish");

            // TODO: add proper runner/container result validation
            //Assert.AreEqual(request.CurrentState, ExperimentRequest.State.Completed);
            //IEnumerable<ExperimentResult> results = repo.GetResults(request.ExperimentId);
            //Assert.AreEqual(request.NumberOfThreads * request.RequestedIterations, results.Count());
        }
예제 #2
0
        public override void Run()
        {
            // This is a sample worker implementation. Replace with your logic.
            Trace.WriteLine("WorkerRole1 entry point called", "Information");

            ExperimentRunner runner = new ExperimentRunner(RoleEnvironment.CurrentRoleInstance.Id, new CloudExperimentRepo(), new CloudExperimentFactory());
            //runner.Start();
        }