コード例 #1
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();
        }
コード例 #2
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();
        }
コード例 #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();
        }