Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@
<PropertyGroup>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<Version>1.0.0-beta.1</Version>
<Description>This extension adds bindings for Storage</Description>
<IsPackable>false</IsPackable>
<PublicSign>false</PublicSign>
<DelaySign>true</DelaySign>
</PropertyGroup>

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

<ItemGroup>
<ProjectReference Include="..\..\Azure.Storage.Webjobs.Extensions.Common\tests\Azure.WebJobs.Extensions.Storage.Common.Tests.csproj" />
<ProjectReference Include="..\..\Microsoft.Azure.WebJobs.Host.TestCommon\Azure.WebJobs.Host.TestCommon.csproj" />
<ProjectReference Include="..\src\Azure.WebJobs.Extensions.Storage.Blobs.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Threading.Tasks;
using Azure.Storage.Blobs.Specialized;
using Azure.WebJobs.Extensions.Storage.Common.Tests;
using Microsoft.Azure.WebJobs.Host.TestCommon;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.Hosting;
using Microsoft.Azure.WebJobs.Host.TestCommon;
using Azure.Storage.Queues;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Specialized;
using NUnit.Framework;
using Azure.WebJobs.Extensions.Storage.Blobs.Tests;
using System.Collections.Generic;
using Azure.WebJobs.Extensions.Storage.Common.Tests;

