-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eafae23
commit df54946
Showing
4 changed files
with
126 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/CSharp/EasyMicroservices.ContentsMicroservice.Tests/ContentMemoryLeakTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using EasyMicroservices.ContentsMicroservice.Contracts.Common; | ||
using EasyMicroservices.ContentsMicroservice.Contracts.Requests; | ||
using EasyMicroservices.ContentsMicroservice.Database.Contexts; | ||
using EasyMicroservices.ContentsMicroservice.Database.Entities; | ||
using EasyMicroservices.ContentsMicroservice.WebApi.Controllers; | ||
using EasyMicroservices.Cores.AspEntityFrameworkCoreApi; | ||
using EasyMicroservices.Cores.AspEntityFrameworkCoreApi.Interfaces; | ||
using EasyMicroservices.Cores.Relational.EntityFrameworkCore; | ||
using EasyMicroservices.Cores.Relational.EntityFrameworkCore.Intrerfaces; | ||
using Microsoft.AspNetCore.Mvc.ApplicationParts; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace EasyMicroservices.ContentsMicroservice.Tests | ||
{ | ||
public class ContentMemoryLeakTest | ||
{ | ||
static bool IsStarted = false; | ||
|
||
static async Task StartServer() | ||
{ | ||
if (IsStarted) | ||
return; | ||
IsStarted = true; | ||
_ = Task.Run(async () => | ||
{ | ||
await EasyMicroservices.ContentsMicroservice.WebApi.Program.Run(null, (s) => | ||
{ | ||
s.AddControllers().PartManager.ApplicationParts.Add(new AssemblyPart(typeof(CategoryController).Assembly)); | ||
}); | ||
}); | ||
await Task.Delay(2000); | ||
} | ||
|
||
//[Fact] | ||
//public async Task CheckMemoryLeakAddContentTest() | ||
//{ | ||
// await StartServer(); | ||
// Contents.GeneratedServices.CategoryClient client = new Contents.GeneratedServices.CategoryClient("http://localhost:2003", new System.Net.Http.HttpClient()); | ||
// var categoryResult = await client.AddAsync(new Contents.GeneratedServices.CreateCategoryRequestContract() | ||
// { | ||
// Key = $"1-1-Title{Guid.NewGuid()}", | ||
// UniqueIdentity = "1-2" | ||
// }); | ||
// Assert.True(categoryResult.IsSuccess); | ||
// Contents.GeneratedServices.ContentClient contentClient = new Contents.GeneratedServices.ContentClient("http://localhost:2003", new System.Net.Http.HttpClient()); | ||
// for (int i = 0; i < 5000; i++) | ||
// { | ||
// var contentResult = await contentClient.AddAsync(new Contents.GeneratedServices.CreateContentRequestContract() | ||
// { | ||
// CategoryId = categoryResult.Result, | ||
// UniqueIdentity = "1-2", | ||
// Data = i.ToString(), | ||
// LanguageId = 1 | ||
// }); | ||
// Assert.True(contentResult.IsSuccess); | ||
// } | ||
|
||
// while (true) | ||
// { | ||
// GC.Collect(); | ||
// await Task.Delay(1000); | ||
// } | ||
//} | ||
|
||
//[Fact] | ||
//public async Task MemoryLeackTest() | ||
//{ | ||
// HostApplicationBuilder builder = Host.CreateApplicationBuilder(null); | ||
// UnitOfWork.DefaultUniqueIdentity = "1-1"; | ||
// UnitOfWork.MicroserviceId = 10; | ||
// builder.Services.AddTransient<IEntityFrameworkCoreDatabaseBuilder, DatabaseBuilder>(); | ||
// builder.Services.AddTransient<RelationalCoreContext, ContentContext>(); | ||
// builder.Services.AddTransient<ContentContext>(); | ||
// //builder.Services.AddTransient<IUnitOfWork, UnitOfWork>(); | ||
|
||
// using IHost host = builder.Build(); | ||
|
||
// for (int i = 0; i < 5000; i++) | ||
// { | ||
// using var scope = host.Services.CreateScope(); | ||
// using var uow = scope.ServiceProvider.GetService<RelationalCoreContext>(); | ||
// //using var logic = uow.GetLongContractLogic<ContentEntity, CreateContentRequestContract, UpdateContentRequestContract, ContentContract>(); | ||
// } | ||
//} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/CSharp/EasyMicroservices.ContentsMicroservice.Tests/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*", | ||
"ConnectionStrings": { | ||
"local": "Server=testtt;Database=Contents;User ID=TrustServerCertificate=True;", // Test | ||
}, | ||
"RootAddresses": { | ||
"WhiteLabel": "http://localhost:1041" | ||
}, | ||
"Urls": "http://*:2003" | ||
} |