Beispiel #1
0
        public void Successful_OSObserver_Run_Cancellation_Via_ObserverManager()
        {
            ObserverManager.FabricServiceContext = this.context;
            ObserverManager.TelemetryEnabled     = false;
            ObserverManager.EtwEnabled           = false;
            ObserverManager.FabricClientInstance = new FabricClient(FabricClientRole.User);

            var stopWatch = new Stopwatch();

            var obs = new OSObserver
            {
                IsEnabled = true,
                NodeName  = "_Test_0",
                IsTestRun = true,
            };

            var obsMgr = new ObserverManager(obs)
            {
                ApplicationName = "fabric:/TestApp0",
            };

            var objReady = new ManualResetEventSlim(false);

            stopWatch.Start();
            var t = Task.Factory.StartNew(() =>
            {
                objReady.Set();
                obsMgr.StartObservers();
            });

            objReady?.Wait();

            while (!obsMgr.IsObserverRunning && stopWatch.Elapsed.TotalSeconds < 10)
            {
                // wait...
            }

            stopWatch.Stop();

            obsMgr.StopObservers();

            Thread.Sleep(5);
            Assert.IsFalse(obsMgr.IsObserverRunning);

            obs.Dispose();
            objReady?.Dispose();
        }
Beispiel #2
0
        public void OSObserver_Constructor_Test()
        {
            ObserverManager.FabricServiceContext = this.context;
            ObserverManager.FabricClientInstance = new FabricClient(FabricClientRole.User);
            ObserverManager.TelemetryEnabled     = false;
            ObserverManager.EtwEnabled           = false;

            var obs = new OSObserver();

            Assert.IsTrue(obs.ObserverLogger != null);
            Assert.IsTrue(obs.CsvFileLogger != null);
            Assert.IsTrue(obs.HealthReporter != null);
            Assert.IsTrue(obs.ObserverName == ObserverConstants.OSObserverName);

            obs.Dispose();
            ObserverManager.FabricClientInstance.Dispose();
        }
Beispiel #3
0
        public async Task OSObserver_ObserveAsync_Successful_Observer_IsHealthy_NoWarningsOrErrors()
        {
            if (!this.isSFRuntimePresentOnTestMachine)
            {
                return;
            }

            var startDateTime = DateTime.Now;

            ObserverManager.FabricServiceContext = this.context;
            ObserverManager.FabricClientInstance = new FabricClient(FabricClientRole.User);
            ObserverManager.TelemetryEnabled     = false;
            ObserverManager.EtwEnabled           = false;

            var obs = new OSObserver()
            {
                IsTestRun        = true,
                TestManifestPath = $@"{Environment.CurrentDirectory}\clusterManifest.xml",
            };

            await obs.ObserveAsync(this.token).ConfigureAwait(true);

            // observer ran to completion with no errors...
            Assert.IsTrue(obs.LastRunDateTime > startDateTime);

            // observer detected no error conditions...
            Assert.IsFalse(obs.HasActiveFabricErrorOrWarning);

            // observer did not have any internal errors during run...
            Assert.IsFalse(obs.IsUnhealthy);

            var outputFilePath = $@"{Environment.CurrentDirectory}\observer_logs\SysInfo.txt";

            // Output log file was created successfully during test...
            Assert.IsTrue(File.Exists(outputFilePath) &&
                          File.GetLastWriteTime(outputFilePath) > startDateTime &&
                          File.GetLastWriteTime(outputFilePath) < obs.LastRunDateTime);

            // Output file is not empty...
            Assert.IsTrue(File.ReadAllLines(outputFilePath).Length > 0);

            obs.Dispose();
            ObserverManager.FabricClientInstance.Dispose();
        }