-
Notifications
You must be signed in to change notification settings - Fork 52
Землянов Владимир Лаб. 3 Группа 6511 #107
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
Open
AvtoBBus
wants to merge
20
commits into
itsecd:main
Choose a base branch
from
AvtoBBus:lab3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4ff9607
adding AppHost and Generator with caching
AvtoBBus 21dd0d5
some fix
AvtoBBus 5d39f5e
fix ServicesDefaults
AvtoBBus 5694a99
Update Generator and Service after review
AvtoBBus 672d98f
Update README.md
AvtoBBus 67a846f
Some update in generator and service
AvtoBBus a98ac50
Merge branch 'main' of https://github.com/AvtoBBus/cloud-development
AvtoBBus ab1cca0
Add ApiGateway with LoadBalancer and some fix in another projects
AvtoBBus 6a86722
Update README.md
AvtoBBus d0146b7
Update README.md
AvtoBBus 924b2bb
Some fix
AvtoBBus 3ae4aab
add some fixes
AvtoBBus f4af71c
some fix after review
AvtoBBus 4cd321c
adding file service
AvtoBBus b213180
add testing
AvtoBBus 3900a09
update gitignore
AvtoBBus 486068e
Delete CompanyEmployees.AppHost/minio-data/.minio.sys directory
AvtoBBus 87f5eeb
Правки посе ревью
AvtoBBus c4039ce
Merge branch 'lab3' of https://github.com/AvtoBBus/cloud-development …
AvtoBBus 0f1956f
Ещё какие-то правки
AvtoBBus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -6,5 +6,5 @@ | |
| } | ||
| }, | ||
| "AllowedHosts": "*", | ||
| "BaseAddress": "" | ||
| } | ||
| "BaseAddress": "http://localhost:5200/employee" | ||
| } | ||
This file contains hidden or 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
This file contains hidden or 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,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> |
This file contains hidden or 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,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 []; | ||
| } | ||
|
|
||
| public async Task DisposeAsync() | ||
| { | ||
| S3Client?.Dispose(); | ||
|
|
||
| try | ||
| { | ||
| await App.DisposeAsync().AsTask().WaitAsync(TimeSpan.FromSeconds(30)); | ||
| } | ||
| catch (TimeoutException) { } | ||
| catch (OperationCanceledException) { } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
В тестах в этом методе не происходит успешного получения файла, нужно проверить почему так