From bf1e16866e84337979b1c0f3e86d39e055d3e1f5 Mon Sep 17 00:00:00 2001 From: Will Sugarman Date: Fri, 17 Nov 2023 15:44:04 -0800 Subject: [PATCH] Fix Test Execution for Azurite (#1004) * Add new pipeline * Use VSTest * Remove SDK installation * Use Debug to prevent signing * Add config to path * Move Test to test * More movement * Update VSTest task * Install SDK * Fix test attributes * Use latest SDK for build * Change APIs * Nit * Use new API as much as possible * Retrieve instead of query * Remove pipeline --- DurableTask.sln | 3 +- samples/Correlation.Samples/appsettings.json | 2 +- samples/DurableTask.Samples/App.config | 2 +- .../AzureStorageScaleTests.cs | 2 +- .../AzureStorageScenarioTests.cs | 4 +- .../KeySanitationTests.cs | 2 +- .../MessageManagerTests.cs | 0 .../Net/UriPathTests.cs | 0 .../Obsolete/LegacyTableEntityConverter.cs | 0 .../ScheduleTaskTests.cs | 0 .../StressTests.cs | 0 .../TableEntityConverterTests.cs | 61 ++++++++++--------- .../TestHelpers.cs | 2 +- .../TestInstance.cs | 0 .../TestTablePartitionManager.cs | 0 .../ExceptionHandlingIntegrationTests.cs | 0 .../RetryInterceptorTests.cs | 0 test/DurableTask.Core.Tests/app.config | 2 +- .../AzureTableClientTest.cs | 2 +- .../OrchestrationHubTableClientTests.cs | 2 +- .../TestObjectCreator.cs | 0 test/DurableTask.ServiceBus.Tests/app.config | 2 +- .../testhost.dll.config | 2 +- .../DurableTask.Stress.Tests.dll.config | 2 +- test/DurableTask.Stress.Tests/app.config | 2 +- ...impleOrchestrationWithSubOrchestration2.cs | 0 .../SimpleRecurringSubOrchestration.cs | 0 27 files changed, 48 insertions(+), 44 deletions(-) rename {Test => test}/DurableTask.AzureStorage.Tests/MessageManagerTests.cs (100%) rename {Test => test}/DurableTask.AzureStorage.Tests/Net/UriPathTests.cs (100%) rename {Test => test}/DurableTask.AzureStorage.Tests/Obsolete/LegacyTableEntityConverter.cs (100%) rename {Test => test}/DurableTask.AzureStorage.Tests/ScheduleTaskTests.cs (100%) rename {Test => test}/DurableTask.AzureStorage.Tests/StressTests.cs (100%) rename {Test => test}/DurableTask.AzureStorage.Tests/TableEntityConverterTests.cs (90%) rename {Test => test}/DurableTask.AzureStorage.Tests/TestInstance.cs (100%) rename {Test => test}/DurableTask.AzureStorage.Tests/TestTablePartitionManager.cs (100%) rename {Test => test}/DurableTask.Core.Tests/ExceptionHandlingIntegrationTests.cs (100%) rename {Test => test}/DurableTask.Core.Tests/RetryInterceptorTests.cs (100%) rename {Test => test}/DurableTask.ServiceBus.Tests/TestObjectCreator.cs (100%) rename {Test => test}/TestFabricApplication/TestApplication.Common/Orchestrations/SimpleOrchestrationWithSubOrchestration2.cs (100%) rename {Test => test}/TestFabricApplication/TestApplication.Common/Orchestrations/SimpleRecurringSubOrchestration.cs (100%) diff --git a/DurableTask.sln b/DurableTask.sln index 4d57ec5e2..f00ae5252 100644 --- a/DurableTask.sln +++ b/DurableTask.sln @@ -67,6 +67,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Correlation.Samples", "samp EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D02EF5EF-3D7E-4223-B256-439BAF0C8853}" ProjectSection(SolutionItems) = preProject + azure-pipelines-build.yml = azure-pipelines-build.yml azure-pipelines-release.yml = azure-pipelines-release.yml EndProjectSection EndProject @@ -320,7 +321,7 @@ Global {D818ED4C-29B9-431F-8D09-EE8C82510E25} = {240FA679-D5A7-41CA-BA22-70B45A966088} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {2D63A120-9394-48D9-8CA9-1184364FB854} EnterpriseLibraryConfigurationToolBinariesPath = packages\TransientFaultHandling.Core.5.1.1209.1\lib\NET4 + SolutionGuid = {2D63A120-9394-48D9-8CA9-1184364FB854} EndGlobalSection EndGlobal diff --git a/samples/Correlation.Samples/appsettings.json b/samples/Correlation.Samples/appsettings.json index 50c3c2427..cf9f64f32 100644 --- a/samples/Correlation.Samples/appsettings.json +++ b/samples/Correlation.Samples/appsettings.json @@ -1,4 +1,4 @@ { - "StorageConnectionString": "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10002/", + "StorageConnectionString": "UseDevelopmentStorage=true", "taskHubName":"SamplesHub" } \ No newline at end of file diff --git a/samples/DurableTask.Samples/App.config b/samples/DurableTask.Samples/App.config index ffe1c8b05..67da5a604 100644 --- a/samples/DurableTask.Samples/App.config +++ b/samples/DurableTask.Samples/App.config @@ -6,7 +6,7 @@ - + diff --git a/test/DurableTask.AzureStorage.Tests/AzureStorageScaleTests.cs b/test/DurableTask.AzureStorage.Tests/AzureStorageScaleTests.cs index e902f2b7d..18417b96d 100644 --- a/test/DurableTask.AzureStorage.Tests/AzureStorageScaleTests.cs +++ b/test/DurableTask.AzureStorage.Tests/AzureStorageScaleTests.cs @@ -201,7 +201,7 @@ private async Task EnsureLeasesMatchControlQueue(string directoryReference, Blob /// REQUIREMENT: Workers can be added or removed at any time and control-queue partitions are load-balanced automatically. /// REQUIREMENT: No two workers will ever process the same control queue. /// - [TestMethod] + [DataTestMethod] [DataRow(PartitionManagerType.V1Legacy, 30)] [DataRow(PartitionManagerType.V2Safe, 180)] public async Task MultiWorkerLeaseMovement(PartitionManagerType partitionManagerType, int timeoutInSeconds) diff --git a/test/DurableTask.AzureStorage.Tests/AzureStorageScenarioTests.cs b/test/DurableTask.AzureStorage.Tests/AzureStorageScenarioTests.cs index 84876f0b2..8e8f7ac69 100644 --- a/test/DurableTask.AzureStorage.Tests/AzureStorageScenarioTests.cs +++ b/test/DurableTask.AzureStorage.Tests/AzureStorageScenarioTests.cs @@ -900,7 +900,7 @@ public async Task TerminateOrchestration(bool enableExtendedSessions) /// /// End-to-end test which validates the Suspend-Resume functionality. /// - [TestMethod] + [DataTestMethod] [DataRow(true)] [DataRow(false)] public async Task SuspendResumeOrchestration(bool enableExtendedSessions) @@ -939,7 +939,7 @@ public async Task SuspendResumeOrchestration(bool enableExtendedSessions) /// /// Test that a suspended orchestration can be terminated. /// - [TestMethod] + [DataTestMethod] [DataRow(true)] [DataRow(false)] public async Task TerminateSuspendedOrchestration(bool enableExtendedSessions) diff --git a/test/DurableTask.AzureStorage.Tests/KeySanitationTests.cs b/test/DurableTask.AzureStorage.Tests/KeySanitationTests.cs index d631241ac..326ffc1e3 100644 --- a/test/DurableTask.AzureStorage.Tests/KeySanitationTests.cs +++ b/test/DurableTask.AzureStorage.Tests/KeySanitationTests.cs @@ -24,7 +24,7 @@ namespace DurableTask.AzureStorage.Tests [TestClass] public class KeySanitationTests { - [TestMethod] + [DataTestMethod] [DataRow("\r")] [DataRow("")] [DataRow("hello")] diff --git a/Test/DurableTask.AzureStorage.Tests/MessageManagerTests.cs b/test/DurableTask.AzureStorage.Tests/MessageManagerTests.cs similarity index 100% rename from Test/DurableTask.AzureStorage.Tests/MessageManagerTests.cs rename to test/DurableTask.AzureStorage.Tests/MessageManagerTests.cs diff --git a/Test/DurableTask.AzureStorage.Tests/Net/UriPathTests.cs b/test/DurableTask.AzureStorage.Tests/Net/UriPathTests.cs similarity index 100% rename from Test/DurableTask.AzureStorage.Tests/Net/UriPathTests.cs rename to test/DurableTask.AzureStorage.Tests/Net/UriPathTests.cs diff --git a/Test/DurableTask.AzureStorage.Tests/Obsolete/LegacyTableEntityConverter.cs b/test/DurableTask.AzureStorage.Tests/Obsolete/LegacyTableEntityConverter.cs similarity index 100% rename from Test/DurableTask.AzureStorage.Tests/Obsolete/LegacyTableEntityConverter.cs rename to test/DurableTask.AzureStorage.Tests/Obsolete/LegacyTableEntityConverter.cs diff --git a/Test/DurableTask.AzureStorage.Tests/ScheduleTaskTests.cs b/test/DurableTask.AzureStorage.Tests/ScheduleTaskTests.cs similarity index 100% rename from Test/DurableTask.AzureStorage.Tests/ScheduleTaskTests.cs rename to test/DurableTask.AzureStorage.Tests/ScheduleTaskTests.cs diff --git a/Test/DurableTask.AzureStorage.Tests/StressTests.cs b/test/DurableTask.AzureStorage.Tests/StressTests.cs similarity index 100% rename from Test/DurableTask.AzureStorage.Tests/StressTests.cs rename to test/DurableTask.AzureStorage.Tests/StressTests.cs diff --git a/Test/DurableTask.AzureStorage.Tests/TableEntityConverterTests.cs b/test/DurableTask.AzureStorage.Tests/TableEntityConverterTests.cs similarity index 90% rename from Test/DurableTask.AzureStorage.Tests/TableEntityConverterTests.cs rename to test/DurableTask.AzureStorage.Tests/TableEntityConverterTests.cs index 358ea8569..f0c4a5c1f 100644 --- a/Test/DurableTask.AzureStorage.Tests/TableEntityConverterTests.cs +++ b/test/DurableTask.AzureStorage.Tests/TableEntityConverterTests.cs @@ -106,21 +106,21 @@ public void DeserializeNull() Assert.IsNull(actual.NullableEnumProperty); Assert.IsNull(actual.StringProperty); Assert.IsNull(actual.BinaryProperty); - Assert.AreEqual(default(bool), actual.BoolProperty); + Assert.AreEqual(default, actual.BoolProperty); Assert.IsNull(actual.NullableBoolProperty); - Assert.AreEqual(default(DateTime), actual.Timestamp); + Assert.AreEqual(default, actual.Timestamp); Assert.IsNull(actual.NullableDateTimeField); - Assert.AreEqual(default(DateTimeOffset), actual.DateTimeOffsetProperty); + Assert.AreEqual(default, actual.DateTimeOffsetProperty); Assert.IsNull(actual.NullableDateTimeOffsetProperty); - Assert.AreEqual(default(double), actual.DoubleField); + Assert.AreEqual(default, actual.DoubleField); Assert.IsNull(actual.NullableDoubleProperty); - Assert.AreEqual(default(Guid), actual.GuidProperty); + Assert.AreEqual(default, actual.GuidProperty); Assert.IsNull(actual.NullableGuidField); - Assert.AreEqual(default(int), actual.IntField); + Assert.AreEqual(default, actual.IntField); Assert.IsNull(actual.NullableIntField); - Assert.AreEqual(default(long), actual.LongField); + Assert.AreEqual(default, actual.LongField); Assert.IsNull(actual.NullableLongProperty); - Assert.AreEqual(default(short), actual.UnsupportedProperty); + Assert.AreEqual(default, actual.UnsupportedProperty); Assert.IsNull(actual.ObjectProperty); } @@ -227,24 +227,26 @@ public async Task BackwardsCompatible() .CreateCloudTableClient() .GetTableReference(nameof(BackwardsCompatible)); + var tableClient = new TableServiceClient(TestHelpers.GetTestStorageAccountConnectionString()) + .GetTableClient(nameof(BackwardsCompatible)); + try { // Initialize table and add the entity - await legacyTableClient.DeleteIfExistsAsync(); - await legacyTableClient.CreateAsync(); + await tableClient.DeleteAsync(); + await tableClient.CreateAsync(); await legacyTableClient.ExecuteAsync(Microsoft.WindowsAzure.Storage.Table.TableOperation.Insert(entity)); // Read the old entity using the new logic - var tableClient = new TableServiceClient(TestHelpers.GetTestStorageAccountConnectionString()).GetTableClient(nameof(BackwardsCompatible)); - var result = await tableClient.QueryAsync(filter: $"{nameof(ITableEntity.RowKey)} eq '1'").SingleAsync(); + var result = await tableClient.GetEntityAsync(entity.PartitionKey, entity.RowKey); // Compare expected.Skipped = null; - Assert.AreEqual(expected, (Example)TableEntityConverter.Deserialize(result, typeof(Example))); + Assert.AreEqual(expected, (Example)TableEntityConverter.Deserialize(result.Value, typeof(Example))); } finally { - await legacyTableClient.DeleteIfExistsAsync(); + await tableClient.DeleteAsync(); } } @@ -286,32 +288,33 @@ public async Task ForwardsCompatible() entity.PartitionKey = "12345"; entity.RowKey = "1"; - var tableClient = new TableServiceClient(TestHelpers.GetTestStorageAccountConnectionString()).GetTableClient(nameof(ForwardsCompatible)); + var legacyTableClient = CloudStorageAccount + .Parse(TestHelpers.GetTestStorageAccountConnectionString()) + .CreateCloudTableClient() + .GetTableReference(nameof(ForwardsCompatible)); + + var tableClient = new TableServiceClient(TestHelpers.GetTestStorageAccountConnectionString()) + .GetTableClient(nameof(ForwardsCompatible)); try { - // Initialize table and add the entity + // Initialize table and add the entity using the latest API await tableClient.DeleteAsync(); await tableClient.CreateAsync(); await tableClient.AddEntityAsync(entity); - // Read the new entity using the old logic - var legacyTableClient = CloudStorageAccount - .Parse(TestHelpers.GetTestStorageAccountConnectionString()) - .CreateCloudTableClient() - .GetTableReference(nameof(ForwardsCompatible)); + // Read the entity using the old API + Microsoft.WindowsAzure.Storage.Table.TableResult response = await legacyTableClient.ExecuteAsync( + Microsoft.WindowsAzure.Storage.Table.TableOperation.Retrieve( + entity.PartitionKey, + entity.RowKey)); - var segment = await legacyTableClient.ExecuteQuerySegmentedAsync( - new Microsoft.WindowsAzure.Storage.Table.TableQuery().Where( - Microsoft.WindowsAzure.Storage.Table.TableQuery.GenerateFilterCondition( - nameof(ITableEntity.RowKey), - Microsoft.WindowsAzure.Storage.Table.QueryComparisons.Equal, - "1")), - null); + var actual = response.Result as Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity; + Assert.IsNotNull(actual); // Compare expected.Skipped = null; - Assert.AreEqual(expected, (Example)new LegacyTableEntityConverter().ConvertFromTableEntity(segment.Single(), x => typeof(Example))); + Assert.AreEqual(expected, (Example)new LegacyTableEntityConverter().ConvertFromTableEntity(actual, x => typeof(Example))); } finally { diff --git a/test/DurableTask.AzureStorage.Tests/TestHelpers.cs b/test/DurableTask.AzureStorage.Tests/TestHelpers.cs index 32cc7f714..3608d0120 100644 --- a/test/DurableTask.AzureStorage.Tests/TestHelpers.cs +++ b/test/DurableTask.AzureStorage.Tests/TestHelpers.cs @@ -55,7 +55,7 @@ public static string GetTestStorageAccountConnectionString() string? storageConnectionString = GetTestSetting("StorageConnectionString"); if (string.IsNullOrEmpty(storageConnectionString)) { - storageConnectionString = "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10002/"; + storageConnectionString = "UseDevelopmentStorage=true"; } return storageConnectionString!; diff --git a/Test/DurableTask.AzureStorage.Tests/TestInstance.cs b/test/DurableTask.AzureStorage.Tests/TestInstance.cs similarity index 100% rename from Test/DurableTask.AzureStorage.Tests/TestInstance.cs rename to test/DurableTask.AzureStorage.Tests/TestInstance.cs diff --git a/Test/DurableTask.AzureStorage.Tests/TestTablePartitionManager.cs b/test/DurableTask.AzureStorage.Tests/TestTablePartitionManager.cs similarity index 100% rename from Test/DurableTask.AzureStorage.Tests/TestTablePartitionManager.cs rename to test/DurableTask.AzureStorage.Tests/TestTablePartitionManager.cs diff --git a/Test/DurableTask.Core.Tests/ExceptionHandlingIntegrationTests.cs b/test/DurableTask.Core.Tests/ExceptionHandlingIntegrationTests.cs similarity index 100% rename from Test/DurableTask.Core.Tests/ExceptionHandlingIntegrationTests.cs rename to test/DurableTask.Core.Tests/ExceptionHandlingIntegrationTests.cs diff --git a/Test/DurableTask.Core.Tests/RetryInterceptorTests.cs b/test/DurableTask.Core.Tests/RetryInterceptorTests.cs similarity index 100% rename from Test/DurableTask.Core.Tests/RetryInterceptorTests.cs rename to test/DurableTask.Core.Tests/RetryInterceptorTests.cs diff --git a/test/DurableTask.Core.Tests/app.config b/test/DurableTask.Core.Tests/app.config index c9cb6243c..d1d912b64 100644 --- a/test/DurableTask.Core.Tests/app.config +++ b/test/DurableTask.Core.Tests/app.config @@ -1,7 +1,7 @@  - + diff --git a/test/DurableTask.ServiceBus.Tests/AzureTableClientTest.cs b/test/DurableTask.ServiceBus.Tests/AzureTableClientTest.cs index 418755cd4..5eb724f94 100644 --- a/test/DurableTask.ServiceBus.Tests/AzureTableClientTest.cs +++ b/test/DurableTask.ServiceBus.Tests/AzureTableClientTest.cs @@ -21,7 +21,7 @@ namespace DurableTask.ServiceBus.Tests [TestClass] public class AzureTableClientTest { - const string ConnectionString = "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://myProxyUri"; + const string ConnectionString = "UseDevelopmentStorage=true"; [TestMethod] public void CreateQueryWithoutFilter() diff --git a/test/DurableTask.ServiceBus.Tests/OrchestrationHubTableClientTests.cs b/test/DurableTask.ServiceBus.Tests/OrchestrationHubTableClientTests.cs index 88f184e5e..7f8407ccb 100644 --- a/test/DurableTask.ServiceBus.Tests/OrchestrationHubTableClientTests.cs +++ b/test/DurableTask.ServiceBus.Tests/OrchestrationHubTableClientTests.cs @@ -36,7 +36,7 @@ public void TestInitialize() { var r = new Random(); this.tableClient = new AzureTableClient("test00" + r.Next(0, 10000), - "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10002/"); + "UseDevelopmentStorage=true"); this.tableClient.CreateTableIfNotExistsAsync().Wait(); this.client = TestHelpers.CreateTaskHubClient(); diff --git a/Test/DurableTask.ServiceBus.Tests/TestObjectCreator.cs b/test/DurableTask.ServiceBus.Tests/TestObjectCreator.cs similarity index 100% rename from Test/DurableTask.ServiceBus.Tests/TestObjectCreator.cs rename to test/DurableTask.ServiceBus.Tests/TestObjectCreator.cs diff --git a/test/DurableTask.ServiceBus.Tests/app.config b/test/DurableTask.ServiceBus.Tests/app.config index f98565623..fb698f72a 100644 --- a/test/DurableTask.ServiceBus.Tests/app.config +++ b/test/DurableTask.ServiceBus.Tests/app.config @@ -1,7 +1,7 @@  - + diff --git a/test/DurableTask.ServiceBus.Tests/testhost.dll.config b/test/DurableTask.ServiceBus.Tests/testhost.dll.config index f61f18af3..b3b5e73b5 100644 --- a/test/DurableTask.ServiceBus.Tests/testhost.dll.config +++ b/test/DurableTask.ServiceBus.Tests/testhost.dll.config @@ -1,7 +1,7 @@  - + diff --git a/test/DurableTask.Stress.Tests/DurableTask.Stress.Tests.dll.config b/test/DurableTask.Stress.Tests/DurableTask.Stress.Tests.dll.config index f3b56052a..9bce5f1b3 100644 --- a/test/DurableTask.Stress.Tests/DurableTask.Stress.Tests.dll.config +++ b/test/DurableTask.Stress.Tests/DurableTask.Stress.Tests.dll.config @@ -12,6 +12,6 @@ - + diff --git a/test/DurableTask.Stress.Tests/app.config b/test/DurableTask.Stress.Tests/app.config index 4b4b89436..3f2787681 100644 --- a/test/DurableTask.Stress.Tests/app.config +++ b/test/DurableTask.Stress.Tests/app.config @@ -12,6 +12,6 @@ - + diff --git a/Test/TestFabricApplication/TestApplication.Common/Orchestrations/SimpleOrchestrationWithSubOrchestration2.cs b/test/TestFabricApplication/TestApplication.Common/Orchestrations/SimpleOrchestrationWithSubOrchestration2.cs similarity index 100% rename from Test/TestFabricApplication/TestApplication.Common/Orchestrations/SimpleOrchestrationWithSubOrchestration2.cs rename to test/TestFabricApplication/TestApplication.Common/Orchestrations/SimpleOrchestrationWithSubOrchestration2.cs diff --git a/Test/TestFabricApplication/TestApplication.Common/Orchestrations/SimpleRecurringSubOrchestration.cs b/test/TestFabricApplication/TestApplication.Common/Orchestrations/SimpleRecurringSubOrchestration.cs similarity index 100% rename from Test/TestFabricApplication/TestApplication.Common/Orchestrations/SimpleRecurringSubOrchestration.cs rename to test/TestFabricApplication/TestApplication.Common/Orchestrations/SimpleRecurringSubOrchestration.cs