Skip to content
Open
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,9 @@ FodyWeavers.xsd
*.msix
*.msm
*.msp

/minio-data
/CompanyEmployees.AppHost/minio-data/.minio.sys/tmp/808628fb-0b20-4cea-9ca9-1b28fea8d489
/CompanyEmployees.AppHost/minio-data/.minio.sys/tmp/05678231-c811-49c5-9e05-55188d7b2e92
/CompanyEmployees.AppHost/minio-data/.minio.sys/tmp
/CompanyEmployees.AppHost/minio-data/.minio.sys/buckets/company-employee/.usage-cache.bin/e1e86355-5b8e-4d71-b0b2-a9cc2939b942
1 change: 1 addition & 0 deletions Client.Wasm/Client.Wasm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Configurations>Debug;Release;123</Configurations>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 6 additions & 4 deletions Client.Wasm/Components/StudentCard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
</CardHeader>
<CardBody>
<UnorderedList Unstyled>
<UnorderedListItem>Номер <Strong>№X "Название лабораторной"</Strong></UnorderedListItem>
<UnorderedListItem>Вариант <Strong>№Х "Название варианта"</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Фамилией Именем 65ХХ</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://puginarug.com/">Ссылка на форк</Link></UnorderedListItem>
<UnorderedListItem>Номер <Strong>№2 "Балансировка нагрузки"</Strong></UnorderedListItem>
<UnorderedListItem>
Вариант <Strong>№8 "Сотрудник компании"</Strong>
</UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Земляновым Владимиром 6511</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://github.com/AvtoBBus/cloud-development">Ссылка на форк</Link></UnorderedListItem>
</UnorderedList>
</CardBody>
</Card>
12 changes: 6 additions & 6 deletions Client.Wasm/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5127",
"applicationUrl": "http://localhost:5128",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7282;http://localhost:5127",
"applicationUrl": "https://localhost:7283;http://localhost:5128",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}
4 changes: 2 additions & 2 deletions Client.Wasm/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
}
},
"AllowedHosts": "*",
"BaseAddress": ""
}
"BaseAddress": "http://localhost:5200/employee"
}
51 changes: 51 additions & 0 deletions CloudDevelopment.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,67 @@ VisualStudioVersion = 17.14.36811.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Wasm", "Client.Wasm\Client.Wasm.csproj", "{AE7EEA74-2FE0-136F-D797-854FD87E022A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyEmployees.AppHost", "CompanyEmployees.AppHost\CompanyEmployees.AppHost.csproj", "{96FC536F-9C20-45C4-B624-F3E2DEE96BA3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyEmployees.Generator", "CompanyEmployees.Generator\CompanyEmployees.Generator.csproj", "{418E6A76-7DE1-04F1-F18A-9A7C9ED44857}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyEmployees.ServiceDefaults", "CompanyEmployees.ServiceDefaults\CompanyEmployees.ServiceDefaults.csproj", "{53C4EDF4-E3C2-A484-171F-78A5FD7190F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyEmployees.ApiGateway", "CompanyEmployees.ApiGateway\CompanyEmployees.ApiGateway.csproj", "{A1370E88-073B-C8F9-1C33-D962F1D383BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyEmployees.FileService", "CompanyEmployees.FileService\CompanyEmployees.FileService.csproj", "{079C1DF9-133E-FD81-C1FA-1FABEBFB1101}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyEmployees.Tests", "CompanyEmployee.Tests\CompanyEmployees.Tests.csproj", "{F9C9F199-85EA-B6C8-1B29-47442974A133}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
123|Any CPU = 123|Any CPU
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.123|Any CPU.ActiveCfg = 123|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.123|Any CPU.Build.0 = 123|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|Any CPU.Build.0 = Release|Any CPU
{96FC536F-9C20-45C4-B624-F3E2DEE96BA3}.123|Any CPU.ActiveCfg = 123|Any CPU
{96FC536F-9C20-45C4-B624-F3E2DEE96BA3}.123|Any CPU.Build.0 = 123|Any CPU
{96FC536F-9C20-45C4-B624-F3E2DEE96BA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96FC536F-9C20-45C4-B624-F3E2DEE96BA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96FC536F-9C20-45C4-B624-F3E2DEE96BA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96FC536F-9C20-45C4-B624-F3E2DEE96BA3}.Release|Any CPU.Build.0 = Release|Any CPU
{418E6A76-7DE1-04F1-F18A-9A7C9ED44857}.123|Any CPU.ActiveCfg = Release|Any CPU
{418E6A76-7DE1-04F1-F18A-9A7C9ED44857}.123|Any CPU.Build.0 = Release|Any CPU
{418E6A76-7DE1-04F1-F18A-9A7C9ED44857}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{418E6A76-7DE1-04F1-F18A-9A7C9ED44857}.Debug|Any CPU.Build.0 = Debug|Any CPU
{418E6A76-7DE1-04F1-F18A-9A7C9ED44857}.Release|Any CPU.ActiveCfg = Release|Any CPU
{418E6A76-7DE1-04F1-F18A-9A7C9ED44857}.Release|Any CPU.Build.0 = Release|Any CPU
{53C4EDF4-E3C2-A484-171F-78A5FD7190F6}.123|Any CPU.ActiveCfg = 123|Any CPU
{53C4EDF4-E3C2-A484-171F-78A5FD7190F6}.123|Any CPU.Build.0 = 123|Any CPU
{53C4EDF4-E3C2-A484-171F-78A5FD7190F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53C4EDF4-E3C2-A484-171F-78A5FD7190F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53C4EDF4-E3C2-A484-171F-78A5FD7190F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53C4EDF4-E3C2-A484-171F-78A5FD7190F6}.Release|Any CPU.Build.0 = Release|Any CPU
{A1370E88-073B-C8F9-1C33-D962F1D383BD}.123|Any CPU.ActiveCfg = Debug|Any CPU
{A1370E88-073B-C8F9-1C33-D962F1D383BD}.123|Any CPU.Build.0 = Debug|Any CPU
{A1370E88-073B-C8F9-1C33-D962F1D383BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1370E88-073B-C8F9-1C33-D962F1D383BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1370E88-073B-C8F9-1C33-D962F1D383BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1370E88-073B-C8F9-1C33-D962F1D383BD}.Release|Any CPU.Build.0 = Release|Any CPU
{079C1DF9-133E-FD81-C1FA-1FABEBFB1101}.123|Any CPU.ActiveCfg = Debug|Any CPU
{079C1DF9-133E-FD81-C1FA-1FABEBFB1101}.123|Any CPU.Build.0 = Debug|Any CPU
{079C1DF9-133E-FD81-C1FA-1FABEBFB1101}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{079C1DF9-133E-FD81-C1FA-1FABEBFB1101}.Debug|Any CPU.Build.0 = Debug|Any CPU
{079C1DF9-133E-FD81-C1FA-1FABEBFB1101}.Release|Any CPU.ActiveCfg = Release|Any CPU
{079C1DF9-133E-FD81-C1FA-1FABEBFB1101}.Release|Any CPU.Build.0 = Release|Any CPU
{F9C9F199-85EA-B6C8-1B29-47442974A133}.123|Any CPU.ActiveCfg = Debug|Any CPU
{F9C9F199-85EA-B6C8-1B29-47442974A133}.123|Any CPU.Build.0 = Debug|Any CPU
{F9C9F199-85EA-B6C8-1B29-47442974A133}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9C9F199-85EA-B6C8-1B29-47442974A133}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9C9F199-85EA-B6C8-1B29-47442974A133}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9C9F199-85EA-B6C8-1B29-47442974A133}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
26 changes: 26 additions & 0 deletions CompanyEmployee.Tests/CompanyEmployees.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting" Version="9.5.2" />
<PackageReference Include="Aspire.Hosting.Testing" Version="9.5.2" />
<PackageReference Include="AWSSDK.S3" Version="4.0.21.1" />
<PackageReference Include="coverlet.collector" Version="8.0.1"/>
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>


<ItemGroup>
<ProjectReference Include="..\CompanyEmployees.AppHost\CompanyEmployees.AppHost.csproj" />
<ProjectReference Include="..\CompanyEmployees.Generator\CompanyEmployees.Generator.csproj" />
</ItemGroup>

</Project>
121 changes: 121 additions & 0 deletions CompanyEmployee.Tests/Fixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
using Amazon.Runtime;
using Amazon.S3;
using Amazon.S3.Model;
using Aspire.Hosting;
using Aspire.Hosting.ApplicationModel;
using Aspire.Hosting.Testing;
using Xunit;

namespace CompanyEmployees.Tests;

/// <summary>
/// Фикстура, поднимающая AppHost для интеграционных тестов.
/// </summary>
public class Fixture : IAsyncLifetime
{
public DistributedApplication App { get; private set; } = null!;
public AmazonS3Client S3Client { get; private set; } = null!;

public string sqsUrl = "";

public async Task InitializeAsync()
{
var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.CompanyEmployees_AppHost>();

appHost.Services.ConfigureHttpClientDefaults(http =>
http.AddStandardResilienceHandler(options =>
{
options.TotalRequestTimeout.Timeout = TimeSpan.FromMinutes(3);
options.AttemptTimeout.Timeout = TimeSpan.FromSeconds(60);
options.CircuitBreaker.SamplingDuration = TimeSpan.FromMinutes(3);
options.Retry.MaxRetryAttempts = 10;
options.Retry.Delay = TimeSpan.FromSeconds(3);
}));

App = await appHost.BuildAsync();
await App.StartAsync();

await Task.WhenAll(
App.ResourceNotifications.WaitForResourceAsync("minio"),
App.ResourceNotifications.WaitForResourceAsync("elasticmq"),
App.ResourceNotifications.WaitForResourceAsync("companyemployees-apigateway"),
App.ResourceNotifications.WaitForResourceAsync("company-employee-fileservice")
).WaitAsync(TimeSpan.FromMinutes(5));

await Task.Delay(TimeSpan.FromSeconds(5));

using var minioClient = App.CreateHttpClient("minio", "http");
var minioUrl = minioClient.BaseAddress!.ToString().TrimEnd('/');


var sqsHttpClient = App.CreateHttpClient("elasticmq", "http");
sqsUrl = sqsHttpClient.BaseAddress?.ToString().TrimEnd('/');


S3Client = new AmazonS3Client(
new BasicAWSCredentials("minioadmin", "minioadmin"),
new AmazonS3Config
{
ServiceURL = minioUrl,
ForcePathStyle = true,
UseHttp = true,
AuthenticationRegion = "us-east-1"
});

var doesExist = await Amazon.S3.Util.AmazonS3Util.DoesS3BucketExistV2Async(S3Client, "company-employee");

if (!doesExist)
{
await S3Client.PutBucketAsync(new PutBucketRequest
{
BucketName = "company-employee"
});
}

}

public async Task<List<S3Object>> WaitForS3ObjectAsync(string key, int maxAttempts = 15)
{
for (var i = 0; i < maxAttempts; i++)
{
await Task.Delay(TimeSpan.FromSeconds(2));

try
{
var doesExist = await Amazon.S3.Util.AmazonS3Util.DoesS3BucketExistV2Async(S3Client, "company-employee");

var response = await S3Client.ListObjectsV2Async(new ListObjectsV2Request
{
BucketName = "company-employee",
Prefix = key,
}
);

if (response.S3Objects is not null && response.S3Objects.Count > 0)
return response.S3Objects;
}
catch (AmazonS3Exception ex) when (ex.Message.Contains("NoSuchBucket"))
{
Console.WriteLine($"Bucket not ready yet, attempt {i + 1}/{maxAttempts}");
}
catch (Exception ex)
{
Console.WriteLine($"Error listing objects: {ex.Message}");
}
}

return [];
}
Comment on lines +77 to +108
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В тестах в этом методе не происходит успешного получения файла, нужно проверить почему так


public async Task DisposeAsync()
{
S3Client?.Dispose();

try
{
await App.DisposeAsync().AsTask().WaitAsync(TimeSpan.FromSeconds(30));
}
catch (TimeoutException) { }
catch (OperationCanceledException) { }
}
}
Loading