namespace Microsoft.Azure.WebJobs.Host.FunctionalTests
{
Expand Down Expand Up @@ -103,6 +103,8 @@ await FunctionalTest.RunTriggerAsync(b => {
{
builder.ConfigureDefaults(options => options.Transport = AzuriteNUnitFixture.Instance.GetTransport());
});
b.AddAzureStorageBlobs();
b.AddAzureStorageQueues();
}, programType,
settings: new Dictionary<string, string>() {
// This takes precedence over env variables.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Host.TestCommon;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Specialized;
using Azure.WebJobs.Extensions.Storage.Common.Tests;
using NUnit.Framework;
using Azure.WebJobs.Extensions.Storage.Blobs.Tests;
using Azure.WebJobs.Extensions.Storage.Blobs;
using Azure.Storage.Queues;

namespace Microsoft.Azure.WebJobs.Host.FunctionalTests
Expand Down Expand Up @@ -113,7 +111,11 @@ private static BlobContainerClient CreateContainer(BlobServiceClient blobService
private async Task<TResult> RunTriggerAsync<TResult>(Type programType,
Action<TaskCompletionSource<TResult>> setTaskSource)
{
return await FunctionalTest.RunTriggerAsync<TResult>(b => b.UseStorageServices(blobServiceClient, queueServiceClient), programType, setTaskSource);
return await FunctionalTest.RunTriggerAsync<TResult>(b =>
{
b.AddAzureStorageBlobs();
b.UseStorageServices(blobServiceClient, queueServiceClient);
}, programType, setTaskSource);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
using Microsoft.Azure.WebJobs.Host.Blobs;
using Microsoft.Azure.WebJobs.Host.Config;
using Azure.Storage.Blobs.Specialized;
using Microsoft.Azure.WebJobs.Host.TestCommon;
using Microsoft.Azure.WebJobs.Extensions.Storage.Common;
using Microsoft.Extensions.Hosting;
using NUnit.Framework;
using Azure.Storage.Blobs;
using Azure.WebJobs.Extensions.Storage.Blobs.Tests;
using Azure.Storage.Queues;
using Azure.WebJobs.Extensions.Storage.Common.Tests;

namespace Microsoft.Azure.WebJobs.Host.FunctionalTests
{
Expand Down Expand Up @@ -460,24 +460,30 @@ private class PocoBlob

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

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

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

private async Task<Exception> CallFailureAsync(Type programType, string methodName)
{
return await FunctionalTest.CallFailureAsync(b => b.UseStorageServices(blobServiceClient, queueServiceClient), programType, programType.GetMethod(methodName), null);
return await FunctionalTest.CallFailureAsync(b => ConfigureStorage(b), programType, programType.GetMethod(methodName), null);
}

private void ConfigureStorage(IWebJobsBuilder builder)
{
builder.AddAzureStorageBlobs();
builder.UseStorageServices(blobServiceClient, queueServiceClient);
}

private struct CustomDataValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the MIT License.

using System.Collections.Generic;
using Azure.WebJobs.Extensions.Storage.Common.Tests;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.WebJobs.Host.TestCommon;
using Microsoft.Extensions.Hosting;
using NUnit.Framework;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
<PropertyGroup>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<Version>1.0.0-beta.1</Version>
<Description>This extension adds bindings for Storage</Description>
<IsPackable>false</IsPackable>
<PublicSign>false</PublicSign>
<DelaySign>true</DelaySign>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Microsoft.Azure.WebJobs.Host.TestCommon
namespace Azure.WebJobs.Extensions.Storage.Common.Tests
{
public class ExpectManualCompletionLogger<TResult> : ILogger
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Host.FunctionalTests.TestDoubles;
using Microsoft.Azure.WebJobs.Host.TestCommon;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NUnit.Framework;

namespace Microsoft.Azure.WebJobs.Host.FunctionalTests
namespace Azure.WebJobs.Extensions.Storage.Common.Tests
{
// $$$ Remove all this. See Blob_IfBoundToCloudBlockBlob_BindsAndCreatesContainerButNotBlob for an example of what it should be.
internal class FunctionalTest
public class FunctionalTest
{
// $$$ Reconcile with TestJobHost.

internal static async Task<TResult> RunTriggerAsync<TResult>(
public static async Task<TResult> RunTriggerAsync<TResult>(
Action<IWebJobsBuilder> configureWebJobsBuilderAction,
Type programType,
Action<TaskCompletionSource<TResult>> setTaskSource,
Expand All @@ -35,13 +32,7 @@ internal static async Task<TResult> RunTriggerAsync<TResult>(
var host = new HostBuilder()
.ConfigureLogging(b => b.AddProvider(new ExpectManualCompletionLoggerProvider<TResult>(src, signalOnFirst, ignoreFailureFunctions)))
.ConfigureAppConfiguration(cb => cb.AddInMemoryCollection(settings))
.ConfigureDefaultTestHost(builder =>
{
builder.AddAzureStorageBlobs().AddAzureStorageQueues();
configureWebJobsBuilderAction.Invoke(builder);

builder.Services.AddSingleton<IConfigureOptions<QueuesOptions>, FakeQueuesOptionsSetup>();
}, programType)
.ConfigureDefaultTestHost(builder => configureWebJobsBuilderAction.Invoke(builder), programType)
.Build();

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

internal static async Task<Exception> RunTriggerFailureAsync<TResult>(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, Action<TaskCompletionSource<TResult>> setTaskSource)
public static async Task<Exception> RunTriggerFailureAsync<TResult>(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, Action<TaskCompletionSource<TResult>> setTaskSource)
{
try
{
Expand All @@ -108,14 +99,10 @@ internal static async Task<Exception> RunTriggerFailureAsync<TResult>(Action<IWe
}

// Call the method, and expect a failure. Return the exception.
internal static async Task<Exception> CallFailureAsync(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, MethodInfo methodInfo, object arguments)
public static async Task<Exception> CallFailureAsync(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, MethodInfo methodInfo, object arguments)
{
var host = new HostBuilder()
.ConfigureDefaultTestHost(b =>
{
b.AddAzureStorageBlobs().AddAzureStorageQueues();
configureWebJobsBuilderAction.Invoke(b);
}, programType)
.ConfigureDefaultTestHost(b => configureWebJobsBuilderAction.Invoke(b), programType)
.Build();

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

internal static async Task CallAsync(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, MethodInfo methodInfo, object arguments, params Type[] customExtensions)
public static async Task CallAsync(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, MethodInfo methodInfo, object arguments, params Type[] customExtensions)
{
var host = new HostBuilder()
.ConfigureDefaultTestHost(b =>
{
b.AddAzureStorageBlobs().AddAzureStorageQueues();
configureWebJobsBuilderAction.Invoke(b);

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

internal static async Task<TResult> CallAsync<TResult>(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, MethodInfo methodInfo, IDictionary<string, object> arguments, Action<TaskCompletionSource<TResult>> setTaskSource)
public static async Task<TResult> CallAsync<TResult>(Action<IWebJobsBuilder> configureWebJobsBuilderAction, Type programType, MethodInfo methodInfo, IDictionary<string, object> arguments, Action<TaskCompletionSource<TResult>> setTaskSource)
{
TaskCompletionSource<TResult> src = new TaskCompletionSource<TResult>();
setTaskSource(src);

var host = new HostBuilder()
.ConfigureDefaultTestHost(builder =>
{
builder.AddAzureStorageBlobs().AddAzureStorageQueues();
configureWebJobsBuilderAction.Invoke(builder);
}, programType)
.ConfigureDefaultTestHost(builder => configureWebJobsBuilderAction.Invoke(builder), programType)
.Build();

var jobHost = host.GetJobHost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

using System;
using System.Globalization;
using Microsoft.Azure.WebJobs;

namespace Microsoft.Azure.WebJobs.Host.TestCommon
namespace Azure.WebJobs.Extensions.Storage.Common.Tests
{
public class RandomNameResolver : INameResolver
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.IO;
using Microsoft.Extensions.Configuration;

namespace Microsoft.Azure.WebJobs.Host.TestCommon
namespace Azure.WebJobs.Extensions.Storage.Common.Tests
{
public static class TestConfigurationBuilderExtensions
{
Expand All @@ -20,4 +20,4 @@ public static IConfigurationBuilder AddTestSettings(this IConfigurationBuilder b
return builder.AddJsonFile(configPath, true);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Azure.Storage.Blobs.Models;
using Azure.Storage.Blobs.Specialized;

namespace Microsoft.Azure.WebJobs.Host.TestCommon
namespace Azure.WebJobs.Extensions.Storage.Common.Tests
{
public static class TestExtensions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
using System.Reflection;
using System.Threading.Tasks;
using Azure.WebJobs.Extensions.Storage.Common.Tests;
using Microsoft.Azure.WebJobs.Host.FunctionalTests.TestDoubles;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.WebJobs.Host.Indexers;
using Microsoft.Azure.WebJobs.Host.Loggers;
using Microsoft.Azure.WebJobs.Host.Timers;
Expand All @@ -20,7 +21,7 @@
using Microsoft.Extensions.Options;
using NUnit.Framework;

namespace Microsoft.Azure.WebJobs.Host.TestCommon
namespace Azure.WebJobs.Extensions.Storage.Common.Tests
{
public static class TestHelpers
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.WebJobs.Host.Executors;
using Microsoft.Azure.WebJobs.Host.Indexers;
using Microsoft.Extensions.Options;
using NUnit.Framework;

namespace Microsoft.Azure.WebJobs.Host.TestCommon
namespace Azure.WebJobs.Extensions.Storage.Common.Tests
{
public class JobHost<TProgram> : JobHost
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@
<PropertyGroup>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<Version>1.0.0-beta.1</Version>
<Description>This extension adds bindings for Storage</Description>
<IsPackable>false</IsPackable>
<PublicSign>false</PublicSign>
<DelaySign>true</DelaySign>
</PropertyGroup>

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

<ItemGroup>
<ProjectReference Include="..\..\Microsoft.Azure.WebJobs.Host.TestCommon\Azure.WebJobs.Host.TestCommon.csproj" />
<ProjectReference Include="..\..\Azure.Storage.Webjobs.Extensions.Common\tests\Azure.WebJobs.Extensions.Storage.Common.Tests.csproj" />
<ProjectReference Include="..\src\Azure.WebJobs.Extensions.Storage.Queues.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Azure.Storage.Queues.Models;
using Azure.WebJobs.Extensions.Storage.Common.Tests;
using Azure.WebJobs.Extensions.Storage.Queues.Tests;
using Microsoft.Extensions.Hosting;
using NUnit.Framework;

namespace Microsoft.Azure.WebJobs.Host.FunctionalTests
Expand Down Expand Up @@ -49,7 +50,10 @@ private static QueueClient CreateQueue(QueueServiceClient queueServiceClient, st
private async Task<Exception> RunTriggerFailureAsync<TResult>(Type programType,
Action<TaskCompletionSource<TResult>> setTaskSource)
{
return await FunctionalTest.RunTriggerFailureAsync<TResult>(b => b.UseQueueService(queueServiceClient), programType, setTaskSource);
return await FunctionalTest.RunTriggerFailureAsync<TResult>(b => {
b.AddAzureStorageQueues();
b.UseQueueService(queueServiceClient);
}, programType, setTaskSource);
}

private class BindToQueueTriggerViaIBinderProgram
Expand Down
Loading