Exemplo n.º 1
0
        public async Task NodeObserver_Negative_Integer_CPU_Mem_Ports_Firewalls_Values_No_Exceptions_Intialize()
        {
            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 NodeObserver
            {
                IsTestRun = true,
                CpuWarningUsageThresholdPct  = -1000,
                MemWarningUsageThresholdMB   = -2500,
                EphemeralPortsErrorThreshold = -42,
            };

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

            // Bad values don't crash Initialize...
            Assert.IsFalse(obs.IsUnhealthy);

            // It ran (crashing in Initialize would not set LastRunDate, which is MinValue until set...)
            Assert.IsTrue(obs.LastRunDateTime > startDateTime);

            obs.Dispose();
            ObserverManager.FabricClientInstance.Dispose();
        }
Exemplo n.º 2
0
        public async Task NodeObserver_Integer_Greater_Than_100_CPU_Warn_Threshold_No_Fail()
        {
            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 NodeObserver
            {
                IsTestRun = true,
                CpuWarningUsageThresholdPct = 10000,
            };

            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);

            obs.Dispose();
            ObserverManager.FabricClientInstance.Dispose();
        }
Exemplo n.º 3
0
        public async Task NodeObserver_ObserveAsync_Successful_Observer_IsHealthy_WarningsOrErrorsDetected()
        {
            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 NodeObserver
            {
                IsTestRun = true,
                MemWarningUsageThresholdMB = 1, // This will generate Warning for sure...
            };

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

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

            Assert.IsTrue(obs.HasActiveFabricErrorOrWarning);

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

            obs.Dispose();
            ObserverManager.FabricClientInstance.Dispose();
        }
Exemplo n.º 4
0
        public void Successful_NodeObserver_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 NodeObserver
            {
                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();
        }
Exemplo n.º 5
0
        public void NodeObserver_Constructor_Test()
        {
            ObserverManager.FabricServiceContext = this.context;
            ObserverManager.FabricClientInstance = new FabricClient(FabricClientRole.User);
            ObserverManager.TelemetryEnabled     = false;
            ObserverManager.EtwEnabled           = false;

            var obs = new NodeObserver();

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

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