예제 #1
0
		internal void LoadTestFile(string filename)
		{
			if (_testcaseProvider != null)
			{
				_testcaseProvider.Unload();
				_testcaseProvider = null;
			}
			_testcaseProvider = new TestcaseProvider(filename);
			_testcaseProvider.CreateAppDomain();
		}
		void IBuildTaskService.SendTestcaseFile(string testsystemName, byte[] data)
		{
			object _lock = _testFileLocker.GetLock(testsystemName);
			lock(_lock)
			{
				Testsystem testsystem = _testsystemRepository.GetByName(testsystemName);
				testsystem.LastUpdated = DateTime.Now;
				_testsystemRepository.Store(testsystem);
				string testFile = RegtestingServerConfiguration.Testsfolder + testsystem.Filename;
				Directory.CreateDirectory(Path.GetDirectoryName(testFile));
				using (FileStream fileStream = new FileStream(testFile, FileMode.Create, FileAccess.Write))
				{
					fileStream.Write(data, 0, data.Length);
				}
				Logger.Log("UPDATE branch: " + testsystemName);
				TestcaseProvider testcaseProvider = new TestcaseProvider(testFile);
				testcaseProvider.CreateAppDomain();
				foreach (string testcaseType in testcaseProvider.Types)
				{
					ITestable testable = testcaseProvider.GetTestableFromTypeName(testcaseType);
					if(testable==null) continue;
					
					Testcase testcase = _testcaseRepository.GetByType(testcaseType);
					string testableName = testable.GetName();
					if (testcase == null)
					{
						Logger.Log("New test: " + testableName);
						testcase = new Testcase { Name = testableName, Type = testcaseType };
						_testcaseRepository.Store(testcase);
					}
					else if (!testcase.Name.Equals(testableName))
					{
						Logger.Log("Renamed test: " + testcase.Name + " to " + testableName);
						testcase.Name = testableName;
						_testcaseRepository.Store(testcase);
						
					}
					
				}
				testcaseProvider.Unload();
			}

		}
예제 #3
0
 private ITestable GetTestable(WorkItem workItem, TestcaseProvider testcaseProvider)
 {
     object branchSpecificFileLock = _testFileLocker.GetLock(workItem.Testsystem.Name);
     lock (branchSpecificFileLock)
     {
         ITestable testable = testcaseProvider.GetTestableFromTypeName(workItem.Testcase.Type);
         return testable;
     }
 }
예제 #4
0
        private void AddTestJobImpl(ITestJobManager testJobManager, ICollection<WorkItem> workItems)
        {
            TestcaseProvider testcaseProvider;

            object branchSpecificFileLock = _testFileLocker.GetLock(testJobManager.TestJob.Testsystem.Name);
            lock (branchSpecificFileLock)
            {
                testcaseProvider =
                    new TestcaseProvider(RegtestingServerConfiguration.Testsfolder + testJobManager.TestJob.Testsystem.Filename);
                testcaseProvider.CreateAppDomain();
            }

            _testJobRepository.Store(testJobManager.TestJob);

            lock (_lockWorkItems)
            {
                List<WorkItem> alreadyFoundWorkItems = new List<WorkItem>();
                List<Result> updatedResults = new List<Result>();

                foreach (WorkItem workItem in workItems)
                {

                    ITestable testable = GetTestable(workItem, testcaseProvider);
                    if (testable==null)
                    {
                        updatedResults.Add(UpdateResultInfos(workItem, testJobManager.TestJob, TestState.NotAvailable));
                        continue;
                    }

                    if (!IsWorkItemSupported(workItem, testable))
                    {
                        updatedResults.Add(UpdateResultInfos(workItem, testJobManager.TestJob, TestState.NotSupported));
                        continue;
                    }

                    WorkItem existingWorkItem = CheckForAlreadyQueyedWorkItems(workItem);
                    if (existingWorkItem != null)
                    {
                        existingWorkItem.AddTestJobManager(testJobManager);
                        alreadyFoundWorkItems.Add(existingWorkItem);
                    }
                    else
                    {
                        testJobManager.AddWorkItem(workItem);
                        updatedResults.Add(UpdateResultInfos(workItem, testJobManager.TestJob, TestState.Pending));
                    }
                }

                //If there is nothing to test, don't add a testsuite
                if (testJobManager.Count == 0 &&
                    alreadyFoundWorkItems.Count == 0)
                    return;

                _currentTestJobManagers.Add(testJobManager);

                //Add new workItems to waiting list
                testJobManager.WorkItems.ForEach(_waitingWorkItems.Add);

                //Add already found workItems back to
                alreadyFoundWorkItems.ForEach(testJobManager.AddWorkItem);
                _resultRepository.Store(updatedResults);
            }
        }
예제 #5
0
        private void UpdateTestcases(Testsystem testsystem)
        {
            const string testfile = @"LocalTests.dll";
            byte[] data;
            using (WcfClient wcfClient = new WcfClient(_serverAdr))
            {
                data = wcfClient.FetchDll(_nodename, testsystem.Name);
            }

            using (FileStream fileStream = new FileStream(testfile, FileMode.Create, FileAccess.Write))
            {
                fileStream.Write(data, 0, data.Length);
            }
            _testcaseProvider = new TestcaseProvider(testfile);
            _testcaseProvider.CreateAppDomain();
        }
		Guid ISlimServerService.AddTestJob(string testsystemName, byte[] data)
		{
			var jobGuid = Guid.NewGuid();
			string testFile = RegtestingServerConfiguration.Testsfolder + jobGuid + ".dll";;
			Directory.CreateDirectory(Path.GetDirectoryName(testFile));
			using (FileStream fileStream = new FileStream(testFile, FileMode.Create, FileAccess.Write))
			{
				fileStream.Write(data, 0, data.Length);
			}
            TestcaseProvider testcaseProvider = new TestcaseProvider(testFile);
			testcaseProvider.CreateAppDomain();


			List<WorkItem> items = new List<WorkItem>();
			foreach (string testcaseType in testcaseProvider.Types)
			{
				ITestable testable = testcaseProvider.GetTestableFromTypeName(testcaseType);
				if (testable == null) continue;
				WorkItem workItem = new WorkItem
				{
					Browser = new BrowserDto
					{
						Browserstring = "chrome",
						Name = "Chrome"
					},
					Language = new LanguageDto
					{
						Name = "Deutsch",
						Languagecode = "DE"
					},
					Testcase = new TestcaseDto
					{
						Name = testable.GetName(),
						Type = testcaseType
					},
					Testsystem = new TestsystemDto
					{
						Filename = jobGuid + ".dll",
						Name = testsystemName,
						Url = testsystemName
					}
				};
				items.Add(workItem);
			}
			testcaseProvider.Unload();

			TestingJob testingJob = new TestingJob
			{
				Guid = jobGuid,
				ResultCode = TestState.Pending,
				WaitingWorkItems = items,
				TestFile = testFile,
				CurrentWorkItems = new Dictionary<string, WorkItemTask>(),
				FinishedWorkItems = new List<WorkItem>(),
				ResultGenerator = new ResultGenerator()
			};

			TestPool.AddTestingJob(testingJob);
			Console.WriteLine("Added Job "  + jobGuid + "(" + testcaseProvider.Types.Count() + " tests) to Testpool.");
			return jobGuid;
		}