Skip to content

Commit

Permalink
EBP-94: updated the endpoint provisioner with sempv2 disconnected mes…
Browse files Browse the repository at this point in the history
…saging service test case fix
  • Loading branch information
oodigie committed Dec 18, 2024
1 parent 4fd85cc commit 571bacb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/endpoint_provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"solace.dev/go/messaging"
"solace.dev/go/messaging/pkg/solace"
"solace.dev/go/messaging/pkg/solace/config"
"solace.dev/go/messaging/pkg/solace/subcode"
"solace.dev/go/messaging/test/helpers"
"solace.dev/go/messaging/test/testcontext"

Expand Down Expand Up @@ -118,15 +119,23 @@ var _ = Describe("EndpointProvisioner", func() {
})

Context("with a connected messaging service that will be disconnected", func() {
var eventChannel chan solace.ServiceEvent
var provisioner solace.EndpointProvisioner
var listenerID uint64

BeforeEach(func() {
helpers.ConnectMessagingService(messagingService)
eventChannel = make(chan solace.ServiceEvent, 1)
listenerID = messagingService.AddServiceInterruptionListener(func(event solace.ServiceEvent) {
eventChannel <- event
})

provisioner = messagingService.EndpointProvisioner()
Expect(provisioner).ToNot(BeNil())
})

AfterEach(func() {
messagingService.RemoveServiceInterruptionListener(listenerID)
if messagingService.IsConnected() {
messagingService.Disconnect()
}
Expand All @@ -138,6 +147,11 @@ var _ = Describe("EndpointProvisioner", func() {
},
"SEMPv2 disconnect": func(messagingService solace.MessagingService) {
helpers.ForceDisconnectViaSEMPv2(messagingService)
var serviceEvent solace.ServiceEvent
Eventually(eventChannel, 20*time.Second).Should(Receive(&serviceEvent), "Expected to receive service down event")
Expect(time.Since(serviceEvent.GetTimestamp())).To(BeNumerically("<=", 1*time.Second), "Expected timestamp of service event to be recent")
helpers.ValidateNativeError(serviceEvent.GetCause(), subcode.CommunicationError)
Consistently(eventChannel).ShouldNot(Receive()) // should not have another event since messaging service is down
},
}

Expand All @@ -146,7 +160,6 @@ var _ = Describe("EndpointProvisioner", func() {

It("fails to provision when given valid queue properties with "+testCase, func() {
disconnectFunction(messagingService)
Eventually(messagingService.IsConnected(), 10*time.Second).Should(BeFalse())

outcome := provisioner.FromConfigurationProvider(config.EndpointPropertyMap{
config.EndpointPropertyDurable: true,
Expand All @@ -159,7 +172,7 @@ var _ = Describe("EndpointProvisioner", func() {

It("fails to deprovision with "+testCase, func() {
disconnectFunction(messagingService)
Eventually(messagingService.IsConnected(), 10*time.Second).Should(BeFalse())
Eventually(messagingService.IsConnected(), 30*time.Second).Should(BeFalse())

err := provisioner.Deprovision(provisionQueueName, true)
Expect(err).To(HaveOccurred())
Expand Down
10 changes: 10 additions & 0 deletions test/helpers/messaging_service_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ func ForceDisconnectViaSEMPv2(messagingService solace.MessagingService) {
ExpectWithOffset(1, err).ToNot(HaveOccurred())
}

func CheckMessagingServiceDisconnectedViaSEMPv2(messagingService solace.MessagingService) {
resp, _, err := testcontext.SEMP().Monitor().MsgVpnApi.
GetMsgVpnClient(testcontext.SEMP().MonitorCtx(), testcontext.Messaging().VPN, "notexist", nil)
ExpectWithOffset(1, err).To(HaveOccurred(), "Expected SEMP to reject call checking for connected client after disconnecting client")
decodeMonitorSwaggerError(err, &resp, 2)
ExpectWithOffset(1, resp.Meta).ToNot(BeNil(), "Expected response from SEMP to contain meta")
ExpectWithOffset(1, resp.Meta.Error_).ToNot(BeNil(), "Expected response from SEMP to contain an error")
ExpectWithOffset(1, resp.Meta.Error_.Status).To(Equal("NOT_FOUND"), "Expected response from SEMP to have error status NOT_FOUND")
}

// ValidateMetric function
func ValidateMetric(messagingService solace.MessagingService, metric metrics.Metric, expectedValue uint64) {
EventuallyWithOffset(1, func() uint64 {
Expand Down

0 comments on commit 571bacb

Please sign in to comment.