Skip to content

Commit bdfe7bf

Browse files
authored
Merge branch 'main' into copilot/fix-sonarcloud-issues
2 parents 92b9f09 + 0489e8a commit bdfe7bf

File tree

60 files changed

+6385
-419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+6385
-419
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ dotnet_diagnostic.IDE0029.severity = warning # Use coalesce expression
439439
dotnet_diagnostic.IDE0030.severity = warning # Use coalesce expression
440440
dotnet_diagnostic.IDE0031.severity = warning # Use null propagation
441441
dotnet_diagnostic.IDE0045.severity = warning # Use conditional expression for assignment
442+
dotnet_style_prefer_conditional_expression_over_return = false:warning
442443
dotnet_diagnostic.IDE0046.severity = warning # Use conditional expression for return
443444
dotnet_diagnostic.IDE0074.severity = warning # Use compound assignment
444445
dotnet_diagnostic.IDE0075.severity = warning # Simplify conditional expression
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: ObservabilityTesting Integration Tests
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
env:
8+
configuration: Release
9+
10+
concurrency:
11+
group: observability-${{ github.head_ref || github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
observability-test:
16+
name: Run Observability Integration Tests
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 20
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up JDK 17
27+
uses: actions/setup-java@v4
28+
with:
29+
java-version: '17'
30+
distribution: 'temurin'
31+
32+
- name: Install Maven
33+
uses: stCarolas/setup-maven@v4
34+
with:
35+
maven-version: '3.9.6'
36+
37+
- name: Set up .NET 9.0
38+
uses: actions/setup-dotnet@v4
39+
with:
40+
dotnet-version: '9.0.x'
41+
42+
- name: Install .NET Aspire workload
43+
run: |
44+
echo "📦 Installing .NET Aspire workload..."
45+
dotnet workload install aspire
46+
echo "✅ Aspire workload installed successfully"
47+
48+
- name: Verify Docker environment
49+
run: |
50+
echo "=== Verifying Docker environment ==="
51+
docker --version
52+
docker compose version
53+
docker info
54+
docker ps -a
55+
echo "Docker service status:"
56+
sudo systemctl status docker --no-pager || true
57+
echo "Starting Docker if not running..."
58+
sudo systemctl start docker || true
59+
sleep 5
60+
docker ps
61+
echo "=== Pulling required Docker images ==="
62+
docker pull confluentinc/cp-kafka:latest || true
63+
docker pull flink:2.1.0-java17 || true
64+
docker pull prom/prometheus:latest || true
65+
docker pull grafana/grafana:latest || true
66+
echo "✅ Docker is ready"
67+
68+
- name: Configure system for Kafka performance
69+
run: |
70+
echo "=== Configuring system for optimal Kafka performance ==="
71+
sudo sysctl -w vm.max_map_count=262144
72+
sudo bash -c 'echo "* soft nofile 65536" >> /etc/security/limits.conf'
73+
sudo bash -c 'echo "* hard nofile 65536" >> /etc/security/limits.conf'
74+
echo "Current vm.max_map_count: $(sysctl vm.max_map_count)"
75+
echo "Current ulimit -n: $(ulimit -n)"
76+
echo "Available memory: $(free -h)"
77+
echo "CPU info: $(nproc) cores"
78+
cat /proc/cpuinfo | grep "model name" | head -1
79+
80+
- name: Build ObservabilityTesting solution
81+
run: |
82+
echo "🔨 Building ObservabilityTesting solution..."
83+
echo " Gateway will be built from Dockerfile as part of Aspire build"
84+
dotnet restore ObservabilityTesting/ObservabilityTesting.sln
85+
dotnet build ObservabilityTesting/ObservabilityTesting.sln --configuration ${{ env.configuration }} --no-restore
86+
87+
- name: Run Observability Integration Tests
88+
timeout-minutes: 20
89+
env:
90+
DOTNET_ENVIRONMENT: Testing
91+
KAFKA_BOOTSTRAP_SERVERS: "localhost:9092"
92+
ASPIRE_ALLOW_UNSECURED_TRANSPORT: "true"
93+
DOCKER_HOST: "unix:///var/run/docker.sock"
94+
TESTCONTAINERS_RYUK_DISABLED: "false"
95+
TESTCONTAINERS_HOST_OVERRIDE: "localhost"
96+
run: |
97+
echo "=== Starting Observability Integration Tests ==="
98+
dotnet test ObservabilityTesting/ObservabilityTesting.IntegrationTests --no-build --configuration ${{ env.configuration }} --verbosity normal --logger "trx;LogFileName=TestResults.trx" --results-directory TestResults
99+
working-directory: ./
100+
101+
- name: Upload test results
102+
uses: actions/upload-artifact@v4
103+
with:
104+
name: ObservabilityTestResults
105+
path: TestResults/
106+
if: always()
107+
108+
- name: Show Docker containers (diagnostic)
109+
if: always()
110+
run: |
111+
echo "=== Docker containers status ==="
112+
docker ps -a
113+
echo "=== Docker logs for Kafka ==="
114+
docker logs $(docker ps -aq --filter "name=kafka") 2>&1 | tail -100 || echo "No Kafka container found"
115+
echo "=== Docker logs for Flink JobManager ==="
116+
docker logs $(docker ps -aq --filter "name=flink-jobmanager") 2>&1 | tail -100 || echo "No Flink container found"
117+
echo "=== Docker logs for Prometheus ==="
118+
docker logs $(docker ps -aq --filter "name=prometheus") 2>&1 | tail -100 || echo "No Prometheus container found"
119+
echo "=== Docker logs for Grafana ==="
120+
docker logs $(docker ps -aq --filter "name=grafana") 2>&1 | tail -100 || echo "No Grafana container found"
121+
122+
- name: Cleanup
123+
if: always()
124+
run: |
125+
docker system prune -f || true
126+
docker volume prune -f || true

FlinkDotNet/Flink.JobBuilder.Tests/FlinkJobGatewayServiceAdditionalBranchCoverageTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class FlinkJobGatewayServiceAdditionalBranchCoverageTests
1717
[SetUp]
1818
public void SetUp()
1919
{
20-
Environment.SetEnvironmentVariable("FLINK_JOB_GATEWAY_URL", "http://localhost:8080");
20+
Environment.SetEnvironmentVariable("FLINK_JOB_GATEWAY_URL", "http://localhost:8086");
2121
FlinkJobGatewayService.RetryDelay = TimeSpan.FromMilliseconds(1);
2222
}
2323

@@ -36,7 +36,7 @@ public void Constructor_WithApiKey_AddsApiKeyHeader()
3636
// Arrange
3737
var config = new FlinkJobGatewayConfiguration
3838
{
39-
BaseUrl = "http://localhost:8080",
39+
BaseUrl = "http://localhost:8086",
4040
ApiKey = "test-api-key-12345"
4141
};
4242

@@ -53,7 +53,7 @@ public void Constructor_WithEmptyApiKey_DoesNotAddApiKeyHeader()
5353
// Arrange
5454
var config = new FlinkJobGatewayConfiguration
5555
{
56-
BaseUrl = "http://localhost:8080",
56+
BaseUrl = "http://localhost:8086",
5757
ApiKey = "" // Empty string
5858
};
5959

@@ -86,7 +86,7 @@ public void Dispose_CalledMultipleTimes_OnlyDisposesOnce()
8686
public void Dispose_WithProvidedHttpClient_DisposesClient()
8787
{
8888
// Arrange
89-
var customClient = new HttpClient { BaseAddress = new Uri("http://localhost:8080") };
89+
var customClient = new HttpClient { BaseAddress = new Uri("http://localhost:8086") };
9090
var service = new FlinkJobGatewayService(null, customClient);
9191

9292
// Act

FlinkDotNet/Flink.JobBuilder.Tests/FlinkJobGatewayServiceBranchImprovementTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void Constructor_WithNullConfigurationAndHttpClient_UsesDefaults()
2020
{
2121
// Target: Line 42 (null configuration), Line 43 (null httpClient)
2222
// Set environment variable to provide BaseUrl for default configuration
23-
Environment.SetEnvironmentVariable("FLINK_JOB_GATEWAY_URL", "http://localhost:8080");
23+
Environment.SetEnvironmentVariable("FLINK_JOB_GATEWAY_URL", "http://localhost:8086");
2424

2525
try
2626
{
@@ -37,8 +37,8 @@ public void Constructor_WithNullConfigurationAndHttpClient_UsesDefaults()
3737
public void Constructor_WithValidHttpClient_UsesProvidedClient()
3838
{
3939
// Target: Line 43 (non-null httpClient branch)
40-
var httpClient = new HttpClient { BaseAddress = new Uri("http://test:8080") };
41-
var config = new FlinkJobGatewayConfiguration { BaseUrl = "http://localhost:8080" };
40+
var httpClient = new HttpClient { BaseAddress = new Uri("http://test:8086") };
41+
var config = new FlinkJobGatewayConfiguration { BaseUrl = "http://localhost:8086" };
4242

4343
using var service = new FlinkJobGatewayService(config, httpClient, null);
4444

@@ -51,7 +51,7 @@ public void CreateDefaultHttpClient_WithApiKey_AddsHeader()
5151
// Target: Line 64 (non-empty API key branch - TRUE path)
5252
var config = new FlinkJobGatewayConfiguration
5353
{
54-
BaseUrl = "http://localhost:8080",
54+
BaseUrl = "http://localhost:8086",
5555
ApiKey = "test-api-key-123"
5656
};
5757

@@ -66,7 +66,7 @@ public void CreateDefaultHttpClient_WithoutApiKey_SkipsHeader()
6666
// Target: Line 64 (empty API key branch - FALSE path)
6767
var config = new FlinkJobGatewayConfiguration
6868
{
69-
BaseUrl = "http://localhost:8080",
69+
BaseUrl = "http://localhost:8086",
7070
ApiKey = null
7171
};
7272

@@ -81,7 +81,7 @@ public async Task SubmitJobAsync_WithValidJobDefinition_PassesValidation()
8181
// Target: Line 98 (validation.IsValid == true), Line 104 branch
8282
var config = new FlinkJobGatewayConfiguration
8383
{
84-
BaseUrl = "http://localhost:8080"
84+
BaseUrl = "http://localhost:8086"
8585
};
8686

8787
var jobDef = CreateValidJobDefinition();
@@ -106,7 +106,7 @@ public async Task SubmitJobAsync_WithValidJobDefinition_PassesValidation()
106106
public void Dispose_MultipleTimes_HandlesGracefully()
107107
{
108108
// Target: Line 461, 466, 468 (Dispose branches)
109-
var config = new FlinkJobGatewayConfiguration { BaseUrl = "http://localhost:8080" };
109+
var config = new FlinkJobGatewayConfiguration { BaseUrl = "http://localhost:8086" };
110110
var service = new FlinkJobGatewayService(config, null, null);
111111

112112
service.Dispose(); // First dispose
@@ -119,7 +119,7 @@ public void Dispose_MultipleTimes_HandlesGracefully()
119119
public void Service_WithLogger_UsesProvidedLogger()
120120
{
121121
// Target: Constructor with logger, Line 157 (logger != null)
122-
var config = new FlinkJobGatewayConfiguration { BaseUrl = "http://localhost:8080" };
122+
var config = new FlinkJobGatewayConfiguration { BaseUrl = "http://localhost:8086" };
123123
var mockLogger = new Microsoft.Extensions.Logging.Abstractions.NullLogger<FlinkJobGatewayService>();
124124

125125
using var service = new FlinkJobGatewayService(config, null, mockLogger);

FlinkDotNet/Flink.JobBuilder.Tests/ServiceCollectionExtensionsBranchCoverageTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void AddFlinkJobGatewayConfiguration_WithBaseUrlInConfig_UsesConfigValue(
2525
var configBuilder = new ConfigurationBuilder();
2626
_ = configBuilder.AddInMemoryCollection(new Dictionary<string, string?>
2727
{
28-
{ "FlinkJobGateway:BaseUrl", "http://config-url:8080/" },
28+
{ "FlinkJobGateway:BaseUrl", "http://config-url:8086/" },
2929
{ "FlinkJobGateway:HttpTimeout", "00:05:00" },
3030
{ "FlinkJobGateway:MaxRetries", "3" },
3131
{ "FlinkJobGateway:RetryDelay", "00:00:01" }
@@ -38,7 +38,7 @@ public void AddFlinkJobGatewayConfiguration_WithBaseUrlInConfig_UsesConfigValue(
3838
var options = provider.GetRequiredService<IOptions<FlinkJobGatewayConfiguration>>().Value;
3939

4040
// Assert
41-
Assert.That(options.BaseUrl, Is.EqualTo("http://config-url:8080/"));
41+
Assert.That(options.BaseUrl, Is.EqualTo("http://config-url:8086/"));
4242
Assert.That(options.MaxRetries, Is.EqualTo(3));
4343
}
4444

@@ -160,7 +160,7 @@ public void AddFlinkJobGateway_RegistersConfiguration()
160160
var configBuilder = new ConfigurationBuilder();
161161
_ = configBuilder.AddInMemoryCollection(new Dictionary<string, string>
162162
{
163-
{ "FlinkJobGateway:BaseUrl", "http://test:8080/" }
163+
{ "FlinkJobGateway:BaseUrl", "http://test:8086/" }
164164
}!);
165165
var configuration = configBuilder.Build();
166166

@@ -171,7 +171,7 @@ public void AddFlinkJobGateway_RegistersConfiguration()
171171
// Assert
172172
var options = provider.GetService<IOptions<FlinkJobGatewayConfiguration>>();
173173
Assert.That(options, Is.Not.Null);
174-
Assert.That(options!.Value.BaseUrl, Is.EqualTo("http://test:8080/"));
174+
Assert.That(options!.Value.BaseUrl, Is.EqualTo("http://test:8086/"));
175175
}
176176

177177
[Test]
@@ -183,7 +183,7 @@ public void AddFlinkJobGateway_RegistersService()
183183
var configBuilder = new ConfigurationBuilder();
184184
_ = configBuilder.AddInMemoryCollection(new Dictionary<string, string>
185185
{
186-
{ "FlinkJobGateway:BaseUrl", "http://test:8080/" }
186+
{ "FlinkJobGateway:BaseUrl", "http://test:8086/" }
187187
}!);
188188
var configuration = configBuilder.Build();
189189

@@ -220,7 +220,7 @@ public void AddFlinkJobGateway_RegistersServiceAsTransient()
220220
var configBuilder = new ConfigurationBuilder();
221221
_ = configBuilder.AddInMemoryCollection(new Dictionary<string, string>
222222
{
223-
{ "FlinkJobGateway:BaseUrl", "http://test:8080/" }
223+
{ "FlinkJobGateway:BaseUrl", "http://test:8086/" }
224224
}!);
225225
var configuration = configBuilder.Build();
226226

FlinkDotNet/Flink.JobBuilder.Tests/Tests/ConfigurationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class ConfigurationTests
99
public void FlinkJobGatewayConfiguration_DefaultConstructor_CreatesInstance()
1010
{
1111
// Set environment variable for test
12-
Environment.SetEnvironmentVariable("FLINK_JOB_GATEWAY_URL", "http://test-gateway:8080");
12+
Environment.SetEnvironmentVariable("FLINK_JOB_GATEWAY_URL", "http://test-gateway:8086");
1313
try
1414
{
1515
var config = new FlinkJobGatewayConfiguration();

FlinkDotNet/Flink.JobBuilder.Tests/Tests/FlinkJobGatewayServiceBranchCoverageTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class FlinkJobGatewayServiceBranchCoverageTests
2020
public void SetUp()
2121
{
2222
// Set environment variable required by FlinkJobGatewayConfiguration
23-
Environment.SetEnvironmentVariable("FLINK_JOB_GATEWAY_URL", "http://localhost:8080");
23+
Environment.SetEnvironmentVariable("FLINK_JOB_GATEWAY_URL", "http://localhost:8086");
2424

2525
// Set retry delay to 1ms for fast tests
2626
FlinkJobGatewayService.RetryDelay = TimeSpan.FromMilliseconds(1);
@@ -198,7 +198,7 @@ public void Constructor_WithNullHttpClient_CreatesDefaultClient()
198198
// Arrange
199199
var config = new FlinkJobGatewayConfiguration
200200
{
201-
BaseUrl = "http://test-gateway:8080",
201+
BaseUrl = "http://test-gateway:8086",
202202
HttpTimeout = TimeSpan.FromSeconds(45)
203203
};
204204

@@ -225,7 +225,7 @@ public void Constructor_WithEmptyApiKey_DoesNotAddApiKeyHeader()
225225
// Arrange
226226
var config = new FlinkJobGatewayConfiguration
227227
{
228-
BaseUrl = "http://localhost:8080",
228+
BaseUrl = "http://localhost:8086",
229229
ApiKey = "" // Empty API key
230230
};
231231

@@ -242,7 +242,7 @@ public void Constructor_WithNullApiKey_DoesNotAddApiKeyHeader()
242242
// Arrange
243243
var config = new FlinkJobGatewayConfiguration
244244
{
245-
BaseUrl = "http://localhost:8080",
245+
BaseUrl = "http://localhost:8086",
246246
ApiKey = null // Null API key
247247
};
248248

FlinkDotNet/Flink.JobBuilder.Tests/Tests/FlinkJobGatewayServiceCompleteCoverageTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ public class FlinkJobGatewayServiceCompleteCoverageTests
2424
[SetUp]
2525
public void SetUp()
2626
{
27-
Environment.SetEnvironmentVariable("FLINK_JOB_GATEWAY_URL", "http://localhost:8080");
27+
Environment.SetEnvironmentVariable("FLINK_JOB_GATEWAY_URL", "http://localhost:8086");
2828

2929
// Set retry delay to 1ms for fast tests
3030
FlinkJobGatewayService.RetryDelay = TimeSpan.FromMilliseconds(1);
3131

3232
_mockHttpMessageHandler = new Mock<HttpMessageHandler>();
3333
_httpClient = new HttpClient(_mockHttpMessageHandler.Object)
3434
{
35-
BaseAddress = new Uri("http://localhost:8080")
35+
BaseAddress = new Uri("http://localhost:8086")
3636
};
3737

3838
_mockLogger = new Mock<ILogger>();

0 commit comments

Comments
 (0)