Browse Source

add test for Dapr

pull/1612/head
Phill Morton 3 years ago
parent
commit
e2806e66d5
  1. 8
      test/E2ETest/TyeRunTests.cs
  2. 13
      test/E2ETest/testassets/projects/dapr-function-app/.idea/.idea.dapr-function-app/.idea/.gitignore
  3. 6
      test/E2ETest/testassets/projects/dapr-function-app/.idea/.idea.dapr-function-app/.idea/GitLink.xml
  4. 6
      test/E2ETest/testassets/projects/dapr-function-app/.idea/.idea.dapr-function-app/.idea/codestream.xml
  5. 4
      test/E2ETest/testassets/projects/dapr-function-app/.idea/.idea.dapr-function-app/.idea/encodings.xml
  6. 8
      test/E2ETest/testassets/projects/dapr-function-app/.idea/.idea.dapr-function-app/.idea/indexLayout.xml
  7. 6
      test/E2ETest/testassets/projects/dapr-function-app/.idea/.idea.dapr-function-app/.idea/vcs.xml
  8. 6
      test/E2ETest/testassets/projects/dapr-function-app/dapr-function-app.sln
  9. 26
      test/E2ETest/testassets/projects/dapr-function-app/dapr/Program.cs
  10. 27
      test/E2ETest/testassets/projects/dapr-function-app/dapr/Properties/launchSettings.json
  11. 51
      test/E2ETest/testassets/projects/dapr-function-app/dapr/Startup.cs
  12. 9
      test/E2ETest/testassets/projects/dapr-function-app/dapr/appsettings.Development.json
  13. 10
      test/E2ETest/testassets/projects/dapr-function-app/dapr/appsettings.json
  14. 11
      test/E2ETest/testassets/projects/dapr-function-app/dapr/dapr.csproj
  15. 4
      test/E2ETest/testassets/projects/dapr-function-app/tye.yaml

8
test/E2ETest/TyeRunTests.cs

@ -148,9 +148,15 @@ services:
{
var backendUri = await GetServiceUrl(client, uri, "dapr-test-project");
await Task.Delay(10000);
var backendResponse = await client.GetAsync(backendUri);
Assert.True(backendResponse.IsSuccessStatusCode);
//The backend calls the Function app via Dapr InvokeMethod. So test that that func has a sidecar, and being proxied.
var responseContent = await backendResponse.Content.ReadAsStringAsync();
Assert.Contains("Welcome to Azure Functions!", responseContent);
});
}

13
test/E2ETest/testassets/projects/dapr-function-app/.idea/.idea.dapr-function-app/.idea/.gitignore

@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/modules.xml
/contentModel.xml
/.idea.dapr-function-app.iml
/projectSettingsUpdater.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

6
test/E2ETest/testassets/projects/dapr-function-app/.idea/.idea.dapr-function-app/.idea/GitLink.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="uk.co.ben_gibson.git.link.SettingsState">
<option name="host" value="72037fcc-cb9c-4c22-960a-ffe73fd5e229" />
</component>
</project>

6
test/E2ETest/testassets/projects/dapr-function-app/.idea/.idea.dapr-function-app/.idea/codestream.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CodeStream">
<option name="webViewContext" value="{&quot;chatProviderAccess&quot;:&quot;strict&quot;,&quot;currentTeamId&quot;:&quot;&quot;,&quot;currentStreamId&quot;:&quot;&quot;,&quot;pullRequestCheckoutBranch&quot;:false,&quot;isRepositioning&quot;:false,&quot;onboardStep&quot;:0,&quot;panelStack&quot;:[&quot;landing-redirect&quot;],&quot;hasFocus&quot;:false,&quot;channelFilter&quot;:&quot;all&quot;,&quot;channelsMuteAll&quot;:false,&quot;codemarkFileFilter&quot;:&quot;all&quot;,&quot;codemarkTypeFilter&quot;:&quot;all&quot;,&quot;codemarkTagFilter&quot;:&quot;all&quot;,&quot;codemarkBranchFilter&quot;:&quot;all&quot;,&quot;codemarkAuthorFilter&quot;:&quot;all&quot;,&quot;codemarksFileViewStyle&quot;:&quot;inline&quot;,&quot;codemarksShowArchived&quot;:false,&quot;codemarksShowResolved&quot;:false,&quot;codemarksWrapComments&quot;:false,&quot;showFeedbackSmiley&quot;:true,&quot;route&quot;:{&quot;name&quot;:&quot;newUserEntry&quot;,&quot;params&quot;:{}},&quot;spatialViewShowPRComments&quot;:false,&quot;currentPullRequestNeedsRefresh&quot;:{&quot;needsRefresh&quot;:false,&quot;providerId&quot;:&quot;&quot;,&quot;pullRequestId&quot;:&quot;&quot;},&quot;__teamless__&quot;:{&quot;selectedRegion&quot;:&quot;us&quot;},&quot;sessionStart&quot;:1695898496347}" />
</component>
</project>

