-
Notifications
You must be signed in to change notification settings - Fork 16
chore: Azure SB Emulator for testing & local development #434
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
base: lock
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
# DBs | ||
TEST_POSTGRES_URL="localhost:35432" | ||
TEST_CLICKHOUSE_URL="localhost:39000" | ||
# MQs | ||
TEST_RABBITMQ_URL="localhost:35672" | ||
TEST_LOCALSTACK_URL="localhost:34566" | ||
TEST_GCP_URL="localhost:38085" | ||
TEST_RABBITMQ_URL="localhost:35672" | ||
TEST_AZURE_SB_CONNSTRING="Endpoint=sb://localhost;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;" | ||
# Misc | ||
TEST_MOCKSERVER_URL="localhost:35555" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: "outpost-azure" | ||
|
||
services: | ||
azuresb: | ||
image: mcr.microsoft.com/azure-messaging/servicebus-emulator:latest | ||
volumes: | ||
- "./config.json:/ServiceBus_Emulator/ConfigFiles/Config.json" | ||
ports: | ||
- "5672:5672" | ||
- "5300:5300" | ||
environment: | ||
SQL_SERVER: sqledge | ||
MSSQL_SA_PASSWORD: "Password!" | ||
ACCEPT_EULA: "Y" | ||
SQL_WAIT_INTERVAL: "5" | ||
depends_on: | ||
- sqledge | ||
|
||
sqledge: | ||
image: mcr.microsoft.com/azure-sql-edge:latest | ||
environment: | ||
ACCEPT_EULA: "Y" | ||
MSSQL_SA_PASSWORD: "Password!" | ||
|
||
networks: | ||
default: | ||
name: outpost | ||
external: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"UserConfig": { | ||
"Namespaces": [ | ||
{ | ||
"Name": "sbemulatorns", | ||
"Queues": [], | ||
"Topics": [ | ||
// dev | ||
{ | ||
"Name": "outpost-delivery", | ||
"Properties": {}, | ||
"Subscriptions": [ | ||
{ | ||
"Name": "outpost-delivery-sub", | ||
"Properties": { | ||
"MaxDeliveryCount": 6 | ||
}, | ||
"Rules": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"Name": "outpost-log", | ||
"Properties": {}, | ||
"Subscriptions": [ | ||
{ | ||
"Name": "outpost-log-sub", | ||
"Properties": { | ||
"MaxDeliveryCount": 6 | ||
}, | ||
"Rules": [] | ||
} | ||
] | ||
}, | ||
|
||
// tests | ||
{ | ||
"Name": "TestIntegrationMQ_AzureServiceBus-topic", | ||
"Properties": {}, | ||
"Subscriptions": [ | ||
{ | ||
"Name": "TestIntegrationMQ_AzureServiceBus-subscription", | ||
"Properties": {}, | ||
"Rules": [] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"Logging": { | ||
"Type": "Console" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,9 @@ import ( | |
) | ||
|
||
type AzureServiceBusConfig struct { | ||
// Using AzureSB with ConnectionString will skip infra management | ||
ConnectionString string `yaml:"connection_string" env:"AZURE_SERVICEBUS_CONNECTION_STRING" desc:"Azure Service Bus connection string" required:"N"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to call attention to this config a bit. This should be "dev-only" config as it's not recommended in production. Outpost is responsible for managing its own mq infra. Using Azure connection string will bypass this mechanism. This could work for now if the operator is comfortable managing their own resources, and most importantly follow along Outpost development to make changes if necessary. Ideally, I'd like to hide this from config away from users if possible. I haven't explored the config docgen much, do you have a suggestion here? @leggetter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alexluong - we could add another attribute: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that should work! |
||
|
||
TenantID string `yaml:"tenant_id" env:"AZURE_SERVICEBUS_TENANT_ID" desc:"Azure Active Directory tenant ID" required:"Y"` | ||
ClientID string `yaml:"client_id" env:"AZURE_SERVICEBUS_CLIENT_ID" desc:"Service principal client ID" required:"Y"` | ||
ClientSecret string `yaml:"client_secret" env:"AZURE_SERVICEBUS_CLIENT_SECRET" desc:"Service principal client secret" required:"Y"` | ||
|
@@ -16,17 +19,17 @@ type AzureServiceBusConfig struct { | |
Namespace string `yaml:"namespace" env:"AZURE_SERVICEBUS_NAMESPACE" desc:"Azure Service Bus namespace" required:"Y"` | ||
|
||
DeliveryTopic string `yaml:"delivery_topic" env:"AZURE_SERVICEBUS_DELIVERY_TOPIC" desc:"Topic name for delivery queue" required:"N" default:"outpost-delivery"` | ||
DeliverySubscription string `yaml:"delivery_subscription" env:"AZURE_SERVICEBUS_DELIVERY_SUBSCRIPTION" desc:"Subscription name for delivery queue" required:"N" default:"outpost-delivery-subscription"` | ||
DeliverySubscription string `yaml:"delivery_subscription" env:"AZURE_SERVICEBUS_DELIVERY_SUBSCRIPTION" desc:"Subscription name for delivery queue" required:"N" default:"outpost-delivery-sub"` | ||
LogTopic string `yaml:"log_topic" env:"AZURE_SERVICEBUS_LOG_TOPIC" desc:"Topic name for log queue" required:"N" default:"outpost-log"` | ||
LogSubscription string `yaml:"log_subscription" env:"AZURE_SERVICEBUS_LOG_SUBSCRIPTION" desc:"Subscription name for log queue" required:"N" default:"outpost-log-subscription"` | ||
LogSubscription string `yaml:"log_subscription" env:"AZURE_SERVICEBUS_LOG_SUBSCRIPTION" desc:"Subscription name for log queue" required:"N" default:"outpost-log-sub"` | ||
|
||
// connectionStringOnce sync.Once | ||
// connectionString string | ||
// connectionStringError error | ||
} | ||
|
||
func (c *AzureServiceBusConfig) IsConfigured() bool { | ||
return c.TenantID != "" && c.ClientID != "" && c.ClientSecret != "" && c.SubscriptionID != "" && c.ResourceGroup != "" && c.Namespace != "" | ||
return c.ConnectionString != "" || (c.TenantID != "" && c.ClientID != "" && c.ClientSecret != "" && c.SubscriptionID != "" && c.ResourceGroup != "" && c.Namespace != "") | ||
} | ||
|
||
func (c *AzureServiceBusConfig) GetProviderType() string { | ||
|
@@ -65,14 +68,15 @@ func (c *AzureServiceBusConfig) ToInfraConfig(queueType string) *mqinfra.MQInfra | |
|
||
return &mqinfra.MQInfraConfig{ | ||
AzureServiceBus: &mqinfra.AzureServiceBusInfraConfig{ | ||
TenantID: c.TenantID, | ||
ClientID: c.ClientID, | ||
ClientSecret: c.ClientSecret, | ||
SubscriptionID: c.SubscriptionID, | ||
ResourceGroup: c.ResourceGroup, | ||
Namespace: c.Namespace, | ||
Topic: topic, | ||
Subscription: subscription, | ||
ConnectionString: c.ConnectionString, | ||
TenantID: c.TenantID, | ||
ClientID: c.ClientID, | ||
ClientSecret: c.ClientSecret, | ||
SubscriptionID: c.SubscriptionID, | ||
ResourceGroup: c.ResourceGroup, | ||
Namespace: c.Namespace, | ||
Topic: topic, | ||
Subscription: subscription, | ||
}, | ||
} | ||
} | ||
|
@@ -85,6 +89,16 @@ func (c *AzureServiceBusConfig) ToQueueConfig(ctx context.Context, queueType str | |
topic := c.getTopicByQueueType(queueType) | ||
subscription := c.getSubscriptionByQueueType(queueType) | ||
|
||
if c.ConnectionString != "" { | ||
return &mqs.QueueConfig{ | ||
AzureServiceBus: &mqs.AzureServiceBusConfig{ | ||
ConnectionString: c.ConnectionString, | ||
Topic: topic, | ||
Subscription: subscription, | ||
}, | ||
}, nil | ||
} | ||
|
||
return &mqs.QueueConfig{ | ||
AzureServiceBus: &mqs.AzureServiceBusConfig{ | ||
Topic: topic, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another quirk. Basically AzureSB emulator requires port 5672 to work, so it's stealing that port from our RabbitMQ deps