diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9621317fc7..f314ddbb4b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -107,7 +107,7 @@ jobs: $expectedAssetsCount = 2 # SCMU & PowerShell module $expectedNugetsCount = 1 # PlatformSample - $expectedZipCount = 3 # ServiceControl, Audit, & Monitoring + $expectedZipCount = 5 # ServiceControl, Audit, & Monitoring + Transports & RavenDBServer if ($assetsCount -ne $expectedAssetsCount) { diff --git a/src/Custom.Build.props b/src/Custom.Build.props index f092c3b285..1fa2b1b442 100644 --- a/src/Custom.Build.props +++ b/src/Custom.Build.props @@ -18,12 +18,6 @@ false - - - - - - false diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets deleted file mode 100644 index a1255ff840..0000000000 --- a/src/Directory.Build.targets +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 2022e0f0a1..8851bb2ab5 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -15,7 +15,6 @@ - diff --git a/src/Particular.PlatformSample.ServiceControl/Particular.PlatformSample.ServiceControl.csproj b/src/Particular.PlatformSample.ServiceControl/Particular.PlatformSample.ServiceControl.csproj index 732d843257..a33747d117 100644 --- a/src/Particular.PlatformSample.ServiceControl/Particular.PlatformSample.ServiceControl.csproj +++ b/src/Particular.PlatformSample.ServiceControl/Particular.PlatformSample.ServiceControl.csproj @@ -23,14 +23,16 @@ - + + + - + - + diff --git a/src/ServiceControl.AcceptanceTesting/ServiceControl.AcceptanceTesting.csproj b/src/ServiceControl.AcceptanceTesting/ServiceControl.AcceptanceTesting.csproj index 3bb44a0479..90a1517e32 100644 --- a/src/ServiceControl.AcceptanceTesting/ServiceControl.AcceptanceTesting.csproj +++ b/src/ServiceControl.AcceptanceTesting/ServiceControl.AcceptanceTesting.csproj @@ -6,7 +6,6 @@ - diff --git a/src/ServiceControl.AcceptanceTests.RavenDB5/ServiceControl.AcceptanceTests.RavenDB5.csproj b/src/ServiceControl.AcceptanceTests.RavenDB5/ServiceControl.AcceptanceTests.RavenDB5.csproj index 08a3855215..09f58a6a5a 100644 --- a/src/ServiceControl.AcceptanceTests.RavenDB5/ServiceControl.AcceptanceTests.RavenDB5.csproj +++ b/src/ServiceControl.AcceptanceTests.RavenDB5/ServiceControl.AcceptanceTests.RavenDB5.csproj @@ -11,7 +11,6 @@ - diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/When_a_native_integration_message_is_retried.cs b/src/ServiceControl.AcceptanceTests/Recoverability/When_a_native_integration_message_is_retried.cs index 95c4d2e97d..6931a14a5e 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/When_a_native_integration_message_is_retried.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/When_a_native_integration_message_is_retried.cs @@ -11,7 +11,6 @@ using NServiceBus.Transport; using NUnit.Framework; using ServiceControl.MessageFailures.Api; - using ServiceControlInstaller.Engine.Instances; using TestSupport.EndpointTemplates; using Conventions = NServiceBus.AcceptanceTesting.Customization.Conventions; @@ -36,16 +35,13 @@ public async Task Should_not_corrupt_headers() .Run(); // ASQ adds this value to it's message wrapper and writes the incoming message header - if (TransportIntegration.Name != TransportNames.AzureStorageQueue) + if (TransportIntegration.Name != "Azure Storage Queue") { Assert.False(context.Headers.ContainsKey(Headers.MessageIntent), "Should not add the intent header"); } //Rabbit defaults the header when deserializing the message based on the IBasicProperties.DeliveryMode - if (TransportIntegration.Name == TransportNames.RabbitMQClassicConventionalRoutingTopology || - TransportIntegration.Name == TransportNames.RabbitMQQuorumConventionalRoutingTopology || - TransportIntegration.Name == TransportNames.RabbitMQClassicDirectRoutingTopology || - TransportIntegration.Name == TransportNames.RabbitMQQuorumDirectRoutingTopology) + if (TransportIntegration.Name.Contains("RabbitMQ")) { Assert.AreEqual("False", context.Headers[Headers.NonDurableMessage], "Should not corrupt the non-durable header"); } diff --git a/src/ServiceControl.Audit.AcceptanceTests/ServiceControl.Audit.AcceptanceTests.csproj b/src/ServiceControl.Audit.AcceptanceTests/ServiceControl.Audit.AcceptanceTests.csproj index 61a8c6b82f..b6fba69ea0 100644 --- a/src/ServiceControl.Audit.AcceptanceTests/ServiceControl.Audit.AcceptanceTests.csproj +++ b/src/ServiceControl.Audit.AcceptanceTests/ServiceControl.Audit.AcceptanceTests.csproj @@ -11,7 +11,6 @@ - diff --git a/src/ServiceControl.Audit.Persistence.InMemory/ServiceControl.Audit.Persistence.InMemory.csproj b/src/ServiceControl.Audit.Persistence.InMemory/ServiceControl.Audit.Persistence.InMemory.csproj index 16c2d3a11e..438db3fea7 100644 --- a/src/ServiceControl.Audit.Persistence.InMemory/ServiceControl.Audit.Persistence.InMemory.csproj +++ b/src/ServiceControl.Audit.Persistence.InMemory/ServiceControl.Audit.Persistence.InMemory.csproj @@ -5,7 +5,8 @@ - + + diff --git a/src/ServiceControl.Audit.Persistence.RavenDb5/Indexes/MessagesViewIndex.cs b/src/ServiceControl.Audit.Persistence.RavenDb5/Indexes/MessagesViewIndex.cs index 5ef34a20e2..892a7d06a1 100644 --- a/src/ServiceControl.Audit.Persistence.RavenDb5/Indexes/MessagesViewIndex.cs +++ b/src/ServiceControl.Audit.Persistence.RavenDb5/Indexes/MessagesViewIndex.cs @@ -2,7 +2,6 @@ namespace ServiceControl.Audit.Persistence.RavenDb.Indexes { using System; using System.Linq; - using Lucene.Net.Analysis.Standard; using Raven.Client.Documents.Indexes; using ServiceControl.Audit.Auditing; using ServiceControl.Audit.Monitoring; @@ -34,7 +33,8 @@ from message in messages Index(x => x.Query, FieldIndexing.Search); - Analyze(x => x.Query, typeof(StandardAnalyzer).AssemblyQualifiedName); + // Not using typeof() to prevent dependency on Lucene + Analyze(x => x.Query, "Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net, Version=3.0.3.0, Culture=neutral, PublicKeyToken=85089178b9ac3181"); } public class SortAndFilterOptions diff --git a/src/ServiceControl.Audit.Persistence.RavenDb5/Indexes/MessagesViewIndexWithFullTextSearch.cs b/src/ServiceControl.Audit.Persistence.RavenDb5/Indexes/MessagesViewIndexWithFullTextSearch.cs index 65a4e14921..736d9b40c3 100644 --- a/src/ServiceControl.Audit.Persistence.RavenDb5/Indexes/MessagesViewIndexWithFullTextSearch.cs +++ b/src/ServiceControl.Audit.Persistence.RavenDb5/Indexes/MessagesViewIndexWithFullTextSearch.cs @@ -2,7 +2,6 @@ namespace ServiceControl.Audit.Persistence.RavenDb.Indexes { using System; using System.Linq; - using Lucene.Net.Analysis.Standard; using Raven.Client.Documents.Indexes; using ServiceControl.Audit.Auditing; using ServiceControl.Audit.Monitoring; @@ -35,7 +34,8 @@ from message in messages Index(x => x.Query, FieldIndexing.Search); - Analyze(x => x.Query, typeof(StandardAnalyzer).AssemblyQualifiedName); + // Not using typeof() to prevent dependency on Lucene + Analyze(x => x.Query, "Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net, Version=3.0.3.0, Culture=neutral, PublicKeyToken=85089178b9ac3181"); } } } \ No newline at end of file diff --git a/src/ServiceControl.Audit.Persistence.RavenDb5/RavenDbPersistenceConfiguration.cs b/src/ServiceControl.Audit.Persistence.RavenDb5/RavenDbPersistenceConfiguration.cs index f9bded18f3..816eedfc70 100644 --- a/src/ServiceControl.Audit.Persistence.RavenDb5/RavenDbPersistenceConfiguration.cs +++ b/src/ServiceControl.Audit.Persistence.RavenDb5/RavenDbPersistenceConfiguration.cs @@ -39,7 +39,7 @@ internal static DatabaseConfiguration GetDatabaseConfiguration(PersistenceSettin { if (!settings.PersisterSpecificSettings.TryGetValue(DatabaseNameKey, out var databaseName)) { - databaseName = "primary"; + databaseName = "audit"; } ServerConfiguration serverConfiguration; diff --git a/src/ServiceControl.Audit.Persistence.RavenDb5/ServiceControl.Audit.Persistence.RavenDb5.csproj b/src/ServiceControl.Audit.Persistence.RavenDb5/ServiceControl.Audit.Persistence.RavenDb5.csproj index 1eea948003..cf77617d3c 100644 --- a/src/ServiceControl.Audit.Persistence.RavenDb5/ServiceControl.Audit.Persistence.RavenDb5.csproj +++ b/src/ServiceControl.Audit.Persistence.RavenDb5/ServiceControl.Audit.Persistence.RavenDb5.csproj @@ -5,12 +5,12 @@ - + + - @@ -21,7 +21,8 @@ - + + diff --git a/src/ServiceControl.Audit.Persistence.Tests.RavenDb5/ServiceControl.Audit.Persistence.Tests.RavenDb5.csproj b/src/ServiceControl.Audit.Persistence.Tests.RavenDb5/ServiceControl.Audit.Persistence.Tests.RavenDb5.csproj index ad26e94b62..7075e17148 100644 --- a/src/ServiceControl.Audit.Persistence.Tests.RavenDb5/ServiceControl.Audit.Persistence.Tests.RavenDb5.csproj +++ b/src/ServiceControl.Audit.Persistence.Tests.RavenDb5/ServiceControl.Audit.Persistence.Tests.RavenDb5.csproj @@ -6,7 +6,8 @@ - + + diff --git a/src/ServiceControl.Audit.Persistence.Tests/InstallationTests.cs b/src/ServiceControl.Audit.Persistence.Tests/InstallationTests.cs deleted file mode 100644 index 74bec7467d..0000000000 --- a/src/ServiceControl.Audit.Persistence.Tests/InstallationTests.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace ServiceControl.Audit.Persistence.Tests -{ - using System.IO; - using System.Linq; - using System.Text.Json; - using NUnit.Framework; - using Particular.Approvals; - using ServiceControlInstaller.Engine.Instances; - - class InstallationTests : PersistenceTestFixture - { - [Test] - public void Should_write_expected_config_file() - { - PersistenceManifest persistenceManifest; - - using (var reader = new StreamReader(GetManifestPath())) - { - var manifestContent = reader.ReadToEnd(); - persistenceManifest = JsonSerializer.Deserialize(manifestContent); - } - - var newInstance = new ServiceControlAuditNewInstance(persistenceManifest); - - var installPath = Path.Combine(Path.GetTempPath(), TestContext.CurrentContext.Test.ID, "install"); - - if (Directory.Exists(installPath)) - { - Directory.Delete(installPath, true); - } - - var dbPath = Path.Combine(Path.GetTempPath(), TestContext.CurrentContext.Test.ID, "db"); - var logPath = Path.Combine(Path.GetTempPath(), TestContext.CurrentContext.Test.ID, "log"); - - newInstance.InstallPath = installPath; - newInstance.TransportPackage = ServiceControlCoreTransports.All.Single(t => t.Name == TransportNames.MSMQ); - - newInstance.DBPath = dbPath; - newInstance.LogPath = logPath; - newInstance.HostName = "localhost"; - newInstance.DatabaseMaintenancePort = 33333; - - newInstance.WriteConfigurationFile(); - - var configFile = File.ReadAllText(Path.Combine(installPath, "ServiceControl.Audit.exe.config")); - - Approver.Verify(configFile, input => input.Replace(dbPath, "value-not-asserted").Replace(logPath, "value-not-asserted")); - } - } -} diff --git a/src/ServiceControl.Audit.Persistence.Tests/ServiceControl.Audit.Persistence.Tests.csproj b/src/ServiceControl.Audit.Persistence.Tests/ServiceControl.Audit.Persistence.Tests.csproj index 381edcf9e0..d60a8ff689 100644 --- a/src/ServiceControl.Audit.Persistence.Tests/ServiceControl.Audit.Persistence.Tests.csproj +++ b/src/ServiceControl.Audit.Persistence.Tests/ServiceControl.Audit.Persistence.Tests.csproj @@ -6,7 +6,8 @@ - + + diff --git a/src/ServiceControl.Monitoring.AcceptanceTests/ServiceControl.Monitoring.AcceptanceTests.csproj b/src/ServiceControl.Monitoring.AcceptanceTests/ServiceControl.Monitoring.AcceptanceTests.csproj index d8f69b3844..45efb12e17 100644 --- a/src/ServiceControl.Monitoring.AcceptanceTests/ServiceControl.Monitoring.AcceptanceTests.csproj +++ b/src/ServiceControl.Monitoring.AcceptanceTests/ServiceControl.Monitoring.AcceptanceTests.csproj @@ -2,14 +2,13 @@ net472 - 8 + 8.0 - @@ -19,13 +18,13 @@ + - diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/ServiceControl.MultiInstance.AcceptanceTests.csproj b/src/ServiceControl.MultiInstance.AcceptanceTests/ServiceControl.MultiInstance.AcceptanceTests.csproj index 8a16f0f87f..4381930a54 100644 --- a/src/ServiceControl.MultiInstance.AcceptanceTests/ServiceControl.MultiInstance.AcceptanceTests.csproj +++ b/src/ServiceControl.MultiInstance.AcceptanceTests/ServiceControl.MultiInstance.AcceptanceTests.csproj @@ -12,7 +12,6 @@ - diff --git a/src/ServiceControl.Persistence.RavenDb5/Indexes/MessagesViewIndex.cs b/src/ServiceControl.Persistence.RavenDb5/Indexes/MessagesViewIndex.cs index 5d2573b3c6..aff8883bc6 100644 --- a/src/ServiceControl.Persistence.RavenDb5/Indexes/MessagesViewIndex.cs +++ b/src/ServiceControl.Persistence.RavenDb5/Indexes/MessagesViewIndex.cs @@ -2,7 +2,6 @@ namespace ServiceControl.Persistence { using System; using System.Linq; - using Lucene.Net.Analysis.Standard; using Raven.Client.Documents.Indexes; using ServiceControl.MessageFailures; using ServiceControl.Operations; @@ -37,9 +36,8 @@ from message in messages ConversationId = (string)last.MessageMetadata["ConversationId"] }; + // StandardAnalyzer is the default analyzer, so no follow-up Analyze() call is needed here Index(x => x.Query, FieldIndexing.Search); - - Analyze(x => x.Query, typeof(StandardAnalyzer).AssemblyQualifiedName); } public class SortAndFilterOptions diff --git a/src/ServiceControl.Persistence.RavenDb5/RavenQueryExtensions.cs b/src/ServiceControl.Persistence.RavenDb5/RavenQueryExtensions.cs index 4e9988311e..58d3b074b1 100644 --- a/src/ServiceControl.Persistence.RavenDb5/RavenQueryExtensions.cs +++ b/src/ServiceControl.Persistence.RavenDb5/RavenQueryExtensions.cs @@ -5,7 +5,6 @@ namespace ServiceControl.Persistence using System.Globalization; using System.Linq; using System.Linq.Expressions; - using System.Net.Http; using Raven.Client.Documents.Linq; using Raven.Client.Documents.Session; using ServiceControl.MessageFailures; @@ -234,146 +233,6 @@ public static IAsyncDocumentQuery FilterByQueueAddress(this IAsyncDocument return source; } - public static IRavenQueryable IncludeSystemMessagesWhere( - this IRavenQueryable source, HttpRequestMessage request) - { - var includeSystemMessages = request.GetQueryStringValue("include_system_messages", false); - return !includeSystemMessages ? source.Where(m => !m.IsSystemMessage) : source; - } - - public static IOrderedQueryable Paging(this IOrderedQueryable source, HttpRequestMessage request) - { - var maxResultsPerPage = request.GetQueryStringValue("per_page", 50); - if (maxResultsPerPage < 1) - { - maxResultsPerPage = 50; - } - - var page = request.GetQueryStringValue("page", 1); - - if (page < 1) - { - page = 1; - } - - var skipResults = (page - 1) * maxResultsPerPage; - - return (IOrderedQueryable)source.Skip(skipResults) - .Take(maxResultsPerPage); - } - - public static IRavenQueryable Paging(this IRavenQueryable source, HttpRequestMessage request) - { - var maxResultsPerPage = request.GetQueryStringValue("per_page", 50); - if (maxResultsPerPage < 1) - { - maxResultsPerPage = 50; - } - - var page = request.GetQueryStringValue("page", 1); - - if (page < 1) - { - page = 1; - } - - var skipResults = (page - 1) * maxResultsPerPage; - - return source.Skip(skipResults) - .Take(maxResultsPerPage); - } - - public static IRavenQueryable Sort(this IRavenQueryable source, HttpRequestMessage request, - Expression> defaultKeySelector = null, string defaultSortDirection = "desc") - where TSource : MessagesViewIndex.SortAndFilterOptions - { - var direction = request.GetQueryStringValue("direction", defaultSortDirection); - if (direction != "asc" && direction != "desc") - { - direction = defaultSortDirection; - } - - Expression> keySelector; - var sort = request.GetQueryStringValue("sort", "time_sent"); - if (!RavenQueryableSortOptions.Contains(sort)) - { - sort = "time_sent"; - } - - switch (sort) - { - case "id": - case "message_id": - keySelector = m => m.MessageId; - break; - - case "message_type": - keySelector = m => m.MessageType; - break; - - case "critical_time": - keySelector = m => m.CriticalTime; - break; - - case "delivery_time": - keySelector = m => m.DeliveryTime; - break; - - case "processing_time": - keySelector = m => m.ProcessingTime; - break; - - case "processed_at": - keySelector = m => m.ProcessedAt; - break; - - case "status": - keySelector = m => m.Status; - break; - - default: - if (defaultKeySelector == null) - { - keySelector = m => m.TimeSent; - } - else - { - keySelector = defaultKeySelector; - } - - break; - } - - if (direction == "asc") - { - return source.OrderBy(keySelector); - } - - return source.OrderByDescending(keySelector); - } - - public static T GetQueryStringValue(this HttpRequestMessage request, string key, T defaultValue = default) - { - Dictionary queryStringDictionary; - if (!request.Properties.TryGetValue("QueryStringAsDictionary", out var dictionaryAsObject)) - { - queryStringDictionary = request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value, StringComparer.OrdinalIgnoreCase); - request.Properties["QueryStringAsDictionary"] = queryStringDictionary; - } - else - { - queryStringDictionary = (Dictionary)dictionaryAsObject; - } - - queryStringDictionary.TryGetValue(key, out var value); - if (string.IsNullOrEmpty(value)) - { - return defaultValue; - } - - return (T)Convert.ChangeType(value, typeof(T)); - } - static HashSet AsyncDocumentQuerySortOptions = new HashSet { "id", @@ -385,19 +244,6 @@ public static T GetQueryStringValue(this HttpRequestMessage request, string k "time_of_failure" }; - static HashSet RavenQueryableSortOptions = new HashSet - { - "processed_at", - "id", - "message_type", - "time_sent", - "critical_time", - "delivery_time", - "processing_time", - "status", - "message_id" - }; - static string[] SplitChars = { "..." diff --git a/src/ServiceControl.Persistence.RavenDb5/ServiceControl.Persistence.RavenDb5.csproj b/src/ServiceControl.Persistence.RavenDb5/ServiceControl.Persistence.RavenDb5.csproj index a507ef682d..41fc0a3740 100644 --- a/src/ServiceControl.Persistence.RavenDb5/ServiceControl.Persistence.RavenDb5.csproj +++ b/src/ServiceControl.Persistence.RavenDb5/ServiceControl.Persistence.RavenDb5.csproj @@ -6,13 +6,14 @@ - - + + + - + @@ -23,7 +24,10 @@ - + + + + \ No newline at end of file diff --git a/src/ServiceControl.Persistence/ServiceControl.Persistence.csproj b/src/ServiceControl.Persistence/ServiceControl.Persistence.csproj index a8a9989c7d..8b1bf0ec8a 100644 --- a/src/ServiceControl.Persistence/ServiceControl.Persistence.csproj +++ b/src/ServiceControl.Persistence/ServiceControl.Persistence.csproj @@ -10,11 +10,6 @@ - - - - - diff --git a/src/ServiceControl.Transports.ASB/ServiceControl.Transports.ASB.csproj b/src/ServiceControl.Transports.ASB/ServiceControl.Transports.ASB.csproj index 56513e9cd0..690d655254 100644 --- a/src/ServiceControl.Transports.ASB/ServiceControl.Transports.ASB.csproj +++ b/src/ServiceControl.Transports.ASB/ServiceControl.Transports.ASB.csproj @@ -5,7 +5,8 @@ - + + @@ -18,7 +19,7 @@ - + \ No newline at end of file diff --git a/src/ServiceControl.Transports.ASBEndpointTopology.Tests/ServiceControl.Transports.ASBEndpointTopology.Tests.csproj b/src/ServiceControl.Transports.ASBEndpointTopology.Tests/ServiceControl.Transports.ASBEndpointTopology.Tests.csproj index 5fd518683d..3e9855515a 100644 --- a/src/ServiceControl.Transports.ASBEndpointTopology.Tests/ServiceControl.Transports.ASBEndpointTopology.Tests.csproj +++ b/src/ServiceControl.Transports.ASBEndpointTopology.Tests/ServiceControl.Transports.ASBEndpointTopology.Tests.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/ServiceControl.Transports.ASBForwardingTopology.Tests/ServiceControl.Transports.ASBForwardingTopology.Tests.csproj b/src/ServiceControl.Transports.ASBForwardingTopology.Tests/ServiceControl.Transports.ASBForwardingTopology.Tests.csproj index 33c09df6f6..17f881f178 100644 --- a/src/ServiceControl.Transports.ASBForwardingTopology.Tests/ServiceControl.Transports.ASBForwardingTopology.Tests.csproj +++ b/src/ServiceControl.Transports.ASBForwardingTopology.Tests/ServiceControl.Transports.ASBForwardingTopology.Tests.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/ServiceControl.Transports.ASBS.Tests/ServiceControl.Transports.ASBS.Tests.csproj b/src/ServiceControl.Transports.ASBS.Tests/ServiceControl.Transports.ASBS.Tests.csproj index d0deb53b83..6011c8c00b 100644 --- a/src/ServiceControl.Transports.ASBS.Tests/ServiceControl.Transports.ASBS.Tests.csproj +++ b/src/ServiceControl.Transports.ASBS.Tests/ServiceControl.Transports.ASBS.Tests.csproj @@ -6,6 +6,7 @@ + diff --git a/src/ServiceControl.Transports.ASBS/ServiceControl.Transports.ASBS.csproj b/src/ServiceControl.Transports.ASBS/ServiceControl.Transports.ASBS.csproj index 0030a9638e..fea00f4223 100644 --- a/src/ServiceControl.Transports.ASBS/ServiceControl.Transports.ASBS.csproj +++ b/src/ServiceControl.Transports.ASBS/ServiceControl.Transports.ASBS.csproj @@ -5,7 +5,8 @@ - + + @@ -19,7 +20,7 @@ - + \ No newline at end of file diff --git a/src/ServiceControl.Transports.ASQ.Tests/ServiceControl.Transports.ASQ.Tests.csproj b/src/ServiceControl.Transports.ASQ.Tests/ServiceControl.Transports.ASQ.Tests.csproj index a370581049..c7fb382222 100644 --- a/src/ServiceControl.Transports.ASQ.Tests/ServiceControl.Transports.ASQ.Tests.csproj +++ b/src/ServiceControl.Transports.ASQ.Tests/ServiceControl.Transports.ASQ.Tests.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/ServiceControl.Transports.ASQ/ServiceControl.Transports.ASQ.csproj b/src/ServiceControl.Transports.ASQ/ServiceControl.Transports.ASQ.csproj index 60dec855f3..57e3542af5 100644 --- a/src/ServiceControl.Transports.ASQ/ServiceControl.Transports.ASQ.csproj +++ b/src/ServiceControl.Transports.ASQ/ServiceControl.Transports.ASQ.csproj @@ -5,7 +5,8 @@ - + + @@ -17,7 +18,7 @@ - + diff --git a/src/ServiceControl.Transports.Learning/ServiceControl.Transports.Learning.csproj b/src/ServiceControl.Transports.Learning/ServiceControl.Transports.Learning.csproj index 773bb37ec0..c04cc3ac0e 100644 --- a/src/ServiceControl.Transports.Learning/ServiceControl.Transports.Learning.csproj +++ b/src/ServiceControl.Transports.Learning/ServiceControl.Transports.Learning.csproj @@ -5,7 +5,8 @@ - + + @@ -13,7 +14,7 @@ - + \ No newline at end of file diff --git a/src/ServiceControl.Transports.Msmq.Tests/ServiceControl.Transports.Msmq.Tests.csproj b/src/ServiceControl.Transports.Msmq.Tests/ServiceControl.Transports.Msmq.Tests.csproj index 4a3798364f..86b51abc73 100644 --- a/src/ServiceControl.Transports.Msmq.Tests/ServiceControl.Transports.Msmq.Tests.csproj +++ b/src/ServiceControl.Transports.Msmq.Tests/ServiceControl.Transports.Msmq.Tests.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/ServiceControl.Transports.Msmq/ServiceControl.Transports.Msmq.csproj b/src/ServiceControl.Transports.Msmq/ServiceControl.Transports.Msmq.csproj index 8d35f8ded1..01c50cec37 100644 --- a/src/ServiceControl.Transports.Msmq/ServiceControl.Transports.Msmq.csproj +++ b/src/ServiceControl.Transports.Msmq/ServiceControl.Transports.Msmq.csproj @@ -5,7 +5,8 @@ - + + @@ -18,7 +19,7 @@ - + diff --git a/src/ServiceControl.Transports.RabbitMQ/ServiceControl.Transports.RabbitMQ.csproj b/src/ServiceControl.Transports.RabbitMQ/ServiceControl.Transports.RabbitMQ.csproj index 19e6524e09..05c31538c3 100644 --- a/src/ServiceControl.Transports.RabbitMQ/ServiceControl.Transports.RabbitMQ.csproj +++ b/src/ServiceControl.Transports.RabbitMQ/ServiceControl.Transports.RabbitMQ.csproj @@ -5,7 +5,8 @@ - + + @@ -17,7 +18,7 @@ - + \ No newline at end of file diff --git a/src/ServiceControl.Transports.RabbitMQClassicConventionalRouting.Tests/ServiceControl.Transports.RabbitMQClassicConventionalRoutingTests.csproj b/src/ServiceControl.Transports.RabbitMQClassicConventionalRouting.Tests/ServiceControl.Transports.RabbitMQClassicConventionalRoutingTests.csproj index 1be9f368d0..67a94d9770 100644 --- a/src/ServiceControl.Transports.RabbitMQClassicConventionalRouting.Tests/ServiceControl.Transports.RabbitMQClassicConventionalRoutingTests.csproj +++ b/src/ServiceControl.Transports.RabbitMQClassicConventionalRouting.Tests/ServiceControl.Transports.RabbitMQClassicConventionalRoutingTests.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/ServiceControl.Transports.RabbitMQClassicDirectRouting.Tests/ServiceControl.Transports.RabbitMQClassicDirectRouting.Tests.csproj b/src/ServiceControl.Transports.RabbitMQClassicDirectRouting.Tests/ServiceControl.Transports.RabbitMQClassicDirectRouting.Tests.csproj index 1be9f368d0..67a94d9770 100644 --- a/src/ServiceControl.Transports.RabbitMQClassicDirectRouting.Tests/ServiceControl.Transports.RabbitMQClassicDirectRouting.Tests.csproj +++ b/src/ServiceControl.Transports.RabbitMQClassicDirectRouting.Tests/ServiceControl.Transports.RabbitMQClassicDirectRouting.Tests.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/ServiceControl.Transports.RabbitMQQuorumConventionalRouting.Tests/ServiceControl.Transports.RabbitMQQuorumConventionalRouting.Tests.csproj b/src/ServiceControl.Transports.RabbitMQQuorumConventionalRouting.Tests/ServiceControl.Transports.RabbitMQQuorumConventionalRouting.Tests.csproj index b570abbaab..6e9acdcf72 100644 --- a/src/ServiceControl.Transports.RabbitMQQuorumConventionalRouting.Tests/ServiceControl.Transports.RabbitMQQuorumConventionalRouting.Tests.csproj +++ b/src/ServiceControl.Transports.RabbitMQQuorumConventionalRouting.Tests/ServiceControl.Transports.RabbitMQQuorumConventionalRouting.Tests.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/ServiceControl.Transports.RabbitMQQuorumDirectRouting.Tests/ServiceControl.Transports.RabbitMQQuorumDirectRouting.Tests.csproj b/src/ServiceControl.Transports.RabbitMQQuorumDirectRouting.Tests/ServiceControl.Transports.RabbitMQQuorumDirectRouting.Tests.csproj index 1be9f368d0..67a94d9770 100644 --- a/src/ServiceControl.Transports.RabbitMQQuorumDirectRouting.Tests/ServiceControl.Transports.RabbitMQQuorumDirectRouting.Tests.csproj +++ b/src/ServiceControl.Transports.RabbitMQQuorumDirectRouting.Tests/ServiceControl.Transports.RabbitMQQuorumDirectRouting.Tests.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/ServiceControl.Transports.SQS.Tests/ServiceControl.Transports.SQS.Tests.csproj b/src/ServiceControl.Transports.SQS.Tests/ServiceControl.Transports.SQS.Tests.csproj index cebcd325a8..7965c9d1bc 100644 --- a/src/ServiceControl.Transports.SQS.Tests/ServiceControl.Transports.SQS.Tests.csproj +++ b/src/ServiceControl.Transports.SQS.Tests/ServiceControl.Transports.SQS.Tests.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/ServiceControl.Transports.SQS/ServiceControl.Transports.SQS.csproj b/src/ServiceControl.Transports.SQS/ServiceControl.Transports.SQS.csproj index ae94a61a17..c210162dcd 100644 --- a/src/ServiceControl.Transports.SQS/ServiceControl.Transports.SQS.csproj +++ b/src/ServiceControl.Transports.SQS/ServiceControl.Transports.SQS.csproj @@ -5,7 +5,8 @@ - + + @@ -17,7 +18,7 @@ - + \ No newline at end of file diff --git a/src/ServiceControl.Transports.SqlServer.Tests/ServiceControl.Transports.SqlServer.Tests.csproj b/src/ServiceControl.Transports.SqlServer.Tests/ServiceControl.Transports.SqlServer.Tests.csproj index 39eba65cec..c24d66eb26 100644 --- a/src/ServiceControl.Transports.SqlServer.Tests/ServiceControl.Transports.SqlServer.Tests.csproj +++ b/src/ServiceControl.Transports.SqlServer.Tests/ServiceControl.Transports.SqlServer.Tests.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/ServiceControl.Transports.SqlServer/ServiceControl.Transports.SqlServer.csproj b/src/ServiceControl.Transports.SqlServer/ServiceControl.Transports.SqlServer.csproj index 8544613fa7..50e5370cd5 100644 --- a/src/ServiceControl.Transports.SqlServer/ServiceControl.Transports.SqlServer.csproj +++ b/src/ServiceControl.Transports.SqlServer/ServiceControl.Transports.SqlServer.csproj @@ -5,7 +5,8 @@ - + + @@ -17,7 +18,7 @@ - + diff --git a/src/ServiceControl.Transports.Tests/ServiceControl.Transports.Tests.csproj b/src/ServiceControl.Transports.Tests/ServiceControl.Transports.Tests.csproj index 7d6b0235a6..054dc4a3d2 100644 --- a/src/ServiceControl.Transports.Tests/ServiceControl.Transports.Tests.csproj +++ b/src/ServiceControl.Transports.Tests/ServiceControl.Transports.Tests.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/ServiceControl.UnitTests/API/APIApprovals.cs b/src/ServiceControl.UnitTests/API/APIApprovals.cs index ba104d11f9..de8ab17d94 100644 --- a/src/ServiceControl.UnitTests/API/APIApprovals.cs +++ b/src/ServiceControl.UnitTests/API/APIApprovals.cs @@ -14,10 +14,8 @@ using Particular.Approvals; using Particular.ServiceControl; using Particular.ServiceControl.Licensing; - using PublicApiGenerator; using ServiceBus.Management.Infrastructure.Settings; using ServiceControl.Infrastructure.WebApi; - using ServiceControlInstaller.Engine.Instances; [TestFixture] class APIApprovals @@ -120,21 +118,6 @@ static string PrettyTypeName(Type t) return t.Name; } - [Test] - public void TransportNames() - { - //HINT: Those names are used in PowerShell scripts thus constitute a public api. - //Also Particular.PlatformSamples relies on it to specify the learning transport. - var transportNamesType = typeof(TransportNames); - var publicTransportNames = transportNamesType.Assembly.GeneratePublicApi(new ApiGeneratorOptions - { - IncludeTypes = new[] { transportNamesType }, - ExcludeAttributes = new[] { "System.Reflection.AssemblyMetadataAttribute" } - }); - - Approver.Verify(publicTransportNames); - } - [Test] public void PlatformSampleSettings() { diff --git a/src/ServiceControl.UnitTests/ServiceControl.UnitTests.csproj b/src/ServiceControl.UnitTests/ServiceControl.UnitTests.csproj index c9124b824a..af059305ac 100644 --- a/src/ServiceControl.UnitTests/ServiceControl.UnitTests.csproj +++ b/src/ServiceControl.UnitTests/ServiceControl.UnitTests.csproj @@ -9,7 +9,6 @@ - diff --git a/src/ServiceControl.sln b/src/ServiceControl.sln index 7b93e36571..d42e304c92 100644 --- a/src/ServiceControl.sln +++ b/src/ServiceControl.sln @@ -39,7 +39,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\.github\workflows\ci.yml = ..\.github\workflows\ci.yml ..\.github\workflows\release.yml = ..\.github\workflows\release.yml Custom.Build.props = Custom.Build.props - Directory.Build.targets = Directory.Build.targets Directory.Packages.props = Directory.Packages.props ProjectReferences.Persisters.Audit.props = ProjectReferences.Persisters.Audit.props ProjectReferences.Persisters.Primary.props = ProjectReferences.Persisters.Primary.props diff --git a/src/ServiceControlInstaller.Engine.UnitTests/API/APIApprovals.cs b/src/ServiceControlInstaller.Engine.UnitTests/API/APIApprovals.cs new file mode 100644 index 0000000000..a459163ddc --- /dev/null +++ b/src/ServiceControlInstaller.Engine.UnitTests/API/APIApprovals.cs @@ -0,0 +1,26 @@ +namespace ServiceControl.UnitTests.API +{ + using NUnit.Framework; + using Particular.Approvals; + using PublicApiGenerator; + using ServiceControlInstaller.Engine.Instances; + + [TestFixture] + class APIApprovals + { + [Test] + public void TransportNames() + { + //HINT: Those names are used in PowerShell scripts thus constitute a public api. + //Also Particular.PlatformSamples relies on it to specify the learning transport. + var transportNamesType = typeof(TransportNames); + var publicTransportNames = transportNamesType.Assembly.GeneratePublicApi(new ApiGeneratorOptions + { + IncludeTypes = new[] { transportNamesType }, + ExcludeAttributes = new[] { "System.Reflection.AssemblyMetadataAttribute" } + }); + + Approver.Verify(publicTransportNames); + } + } +} \ No newline at end of file diff --git a/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.TransportNames.approved.txt b/src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/APIApprovals.TransportNames.approved.txt similarity index 100% rename from src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.TransportNames.approved.txt rename to src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/APIApprovals.TransportNames.approved.txt diff --git a/src/ServiceControl.Audit.Persistence.Tests/ApprovalFiles/InstallationTests.Should_write_expected_config_file.approved.txt b/src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/InstallationTests.Audit_install_should_write_expected_config_file.InMemory.approved.txt similarity index 100% rename from src/ServiceControl.Audit.Persistence.Tests/ApprovalFiles/InstallationTests.Should_write_expected_config_file.approved.txt rename to src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/InstallationTests.Audit_install_should_write_expected_config_file.InMemory.approved.txt diff --git a/src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/InstallationTests.Audit_install_should_write_expected_config_file.RavenDB35.approved.txt b/src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/InstallationTests.Audit_install_should_write_expected_config_file.RavenDB35.approved.txt new file mode 100644 index 0000000000..0fece5c346 --- /dev/null +++ b/src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/InstallationTests.Audit_install_should_write_expected_config_file.RavenDB35.approved.txt @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ServiceControl.Audit.Persistence.Tests.RavenDb5/ApprovalFiles/InstallationTests.Should_write_expected_config_file.approved.txt b/src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/InstallationTests.Audit_install_should_write_expected_config_file.RavenDB5.approved.txt similarity index 100% rename from src/ServiceControl.Audit.Persistence.Tests.RavenDb5/ApprovalFiles/InstallationTests.Should_write_expected_config_file.approved.txt rename to src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/InstallationTests.Audit_install_should_write_expected_config_file.RavenDB5.approved.txt diff --git a/src/ServiceControlInstaller.Engine.UnitTests/InstallationTests.cs b/src/ServiceControlInstaller.Engine.UnitTests/InstallationTests.cs new file mode 100644 index 0000000000..6c5b473e4c --- /dev/null +++ b/src/ServiceControlInstaller.Engine.UnitTests/InstallationTests.cs @@ -0,0 +1,73 @@ +namespace ServiceControl.Audit.Persistence.Tests +{ + using System.IO; + using System.Linq; + using System.Text.Json; + using NUnit.Framework; + using Particular.Approvals; + using ServiceControlInstaller.Engine.FileSystem; + using ServiceControlInstaller.Engine.Instances; + + class InstallationTests + { + [Test] + [TestCaseSource("GetAuditPersistenceManifestPaths")] + public void Audit_install_should_write_expected_config_file(string manifestPath) + { + var installPath = Path.Combine(Path.GetTempPath(), TestContext.CurrentContext.Test.ID, "install"); + var dbPath = Path.Combine(Path.GetTempPath(), TestContext.CurrentContext.Test.ID, "db"); + var logPath = Path.Combine(Path.GetTempPath(), TestContext.CurrentContext.Test.ID, "log"); + + try + { + PersistenceManifest persistenceManifest; + + using (var reader = new StreamReader(manifestPath)) + { + var manifestContent = reader.ReadToEnd(); + persistenceManifest = JsonSerializer.Deserialize(manifestContent); + } + + var newInstance = new ServiceControlAuditNewInstance(persistenceManifest); + + + if (Directory.Exists(installPath)) + { + Directory.Delete(installPath, true); + } + + newInstance.InstallPath = installPath; + newInstance.TransportPackage = ServiceControlCoreTransports.All.Single(t => t.Name == TransportNames.MSMQ); + + newInstance.DBPath = dbPath; + newInstance.LogPath = logPath; + newInstance.HostName = "localhost"; + newInstance.DatabaseMaintenancePort = 33333; + + newInstance.WriteConfigurationFile(); + + var configFile = File.ReadAllText(Path.Combine(installPath, "ServiceControl.Audit.exe.config")); + var scenario = Path.GetFileName(Path.GetDirectoryName(manifestPath)); + + Approver.Verify(configFile, input => input.Replace(dbPath, "value-not-asserted").Replace(logPath, "value-not-asserted"), scenario); + } + finally + { + FileUtils.DeleteDirectory(installPath, true, false); + FileUtils.DeleteDirectory(dbPath, true, false); + FileUtils.DeleteDirectory(logPath, true, false); + } + } + + public static string[][] GetAuditPersistenceManifestPaths() + { + var deployPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "..", "..", "..", "..", "deploy")); + var persistersPath = Path.Combine(deployPath, "Particular.ServiceControl.Audit", "Persisters"); + var manifestPaths = Directory.GetFiles(persistersPath, "persistence.manifest", SearchOption.AllDirectories); + + return manifestPaths + .Select(path => new string[] { path }) + .ToArray(); + } + } +} diff --git a/src/ServiceControlInstaller.Engine.UnitTests/ServiceControlInstaller.Engine.UnitTests.csproj b/src/ServiceControlInstaller.Engine.UnitTests/ServiceControlInstaller.Engine.UnitTests.csproj index c18aebfd86..ec1175bc72 100644 --- a/src/ServiceControlInstaller.Engine.UnitTests/ServiceControlInstaller.Engine.UnitTests.csproj +++ b/src/ServiceControlInstaller.Engine.UnitTests/ServiceControlInstaller.Engine.UnitTests.csproj @@ -21,6 +21,7 @@ + \ No newline at end of file diff --git a/src/ServiceControlInstaller.Engine.UnitTests/Zip/UnpackTest.cs b/src/ServiceControlInstaller.Engine.UnitTests/Zip/UnpackTest.cs index 816d7266e8..3e225c01b2 100644 --- a/src/ServiceControlInstaller.Engine.UnitTests/Zip/UnpackTest.cs +++ b/src/ServiceControlInstaller.Engine.UnitTests/Zip/UnpackTest.cs @@ -65,6 +65,21 @@ public void FilterUnzipTest() Assert.True(workingFolder.GetDirectories().Count() == 1, "Should only be one directory after unpack"); } + [TestCase("")] + [TestCase(null)] + public void UnzipAllTest(string filter) + { + workingFolder.Delete(true); + Directory.CreateDirectory(workingFolder.FullName); + using (var zipStream = File.OpenRead(zipFilePath)) + { + FileUtils.UnzipToSubdirectory(zipStream, workingFolder.FullName, filter); + } + Assert.True(workingFolder.GetDirectories().Count() == 3, "Should include all directories"); + Assert.True(workingFolder.GetFiles("*.txt", SearchOption.TopDirectoryOnly).Count() == 0, "Should have no files extracted to the root install path"); + Assert.True(workingFolder.GetFiles("*.txt", SearchOption.AllDirectories).Count() == 6, "Should include all 3 root and subfolder files"); + } + [TearDown] public void TearDown() { diff --git a/src/ServiceControlInstaller.Engine/FileSystem/FileUtils.cs b/src/ServiceControlInstaller.Engine/FileSystem/FileUtils.cs index ae74eeda09..41ddd2d278 100644 --- a/src/ServiceControlInstaller.Engine/FileSystem/FileUtils.cs +++ b/src/ServiceControlInstaller.Engine/FileSystem/FileUtils.cs @@ -94,7 +94,11 @@ internal static void UnzipToSubdirectory(Stream zipStream, string targetPath, st var dir = Path.GetDirectoryName(e.FileName); string filename = null; - if (dir.StartsWith(zipFolderNameToExtract, StringComparison.OrdinalIgnoreCase)) + if (string.IsNullOrEmpty(zipFolderNameToExtract)) + { + filename = Path.Combine(targetPath, e.FileName); + } + else if (dir.StartsWith(zipFolderNameToExtract, StringComparison.OrdinalIgnoreCase)) { filename = Path.Combine(targetPath, e.FileName.Substring(zipFolderNameToExtract.Length + 1)); } diff --git a/src/ServiceControlInstaller.Engine/Instances/MonitoringInstance.cs b/src/ServiceControlInstaller.Engine/Instances/MonitoringInstance.cs index c005a46e68..4e5d040151 100644 --- a/src/ServiceControlInstaller.Engine/Instances/MonitoringInstance.cs +++ b/src/ServiceControlInstaller.Engine/Instances/MonitoringInstance.cs @@ -251,7 +251,8 @@ public void UpgradeFiles(string zipFilePath) { FileUtils.DeleteDirectory(InstallPath, true, true, "license", $"{Constants.MonitoringExe}.config"); FileUtils.UnzipToSubdirectory(zipFilePath, InstallPath, "ServiceControl.Monitoring"); - FileUtils.UnzipToSubdirectory(zipFilePath, InstallPath, $@"Transports\{TransportPackage.ZipName}"); + FileUtils.UnzipToSubdirectory("Transports.zip", InstallPath, TransportPackage.ZipName); + FileUtils.UnzipToSubdirectory("RavenDBServer.zip", Path.Combine(InstallPath, "RavenDBServer"), string.Empty); } public void RestoreAppConfig(string sourcePath) diff --git a/src/ServiceControlInstaller.Engine/Instances/MonitoringNewInstance.cs b/src/ServiceControlInstaller.Engine/Instances/MonitoringNewInstance.cs index afae2e2c20..615cf945db 100644 --- a/src/ServiceControlInstaller.Engine/Instances/MonitoringNewInstance.cs +++ b/src/ServiceControlInstaller.Engine/Instances/MonitoringNewInstance.cs @@ -88,7 +88,8 @@ public void CopyFiles(string zipResourceName) // Copy the binaries from a zip FileUtils.UnzipToSubdirectory(zipResourceName, InstallPath, "ServiceControl.Monitoring"); - FileUtils.UnzipToSubdirectory(zipResourceName, InstallPath, $@"Transports\{TransportPackage.ZipName}"); + FileUtils.UnzipToSubdirectory("Transports.zip", InstallPath, TransportPackage.ZipName); + FileUtils.UnzipToSubdirectory("RavenDBServer.zip", Path.Combine(InstallPath, "RavenDBServer"), string.Empty); } public void WriteConfigurationFile() diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditInstance.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditInstance.cs index c4c8c75e3a..71b9f09449 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditInstance.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditInstance.cs @@ -109,7 +109,8 @@ public override void UpgradeFiles(string zipResourceName) { FileUtils.DeleteDirectory(InstallPath, true, true, "license", $"{Constants.ServiceControlAuditExe}.config"); FileUtils.UnzipToSubdirectory(zipResourceName, InstallPath, BaseServiceName); - FileUtils.UnzipToSubdirectory(zipResourceName, InstallPath, $@"Transports\{TransportPackage.ZipName}"); + FileUtils.UnzipToSubdirectory("Transports.zip", InstallPath, TransportPackage.ZipName); + FileUtils.UnzipToSubdirectory("RavenDBServer.zip", Path.Combine(InstallPath, "RavenDBServer"), string.Empty); FileUtils.UnzipToSubdirectory(zipResourceName, InstallPath, $@"Persisters\{PersistenceManifest.Name}"); } diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstallableBase.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstallableBase.cs index 2d6dc1615f..fc7684ad43 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstallableBase.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstallableBase.cs @@ -140,7 +140,8 @@ public virtual void CopyFiles(string zipResourceName) // Copy the binaries from a zip FileUtils.UnzipToSubdirectory(zipResourceName, InstallPath, DirectoryName); - FileUtils.UnzipToSubdirectory(zipResourceName, InstallPath, $@"Transports\{TransportPackage.ZipName}"); + FileUtils.UnzipToSubdirectory("Transports.zip", InstallPath, TransportPackage.ZipName); + FileUtils.UnzipToSubdirectory("RavenDBServer.zip", Path.Combine(InstallPath, "RavenDBServer"), string.Empty); } public virtual void WriteConfigurationFile() diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstance.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstance.cs index 7bcdacbfc5..a7448d1854 100644 --- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstance.cs +++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstance.cs @@ -203,7 +203,8 @@ public override void UpgradeFiles(string zipFilePath) { FileUtils.DeleteDirectory(InstallPath, true, true, "license", $"{Constants.ServiceControlExe}.config"); FileUtils.UnzipToSubdirectory(zipFilePath, InstallPath, "ServiceControl"); - FileUtils.UnzipToSubdirectory(zipFilePath, InstallPath, $@"Transports\{TransportPackage.ZipName}"); + FileUtils.UnzipToSubdirectory("Transports.zip", InstallPath, TransportPackage.ZipName); + FileUtils.UnzipToSubdirectory("RavenDBServer.zip", Path.Combine(InstallPath, "RavenDBServer"), string.Empty); FileUtils.UnzipToSubdirectory(zipFilePath, InstallPath, $@"Persisters\{PersistenceManifest.Name}"); } diff --git a/src/ServiceControlInstaller.Engine/ServiceControlInstaller.Engine.csproj b/src/ServiceControlInstaller.Engine/ServiceControlInstaller.Engine.csproj index adf224c1c5..77e0728f63 100644 --- a/src/ServiceControlInstaller.Engine/ServiceControlInstaller.Engine.csproj +++ b/src/ServiceControlInstaller.Engine/ServiceControlInstaller.Engine.csproj @@ -32,7 +32,7 @@ - + diff --git a/src/ServiceControlInstaller.Engine/Validation/DotnetVersionValidator.cs b/src/ServiceControlInstaller.Engine/Validation/DotnetVersionValidator.cs index b1adbe69a7..6658ce1f2e 100644 --- a/src/ServiceControlInstaller.Engine/Validation/DotnetVersionValidator.cs +++ b/src/ServiceControlInstaller.Engine/Validation/DotnetVersionValidator.cs @@ -53,14 +53,19 @@ public static bool FrameworkRequirementsAreMissing(bool needsRavenDB, out string missing.Add($".NET {dotnetMinVersion.Major} Runtime (x64), requires {dotnetMinVersion} or greater, found {dotnetClosest}: Download from https://dotnet.microsoft.com/download/dotnet/{majorMinor}"); } + var aspOk = false; + string aspClosest = null; using var aspNetKey = registry.OpenSubKey($@"SOFTWARE\Microsoft\ASP.NET Core\Shared Framework"); - var aspNetVersions = aspNetKey.GetSubKeyNames() - .Where(key => key.StartsWith("v")) - .SelectMany(key => aspNetKey.OpenSubKey(key).GetSubKeyNames()) - .ToArray(); + if (aspNetKey != null) + { + var aspNetVersions = aspNetKey.GetSubKeyNames() + .Where(key => key.StartsWith("v")) + .SelectMany(key => aspNetKey.OpenSubKey(key).GetSubKeyNames()) + .ToArray(); - var aspClosest = HighestMatchingMajorMinor(dotnetMinVersion, aspNetVersions); - var aspOk = DotnetVersionOk(dotnetMinVersion, aspClosest); + aspClosest = HighestMatchingMajorMinor(dotnetMinVersion, aspNetVersions); + aspOk = DotnetVersionOk(dotnetMinVersion, aspClosest); + } if (!aspOk) { var foundString = aspClosest != null ? $", found {aspClosest}" : string.Empty; diff --git a/src/ServiceControlInstaller.Packaging.UnitTests/AuditDeploymentPackageTests.cs b/src/ServiceControlInstaller.Packaging.UnitTests/AuditDeploymentPackageTests.cs index 3f4c8f141c..32c18d0c49 100644 --- a/src/ServiceControlInstaller.Packaging.UnitTests/AuditDeploymentPackageTests.cs +++ b/src/ServiceControlInstaller.Packaging.UnitTests/AuditDeploymentPackageTests.cs @@ -1,5 +1,6 @@ namespace Tests { + using System.IO; using System.Linq; using NUnit.Framework; @@ -32,9 +33,12 @@ public void Should_package_storages_individually() } [Test] - public void Raven5_should_include_raven_server() + public void Raven_server_should_be_included() { - DirectoryAssert.Exists($"{deploymentPackage.Directory.FullName}/Persisters/RavenDB5/RavenDBServer", "RavenDBServer should be bundled"); + var inPersisterPath = Path.Combine(deploymentPackage.Directory.FullName, "Persisters", "RavenDB5", "RavenDBServer"); + var separateAssetPath = Path.GetFullPath(Path.Combine(deploymentPackage.Directory.FullName, "..", "RavenDBServer")); + DirectoryAssert.DoesNotExist(inPersisterPath, "RavenDBServer should not be bundled inside the persister"); + DirectoryAssert.Exists(separateAssetPath, "RavenDBServer should be bundled as its own resource"); } readonly DeploymentPackage deploymentPackage; diff --git a/src/ServiceControlInstaller.Packaging.UnitTests/DeploymentPackage.cs b/src/ServiceControlInstaller.Packaging.UnitTests/DeploymentPackage.cs index d21dc6e915..ac63b47364 100644 --- a/src/ServiceControlInstaller.Packaging.UnitTests/DeploymentPackage.cs +++ b/src/ServiceControlInstaller.Packaging.UnitTests/DeploymentPackage.cs @@ -37,7 +37,7 @@ public DeploymentPackage(DirectoryInfo directory) public static IEnumerable All => GetDeployDirectory() .EnumerateDirectories() - .Where(d => d.Name != "PowerShellModules") + .Where(d => d.Name != "PowerShellModules" && d.Name != "Transports" && d.Name != "RavenDBServer") .Select(d => new DeploymentPackage(d)); public static DirectoryInfo GetDeployDirectory() diff --git a/src/ServiceControlInstaller.Packaging.UnitTests/DeploymentPackageTests.cs b/src/ServiceControlInstaller.Packaging.UnitTests/DeploymentPackageTests.cs index c804a78f87..6922d2298a 100644 --- a/src/ServiceControlInstaller.Packaging.UnitTests/DeploymentPackageTests.cs +++ b/src/ServiceControlInstaller.Packaging.UnitTests/DeploymentPackageTests.cs @@ -19,7 +19,8 @@ public void CheckPackageStructure() var rootDirectory = deploymentPackage.Directory; DirectoryAssert.Exists($"{rootDirectory.FullName}/{deploymentPackage.ServiceName}", $"Expected a {deploymentPackage.ServiceName} folder"); - DirectoryAssert.Exists($"{rootDirectory.FullName}/Transports", $"Expected a Transports folder"); + DirectoryAssert.DoesNotExist($"{rootDirectory.FullName}/Transports", $"Transports folder should be a separate asset"); + DirectoryAssert.Exists($"{rootDirectory.FullName}/../Transports", $"Transports folder should be a separate asset"); foreach (var deploymentUnit in deploymentPackage.DeploymentUnits) { @@ -99,11 +100,20 @@ public void Should_package_transports_individually() "LearningTransport"}; - var transports = deploymentPackage.DeploymentUnits + var transportsIfBundledInAppZips = deploymentPackage.DeploymentUnits .Where(u => u.Category == "Transports") .Select(u => u.Name); - CollectionAssert.AreEquivalent(allTransports, transports, $"Expected transports folder to contain {string.Join(",", allTransports)}"); + CollectionAssert.IsEmpty(transportsIfBundledInAppZips, "Transports should not be bundled inside app zips to conserve space"); + + var trueTransportDirectories = deploymentPackage.Directory + .Parent + .GetDirectories("Transports") + .Single() + .GetDirectories() + .Select(di => di.Name); + + CollectionAssert.AreEquivalent(allTransports, trueTransportDirectories, $"Expected transports folder to contain {string.Join(",", allTransports)}"); } readonly DeploymentPackage deploymentPackage; diff --git a/src/ServiceControlInstaller.Packaging/ServiceControlInstaller.Packaging.csproj b/src/ServiceControlInstaller.Packaging/ServiceControlInstaller.Packaging.csproj index d3f6f76d7d..65ff37aa32 100644 --- a/src/ServiceControlInstaller.Packaging/ServiceControlInstaller.Packaging.csproj +++ b/src/ServiceControlInstaller.Packaging/ServiceControlInstaller.Packaging.csproj @@ -20,12 +20,20 @@ + + + + + + + + ..\..\zip\ - +