Skip to content
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

Debug locally instead of in Docker #538

Merged
merged 9 commits into from
Feb 27, 2024
Merged
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
4 changes: 1 addition & 3 deletions AdminUi/src/AdminUi/AdminUi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
<PropertyGroup>
<IsPackable>false</IsPackable>
<SpaRoot>ClientApp\</SpaRoot>
<SpaProxyServerUrl>http://localhost:4200</SpaProxyServerUrl>
<SpaProxyServerUrl>http://localhost:8080</SpaProxyServerUrl>
<SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..\..</DockerfileContext>
</PropertyGroup>

<ItemGroup>
Expand Down
13 changes: 0 additions & 13 deletions AdminUi/src/AdminUi/ClientApp/Dockerfile.debug

This file was deleted.

2 changes: 1 addition & 1 deletion AdminUi/src/AdminUi/ClientApp/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
Run `ng serve` for a dev server. Navigate to `http://localhost:8080/`. The application will automatically reload if you change any of the source files.

## Code scaffolding

Expand Down
2 changes: 1 addition & 1 deletion AdminUi/src/AdminUi/ClientApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --disable-host-check --poll 1000",
"start": "ng serve --port 8080 --host 0.0.0.0 --disable-host-check --poll 1000",
"build": "ng build",
"build:ssr": "ng run AdminUi:server:dev",
"watch": "ng build --watch --configuration development",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const environment = {
production: false,
apiUrl: "http://localhost:5173/api/v1",
odataUrl: "http://localhost:5173/odata"
apiUrl: "http://localhost:8082/api/v1",
odataUrl: "http://localhost:8082/odata"
};
8 changes: 0 additions & 8 deletions AdminUi/src/AdminUi/Dockerfile.debug

This file was deleted.

1 change: 0 additions & 1 deletion AdminUi/src/AdminUi/Properties/.gitignore

This file was deleted.

