Skip to content

Чукарев Михаил Лаб. 3 Группа 6511#133

Open
Mishachuu wants to merge 29 commits into
itsecd:mainfrom
Mishachuu:main
Open

Чукарев Михаил Лаб. 3 Группа 6511#133
Mishachuu wants to merge 29 commits into
itsecd:mainfrom
Mishachuu:main

Conversation

@Mishachuu
Copy link
Copy Markdown

ФИО: Чукарев Михаил
Номер группы: 6511
Номер лабораторной: 3
Номер варианта: 17
Краткое описание предметной области: Транспортное средство
Краткое описание добавленных фич: Добавлен SQS брокер, MinIO хранилище и интеграционные тесты

@github-actions github-actions Bot added In progress Код в процессе проверки Lab 3 Лабораторная №3. Интеграционное тестирование labels May 6, 2026
@github-actions github-actions Bot requested a review from danlla May 6, 2026 19:48
Added details about the third laboratory work on integration testing, including descriptions of the file service, message broker, object storage, and integration tests.
Comment thread src/AppHost/Program.cs
Comment on lines +54 to +61
var replica = builder.AddProject<Projects.VehicleApi>($"vehicleapi-{serviceId++}")
.WithReference(cache)
.WithEnvironment("Sqs__ServiceUrl", sqsServiceUrl)
.WithEnvironment("Sqs__QueueUrl", sqsQueueUrl)
.WithHttpEndpoint(port: port, name: "api-endpoint", isProxied: false)
.WithExternalHttpEndpoints()
.WaitFor(cache)
.WaitFor(localstack);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Сейчас при запуске в консоли есть ошибки, связанные с тем, что не получается назначить 5000 порт всем 3 сервисам

происходит это из-за того, что в launchSettings.json файле VehicleApi 5000 задан по дефолту

поправить это можно двумя способами:

  1. явно переопределить 5000 порт на нужный:
var replica = builder.AddProject<Projects.VehicleApi>($"vehicleapi-{serviceId++}")
    .WithReference(cache)
    .WithEnvironment("Sqs__ServiceUrl", sqsServiceUrl)
    .WithEnvironment("Sqs__QueueUrl", sqsQueueUrl)
    .WithEndpoint("http", e =>
    {
        e.Port = port;
        e.IsProxied = false;
    })
    .WithExternalHttpEndpoints()
    .WaitFor(cache)
    .WaitFor(localstack);
  1. задать запускаемый профиль как null:
var replica = builder.AddProject<Projects.VehicleApi>($"vehicleapi-{serviceId++}", launchProfileName: null)
    .WithReference(cache)
    .WithEnvironment("Sqs__ServiceUrl", sqsServiceUrl)
    .WithEnvironment("Sqs__QueueUrl", sqsQueueUrl)
    .WithHttpEndpoint(port: port, name: "api-endpoint", isProxied: false)
    .WithExternalHttpEndpoints()
    .WaitFor(cache)
    .WaitFor(localstack);

Comment thread src/AppHost/Program.cs
ports = [5101, 5102, 5103];

var gatewayPort = int.TryParse(builder.Configuration["ApiGateway:Port"], out var p) ? p : 5200;
var fileServicePort = int.TryParse(builder.Configuration["FileService:Port"], out var fp) ? fp : 5300;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Эта переменная нигде не используется

Comment thread src/AppHost/Program.cs
var localstackEndpoint = localstack.GetEndpoint("api");
var minioEndpoint = minio.GetEndpoint("api");

var sqsServiceUrl = ReferenceExpression.Create($"http://{localstackEndpoint.Property(EndpointProperty.Host)}:{localstackEndpoint.Property(EndpointProperty.Port)}");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно же просто .WithReference(localstack) сделать и в ConnectionStrings появится нужный url для подключения

Comment thread src/AppHost/Program.cs
var fileService = builder.AddProject<Projects.FileService>("fileservice")
.WithEnvironment("Sqs__ServiceUrl", sqsServiceUrl)
.WithEnvironment("Sqs__QueueUrl", sqsQueueUrl)
.WithEnvironment("Minio__Endpoint", ReferenceExpression.Create($"{minioEndpoint.Property(EndpointProperty.Host)}:{minioEndpoint.Property(EndpointProperty.Port)}"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Аналогично

Comment on lines +34 to +46
public async Task EnsureQueueExistsAsync()
{
try
{
var queueName = _queueUrl.Split('/').Last();
await sqs.CreateQueueAsync(new Amazon.SQS.Model.CreateQueueRequest { QueueName = queueName });
logger.LogInformation("SQS queue ensured by VehicleApi");
}
catch (Exception ex)
{
logger.LogWarning("Could not create queue: {Message}", ex.Message);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Нужно поправить табуляцию

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

In progress Код в процессе проверки Lab 3 Лабораторная №3. Интеграционное тестирование

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants