Skip to content

Commit

Permalink
[DevOps] Ensure build and integration tests can run in parallel #319
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Maruszak <[email protected]>
  • Loading branch information
zarusz committed Oct 6, 2024
1 parent 4abd06a commit 2239152
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 32 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ env:
jobs:
build:
runs-on: ubuntu-latest
concurrency: int-tests

# allow to run concurrently within separate branches
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
# - name: Dump GitHub context
# env:
Expand Down Expand Up @@ -120,10 +122,10 @@ jobs:
azure_eventhub_connectionstring: ${{ secrets.azure_eventhub_connectionstring }}
azure_storagecontainer_connectionstring: ${{ secrets.azure_storagecontainer_connectionstring }}

#kafka_brokers: ${{ secrets.kafka_brokers }}
#kafka_username: ${{ secrets.kafka_username }}
#kafka_password: ${{ secrets.kafka_password }}
#kafka_secure: ${{ secrets.kafka_secure }}
_kafka_brokers: ${{ secrets.kafka_brokers }}
_kafka_username: ${{ secrets.kafka_username }}
_kafka_password: ${{ secrets.kafka_password }}
_kafka_secure: ${{ secrets.kafka_secure }}

_mqtt_server: ${{ secrets.mqtt_server }}
_mqtt_port: ${{ secrets.mqtt_port }}
Expand All @@ -135,7 +137,7 @@ jobs:

_redis_connectionstring: ${{ secrets.redis_connectionstring }}

sqlserver_connectionstring: ${{ secrets.sqlserver_connectionstring }}
_sqlserver_connectionstring: ${{ secrets.sqlserver_connectionstring }}

# Connects to the local Test Containers
kafka_brokers: localhost:9092
Expand All @@ -153,7 +155,7 @@ jobs:

redis_connectionstring: localhost:6379

#sqlserver_connectionstring: "Server=localhost;Initial Catalog=SlimMessageBus_Outbox;User ID=sa;Password=SuperSecretP@55word;TrustServerCertificate=true;MultipleActiveResultSets=true;"
sqlserver_connectionstring: "Server=localhost;Initial Catalog=SlimMessageBus_Outbox;User ID=sa;Password=SuperSecretP@55word;TrustServerCertificate=true;MultipleActiveResultSets=true;"

nats_endpoint: "nats://localhost:4222"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ namespace SlimMessageBus.Host.AzureEventHub.Test;
using SlimMessageBus.Host.Serialization.Json;
using SlimMessageBus.Host.Test.Common.IntegrationTest;

/// <summary>
/// Runs the integration tests for the <see cref="EventHubMessageBus"/>.
/// Notice that this test needs to run against a real Azure Event Hub infrastructure.
/// Inside the GitHub Actions pipeline, the Azure Event Hub infrastructure is shared, and so if tests are run in parallel they might affect each other (flaky tests).
/// </summary>
[Trait("Category", "Integration")]
public class EventHubMessageBusIt : BaseIntegrationTest<EventHubMessageBusIt>
public class EventHubMessageBusIt(ITestOutputHelper testOutputHelper) : BaseIntegrationTest<EventHubMessageBusIt>(testOutputHelper)
{
private const int NumberOfMessages = 77;

public EventHubMessageBusIt(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}

protected override void SetupServices(ServiceCollection services, IConfigurationRoot configuration)
{
services.AddSlimMessageBus(mbb =>
Expand Down
13 changes: 0 additions & 13 deletions src/Tests/SlimMessageBus.Host.AzureEventHub.Test/SampleMessages.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ namespace SlimMessageBus.Host.AzureServiceBus.Test;
using SlimMessageBus.Host.Serialization.Json;
using SlimMessageBus.Host.Test.Common.IntegrationTest;

/// <summary>
/// Runs the integration tests for the <see cref="ServiceBusMessageBus"/>.
/// Notice that this test needs to run against a real Azure Service Bus infrastructure.
/// Inside the GitHub Actions pipeline, the Azure Service Bus infrastructure is shared, and this tests attempts to isolate itself by using unique queue/topic names.
/// </summary>
[Trait("Category", "Integration")]
public class ServiceBusMessageBusIt(ITestOutputHelper testOutputHelper) : BaseIntegrationTest<ServiceBusMessageBusIt>(testOutputHelper)
{
Expand All @@ -29,6 +34,7 @@ protected override void SetupServices(ServiceCollection services, IConfiguration
cfg.ConnectionString = Secrets.Service.PopulateSecrets(configuration["Azure:ServiceBus"]);
cfg.PrefetchCount = 100;
cfg.MaxConcurrentSessions = 20;
// auto-delete queues and topics after 5 minutes, we create temp topics and queues
cfg.TopologyProvisioning.CreateQueueOptions = o => o.AutoDeleteOnIdle = TimeSpan.FromMinutes(5);
cfg.TopologyProvisioning.CreateTopicOptions = o => o.AutoDeleteOnIdle = TimeSpan.FromMinutes(5);
});
Expand Down Expand Up @@ -323,14 +329,10 @@ public async Task FIFOUsingSessionsOnTopic()
}

private static string QueueName([CallerMemberName] string testName = null)
{
return $"smb-tests/{nameof(ServiceBusMessageBusIt)}/{testName}/{DateTimeOffset.UtcNow.Ticks}";
}
=> $"smb-tests/{nameof(ServiceBusMessageBusIt)}/{testName}/{DateTimeOffset.UtcNow.Ticks}";

private static string TopicName([CallerMemberName] string testName = null)
{
return QueueName(testName);
}
=> QueueName(testName);
}

public record TestEvent(PingMessage Message, string MessageId, string SessionId);
Expand Down

0 comments on commit 2239152

Please sign in to comment.