示例#1
0
        public IObservable <bfgWorker> SpawnTestWorker(string[] tags = null)
        {
            var instanceId = _workerCluster.Workflow.Workers.Count + 1;

            "Spawning worker".LogDebug(instanceId);

            //$"Streaming logs".LogDebug();
            //rxnManager.Publish(new StreamLogs(TimeSpan.FromMinutes(60))).Until();

            $"Starting worker".LogDebug();

            var testWorker = new bfgWorker(
                $"{ClientId}/TestWorker#{instanceId}",
                "local",
                tags ?? theBfg.Args.Where(w => w.StartsWith("#")).ToArray(),
                _appServiceRegistry, _serviceDiscovery,
                _zipService, _appStatus,
                _eventManager, _appUpdates,
                _appStatusCfg,
                _resolver.Resolve <Func <ITestArena[]> >()
                );

            _workerCluster.Process(new WorkerDiscovered <StartUnitTest, UnitTestResult>()
            {
                Worker = testWorker
            })
            .SelectMany(e => _eventManager.Publish(e)).Until();

            return(StartDiscoveringTestsIf(_cfg, testWorker).Select(_ => testWorker));
        }
示例#2
0
 public void Publish(IRxn rxn)
 {
     _rxnManager.Publish(rxn).Until();
 }
示例#3
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());
        }
示例#4
0
 public AssertionFilter(IAppNav <Page, IRxnPageModel> appNav, IRxnManager <IRxn> eventManager)
 {
     _appNav = appNav;
     eventManager.CreateSubscription <ShakeGesture>().Do(_ => eventManager.Publish(new AssertModel(Snapshot(_appNav.Current.Model)))).Until();
 }