Solace Pubsub+¶
Not available until the next release main
Introduction¶
The Testcontainers module for Solace Pubsub+.
Adding this module to your project dependencies¶
Please run the following command to add the Solace Pubsub+ module to your Go dependencies:
go get github.com/testcontainers/testcontainers-go/modules/solace
Usage example¶
ctx := context.Background()
ctr, err := sc.Run(ctx, "solace/solace-pubsub-standard:latest",
sc.WithCredentials("admin", "admin"),
sc.WithServices(sc.ServiceAMQP, sc.ServiceManagement),
testcontainers.WithEnv(map[string]string{
"username_admin_globalaccesslevel": "admin",
"username_admin_password": "admin",
}),
sc.WithShmSize(1<<30),
)
defer func() {
if err := testcontainers.TerminateContainer(ctr); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
fmt.Println(err)
Module Reference¶
Run function¶
- Not available until the next release main
The Solace Pubsub+ module exposes one entrypoint function to create the Solace Pubsub+ container, and this function receives three parameters:
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*SolaceContainer, error)
context.Context
, the Go context.string
, the Docker image to use.testcontainers.ContainerCustomizer
, a variadic argument for passing options.
Image¶
Use the second argument in the Run
function to set a valid Docker image.
In example: Run(context.Background(), "solace/solace-pubsub-standard:latest")
.
Container Options¶
When starting the Solace Pubsub+ container, you can pass options in a variadic way to configure it.
WithCredentials¶
- Not available until the next release main
WithCredentials(username, password string)
: sets the client credentials for authentication
WithVpn¶
- Not available until the next release main
WithVpn(vpn string)
: sets the VPN name (defaults to "default")
WithQueue¶
- Not available until the next release main
WithQueue(queueName, topic string)
: subscribes a given topic to a queue (for SMF/AMQP testing)
WithShmSize¶
- Not available until the next release main
WithShmSize(size int64)
: sets the shared memory size (defaults to 1 GiB)
WithServices¶
- Not available until the next release main
The WithServices
option is the recommended way to configure which Solace services should be exposed and made available in your container. This option automatically handles port exposure and sets up wait strategies for each specified service.
Available services:
ServiceAMQP
- AMQP service (port 5672)ServiceMQTT
- MQTT service (port 1883)ServiceREST
- REST service (port 9000)ServiceManagement
- Management service (port 8080)ServiceSMF
- SMF service (port 55555)ServiceSMFSSL
- SMF SSL service (port 55443)
By default, when no WithServices
option is specified, the container will expose AMQP, SMF, REST, and MQTT services.
The following options are exposed by the testcontainers
package.
Basic Options¶
WithExposedPorts
Since v0.37.0WithEnv
Since v0.29.0WithWaitStrategy
Since v0.20.0WithAdditionalWaitStrategy
Since v0.38.0WithWaitStrategyAndDeadline
Since v0.20.0WithAdditionalWaitStrategyAndDeadline
Since v0.38.0WithEntrypoint
Since v0.37.0WithEntrypointArgs
Since v0.37.0WithCmd
Since v0.37.0WithCmdArgs
Since v0.37.0WithLabels
Since v0.37.0
Lifecycle Options¶
WithLifecycleHooks
Since v0.38.0WithAdditionalLifecycleHooks
Since v0.38.0WithStartupCommand
Since v0.25.0WithAfterReadyCommand
Since v0.28.0
Files & Mounts Options¶
WithFiles
Since v0.37.0WithMounts
Since v0.37.0WithTmpfs
Since v0.37.0WithImageMount
Since v0.37.0
Build Options¶
WithDockerfile
Since v0.37.0
Logging Options¶
WithLogConsumers
Since v0.28.0WithLogConsumerConfig
Since v0.38.0WithLogger
Since v0.29.0
Image Options¶
WithAlwaysPull
Since v0.38.0WithImageSubstitutors
Since v0.26.0WithImagePlatform
Since v0.38.0
Networking Options¶
WithNetwork
Since v0.27.0WithNetworkByName
Since v0.38.0WithBridgeNetwork
Since v0.38.0WithNewNetwork
Since v0.27.0
Advanced Options¶
WithHostPortAccess
Since v0.31.0WithConfigModifier
Since v0.20.0WithHostConfigModifier
Since v0.20.0WithEndpointSettingsModifier
Since v0.20.0CustomizeRequest
Since v0.20.0WithName
Since v0.38.0WithNoStart
Since v0.38.0WithProvider
Not available until the next release main
Experimental Options¶
WithReuseByName
Since v0.37.0
Container Methods¶
The Solace Pubsub+ container exposes the following methods:
BrokerURLFor¶
- Not available until the next release main
BrokerURLFor(ctx context.Context, service Service) (string, error)
- returns the connection URL for a given Solace service.
This method allows you to retrieve the connection URL for specific Solace services. The available services are:
ServiceAMQP
- AMQP service (port 5672, protocol: amqp)ServiceMQTT
- MQTT service (port 1883, protocol: tcp)ServiceREST
- REST service (port 9000, protocol: http)ServiceManagement
- Management service (port 8080, protocol: http)ServiceSMF
- SMF service (port 55555, protocol: tcp)ServiceSMFSSL
- SMF SSL service (port 55443, protocol: tcps)
// Get the AMQP connection URL
amqpURL, err := container.BrokerURLFor(ctx, solace.ServiceAMQP)
if err != nil {
log.Fatal(err)
}
// amqpURL will be something like: amqp://localhost:32768
// Get the management URL
mgmtURL, err := container.BrokerURLFor(ctx, solace.ServiceManagement)
if err != nil {
log.Fatal(err)
}
// mgmtURL will be something like: http://localhost:32769
Username¶
- Not available until the next release main
Username() string
- returns the configured username for authentication
Password¶
- Not available until the next release main
Password() string
- returns the configured password for authentication
VPN¶
- Not available until the next release main
VPN() string
- returns the configured VPN name