Skip to content

Commit 3d12ebf

Browse files
authored
[Storage][Webjobs] Remove TestCommon. (#15878)
* move fake queue options. * get rid of test common. * rename. * get common tests namespace in order. * this remains... * remove e2e project. * fix sln. * realy? * trim signing knobs after dropping key depedency. * let's see if we need this.
1 parent 4fef704 commit 3d12ebf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+98
-172
lines changed

sdk/storage/Azure.Storage.Webjobs.Extensions.Blobs/tests/Azure.WebJobs.Extensions.Storage.Blobs.Tests.csproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@
22
<PropertyGroup>
33
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
44
</PropertyGroup>
5-
<PropertyGroup>
6-
<Version>1.0.0-beta.1</Version>
7-
<Description>This extension adds bindings for Storage</Description>
8-
<IsPackable>false</IsPackable>
9-
<PublicSign>false</PublicSign>
10-
<DelaySign>true</DelaySign>
11-
</PropertyGroup>
125

136
<ItemGroup>
147
<Compile Include="$(AzureStorageWebjobsExtensionSharedTestSources)\**\*.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
158
</ItemGroup>
169

1710
<ItemGroup>
1811
<ProjectReference Include="..\..\Azure.Storage.Webjobs.Extensions.Common\tests\Azure.WebJobs.Extensions.Storage.Common.Tests.csproj" />
19-
<ProjectReference Include="..\..\Microsoft.Azure.WebJobs.Host.TestCommon\Azure.WebJobs.Host.TestCommon.csproj" />
2012
<ProjectReference Include="..\src\Azure.WebJobs.Extensions.Storage.Blobs.csproj" />
2113
</ItemGroup>
2214
</Project>

sdk/storage/Azure.Storage.Webjobs.Extensions.Blobs/tests/BlobConfigurationTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Threading.Tasks;
66
using Azure.Storage.Blobs.Specialized;
77
using Azure.WebJobs.Extensions.Storage.Common.Tests;
8-
using Microsoft.Azure.WebJobs.Host.TestCommon;
98
using Microsoft.Extensions.Azure;
109
using Microsoft.Extensions.Configuration;
1110
using Microsoft.Extensions.Hosting;

sdk/storage/Azure.Storage.Webjobs.Extensions.Blobs/tests/BlobTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
using System.Threading.Tasks;
77
using Microsoft.Extensions.Azure;
88
using Microsoft.Extensions.Hosting;
9-
using Microsoft.Azure.WebJobs.Host.TestCommon;
109
using Azure.Storage.Queues;
1110
using Azure.Storage.Blobs;
1211
using Azure.Storage.Blobs.Specialized;
1312
using NUnit.Framework;
1413
using Azure.WebJobs.Extensions.Storage.Blobs.Tests;
1514
using System.Collections.Generic;
15+
using Azure.WebJobs.Extensions.Storage.Common.Tests;
1616

1717
namespace Microsoft.Azure.WebJobs.Host.FunctionalTests
1818
{
@@ -103,6 +103,8 @@ await FunctionalTest.RunTriggerAsync(b => {
103103
{
104104
builder.ConfigureDefaults(options => options.Transport = AzuriteNUnitFixture.Instance.GetTransport());
105105
});
106+
b.AddAzureStorageBlobs();
107+
b.AddAzureStorageQueues();
106108
}, programType,
107109
settings: new Dictionary<string, string>() {
108110
// This takes precedence over env variables.

sdk/storage/Azure.Storage.Webjobs.Extensions.Blobs/tests/BlobTriggerTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Threading.Tasks;
7-
using Microsoft.Azure.WebJobs.Host.TestCommon;
87
using Microsoft.Extensions.DependencyInjection;
98
using Microsoft.Extensions.Hosting;
109
using Azure.Storage.Blobs;
1110
using Azure.Storage.Blobs.Specialized;
1211
using Azure.WebJobs.Extensions.Storage.Common.Tests;
1312
using NUnit.Framework;
1413
using Azure.WebJobs.Extensions.Storage.Blobs.Tests;
15-
using Azure.WebJobs.Extensions.Storage.Blobs;
1614
using Azure.Storage.Queues;
1715

1816
namespace Microsoft.Azure.WebJobs.Host.FunctionalTests
@@ -113,7 +111,11 @@ private static BlobContainerClient CreateContainer(BlobServiceClient blobService
113111
private async Task<TResult> RunTriggerAsync<TResult>(Type programType,
114112
Action<TaskCompletionSource<TResult>> setTaskSource)
115113
{
116-
return await FunctionalTest.RunTriggerAsync<TResult>(b => b.UseStorageServices(blobServiceClient, queueServiceClient), programType, setTaskSource);
114+
return await FunctionalTest.RunTriggerAsync<TResult>(b =>
115+
{
116+
b.AddAzureStorageBlobs();
117+
b.UseStorageServices(blobServiceClient, queueServiceClient);
118+
}, programType, setTaskSource);
117119
}
118120
}
119121
}

sdk/storage/Azure.Storage.Webjobs.Extensions.Blobs/tests/HostCallTests.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
using Microsoft.Azure.WebJobs.Host.Blobs;
1010
using Microsoft.Azure.WebJobs.Host.Config;
1111
using Azure.Storage.Blobs.Specialized;
12-
using Microsoft.Azure.WebJobs.Host.TestCommon;
13-
using Microsoft.Azure.WebJobs.Extensions.Storage.Common;
12+
using Microsoft.Extensions.Hosting;
1413
using NUnit.Framework;
1514
using Azure.Storage.Blobs;
1615
using Azure.WebJobs.Extensions.Storage.Blobs.Tests;
1716
using Azure.Storage.Queues;
17+
using Azure.WebJobs.Extensions.Storage.Common.Tests;
1818

1919
namespace Microsoft.Azure.WebJobs.Host.FunctionalTests
2020
{
@@ -460,24 +460,30 @@ private class PocoBlob
460460

461461
private async Task CallAsync(Type programType, string methodName, params Type[] customExtensions)
462462
{
463-
await FunctionalTest.CallAsync(b => b.UseStorageServices(blobServiceClient, queueServiceClient), programType, programType.GetMethod(methodName), null, customExtensions);
463+
await FunctionalTest.CallAsync(b => ConfigureStorage(b), programType, programType.GetMethod(methodName), null, customExtensions);
464464
}
465465

466466
private async Task CallAsync(Type programType, string methodName,
467467
IDictionary<string, object> arguments, params Type[] customExtensions)
468468
{
469-
await FunctionalTest.CallAsync(b => b.UseStorageServices(blobServiceClient, queueServiceClient), programType, programType.GetMethod(methodName), arguments, customExtensions);
469+
await FunctionalTest.CallAsync(b => ConfigureStorage(b), programType, programType.GetMethod(methodName), arguments, customExtensions);
470470
}
471471

472472
private async Task<TResult> CallAsync<TResult>(Type programType, string methodName,
473473
IDictionary<string, object> arguments, Action<TaskCompletionSource<TResult>> setTaskSource)
474474
{
475-
return await FunctionalTest.CallAsync<TResult>(b => b.UseStorageServices(blobServiceClient, queueServiceClient), programType, programType.GetMethod(methodName), arguments, setTaskSource);
475+
return await FunctionalTest.CallAsync<TResult>(b => ConfigureStorage(b), programType, programType.GetMethod(methodName), arguments, setTaskSource);
476476
}
477477

478478
private async Task<Exception> CallFailureAsync(Type programType, string methodName)
479479
{
480-
return await FunctionalTest.CallFailureAsync(b => b.UseStorageServices(blobServiceClient, queueServiceClient), programType, programType.GetMethod(methodName), null);
480+
return await FunctionalTest.CallFailureAsync(b => ConfigureStorage(b), programType, programType.GetMethod(methodName), null);
481+
}
482+
483+
private void ConfigureStorage(IWebJobsBuilder builder)
484+
{
485+
builder.AddAzureStorageBlobs();
486+
builder.UseStorageServices(blobServiceClient, queueServiceClient);
481487
}
482488

483489
private struct CustomDataValue

sdk/storage/Azure.Storage.Webjobs.Extensions.Blobs/tests/StorageBlobsWebJobsBuilderExtensionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Licensed under the MIT License.
33

44
using System.Collections.Generic;
5+
using Azure.WebJobs.Extensions.Storage.Common.Tests;
56
using Microsoft.Azure.WebJobs.Host;
6-
using Microsoft.Azure.WebJobs.Host.TestCommon;
77
using Microsoft.Extensions.Hosting;
88
using NUnit.Framework;
99

sdk/storage/Azure.Storage.Webjobs.Extensions.Common/tests/Azure.WebJobs.Extensions.Storage.Common.Tests.csproj

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22
<PropertyGroup>
33
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
44
</PropertyGroup>
5-
<PropertyGroup>
6-
<Version>1.0.0-beta.1</Version>
7-
<Description>This extension adds bindings for Storage</Description>
8-
<IsPackable>false</IsPackable>
9-
<PublicSign>false</PublicSign>
10-
<DelaySign>true</DelaySign>
11-
</PropertyGroup>
125

136
<ItemGroup>
147
<PackageReference Include="Microsoft.Azure.WebJobs" />

sdk/storage/Microsoft.Azure.WebJobs.Host.TestCommon/ExpectManualCompletionLogger{TResult}.cs renamed to sdk/storage/Azure.Storage.Webjobs.Extensions.Common/tests/ExpectManualCompletionLogger{TResult}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using System.Collections.Generic;
88
using System.Threading.Tasks;
99

10-
namespace Microsoft.Azure.WebJobs.Host.TestCommon
10+
namespace Azure.WebJobs.Extensions.Storage.Common.Tests
1111
{
1212
public class ExpectManualCompletionLogger<TResult> : ILogger
1313
{

sdk/storage/Microsoft.Azure.WebJobs.Host.TestCommon/FunctionalTest.cs renamed to sdk/storage/Azure.Storage.Webjobs.Extensions.Common/tests/FunctionalTest.cs

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,20 @@
55
using System.Collections.Generic;
66
using System.Reflection;
77
using System.Threading.Tasks;
8-
using Microsoft.Azure.WebJobs.Host.FunctionalTests.TestDoubles;
9-
using Microsoft.Azure.WebJobs.Host.TestCommon;
8+
using Microsoft.Azure.WebJobs;
109
using Microsoft.Extensions.Configuration;
11-
using Microsoft.Extensions.DependencyInjection;
1210
using Microsoft.Extensions.Hosting;
1311
using Microsoft.Extensions.Logging;
14-
using Microsoft.Extensions.Options;
1512
using NUnit.Framework;
1613

17-
namespace Microsoft.Azure.WebJobs.Host.FunctionalTests
14+
namespace Azure.WebJobs.Extensions.Storage.Common.Tests
1815
{
1916
// $$$ Remove all this. See Blob_IfBoundToCloudBlockBlob_BindsAndCreatesContainerButNotBlob for an example of what it should be.
20-
internal class FunctionalTest
17+
public class FunctionalTest
2118
{
2219
// $$$ Reconcile with TestJobHost.
2320

24-
internal static async Task<TResult> RunTriggerAsync<TResult>(
21+
public static async Task<TResult> RunTriggerAsync<TResult>(
2522
Action<IWebJobsBuilder> configureWebJobsBuilderAction,
2623
Type programType,
2724
Action<TaskCompletionSource<TResult>> setTaskSource,
@@ -35,13 +32,7 @@ internal static async Task<TResult> RunTriggerAsync<TResult>(
3532
var host = new HostBuilder()
3633
.ConfigureLogging(b => b.AddProvider(new ExpectManualCompletionLoggerProvider<TResult>(src, signalOnFirst, ignoreFailureFunctions)))
3734
.ConfigureAppConfiguration(cb => cb.AddInMemoryCollection(settings))
38-
.ConfigureDefaultTestHost(builder =>
39-
{
40-
builder.AddAzureStorageBlobs().AddAzureStorageQueues();
41-
configureWebJobsBuilderAction.Invoke(builder);
42-
43-
builder.Services.AddSingleton<IConfigureOptions<QueuesOptions>, FakeQueuesOptionsSetup>();
44-
}, programType)
35+
.ConfigureDefaultTestHost(builder => configureWebJobsBuilderAction.Invoke(builder), programType)
4536
.Build();
4637

4738
try
@@ -82,7 +73,7 @@ internal static async Task<TResult> RunTriggerAsync<TResult>(
8273
// Runs the first triggered function and then returns.
8374
// Expected that this instance provided some side-effect (ie, wrote to storage)
8475
// that the caller can monitor.
85-
internal static async Task RunTriggerAsync(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, Dictionary<string, string> settings = default)
76+
public static async Task RunTriggerAsync(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, Dictionary<string, string> settings = default)
8677
{
8778
TaskCompletionSource<bool> src = new TaskCompletionSource<bool>();
8879
await RunTriggerAsync<bool>(
@@ -93,7 +84,7 @@ await RunTriggerAsync<bool>(
9384
settings: settings);
9485
}
9586

96-
internal static async Task<Exception> RunTriggerFailureAsync<TResult>(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, Action<TaskCompletionSource<TResult>> setTaskSource)
87+
public static async Task<Exception> RunTriggerFailureAsync<TResult>(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, Action<TaskCompletionSource<TResult>> setTaskSource)
9788
{
9889
try
9990
{
@@ -108,14 +99,10 @@ internal static async Task<Exception> RunTriggerFailureAsync<TResult>(Action<IWe
10899
}
109100

110101
// Call the method, and expect a failure. Return the exception.
111-
internal static async Task<Exception> CallFailureAsync(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, MethodInfo methodInfo, object arguments)
102+
public static async Task<Exception> CallFailureAsync(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, MethodInfo methodInfo, object arguments)
112103
{
113104
var host = new HostBuilder()
114-
.ConfigureDefaultTestHost(b =>
115-
{
116-
b.AddAzureStorageBlobs().AddAzureStorageQueues();
117-
configureWebJobsBuilderAction.Invoke(b);
118-
}, programType)
105+
.ConfigureDefaultTestHost(b => configureWebJobsBuilderAction.Invoke(b), programType)
119106
.Build();
120107

121108
var jobHost = host.GetJobHost();
@@ -132,12 +119,11 @@ internal static async Task<Exception> CallFailureAsync(Action<IWebJobsBuilder> c
132119
return null;
133120
}
134121

135-
internal static async Task CallAsync(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, MethodInfo methodInfo, object arguments, params Type[] customExtensions)
122+
public static async Task CallAsync(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, MethodInfo methodInfo, object arguments, params Type[] customExtensions)
136123
{
137124
var host = new HostBuilder()
138125
.ConfigureDefaultTestHost(b =>
139126
{
140-
b.AddAzureStorageBlobs().AddAzureStorageQueues();
141127
configureWebJobsBuilderAction.Invoke(b);
142128

143129
foreach (var extension in customExtensions)
@@ -151,17 +137,13 @@ internal static async Task CallAsync(Action<IWebJobsBuilder> configureWebJobsBui
151137
await jobHost.CallAsync(methodInfo, arguments);
152138
}
153139

154-
internal static async Task<TResult> CallAsync<TResult>(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, MethodInfo methodInfo, IDictionary<string, object> arguments, Action<TaskCompletionSource<TResult>> setTaskSource)
140+
public static async Task<TResult> CallAsync<TResult>(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, MethodInfo methodInfo, IDictionary<string, object> arguments, Action<TaskCompletionSource<TResult>> setTaskSource)
155141
{
156142
TaskCompletionSource<TResult> src = new TaskCompletionSource<TResult>();
157143
setTaskSource(src);
158144

159145
var host = new HostBuilder()
160-
.ConfigureDefaultTestHost(builder =>
161-
{
162-
builder.AddAzureStorageBlobs().AddAzureStorageQueues();
163-
configureWebJobsBuilderAction.Invoke(builder);
164-
}, programType)
146+
.ConfigureDefaultTestHost(builder => configureWebJobsBuilderAction.Invoke(builder), programType)
165147
.Build();
166148

167149
var jobHost = host.GetJobHost();

sdk/storage/Microsoft.Azure.WebJobs.Host.TestCommon/RandomNameResolver.cs renamed to sdk/storage/Azure.Storage.Webjobs.Extensions.Common/tests/RandomNameResolver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
using System;
55
using System.Globalization;
6+
using Microsoft.Azure.WebJobs;
67

7-
namespace Microsoft.Azure.WebJobs.Host.TestCommon
8+
namespace Azure.WebJobs.Extensions.Storage.Common.Tests
89
{
910
public class RandomNameResolver : INameResolver
1011
{

0 commit comments

Comments
 (0)