Пример #1
0
        private static IObservable <string> GetOrCreateWatcher(string testDll)
        {
            var dlld = new FileInfo(testDll);

            if (_watchers.ContainsKey(dlld.FullName))
            {
                return(Rxn.Empty <string>()); //already subscribed to updates
            }
            var watcher = Files.WatchForChanges(dlld.DirectoryName, dlld.Name, true, false, false);

            _watchers.Add(dlld.FullName, watcher);
            return(watcher);
        }
Пример #2
0
        public static IObservable <StartUnitTest> GetTargets(string testSyntax, string[] args, Func <ITestArena[]> forCompete, IServiceCommandFactory parseTestSyntax, IObservable <UnitTestResult> forParallelExection)
        {
            return(testSyntax.IsNullOrWhitespace() ?
                   Rxn.Empty <StartUnitTest>() :
                   Rxn.DfrCreate <StartUnitTest>(() =>
            {
                if (!(testSyntax.Contains(".dll", StringComparison.InvariantCultureIgnoreCase) ||
                      testSyntax.Contains(".csproj", StringComparison.InvariantCultureIgnoreCase) ||
                      testSyntax.Contains(".bfc", StringComparison.InvariantCultureIgnoreCase)))
                {
                    "Target must be either .dll or .csproj or .bfc".LogDebug();
                    return Rxn.Empty <StartUnitTest>();
                }

                if (testSyntax.Contains(".bfc"))
                {
                    return GetTargetsFromBfc(testSyntax, parseTestSyntax, forParallelExection);
                }

                if (!testSyntax.Contains("*"))
                {
                    return GetTargetsFromDll(args, testSyntax, forCompete);
                }
                else
                {
                    return GetTargetsFromPath(args, testSyntax, forCompete);
                }
            })
                   .Select(e =>
            {
                e.Dll = e.Dll.AsCrossPlatformPath();

                if (!FocusedTest.IsNullOrWhitespace())
                {
                    e.RunThisTest = FocusedTest;
                }

                return e;
            }));
        }
Пример #3
0
 public IObservable <CommandResult> Handle(StartUnitTest command)
 {
     Queue(command);
     //the result will be broadcast when the queue processes the command
     return(Rxn.Empty <CommandResult>());
 }
Пример #4
0
        public IObservable <Unit> RunTestSuiteInTestArena(StartUnitTest work, StreamWriter testLog, string logDir)
        {
            $"Preparing to run {(work.RunAllTest ? "All" : work.RunThisTest)} in {work.Dll}".LogDebug();

            if (!Directory.Exists(logDir))
            {
                Directory.CreateDirectory(logDir);
            }

            var keepTestUpdatedIfRequested =
                work.UseAppUpdate.ToObservable(); //if not using updates, the dest folder is our root

            if (!File.Exists(work.Dll))
            {
                if (work.UseAppUpdate.IsNullOrWhitespace())
                {
                    _rxnManager.Publish(new UnitTestResult()
                    {
                        WasSuccessful = false, Message = $"Cannot find target @{work.Dll}".LogDebug()
                    }.AsResultOf(work));
                    return(Rxn.Empty <Unit>());
                }

                keepTestUpdatedIfRequested = _updateService.KeepUpdated(work.UseAppUpdate, work.UseAppVersion, theBfg.GetTestSuiteDir(work.UseAppUpdate, work.UseAppVersion), new RxnAppCfg()
                {
                    AppStatusUrl = work.AppStatusUrl.IsNullOrWhiteSpace("http://localhost:888"),
                    SystemName   = work.UseAppUpdate,
                    KeepUpdated  = true
                }, true);
            }
            else
            {
                work.Dll = FindIfNotExists(work.Dll);
            }

            return(keepTestUpdatedIfRequested //run the test
                   .Select(testPath =>
            {
                $"Running {work.Dll}".LogDebug();

                foreach (var arena in _arena())
                {
                    try
                    {
                        var tests = arena.ListTests(work.Dll).WaitR();
                        if (tests.AnyItems())
                        {
                            return arena.Start(Name, work, testLog, logDir).SelectMany(_ => _rxnManager.Publish(_));
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }

                "Argh, couldnt find a test arena to run this test".LogDebug();
                _rxnManager.Publish(new UnitTestResult()
                {
                    WasSuccessful = false, Message = $"No test arena on host is compatible with {work.Dll}"
                }.AsResultOf(work));
                return Rxn.Empty <Unit>();
            })
                   .Switch());
        }
Пример #5
0
        public IObservable <IRxn> Process(TestArenaCfgUpdated @event)
        {
            @event.Cfg?.Save();

            return(Rxn.Empty <IRxn>());
        }
Пример #6
0
        /// <summary>
        /// todo: fix issue with not broadcasting all test stats to appstatus, only first time
        /// </summary>
        /// <param name="testCluster"></param>
        /// <param name="unitTestToRun"></param>
        /// <param name="publusher"></param>
        /// <param name="reactorMgr"></param>
        private void BroadcasteStatsToTestArena(IManageReactors reactorMgr)
        {
            var bfgReactor = reactorMgr.GetOrCreate("bfg").Reactor;

            //need to fix health which will allow this to be viewed on the appstatus portal. should monitor health of fanout stratergy
            //
            //IMonitorActionFactory<IRxn> health =MonitorHealth
            RxnCreator.MonitorHealth <IRxn>(bfgReactor, "theBFG", out var _before, () => Rxn.Empty()).SelectMany(bfgReactor.Output).Until();


            $"Heartbeating".LogDebug();
            bfgReactor.Output.Publish(new PerformAPing()).Until();
        }