-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests: Added tests for .NET Core 1.0 and 2.0 apps #167
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,49 @@ public DotNetCoreEndToEndTests(ITestOutputHelper output, TestTempDirTestFixture | |
_tempRootDir = testTempDirTestFixture.RootDirPath; | ||
} | ||
|
||
[Fact] | ||
public async Task CanBuildAndRun_NetCoreApp10WebApp() | ||
{ | ||
// Arrange | ||
var hostDir = Path.Combine(_hostSamplesDir, "DotNetCore", "aspnetcore10"); | ||
var volume = DockerVolume.Create(hostDir); | ||
var appDir = volume.ContainerDir; | ||
var appOutputDir = $"{appDir}/myoutputdir"; | ||
var buildImageScript = new ShellScriptBuilder() | ||
// NOTE: we are using 1.1 'sdk' version to build 1.0 netcoreapp | ||
.AddCommand($"oryx build {appDir} -l dotnet --language-version 1.1 -o {appOutputDir}") | ||
.ToString(); | ||
var runtimeImageScript = new ShellScriptBuilder() | ||
.AddCommand( | ||
$"oryx -appPath {appOutputDir} -bindPort {ContainerPort}") | ||
.AddCommand(DefaultStartupFilePath) | ||
.ToString(); | ||
|
||
await EndToEndTestHelper.BuildRunAndAssertAppAsync( | ||
NetCoreApp11WebApp, | ||
_output, | ||
volume, | ||
"/bin/sh", | ||
new[] | ||
{ | ||
"-c", | ||
buildImageScript | ||
}, | ||
"oryxdevms/dotnetcore-1.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The runtime image is still 1.0 |
||
ContainerPort, | ||
"/bin/sh", | ||
new[] | ||
{ | ||
"-c", | ||
runtimeImageScript | ||
}, | ||
async (hostPort) => | ||
{ | ||
var data = await _httpClient.GetStringAsync($"http://localhost:{hostPort}/"); | ||
Assert.Contains("Hello World!", data); | ||
}); | ||
} | ||
|
||
[Fact] | ||
public async Task CanBuildAndRun_NetCore11WebApp() | ||
{ | ||
|
@@ -124,6 +167,49 @@ await EndToEndTestHelper.BuildRunAndAssertAppAsync( | |
}); | ||
} | ||
|
||
[Fact] | ||
public async Task CanBuildAndRun_NetCoreApp20WebApp() | ||
{ | ||
// Arrange | ||
var hostDir = Path.Combine(_hostSamplesDir, "DotNetCore", "aspnetcore20"); | ||
var volume = DockerVolume.Create(hostDir); | ||
var appDir = volume.ContainerDir; | ||
var appOutputDir = $"{appDir}/myoutputdir"; | ||
var buildImageScript = new ShellScriptBuilder() | ||
// NOTE: we are using 2.1 'sdk' version to build 2.0 netcoreapp | ||
.AddCommand($"oryx build {appDir} -l dotnet --language-version 2.1 -o {appOutputDir}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly this is a 2.0 runtime app built with 2.1 SDK |
||
.ToString(); | ||
var runtimeImageScript = new ShellScriptBuilder() | ||
.AddCommand( | ||
$"oryx -appPath {appOutputDir} -bindPort {ContainerPort}") | ||
.AddCommand(DefaultStartupFilePath) | ||
.ToString(); | ||
|
||
await EndToEndTestHelper.BuildRunAndAssertAppAsync( | ||
NetCoreApp11WebApp, | ||
_output, | ||
volume, | ||
"/bin/sh", | ||
new[] | ||
{ | ||
"-c", | ||
buildImageScript | ||
}, | ||
"oryxdevms/dotnetcore-2.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The runtime image is still 2.0 |
||
ContainerPort, | ||
"/bin/sh", | ||
new[] | ||
{ | ||
"-c", | ||
runtimeImageScript | ||
}, | ||
async (hostPort) => | ||
{ | ||
var data = await _httpClient.GetStringAsync($"http://localhost:{hostPort}/"); | ||
Assert.Contains("Hello World!", data); | ||
}); | ||
} | ||
|
||
[Fact] | ||
public async Task CanBuildAndRun_NetCore21WebApp_UsingDefaultPublishOutputDirectory() | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"directory": "wwwroot/lib" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace app.Controllers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This apps were taken from the share that @JennyLawrance shared with us |
||
{ | ||
public class HomeController : Controller | ||
{ | ||
public string Index() | ||
{ | ||
return "Hello World!"; | ||
} | ||
|
||
public IActionResult About() | ||
{ | ||
ViewData["Message"] = "Your application description page."; | ||
|
||
return View(); | ||
} | ||
|
||
public IActionResult Contact() | ||
{ | ||
ViewData["Message"] = "Your contact page."; | ||
|
||
return View(); | ||
} | ||
|
||
public IActionResult Error() | ||
{ | ||
return View(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Hosting; | ||
|
||
namespace app | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var host = new WebHostBuilder() | ||
.UseKestrel() | ||
.UseContentRoot(Directory.GetCurrentDirectory()) | ||
.UseIISIntegration() | ||
.UseStartup<Startup>() | ||
.Build(); | ||
|
||
host.Run(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace app | ||
{ | ||
public class Startup | ||
{ | ||
public Startup(IHostingEnvironment env) | ||
{ | ||
var builder = new ConfigurationBuilder() | ||
.SetBasePath(env.ContentRootPath) | ||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) | ||
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) | ||
.AddEnvironmentVariables(); | ||
Configuration = builder.Build(); | ||
} | ||
|
||
public IConfigurationRoot Configuration { get; } | ||
|
||
// This method gets called by the runtime. Use this method to add services to the container. | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
// Add framework services. | ||
services.AddMvc(); | ||
} | ||
|
||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | ||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) | ||
{ | ||
loggerFactory.AddConsole(Configuration.GetSection("Logging")); | ||
loggerFactory.AddDebug(); | ||
|
||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
else | ||
{ | ||
app.UseExceptionHandler("/Home/Error"); | ||
} | ||
|
||
app.UseStaticFiles(); | ||
|
||
app.UseMvc(routes => | ||
{ | ||
routes.MapRoute( | ||
name: "default", | ||
template: "{controller=Home}/{action=Index}/{id?}"); | ||
}); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@{ | ||
ViewData["Title"] = "About"; | ||
} | ||
<h2>@ViewData["Title"].</h2> | ||
<h3>@ViewData["Message"]</h3> | ||
|
||
<p>Use this area to provide additional information.</p> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@{ | ||
ViewData["Title"] = "Contact"; | ||
} | ||
<h2>@ViewData["Title"].</h2> | ||
<h3>@ViewData["Message"]</h3> | ||
|
||
<address> | ||
One Microsoft Way<br /> | ||
Redmond, WA 98052-6399<br /> | ||
<abbr title="Phone">P:</abbr> | ||
425.555.0100 | ||
</address> | ||
|
||
<address> | ||
<strong>Support:</strong> <a href="mailto:Support@example.com">Support@example.com</a><br /> | ||
<strong>Marketing:</strong> <a href="mailto:Marketing@example.com">Marketing@example.com</a> | ||
</address> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
@{ | ||
ViewData["Title"] = "Home Page"; | ||
} | ||
|
||
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="6000"> | ||
<ol class="carousel-indicators"> | ||
<li data-target="#myCarousel" data-slide-to="0" class="active"></li> | ||
<li data-target="#myCarousel" data-slide-to="1"></li> | ||
<li data-target="#myCarousel" data-slide-to="2"></li> | ||
<li data-target="#myCarousel" data-slide-to="3"></li> | ||
</ol> | ||
<div class="carousel-inner" role="listbox"> | ||
<div class="item active"> | ||
<img src="~/images/banner1.svg" alt="ASP.NET" class="img-responsive" /> | ||
<div class="carousel-caption" role="option"> | ||
<p> | ||
Learn how to build ASP.NET apps that can run anywhere. | ||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525028&clcid=0x409"> | ||
Learn More | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="item"> | ||
<img src="~/images/banner2.svg" alt="Visual Studio" class="img-responsive" /> | ||
<div class="carousel-caption" role="option"> | ||
<p> | ||
There are powerful new features in Visual Studio for building modern web apps. | ||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525030&clcid=0x409"> | ||
Learn More | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="item"> | ||
<img src="~/images/banner3.svg" alt="Package Management" class="img-responsive" /> | ||
<div class="carousel-caption" role="option"> | ||
<p> | ||
Bring in libraries from NuGet, Bower, and npm, and automate tasks using Grunt or Gulp. | ||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525029&clcid=0x409"> | ||
Learn More | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="item"> | ||
<img src="~/images/banner4.svg" alt="Microsoft Azure" class="img-responsive" /> | ||
<div class="carousel-caption" role="option"> | ||
<p> | ||
Learn how Microsoft's Azure cloud platform allows you to build, deploy, and scale web apps. | ||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525027&clcid=0x409"> | ||
Learn More | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> | ||
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> | ||
<span class="sr-only">Previous</span> | ||
</a> | ||
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> | ||
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> | ||
<span class="sr-only">Next</span> | ||
</a> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-md-3"> | ||
<h2>Application uses</h2> | ||
<ul> | ||
<li>Sample pages using ASP.NET Core MVC</li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=518004">Bower</a> for managing client-side libraries</li> | ||
<li>Theming using <a href="https://go.microsoft.com/fwlink/?LinkID=398939">Bootstrap</a></li> | ||
</ul> | ||
</div> | ||
<div class="col-md-3"> | ||
<h2>How to</h2> | ||
<ul> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398600">Add a Controller and View</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699315">Manage User Secrets using Secret Manager.</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699316">Use logging to log a message.</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699317">Add packages using NuGet.</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699318">Add client packages using Bower.</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699319">Target development, staging or production environment.</a></li> | ||
</ul> | ||
</div> | ||
<div class="col-md-3"> | ||
<h2>Overview</h2> | ||
<ul> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=518008">Conceptual overview of what is ASP.NET Core</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699320">Fundamentals of ASP.NET Core such as Startup and middleware.</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398602">Working with Data</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398603">Security</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699321">Client side development</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699322">Develop on different platforms</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699323">Read more on the documentation site</a></li> | ||
</ul> | ||
</div> | ||
<div class="col-md-3"> | ||
<h2>Run & Deploy</h2> | ||
<ul> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517851">Run your app</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517853">Run tools such as EF migrations and more</a></li> | ||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398609">Publish to Microsoft Azure Web Apps</a></li> | ||
</ul> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@{ | ||
ViewData["Title"] = "Error"; | ||
} | ||
|
||
<h1 class="text-danger">Error.</h1> | ||
<h2 class="text-danger">An error occurred while processing your request.</h2> | ||
|
||
<h3>Development Mode</h3> | ||
<p> | ||
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred. | ||
</p> | ||
<p> | ||
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application. | ||
</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we have a 1.0 runtime app built with 1.1 SDK