46 changes: 10 additions & 36 deletions AdminUi/src/AdminUi/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,13 @@
{
"profiles": {
"AdminAPI": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"Infrastructure__EventBus__ConnectionInfo": "localhost",
"Infrastructure__SqlDatabase__ConnectionString": "User ID=adminUi;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;", // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=adminUi;Password=Passw0rd;TrustServerCertificate=True"
"Modules__Devices__Infrastructure__SqlDatabase__ConnectionString": "User ID=devices;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;", // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=devices;Password=Passw0rd;TrustServerCertificate=True"
"Modules__Quotas__Infrastructure__SqlDatabase__ConnectionString": "User ID=quotas;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;", // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=quotas;Password=Passw0rd;TrustServerCertificate=True"
"Logging__WriteTo__Seq__Args__ServerUrl": "http://localhost:5341"
},
"applicationUrl": "http://0.0.0.0:5000"
},
"AdminUi": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:5173",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy",
"Infrastructure__EventBus__ConnectionInfo": "localhost",
"Infrastructure__SqlDatabase__ConnectionString": "User ID=adminUi;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;", // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=adminUi;Password=Passw0rd;TrustServerCertificate=True"
"Modules__Devices__Infrastructure__SqlDatabase__ConnectionString": "User ID=devices;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;", // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=devices;Password=Passw0rd;TrustServerCertificate=True"
"Modules__Quotas__Infrastructure__SqlDatabase__ConnectionString": "User ID=quotas;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;", // "ConnectionString": "Server=localhost;Database=enmeshed;User Id=quotas;Password=Passw0rd;TrustServerCertificate=True"
"Logging__WriteTo__Seq__Args__ServerUrl": "http://localhost:5341"
}
}
},
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:39955",
"sslPort": 0
}
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"Default": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Local",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy",
"ASPNETCORE_URLS": "http://localhost:8082"
}
}
}
}
15 changes: 9 additions & 6 deletions AdminUi/src/AdminUi/appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"ApiKey": "test"
},
"Cors": {
"AllowedOrigins": "http://localhost:4200;https://localhost:4200",
"AllowedOrigins": "http://localhost:8080;https://localhost:8080",
"ExposedHeaders": "",
"AccessControlAllowCredentials": true
},
Expand All @@ -13,7 +13,7 @@
"Infrastructure": {
"EventBus": {
"Vendor": "RabbitMQ", // possible values: InMemory, RabbitMQ, GoogleCloud, Azure
"ConnectionInfo": "rabbitmq",
"ConnectionInfo": "localhost",

"RabbitMQUsername": "guest", // only available for RabbitMQ
"RabbitMQPassword": "guest", // only available for RabbitMQ
Expand All @@ -24,7 +24,7 @@
},
"SqlDatabase": {
"Provider": "Postgres",
"ConnectionString": "User ID=adminUi;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres
"ConnectionString": "User ID=adminUi;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;" // postgres
//"ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=adminUi;Password=Passw0rd;TrustServerCertificate=True"
}
},
Expand All @@ -40,7 +40,7 @@
"Infrastructure": {
"SqlDatabase": {
"Provider": "Postgres",
"ConnectionString": "User ID=devices;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres
"ConnectionString": "User ID=devices;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;" // postgres
//"ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=devices;Password=Passw0rd;TrustServerCertificate=True"
},
"PushNotifications": {
Expand All @@ -58,7 +58,7 @@
"Infrastructure": {
"SqlDatabase": {
"Provider": "Postgres",
"ConnectionString": "User ID=quotas;Password=Passw0rd;Server=postgres;Port=5432;Database=enmeshed;" // postgres
"ConnectionString": "User ID=quotas;Password=Passw0rd;Server=localhost;Port=5432;Database=enmeshed;" // postgres
//"ConnectionString": "Server=ms-sql-server;Database=enmeshed;User Id=quotas;Password=Passw0rd;TrustServerCertificate=True"
}
}
Expand All @@ -79,8 +79,11 @@
"Seq": {
"Name": "Seq",
"Args": {
"ServerUrl": "http://seq:5341"
"ServerUrl": "http://localhost:5341"
}
},
"Debug": {
"Name": "Debug"
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions Backbone.slnLaunch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"Name": "Admin UI \u002B Consumer API",
"Projects": [
{
"Name": "ConsumerApi\\ConsumerApi.csproj",
"Action": "Start",
"DebugTarget": ""
},
{
"Name": "docker-compose\\docker-compose.dcproj",
"Action": "StartWithoutDebugging",
"DebugTarget": ""
},
{
"Name": "AdminUi\\src\\AdminUi\\AdminUi.csproj",
"Action": "Start",
"DebugTarget": ""
}
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Npgsql;
using Polly;
using Polly.Retry;

namespace Backbone.BuildingBlocks.API.Extensions;

Expand All @@ -20,13 +22,12 @@ public static IHost MigrateDbContext<TContext>(this IHost host) where TContext :
{
logger.LogInformation("Migrating database associated with context '{context}'", typeof(TContext).Name);

var retry = Policy.Handle<SqlException>()
.WaitAndRetry(new[]
{
var retry = Policy.Handle<SqlException>().Or<PostgresException>()
.WaitAndRetry([
TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(10),
TimeSpan.FromSeconds(15)
});
]);

retry.Execute(context.Database.Migrate);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static void AddRabbitMq(this IServiceCollection services, Action<RabbitMq
{
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMqPersistentConnection>>();


var factory = new ConnectionFactory
{
HostName = options.HostName
Expand Down
96 changes: 48 additions & 48 deletions ConsumerApi.Tests.Integration/Features/Tokens/{id}/GET.feature
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
@Integration
Feature: GET Token
User requests a Token
Scenario: Requesting an own Token as an authenticated user
Given the user is authenticated
And an own Token t
When a GET request is sent to the Tokens/{id} endpoint with t.Id
Then the response status code is 200 (OK)
And the response contains a Token
Scenario: Requesting an own Token as an anonymous user
Given the user is unauthenticated
And an own Token t
When a GET request is sent to the Tokens/{id} endpoint with t.Id
Then the response status code is 200 (OK)
And the response contains a Token
Scenario: Requesting a peer Token as an authenticated user
Given the user is authenticated
And a peer Token p
When a GET request is sent to the Tokens/{id} endpoint with p.Id
Then the response status code is 200 (OK)
And the response contains a Token
Scenario: Requesting a nonexistent Token as an authenticated user
Given the user is authenticated
When a GET request is sent to the Tokens/{id} endpoint with "TOKthisisnonexisting"
Then the response status code is 404 (Not Found)
And the response content includes an error with the error code "error.platform.recordNotFound"
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario: Requesting a Token with an unsupported Accept Header
# Given the Accept header is 'application/xml'
# When a GET request is sent to the Tokens/{id} endpoint with a valid Id
# Then the response status code is 406 (Not Acceptable)
#
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario Outline: Requesting a Token with an invalid id
# When a GET request is sent to the Tokens/{id} endpoint with <id>
# Then the response status code is 400 (Bad Request)
# And the response content includes an error with the error code "error.platform.invalidId"
#Examples:
# | id | description |
# | TOKthishastoomanycharacters | More than 20 characters |
# | TOKnotenoughchars | Less than 20 characters |
# | TOK_frfssd_fdfdsed#_ | Contains invalid characters |
@Integration
Feature: GET Token

User requests a Token

Scenario: Requesting an own Token as an authenticated user
Given the user is authenticated
And an own Token t
When a GET request is sent to the Tokens/{id} endpoint with t.Id
Then the response status code is 200 (OK)
And the response contains a Token

Scenario: Requesting an own Token as an anonymous user
Given the user is unauthenticated
And an own Token t
When a GET request is sent to the Tokens/{id} endpoint with t.Id
Then the response status code is 200 (OK)
And the response contains a Token

Scenario: Requesting a peer Token as an authenticated user
Given the user is authenticated
And a peer Token p
When a GET request is sent to the Tokens/{id} endpoint with p.Id
Then the response status code is 200 (OK)
And the response contains a Token

Scenario: Requesting a nonexistent Token as an authenticated user
Given the user is authenticated
When a GET request is sent to the Tokens/{id} endpoint with "TOKthisisnonexisting"
Then the response status code is 404 (Not Found)
And the response content includes an error with the error code "error.platform.recordNotFound"

#@ignore("skipping_due_to_required_backbone_changes")
#Scenario: Requesting a Token with an unsupported Accept Header
# Given the Accept header is 'application/xml'
# When a GET request is sent to the Tokens/{id} endpoint with a valid Id
# Then the response status code is 406 (Not Acceptable)
#
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario Outline: Requesting a Token with an invalid id
# When a GET request is sent to the Tokens/{id} endpoint with <id>
# Then the response status code is 400 (Bad Request)
# And the response content includes an error with the error code "error.platform.invalidId"
#Examples:
# | id | description |
# | TOKthishastoomanycharacters | More than 20 characters |
# | TOKnotenoughchars | Less than 20 characters |
# | TOK_frfssd_fdfdsed#_ | Contains invalid characters |
# | POKfdjfdjflndjkfndjk | Does not have TOK prefix |
2 changes: 0 additions & 2 deletions ConsumerApi/ConsumerApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

<PropertyGroup>
<UserSecretsId>f114fba8-95dd-4fee-8385-af8e8a343c68</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 0 additions & 9 deletions ConsumerApi/Dockerfile.debug

This file was deleted.

22 changes: 11 additions & 11 deletions ConsumerApi/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"profiles": {
"Default": {
"commandName": "Project"
},
"Docker": {
"commandName": "Docker",
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"publishAllPorts": true
}
},
"$schema": "http://json.schemastore.org/launchsettings.json"
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"Default": {
"commandName": "Project",
"environmentVariables": {
"Modules__Files__Infrastructure__BlobStorage__ConnectionInfo": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;",
"ASPNETCORE_ENVIRONMENT": "Local",
"ASPNETCORE_URLS": "http://localhost:8081"
}
}
}
}
4 changes: 2 additions & 2 deletions ConsumerApi/QuotasDbContextSeeder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public QuotasDbContextSeeder(DevicesDbContext devicesDbContext, IMediator mediat

public async Task SeedAsync(QuotasDbContext context)
{
await SeedTier(context);
await SeedTiers(context);
await AddTierToIdentities(context);
await EnsureQueuedForDeletionTierWithQuotas();
}
Expand All @@ -45,7 +45,7 @@ private async Task AddTierToIdentities(QuotasDbContext context)
await context.SaveChangesAsync();
}

private async Task SeedTier(QuotasDbContext context)
private async Task SeedTiers(QuotasDbContext context)
{
if (await context.Tiers.AnyAsync())
return;
Expand Down
Loading