4
test/E2ETest/testassets/projects/dapr-function-app/.idea/.idea.dapr-function-app/.idea/encodings.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

8
test/E2ETest/testassets/projects/dapr-function-app/.idea/.idea.dapr-function-app/.idea/indexLayout.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

6
test/E2ETest/testassets/projects/dapr-function-app/.idea/.idea.dapr-function-app/.idea/vcs.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../../../.." vcs="Git" />
</component>
</project>

6
test/E2ETest/testassets/projects/dapr-function-app/dapr-function-app.sln

@ -5,6 +5,8 @@ VisualStudioVersion = 25.0.1706.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dapr-function-app", "function/dapr-function-app.csproj", "{0979B3EB-D56F-4402-A858-AB19B6D9B902}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dapr", "dapr\dapr.csproj", "{8336F6C8-57F3-4D80-B4AF-CFE0A9DA446E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,6 +17,10 @@ Global
{0979B3EB-D56F-4402-A858-AB19B6D9B902}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0979B3EB-D56F-4402-A858-AB19B6D9B902}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0979B3EB-D56F-4402-A858-AB19B6D9B902}.Release|Any CPU.Build.0 = Release|Any CPU
{8336F6C8-57F3-4D80-B4AF-CFE0A9DA446E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8336F6C8-57F3-4D80-B4AF-CFE0A9DA446E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8336F6C8-57F3-4D80-B4AF-CFE0A9DA446E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8336F6C8-57F3-4D80-B4AF-CFE0A9DA446E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

26
test/E2ETest/testassets/projects/dapr-function-app/dapr/Program.cs

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace dapr
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

27
test/E2ETest/testassets/projects/dapr-function-app/dapr/Properties/launchSettings.json

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:64181",
"sslPort": 44315
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dapr": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

51
test/E2ETest/testassets/projects/dapr-function-app/dapr/Startup.cs

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Dapr.Client;
namespace dapr
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
var functionAppId = "dapr-function-app";
var methodName = "api/HttpTrigger1";
var daprClient = new DaprClientBuilder().Build();
var daprRequest = daprClient.CreateInvokeMethodRequest(HttpMethod.Post, functionAppId, methodName);
var response = await daprClient.InvokeMethodWithResponseAsync(daprRequest);
await context.Response.WriteAsync(await response.Content.ReadAsStringAsync());
});
});
}
}
}

9
test/E2ETest/testassets/projects/dapr-function-app/dapr/appsettings.Development.json

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

10
test/E2ETest/testassets/projects/dapr-function-app/dapr/appsettings.json

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

11
test/E2ETest/testassets/projects/dapr-function-app/dapr/dapr.csproj

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapr.Client" Version="1.11.0" />
</ItemGroup>
</Project>

4
test/E2ETest/testassets/projects/dapr-function-app/tye.yaml

@ -4,5 +4,7 @@ extensions:
config: tracing
log-level: debug
services:
- name: dapr-function-app
azureFunction: function/
- name: dapr-test-project
azureFunction: function/
project: dapr/dapr.csproj
Loading…
Cancel
Save