Skip to content
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
16 changes: 16 additions & 0 deletions src/Http/Wolverine.Http.Tests/broker_role_tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Shouldly;
using Wolverine.Configuration;
using Wolverine.Http.Transport;
using Xunit;

namespace Wolverine.Http.Tests;

public class broker_role_tests
{
[Fact]
public void http_endpoint_broker_role_is_route()
{
new HttpEndpoint(new Uri("http://localhost:5000/orders"), EndpointRole.Application)
.BrokerRole.ShouldBe("route");
}
}
1 change: 1 addition & 0 deletions src/Http/Wolverine.Http/Transport/HttpEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class HttpEndpoint : Endpoint
{
public HttpEndpoint(Uri uri, EndpointRole role) : base(uri, role)
{
BrokerRole = "route";
}

internal bool SupportsNativeScheduledSend { get; set; }
Expand Down
14 changes: 14 additions & 0 deletions src/Persistence/MySql/MySqlTests/Transport/broker_role_tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Shouldly;
using Wolverine.MySql.Transport;
using Xunit;

namespace MySqlTests.Transport;

public class broker_role_tests
{
[Fact]
public void mysql_queue_broker_role_is_queue()
{
new MySqlQueue("q", new MySqlTransport()).BrokerRole.ShouldBe("queue");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public MySqlQueue(string name, MySqlTransport parent, EndpointRole role = Endpoi
Mode = EndpointMode.Durable;
Name = name;
EndpointName = name;
BrokerRole = "queue";

_queueTable = new Lazy<QueueTable>(() => new QueueTable(Parent, queueTableName));
_scheduledMessageTable =
Expand Down
14 changes: 14 additions & 0 deletions src/Persistence/Oracle/OracleTests/Transport/broker_role_tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Shouldly;
using Wolverine.Oracle.Transport;
using Xunit;

namespace OracleTests.Transport;

public class broker_role_tests
{
[Fact]
public void oracle_queue_broker_role_is_queue()
{
new OracleQueue("q", new OracleTransport()).BrokerRole.ShouldBe("queue");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public OracleQueue(string name, OracleTransport parent, EndpointRole role = Endp
Mode = EndpointMode.Durable;
Name = name;
EndpointName = name;
BrokerRole = "queue";

_queueTable = new Lazy<QueueTable>(() => new QueueTable(Parent, queueTableName));
_scheduledMessageTable =
Expand Down
14 changes: 14 additions & 0 deletions src/Persistence/PostgresqlTests/Transport/broker_role_tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Shouldly;
using Wolverine.Postgresql.Transport;
using Xunit;

namespace PostgresqlTests.Transport;

public class broker_role_tests
{
[Fact]
public void postgresql_queue_broker_role_is_queue()
{
new PostgresqlQueue("q", new PostgresqlTransport()).BrokerRole.ShouldBe("queue");
}
}
21 changes: 21 additions & 0 deletions src/Persistence/SqlServerTests/Transport/broker_role_tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using IntegrationTests;
using Shouldly;
using Wolverine.RDBMS;
using Wolverine.SqlServer.Transport;
using Xunit;

namespace SqlServerTests.Transport;

public class broker_role_tests
{
[Fact]
public void sql_server_queue_broker_role_is_queue()
{
var transport = new SqlServerTransport(new DatabaseSettings
{
ConnectionString = Servers.SqlServerConnectionString,
SchemaName = "transport"
});
new SqlServerQueue("q", transport).BrokerRole.ShouldBe("queue");
}
}
14 changes: 14 additions & 0 deletions src/Persistence/SqliteTests/Transport/broker_role_tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Shouldly;
using Wolverine.Sqlite.Transport;
using Xunit;

namespace SqliteTests.Transport;

public class broker_role_tests
{
[Fact]
public void sqlite_queue_broker_role_is_queue()
{
new SqliteQueue("q", new SqliteTransport()).BrokerRole.ShouldBe("queue");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ public PostgresqlQueue(string name, PostgresqlTransport parent, EndpointRole rol
Mode = EndpointMode.Durable;
Name = name;
EndpointName = name;
BrokerRole = "queue";

// Gotta be lazy so the schema names get set
// Gotta be lazy so the schema names get set
_queueTable = new Lazy<QueueTable>(() => new QueueTable(Parent, queueTableName));
_scheduledMessageTable =
new Lazy<ScheduledMessageTable>(() => new ScheduledMessageTable(Parent, scheduledTableName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public TenantedPostgresqlQueue(PostgresqlQueue parent, NpgsqlDataSource dataSour
_parent = parent;
_dataSource = dataSource;
_databaseName = databaseName;
BrokerRole = "queue";
}

public override async ValueTask<IListener> BuildListenerAsync(IWolverineRuntime runtime, IReceiver receiver)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public DatabaseControlEndpoint(DatabaseControlTransport parent, Guid nodeId) : b
_parent = parent;
Mode = EndpointMode.BufferedInMemory;
MaxDegreeOfParallelism = 1;
BrokerRole = "queue";

// No otel for this one!
TelemetryEnabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public ExternalMessageTable(DbObjectName tableName) : base(new Uri($"{ExternalDb
IsListener = true;
TableName = tableName;
Mode = EndpointMode.Durable;
BrokerRole = "table";
}

protected override bool supportsMode(EndpointMode mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public SqlServerQueue(string name, SqlServerTransport parent, EndpointRole role
Mode = EndpointMode.Durable;
Name = name;
EndpointName = name;
BrokerRole = "queue";

// Gotta be lazy so the schema names get set
_queueTable = new Lazy<QueueTable>(() => new QueueTable(Parent, _queueTableName));
Expand Down
1 change: 1 addition & 0 deletions src/Persistence/Wolverine.Sqlite/Transport/SqliteQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public SqliteQueue(string name, SqliteTransport parent, EndpointRole role = Endp
Mode = EndpointMode.Durable;
Name = name;
EndpointName = name;
BrokerRole = "queue";

_queueTable = new Lazy<QueueTable>(() => new QueueTable(Parent, queueTableName));
_scheduledMessageTable =
Expand Down
75 changes: 75 additions & 0 deletions src/Testing/CoreTests/Configuration/broker_role_tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using Shouldly;
using Wolverine.Configuration;
using Wolverine.Configuration.Capabilities;
using Wolverine.Transports.Local;
using Wolverine.Transports.SharedMemory;
using Wolverine.Transports.Stub;
using Wolverine.Transports.Tcp;
using Xunit;

namespace CoreTests.Configuration;

/// <summary>
/// Locks down GH-2601: every endpoint kind exposes a short, non-empty
/// <see cref="Endpoint.BrokerRole"/> string identifying the underlying
/// broker object kind ("queue", "exchange", "topic", "subscription",
/// "stream", etc.). CritterWatch and other diagnostic UIs read this.
/// </summary>
public class broker_role_tests
{
[Fact]
public void base_default_when_subclass_does_not_set_broker_role()
{
// The base Endpoint default — should be a sentinel value, not empty,
// so a custom subclass that forgets to set BrokerRole still produces
// something a UI can render.
new TestEndpoint(EndpointRole.Application).BrokerRole.ShouldBe("endpoint");
}

[Theory]
[MemberData(nameof(CoreEndpoints))]
public void core_endpoint_has_expected_broker_role(Endpoint endpoint, string expectedRole)
{
endpoint.BrokerRole.ShouldBe(expectedRole);
}

[Fact]
public void endpoint_descriptor_lifts_broker_role_and_endpoint_role()
{
// EndpointDescriptor is what CritterWatch reads. Both the existing
// EndpointRole (System / Application) and the new BrokerRole string
// should be first-class properties on the descriptor, populated from
// the underlying Endpoint. See GH-2601.
var queue = new LocalQueue("queue-x");
var descriptor = new EndpointDescriptor(queue);

descriptor.BrokerRole.ShouldBe("queue");
descriptor.EndpointRole.ShouldBe(EndpointRole.Application);
}

[Fact]
public void endpoint_descriptor_endpoint_role_reflects_system_endpoints()
{
var systemSubscription = new SharedMemorySubscription(
new SharedMemoryTopic("topic-y"), "sub-y", EndpointRole.System);
var descriptor = new EndpointDescriptor(systemSubscription);

descriptor.EndpointRole.ShouldBe(EndpointRole.System);
descriptor.BrokerRole.ShouldBe("subscription");
}

public static TheoryData<Endpoint, string> CoreEndpoints()
{
var stubTransport = new StubTransport();
var sharedTopic = new SharedMemoryTopic("topic-x");

return new TheoryData<Endpoint, string>
{
{ new LocalQueue("queue-x"), "queue" },
{ new StubEndpoint("stub-x", stubTransport), "stub" },
{ new TcpEndpoint("localhost", 2222), "socket" },
{ sharedTopic, "topic" },
{ new SharedMemorySubscription(sharedTopic, "sub-x", EndpointRole.Application), "subscription" },
};
}
}
14 changes: 14 additions & 0 deletions src/Transports/AWS/Wolverine.AmazonSns.Tests/broker_role_tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Shouldly;
using Wolverine.AmazonSns.Internal;
using Xunit;

namespace Wolverine.AmazonSns.Tests;

public class broker_role_tests
{
[Fact]
public void sns_topic_broker_role_is_topic()
{
new AmazonSnsTopic("t", new AmazonSnsTransport()).BrokerRole.ShouldBe("topic");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ internal AmazonSnsTopic(string topicName, AmazonSnsTransport parent)
: base(new Uri($"{AmazonSnsTransport.SnsProtocol}://{topicName}"), EndpointRole.Application)
{
Parent = parent;

TopicName = topicName;
EndpointName = topicName;
TopicArn = string.Empty;
BrokerRole = "topic";

Configuration = new CreateTopicRequest(TopicName);

MessageBatchSize = 10;
}

Expand Down
14 changes: 14 additions & 0 deletions src/Transports/AWS/Wolverine.AmazonSqs.Tests/broker_role_tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Shouldly;
using Wolverine.AmazonSqs.Internal;
using Xunit;

namespace Wolverine.AmazonSqs.Tests;

public class broker_role_tests
{
[Fact]
public void sqs_queue_broker_role_is_queue()
{
new AmazonSqsQueue("q", new AmazonSqsTransport()).BrokerRole.ShouldBe("queue");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ internal AmazonSqsQueue(string queueName, AmazonSqsTransport parent) : base(
_parent = parent;
QueueName = queueName;
EndpointName = queueName;
BrokerRole = "queue";

Configuration = new CreateQueueRequest(QueueName);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Shouldly;
using Wolverine.AzureServiceBus.Internal;
using Xunit;

namespace Wolverine.AzureServiceBus.Tests;

// Locks down GH-2601 for the Azure Service Bus endpoints.
public class broker_role_tests
{
[Fact]
public void queue_broker_role_is_queue()
{
var transport = new AzureServiceBusTransport();
new AzureServiceBusQueue(transport, "q").BrokerRole.ShouldBe("queue");
}

[Fact]
public void topic_broker_role_is_topic()
{
var transport = new AzureServiceBusTransport();
new AzureServiceBusTopic(transport, "t").BrokerRole.ShouldBe("topic");
}

[Fact]
public void subscription_broker_role_is_subscription()
{
var transport = new AzureServiceBusTransport();
var topic = new AzureServiceBusTopic(transport, "t");
new AzureServiceBusSubscription(transport, topic, "s").BrokerRole.ShouldBe("subscription");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public AzureServiceBusQueue(AzureServiceBusTransport parent, string queueName,
{
DeadLetteringOnMessageExpiration = false
};
BrokerRole = "queue";
}

[ChildDescription]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public AzureServiceBusSubscription(AzureServiceBusTransport parent, AzureService
// This is the same rule as the one used if you
// use CreateSubscriptionAsync() without specifying a rule
RuleOptions = new CreateRuleOptions();
BrokerRole = "subscription";
}

[ChildDescription]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public AzureServiceBusTopic(AzureServiceBusTransport parent, string topicName) :

TopicName = EndpointName = topicName ?? throw new ArgumentNullException(nameof(topicName));
Options = new CreateTopicOptions(TopicName);
BrokerRole = "topic";
}

public string TopicName { get; }
Expand Down
23 changes: 23 additions & 0 deletions src/Transports/GCP/Wolverine.Pubsub.Tests/broker_role_tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Google.Api.Gax;
using Google.Cloud.PubSub.V1;
using NSubstitute;
using Shouldly;
using Xunit;

namespace Wolverine.Pubsub.Tests;

public class broker_role_tests
{
[Fact]
public void pubsub_endpoint_broker_role_is_pubsub()
{
var transport = new PubsubTransport("wolverine")
{
PublisherApiClient = Substitute.For<PublisherServiceApiClient>(),
SubscriberApiClient = Substitute.For<SubscriberServiceApiClient>(),
EmulatorDetection = EmulatorDetection.EmulatorOnly
};

new PubsubEndpoint("foo", transport).BrokerRole.ShouldBe("pubsub");
}
}
1 change: 1 addition & 0 deletions src/Transports/GCP/Wolverine.Pubsub/PubsubEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public PubsubEndpoint(
: topicName
);
EndpointName = topicName;
BrokerRole = "pubsub";

if (transport.DeadLetter.Enabled)
{
Expand Down
Loading
Loading