Ejemplo n.º 1
0
 public TestController(IApplicationContext ctx)
 {
     _ctx = ctx;
     _resourceManager = (IResourceManager)ctx.GetObject("ResourceManager");
     _resourceManager.SetTestController(this);
     _testCases = new BindingList<TestCase>();
     _communicationManager = new CommunicatorManager();
     _robotRepo = new RobotsRepository();
     _clientThreadPool = new AgentThreadPool();
     _focusedAgent = null;
     _focusedTestCase = null;
     _refreshFocusViewLock = new Object();
     _driverList = new List<IRobotDriver>();
     _mapManager = new MapManager();
 }
Ejemplo n.º 2
0
        public void initTestCase(TestCase te)
        {
            LOG.Info("Initing Working group for C{"+te.WorkingGroup.Client.Name+"}");
            _testCasesMap.Add(te.WorkingGroup.Client.Name, te);
            IAgentLeader leader = _testController.CreateLeader("AgentLeader");
            te.WorkingGroup.Leader = leader;
            te.WorkingGroup.Client.SetLeader(leader);
            leader.SetClient(te.WorkingGroup.Client);

            Vector clientPositon = te.Description.StartPosition;
            int allTest = _testController.TestCasesList.Count;
            int allRobots = _testController.RobotsRepository.GetRobotsCount("FiraRobot");
            int scoutsCount = allRobots / allTest;

            for (int i = 0; i < scoutsCount; i++ )
            {
                Vector position = calculatePosition(clientPositon,i,scoutsCount, 0.7);
                IScoutAgent scount = _testController.CreateScout("AgnetScout", position);
                scount.SetLeader(leader);
                leader.AssignScout(scount);
                te.WorkingGroup.Scouts.Add(scount);
            }
        }
Ejemplo n.º 3
0
        private void FireTestCase(TestCase te)
        {
            try
            {
                LOG.Info("Strating test case : " + te.ToString());
                te.Status = TestState.Processing;
                IClientAgent client = CreateClient(te.Description.ClientType, te.Description.StartPosition);
                te.WorkingGroup = new WorkingGroup();
                te.WorkingGroup.Client = client;
                _resourceManager.initTestCase(te);

                _driverList.Add(client.GetDriver());
                foreach (IRobotAgent scaut in te.WorkingGroup.Scouts)
                {
                    _driverList.Add(scaut.GetDriver());
                }

                _clientThreadPool.RunAgentThread(client);

                IMapManagment leaderMap = _mapManager.GetMainMap().CreateChildMap();

                foreach (IScoutAgent scout in te.WorkingGroup.Scouts)
                {
                    IMapManagment scoutMap = leaderMap.CreateChildMap();
                    AgentContainer container = new AgentContainer(scout, scoutMap);
                    scout.SetMap(scoutMap);
                    scout.GetDriver().SetMap(scoutMap);
                    _clientThreadPool.RunAgentThread(container);
                }

                te.WorkingGroup.Leader.SetMap(leaderMap);
                AgentContainer leaderContainer = new AgentContainer(te.WorkingGroup.Leader, leaderMap);
                _clientThreadPool.RunAgentThread(leaderContainer);
                LOG.Info("Strating test case : " + te.ToString() + " DONE");
            }
            catch (Exception ex)
            {
                te.Status = TestState.Fail;
                LOG.Error("Cannot run test " + te.ToString(), ex);
            }
        }
Ejemplo n.º 4
0
 public void SetTestCases(List<TestCaseDescription> testCasesDescription)
 {
     LOG.Info("Setting TestCases");
     foreach (TestCaseDescription testDescription in testCasesDescription)
     {
         TestCase testCase = new TestCase(testDescription);
         TestCasesList.Add(testCase);
         LOG.Info("Add test case: " + testCase.ToString());
     }
     UpdateUI();
 }
Ejemplo n.º 5
0
 public void SetFocusOnTestCase(TestCase testCase)
 {
     lock (_refreshFocusViewLock)
     {
         _focusedTestCase = testCase;
         UpdateUI();
     }
 }
Ejemplo n.º 6
0
 public void Reset()
 {
     try
     {
         LOG.Info("Resetting");
         UpdateProgress("Resetting...", 10);
         StopTestThread();
         UpdateProgress("Resetting...", 20);
         _resourceManager.Reset();
         _driverList.Clear();
         _testCases.Clear();
         UpdateProgress("Resetting...", 50);
         _communicationManager.Reset();
         UpdateProgress("Resetting...", 70);
         _robotRepo.Reset();
         _clientThreadPool.Dispose();
         _clientThreadPool = new AgentThreadPool();
         UpdateProgress("Resetting...", 90);
         lock (_refreshFocusViewLock)
         {
             _focusedAgent = null;
             _focusedTestCase = null;
         }
         UpdateProgress("", 0);
         _mapManager.Reset();
     }
     catch (CommunicatorException ce)
     {
         LogError("Error during reseting: " + ce.Message);
         UpdateProgress("", 0);
     }
     UpdateUI();
 }