示例#1
0
        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();
            }
        }
示例#2
0
        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 = "phantomjs",
                        Name          = "phantomjs"
                    },
                    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);
        }