diff --git a/src/ServicePulse.Host/app/js/endpoints/endpoints.controller.js b/src/ServicePulse.Host/app/js/endpoints/endpoints.controller.js index 36504d41ff..3ee78dc127 100644 --- a/src/ServicePulse.Host/app/js/endpoints/endpoints.controller.js +++ b/src/ServicePulse.Host/app/js/endpoints/endpoints.controller.js @@ -1,4 +1,5 @@ -; (function (window, angular, undefined) { +; +(function(window, angular, undefined) { 'use strict'; @@ -8,32 +9,67 @@ $scope.model = { active: [], inactive: [] }; - $scope.$on('$destroy', function () { + $scope.$on('$destroy', function() { $timeout.cancel(timeoutId); }); function updateUI() { - configurationService.getData().then(function (endpoints) { - $scope.model.active = []; - $scope.model.inactive = []; + configurationService.getData().then(function(endpoints) { var endpointList = endpoints.data; - for (var j = 0; j < endpointList.length; j++) { - var item = endpointList[j]; + // remove unmonitored + var unmonitored = endpointList.filter(function(umi) { + return !umi.monitor_heartbeat; + }); - if (!item.monitor_heartbeat) { - continue; + var i, obj; + + for (i = 0; i < $scope.model.active.length; i++) { + obj = $scope.model.active[i]; + if (unmonitored.indexOf(obj.id) !== -1) { + $scope.model.active.splice(i, 1); + i--; // we just made the array 1 shorter } + } + + for (i = 0; i < $scope.model.inactive.length; i++) { + obj = $scope.model.inactive[i]; + if (unmonitored.indexOf(obj.id) !== -1) { + $scope.model.inactive.splice(i, 1); + i--; + } + } + + var monitored = endpointList.filter(function(mi) { + return mi.monitor_heartbeat; + }); + + for (var j = 0; j < monitored.length; j++) { + var item = monitored[j]; + + var activeIndex = $scope.model.active.map(function(bi) { return bi.id; }).indexOf(item.id); + var inactiveIndex = $scope.model.inactive.map(function(bi) { return bi.id; }).indexOf(item.id); if (item.hasOwnProperty('heartbeat_information') && item.heartbeat_information.reported_status === 'beating') { - $scope.model.active.push(item); + if (activeIndex === -1) { + $scope.model.active.push(item); + } + if (inactiveIndex !== -1) { + $scope.model.inactive.splice(inactiveIndex, 1); + } } else { - $scope.model.inactive.push(item); + if (inactiveIndex === -1) { + $scope.model.inactive.push(item); + } + if (activeIndex !== -1) { + $scope.model.active.splice(activeIndex, 1); + } + } } - timeoutId = $timeout(function () { + timeoutId = $timeout(function() { updateUI(); }, 5000); }); @@ -43,10 +79,10 @@ }; controller.$inject = [ - '$scope', '$timeout' , 'configurationService' + '$scope', '$timeout', 'configurationService' ]; angular.module('endpoints') .controller('EndpointsCtrl', controller); -} (window, window.angular)); \ No newline at end of file +}(window, window.angular)); \ No newline at end of file diff --git a/src/ServicePulse.Host/app/js/services/services.service-control.js b/src/ServicePulse.Host/app/js/services/services.service-control.js index 46d5891491..5c3abcdda1 100644 --- a/src/ServicePulse.Host/app/js/services/services.service-control.js +++ b/src/ServicePulse.Host/app/js/services/services.service-control.js @@ -84,7 +84,7 @@ }; function getTotalFailingCustomChecks() { - var url = uri.join(scConfig.service_control_url, 'customchecks?status=unresolved'); + var url = uri.join(scConfig.service_control_url, 'customchecks?status=fail'); return $http.get(url).then(function(response) { return response.headers('Total-Count'); }); diff --git a/src/ServicePulse.sln b/src/ServicePulse.sln index 2abbd2a44f..ff7b20dbed 100644 --- a/src/ServicePulse.sln +++ b/src/ServicePulse.sln @@ -18,6 +18,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Chocolatey", "Chocolatey", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServicePulse.Host.Tests", "ServicePulse.Host.Tests\ServicePulse.Host.Tests.csproj", "{113A09CC-9665-4E87-9FC7-7E5C8C0AFE71}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SmokeTesting", "SmokeTesting", "{E4018B8E-ED2B-464C-B9A7-70BD97448D4B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmokeTest.Client", "SmokeTest.Client\SmokeTest.Client.csproj", "{A9B109A2-71C7-40C5-B1F4-D637D3808796}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmokeTest.Server", "SmokeTest.Server\SmokeTest.Server.csproj", "{CBC386E8-36FB-4427-A212-88F75C65A6A9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmokeTest.Shared", "SmokeTest.Shared\SmokeTest.Shared.csproj", "{122AD54A-B249-41C7-858F-CB75E7C0F463}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -40,11 +48,26 @@ Global {113A09CC-9665-4E87-9FC7-7E5C8C0AFE71}.Debug|Any CPU.Build.0 = Debug|Any CPU {113A09CC-9665-4E87-9FC7-7E5C8C0AFE71}.Release|Any CPU.ActiveCfg = Release|Any CPU {113A09CC-9665-4E87-9FC7-7E5C8C0AFE71}.Release|Any CPU.Build.0 = Release|Any CPU + {A9B109A2-71C7-40C5-B1F4-D637D3808796}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A9B109A2-71C7-40C5-B1F4-D637D3808796}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A9B109A2-71C7-40C5-B1F4-D637D3808796}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A9B109A2-71C7-40C5-B1F4-D637D3808796}.Release|Any CPU.Build.0 = Release|Any CPU + {CBC386E8-36FB-4427-A212-88F75C65A6A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CBC386E8-36FB-4427-A212-88F75C65A6A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CBC386E8-36FB-4427-A212-88F75C65A6A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CBC386E8-36FB-4427-A212-88F75C65A6A9}.Release|Any CPU.Build.0 = Release|Any CPU + {122AD54A-B249-41C7-858F-CB75E7C0F463}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {122AD54A-B249-41C7-858F-CB75E7C0F463}.Debug|Any CPU.Build.0 = Debug|Any CPU + {122AD54A-B249-41C7-858F-CB75E7C0F463}.Release|Any CPU.ActiveCfg = Release|Any CPU + {122AD54A-B249-41C7-858F-CB75E7C0F463}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {FA2792B9-B82D-4936-871E-16812FA60D13} = {CBD21A52-A2D6-45FF-B921-A0743CFB13F7} + {A9B109A2-71C7-40C5-B1F4-D637D3808796} = {E4018B8E-ED2B-464C-B9A7-70BD97448D4B} + {CBC386E8-36FB-4427-A212-88F75C65A6A9} = {E4018B8E-ED2B-464C-B9A7-70BD97448D4B} + {122AD54A-B249-41C7-858F-CB75E7C0F463} = {E4018B8E-ED2B-464C-B9A7-70BD97448D4B} EndGlobalSection EndGlobal diff --git a/src/SmokeTest.Client/App.config b/src/SmokeTest.Client/App.config new file mode 100644 index 0000000000..88fa4027bd --- /dev/null +++ b/src/SmokeTest.Client/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/SmokeTest.Client/Program.cs b/src/SmokeTest.Client/Program.cs new file mode 100644 index 0000000000..b4bcd3a45d --- /dev/null +++ b/src/SmokeTest.Client/Program.cs @@ -0,0 +1,59 @@ +using System; +using NServiceBus; + +class Program +{ + const string wordblob = "Flank filet mignon rump prosciutto kevin Tail pancetta tenderloin tongue prosciutto, short loin pork pastrami flank swine leberkas Pig beef ribs hamburger, ball tip pastrami ham hock flank meatloaf Shoulder boudin meatloaf sirloin porchetta short loin ground round corned beef T-bone ground round pork chop pancetta short ribs, tenderloin brisket frankfurter Pig chuck porchetta meatball tongue capicola swine turducken, beef pastrami prosciutto bresaola bacon alcatra"; + + + static void Main() + { + var busConfiguration = new BusConfiguration(); + busConfiguration.EndpointName("SmokeTest.Client"); + busConfiguration.UseSerialization(); + busConfiguration.EnableInstallers(); + busConfiguration.UsePersistence(); + + using (var bus = Bus.Create(busConfiguration).Start()) + { + Console.WriteLine("Press enter to send a message"); + Console.WriteLine("Press any key to exit"); + + while (true) + { + var killMe = false; + var count = 1; + + var key = Console.ReadKey(); + switch (key.Key) + { + case ConsoleKey.Enter: + killMe = true; + count = 10; + break; + case ConsoleKey.Spacebar: + killMe = true; + break; + case ConsoleKey.Q: + return; + } + + var text = wordblob.LoremIpsum(5, 5, 1, 1, 1); + for (var i = 0; i < count; i++) + { + var id = Guid.NewGuid(); + + bus.Send("SmokeTest.Server", new MyMessage + { + Id = id, + KillMe = killMe, + SomeText = text + }); + + Console.WriteLine("Sent a new message with id: {0}", id.ToString("N")); + } + + } + } + } +} diff --git a/src/SmokeTest.Client/Properties/AssemblyInfo.cs b/src/SmokeTest.Client/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..94bd4c3bd3 --- /dev/null +++ b/src/SmokeTest.Client/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SmokeTest.Client")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SmokeTest.Client")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a9b109a2-71c7-40c5-b1f4-d637d3808796")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/SmokeTest.Client/SmokeTest.Client.csproj b/src/SmokeTest.Client/SmokeTest.Client.csproj new file mode 100644 index 0000000000..fe2994b8e1 --- /dev/null +++ b/src/SmokeTest.Client/SmokeTest.Client.csproj @@ -0,0 +1,75 @@ + + + + + Debug + AnyCPU + {A9B109A2-71C7-40C5-B1F4-D637D3808796} + Exe + Properties + SmokeTest.Client + SmokeTest.Client + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\NServiceBus.5.2.9\lib\net45\NServiceBus.Core.dll + True + + + ..\packages\ServiceControl.Plugin.Nsb5.Heartbeat.2.0.0\lib\net45\ServiceControl.Plugin.Nsb5.Heartbeat.dll + True + + + + + + + + + + + + + + + + + + + + + {122ad54a-b249-41c7-858f-cb75e7c0f463} + SmokeTest.Shared + + + + + \ No newline at end of file diff --git a/src/SmokeTest.Client/packages.config b/src/SmokeTest.Client/packages.config new file mode 100644 index 0000000000..983b18aef0 --- /dev/null +++ b/src/SmokeTest.Client/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/SmokeTest.Server/App.config b/src/SmokeTest.Server/App.config new file mode 100644 index 0000000000..88fa4027bd --- /dev/null +++ b/src/SmokeTest.Server/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/SmokeTest.Server/MyHandler.cs b/src/SmokeTest.Server/MyHandler.cs new file mode 100644 index 0000000000..f1a70ab2dd --- /dev/null +++ b/src/SmokeTest.Server/MyHandler.cs @@ -0,0 +1,42 @@ +using System; + +using NServiceBus; + +public class MyHandler : IHandleMessages +{ + public void Handle(MyMessage message) + { + Console.WriteLine(@"Message received. Id: {0}", message.Id); + + if (!message.KillMe) + { + return; + } + + if (!Program.KillMe) + { + return; + } + + RandomException(message.SomeText); + } + + static void RandomException(string message) + { + var rand = new Random(); + var wheelOfFortune = rand.Next(3) + 1; + + switch (wheelOfFortune) + { + case 1: + throw new OutOfMemoryException(message + "Uh oh...I forget Why this happened"); + case 2: + throw new NullReferenceException(message + "Uh oh...Nulls are bad MK"); + case 3: + throw new DivideByZeroException(message + "Uh oh...Zero and Divisions just don't get along"); + default: + throw new Exception(message + "Uh oh...Because, Reasons"); + } + + } +} \ No newline at end of file diff --git a/src/SmokeTest.Server/Program.cs b/src/SmokeTest.Server/Program.cs new file mode 100644 index 0000000000..50cd8934ae --- /dev/null +++ b/src/SmokeTest.Server/Program.cs @@ -0,0 +1,45 @@ +using System; +using NServiceBus; +using NServiceBus.Features; + +class Program +{ + public static bool KillMe = false; + static void Main() + { + var busConfiguration = new BusConfiguration(); + busConfiguration.EndpointName("SmokeTest.Server"); + busConfiguration.UseSerialization(); + busConfiguration.EnableInstallers(); + busConfiguration.UsePersistence(); + + // To disable second level retries(SLR), uncomment the following line. SLR is enabled by default. + busConfiguration.DisableFeature(); + + + using (var bus = Bus.Create(busConfiguration).Start()) + { + while (true) + { + var key = Console.ReadKey(); + switch (key.Key) + { + case ConsoleKey.Enter: + KillMe = true; + Console.WriteLine("Allow Exception Processing"); + break; + case ConsoleKey.Spacebar: + Console.WriteLine("Stop Exception Processing"); + KillMe = false; + break; + case ConsoleKey.Q: + return; + } + } + } + } +} + + + + diff --git a/src/SmokeTest.Server/Properties/AssemblyInfo.cs b/src/SmokeTest.Server/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..5ff18533d7 --- /dev/null +++ b/src/SmokeTest.Server/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SmokeTest.Server")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SmokeTest.Server")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("cbc386e8-36fb-4427-a212-88f75c65a6a9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/SmokeTest.Server/SmokeTest.Server.csproj b/src/SmokeTest.Server/SmokeTest.Server.csproj new file mode 100644 index 0000000000..bc99acdbbc --- /dev/null +++ b/src/SmokeTest.Server/SmokeTest.Server.csproj @@ -0,0 +1,76 @@ + + + + + Debug + AnyCPU + {CBC386E8-36FB-4427-A212-88F75C65A6A9} + Exe + Properties + SmokeTest.Server + SmokeTest.Server + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\NServiceBus.5.2.9\lib\net45\NServiceBus.Core.dll + True + + + ..\packages\ServiceControl.Plugin.Nsb5.Heartbeat.2.0.0\lib\net45\ServiceControl.Plugin.Nsb5.Heartbeat.dll + True + + + + + + + + + + + + + + + + + + + + + + {122ad54a-b249-41c7-858f-cb75e7c0f463} + SmokeTest.Shared + + + + + \ No newline at end of file diff --git a/src/SmokeTest.Server/packages.config b/src/SmokeTest.Server/packages.config new file mode 100644 index 0000000000..983b18aef0 --- /dev/null +++ b/src/SmokeTest.Server/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/SmokeTest.Shared/ConfigErrorQueue.cs b/src/SmokeTest.Shared/ConfigErrorQueue.cs new file mode 100644 index 0000000000..0370cf7b66 --- /dev/null +++ b/src/SmokeTest.Shared/ConfigErrorQueue.cs @@ -0,0 +1,15 @@ +using NServiceBus.Config; +using NServiceBus.Config.ConfigurationSource; + + + + class ConfigErrorQueue : IProvideConfiguration + { + public MessageForwardingInCaseOfFaultConfig GetConfiguration() + { + return new MessageForwardingInCaseOfFaultConfig + { + ErrorQueue = "error" + }; + } +} \ No newline at end of file diff --git a/src/SmokeTest.Shared/MyMessage.cs b/src/SmokeTest.Shared/MyMessage.cs new file mode 100644 index 0000000000..31107ff449 --- /dev/null +++ b/src/SmokeTest.Shared/MyMessage.cs @@ -0,0 +1,10 @@ +using System; +using NServiceBus; + + +public class MyMessage : IMessage +{ + public Guid Id { get; set; } + public bool KillMe { get; set; } + public string SomeText { get; set; } +} \ No newline at end of file diff --git a/src/SmokeTest.Shared/Properties/AssemblyInfo.cs b/src/SmokeTest.Shared/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..7b85ba11c6 --- /dev/null +++ b/src/SmokeTest.Shared/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SmokeTest.Shared")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SmokeTest.Shared")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("122ad54a-b249-41c7-858f-cb75e7c0f463")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/SmokeTest.Shared/SmokeTest.Shared.csproj b/src/SmokeTest.Shared/SmokeTest.Shared.csproj new file mode 100644 index 0000000000..829772eef0 --- /dev/null +++ b/src/SmokeTest.Shared/SmokeTest.Shared.csproj @@ -0,0 +1,64 @@ + + + + + Debug + AnyCPU + {122AD54A-B249-41C7-858F-CB75E7C0F463} + Library + Properties + SmokeTest.Shared + SmokeTest.Shared + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\NServiceBus.5.2.9\lib\net45\NServiceBus.Core.dll + True + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/SmokeTest.Shared/WordGen.cs b/src/SmokeTest.Shared/WordGen.cs new file mode 100644 index 0000000000..42d33617ef --- /dev/null +++ b/src/SmokeTest.Shared/WordGen.cs @@ -0,0 +1,32 @@ +using System; +using System.Text; + +public static class WordGen +{ + public static string LoremIpsum(this string wordblob, int minWords, int maxWords, int minSentences, int maxSentences, int numParagraphs) + { + var words = wordblob.Split(' '); + + var rand = new Random(); + var numSentences = rand.Next(maxSentences - minSentences) + minSentences + 1; + var numWords = rand.Next(maxWords - minWords) + minWords + 1; + + var result = new StringBuilder(); + + for (var p = 0; p < numParagraphs; p++) + { + for (var s = 0; s < numSentences; s++) + { + for (var w = 0; w < numWords; w++) + { + if (w > 0) { result.Append(" "); } + result.Append(words[rand.Next(words.Length)]); + } + } + } + + return result.ToString(); + } + + +} \ No newline at end of file diff --git a/src/SmokeTest.Shared/packages.config b/src/SmokeTest.Shared/packages.config new file mode 100644 index 0000000000..d537f4f160 --- /dev/null +++ b/src/SmokeTest.Shared/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file