Skip to content

Commit

Permalink
Fix Test Execution for Azurite (#1004)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wsugarman authored Nov 17, 2023
1 parent edf4f19 commit bf1e168
Show file tree
Hide file tree
Showing 27 changed files with 48 additions and 44 deletions.
3 changes: 2 additions & 1 deletion DurableTask.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion samples/Correlation.Samples/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"StorageConnectionString": "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10002/",
"StorageConnectionString": "UseDevelopmentStorage=true",
"taskHubName":"SamplesHub"
}
2 changes: 1 addition & 1 deletion samples/DurableTask.Samples/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</sectionGroup>
</configSections>
<appSettings>
<add key="StorageConnectionString" value="UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10002/" />
<add key="StorageConnectionString" value="UseDevelopmentStorage=true" />
<add key="taskHubName" value="SamplesHub" />
<add key="SmtpNetworkCredentials" value="" />
</appSettings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
[TestMethod]
[DataTestMethod]
[DataRow(PartitionManagerType.V1Legacy, 30)]
[DataRow(PartitionManagerType.V2Safe, 180)]
public async Task MultiWorkerLeaseMovement(PartitionManagerType partitionManagerType, int timeoutInSeconds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ public async Task TerminateOrchestration(bool enableExtendedSessions)
/// <summary>
/// End-to-end test which validates the Suspend-Resume functionality.
/// </summary>
[TestMethod]
[DataTestMethod]
[DataRow(true)]
[DataRow(false)]
public async Task SuspendResumeOrchestration(bool enableExtendedSessions)
Expand Down Expand Up @@ -939,7 +939,7 @@ public async Task SuspendResumeOrchestration(bool enableExtendedSessions)
/// <summary>
/// Test that a suspended orchestration can be terminated.
/// </summary>
[TestMethod]
[DataTestMethod]
[DataRow(true)]
[DataRow(false)]
public async Task TerminateSuspendedOrchestration(bool enableExtendedSessions)
Expand Down
2 changes: 1 addition & 1 deletion test/DurableTask.AzureStorage.Tests/KeySanitationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace DurableTask.AzureStorage.Tests
[TestClass]
public class KeySanitationTests
{
[TestMethod]
[DataTestMethod]
[DataRow("\r")]
[DataRow("")]
[DataRow("hello")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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<TableEntity>(filter: $"{nameof(ITableEntity.RowKey)} eq '1'").SingleAsync();
var result = await tableClient.GetEntityAsync<TableEntity>(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();
}
}

Expand Down Expand Up @@ -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<Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity>().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
{
Expand Down
2 changes: 1 addition & 1 deletion test/DurableTask.AzureStorage.Tests/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
Expand Down
2 changes: 1 addition & 1 deletion test/DurableTask.Core.Tests/app.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="StorageConnectionString" value="UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10002/" />
<add key="StorageConnectionString" value="UseDevelopmentStorage=true" />
<add key="ServiceBusConnectionString" value="" />
<add key="TaskHubName" value="test" />
</appSettings>
Expand Down
2 changes: 1 addition & 1 deletion test/DurableTask.ServiceBus.Tests/AzureTableClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/DurableTask.ServiceBus.Tests/app.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="StorageConnectionString" value="UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10002/" />
<add key="StorageConnectionString" value="UseDevelopmentStorage=true" />
<add key="ServiceBusConnectionString" value="" />
<add key="TaskHubName" value="test" />
</appSettings>
Expand Down
2 changes: 1 addition & 1 deletion test/DurableTask.ServiceBus.Tests/testhost.dll.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="StorageConnectionString" value="UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10002/" />
<add key="StorageConnectionString" value="UseDevelopmentStorage=true" />
<add key="ServiceBusConnectionString" value="" />
<add key="TaskHubName" value="test" />
</appSettings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<add key="TestTaskMaxDelayInMinutes" value="5" />
</appSettings>
<connectionStrings>
<add name="AzureStorage" connectionString="UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10002/" />
<add name="AzureStorage" connectionString="UseDevelopmentStorage=true" />
</connectionStrings>
</configuration>
2 changes: 1 addition & 1 deletion test/DurableTask.Stress.Tests/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<add key="TestTaskMaxDelayInMinutes" value="5" />
</appSettings>
<connectionStrings>
<add name="AzureStorage" connectionString="UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10002/" />
<add name="AzureStorage" connectionString="UseDevelopmentStorage=true" />
</connectionStrings>
</configuration>

0 comments on commit bf1e168

Please sign in to comment.