Skip to content

Commit

Permalink
Merge pull request #13 from SolaceDev/dev
Browse files Browse the repository at this point in the history
Release v1.4.0
  • Loading branch information
mcardy authored Jun 30, 2023
2 parents 4cd3329 + 7433a31 commit 339b370
Show file tree
Hide file tree
Showing 22 changed files with 531 additions and 42 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ To get started using the Solace PubSub+ API for Go, simply include it as a requi

The Solace PubSub+ API for Go is a wrapper around the high performance Solace C API via Cgo and has support for the following operating systems:
- Linux (x86/x86_64) variants with Linux 2.6 or later (compatible with glibc (desktop/server) and musl-c (Alpine Linux))
- Linux (arm64) variants compatible with glibc (desktop/server)
- Windows WSL 2.0
- macOS 10.15 and later (x86_64 versions)
- macOS 11.0 and later (arm64 versions)

## Contributing

Expand Down
3 changes: 2 additions & 1 deletion internal/ccsmp/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ package ccsmp
import (
_ "solace.dev/go/messaging/internal/ccsmp/lib/darwin"
_ "solace.dev/go/messaging/internal/ccsmp/lib/include/solclient"
_ "solace.dev/go/messaging/internal/ccsmp/lib/linux"
_ "solace.dev/go/messaging/internal/ccsmp/lib/linux_amd64"
_ "solace.dev/go/messaging/internal/ccsmp/lib/linux_arm64"
)
2 changes: 0 additions & 2 deletions internal/ccsmp/includes_darwin_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ package ccsmp
#cgo LDFLAGS: -L/usr/local/opt/[email protected]/lib ${SRCDIR}/lib/darwin/libsolclient.a -lssl -lcrypto -framework Kerberos
*/
import "C"

var SolClientRunningOnAlpine bool = false
2 changes: 0 additions & 2 deletions internal/ccsmp/includes_darwin_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ package ccsmp
#cgo LDFLAGS: -L/opt/homebrew/opt/[email protected]/lib ${SRCDIR}/lib/darwin/libsolclient.a -lssl -lcrypto -framework Kerberos
*/
import "C"

var SolClientRunningOnAlpine bool = false
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@ package ccsmp
/*
// specific flags for linux static builds in C
#cgo CFLAGS: -I${SRCDIR}/lib/include
#cgo LDFLAGS: ${SRCDIR}/lib/linux/libsolclient.a -lm -ldl -lpthread -lrt
#cgo LDFLAGS: ${SRCDIR}/lib/linux_amd64/libsolclient.a -lm -ldl -lpthread -lrt
#include <dlfcn.h>
#include <features.h>
#ifdef __GLIBC__
#define SOLCLIENT_USING_MUSL 0
#else
#define SOLCLIENT_USING_MUSL 1
#endif
*/
import "C"

Expand All @@ -38,5 +32,3 @@ import "C"
func funcToLinkAgainstLibdl() {
C.dlerror()
}

var SolClientRunningOnAlpine bool = C.SOLCLIENT_USING_MUSL == 1
34 changes: 34 additions & 0 deletions internal/ccsmp/includes_linux_arm64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// pubsubplus-go-client
//
// Copyright 2021-2023 Solace Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ccsmp

/*
// specific flags for linux static builds in C
#cgo CFLAGS: -I${SRCDIR}/lib/include
#cgo LDFLAGS: ${SRCDIR}/lib/linux_arm64/libsolclient.a -lm -ldl -lpthread -lrt
#include <dlfcn.h>
*/
import "C"

// Because of some strange behaviour of CCSMP, libdl is not actually required as far as the compiler is concerned.
// As a result, we must write a function that allows us to link against the dynamic libdl system library. This
// function should NOT be used as it does nothing and may cause issues.
func funcToLinkAgainstLibdl() {
C.dlerror()
}
Binary file modified internal/ccsmp/lib/darwin/libsolclient.a
Binary file not shown.
20 changes: 18 additions & 2 deletions internal/ccsmp/lib/include/solclient/solClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern "C"
{
#endif /* _cplusplus */


/**
@mainpage
Expand Down Expand Up @@ -1101,7 +1102,7 @@ typedef struct solClient_field {
* <tr>
* <td width="300"> SOLCLIENT_SUBCODE_TE_SHUTDOWN</td>
* <td width="300"> An attempt was made to operate on a shutdown Guaranteed Delivery Topic Endpoint.</td>
* <td width="300"> 503 Durable Topic Endpoint Shutdown, 503 TE Shutdown, 503 Endpoint Shutdown </td>
* <td width="300"> 503 Durable Topic Endpoint Shutdown, 503 TE Shutdown </td>
* </tr>
* <tr>
* <td width="300"> SOLCLIENT_SUBCODE_NO_MORE_NON_DURABLE_QUEUE_OR_TE</td>
Expand Down Expand Up @@ -1543,6 +1544,16 @@ typedef struct solClient_field {
* <td width="300"> Egress selectors are not permitted when binding to a Partitioned Queue. </td>
* <td width="300"> 403 Selectors Not Supported on Partititoned Queue </td>
* </tr>
* <tr>
* <td width="300"> SOLCLIENT_SUBCODE_SYNC_REPLICATION_INELIGIBLE </td>
* <td width="300"> A guaranteed message was rejected because the broker has been configured to reject messages when sync replication mode is ineligible. A transaction commit failed because replication became ineligible during the transaction. </td>
* <td width="300"> 503 Sync Replication Ineligible </td>
* </tr>
* <tr>
* <td width="300"> SOLCLIENT_SUBCODE_ENDPOINT_SHUTDOWN </td>
* <td width="300"> The client has attempted to publish to a topic that matched a queue or topic endpoint subscription which has its ingress flow shutdown. </td>
* <td width="300"> 503 Endpoint Shutdown </td>
* </tr>
* </table>
*/
typedef enum solClient_subCode
Expand Down Expand Up @@ -1711,7 +1722,9 @@ typedef struct solClient_field {
SOLCLIENT_SUBCODE_MESSAGE_ID_NOT_COMPARABLE = 157, /**< Replication Group Message Id are not comparable. Messages must be published to the same broker or HA pair for their Replicaton Group Message Id to be comparable. */
SOLCLIENT_SUBCODE_REPLAY_ANONYMOUS_NOT_SUPPORTED = 158, /**< The client attempted to start replay on a flow bound to an anonymous queue. */
SOLCLIENT_SUBCODE_BROWSING_NOT_SUPPORTED_ON_PARTITIONED_QUEUE = 159, /**< Browser flows to Partitioned Queues are not permitted. */
SOLCLIENT_SUBCODE_SELECTORS_NOT_SUPPORTED_ON_PARTITIONED_QUEUE = 160 /**< Egress selectors are not permitted when binding to a Partitioned Queue. */
SOLCLIENT_SUBCODE_SELECTORS_NOT_SUPPORTED_ON_PARTITIONED_QUEUE = 160, /**< Egress selectors are not permitted when binding to a Partitioned Queue. */
SOLCLIENT_SUBCODE_SYNC_REPLICATION_INELIGIBLE = 161, /**< A guaranteed message was rejected because the broker has been configured to reject messages when sync replication mode is ineligible. A transaction commit failed because replication became ineligible during the transaction. */
SOLCLIENT_SUBCODE_ENDPOINT_SHUTDOWN = 162, /**< The client has attempted to publish to a topic that matched a queue or topic endpoint subscription which has its ingress flow shutdown. */
/*
* ADDING NEW SUBCODES: When adding a new subcode always add a new entry to the HTML table in
* the comment above this enumeration
Expand Down Expand Up @@ -2575,6 +2588,7 @@ Note: This property is used for all entries specified by the property ::SOLCLIEN
#define SOLCLIENT_SESSION_CAPABILITY_LONG_SELECTORS "SESSION_CAPABILITY_LONG_SELECTORS" /**< Boolean - The peer can support selectors longer than 1023 bytes */
#define SOLCLIENT_SESSION_CAPABILITY_SHARED_SUBSCRIPTIONS "SESSION_CAPABILITY_SHARED_SUBSCRIPTIONS" /**< Boolean - The peer can support \#shared and \#noexport subscriptions */
#define SOLCLIENT_SESSION_CAPABILITY_BR_REPLAY_ERRORID "SESSION_CAPABILITY_BR_REPLAY_ERRORID" /**< Boolean - The peer can support the endpoint error id parameter on the flow bind response during message replay */
#define SOLCLIENT_SESSION_CAPABILITY_VAR_LEN_EXT_PARAM "SESSION_CAPABILITY_VAR_LEN_EXT_PARAM" /**< Boolean - The peer can support variable length extended parameters. */
#define SOLCLIENT_SESSION_CAPABILITY_ADCTRL_VERSION_MIN "SESSION_CAPABILITY_ADCTRL_VERSION_MIN" /**< Uint32 - Lowest AdCtrl version supported by the broker. */
#define SOLCLIENT_SESSION_CAPABILITY_ADCTRL_VERSION_MAX "SESSION_CAPABILITY_ADCTRL_VERSION_MAX" /**< Uint32 - Highest AdCtrl version supported by the broker. */
/*@}*/
Expand Down Expand Up @@ -5603,6 +5617,8 @@ solClient_dllExport solClient_returnCode_t
solClient_flow_getTransactedSession(solClient_opaqueFlow_pt flow_p,
solClient_opaqueTransactedSession_pt *transactedSession_p);



#ifndef SOLCLIENT_EXCLUDE_DEPRECATED
#include "solClientDeprecated.h"
#endif /* SOLCLIENT_EXCLUDE_DEPRECATED */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
//go:build dummy
// +build dummy

// Package linux is provided as a workaround for go vendoring and contains no go code.
// Package linux_amd64 is provided as a workaround for go vendoring and contains no go code.
// See internal/ccsmp/dummy.go for more information.
package linux
package linux_amd64
Binary file not shown.
22 changes: 22 additions & 0 deletions internal/ccsmp/lib/linux_arm64/dummy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// pubsubplus-go-client
//
// Copyright 2021-2023 Solace Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build dummy
// +build dummy

// Package linux_arm64 is provided as a workaround for go vendoring and contains no go code.
// See internal/ccsmp/dummy.go for more information.
package linux_arm64
Binary file added internal/ccsmp/lib/linux_arm64/libsolclient.a
Binary file not shown.
5 changes: 0 additions & 5 deletions internal/impl/core/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ var libraryEnvironmentMapping = map[string]string{
// ccsmp initialization, calls solClient_initialize
func init() {
propertyMap := make(map[string]string)
if ccsmp.SolClientRunningOnAlpine {
// SOL-78608 we need to use the full library names to pick up the default alpine SSL libs
propertyMap[ccsmp.SolClientGlobalPropCryptoLib] = "libcrypto.so.1.1"
propertyMap[ccsmp.SolClientGlobalPropSslLib] = "libssl.so.1.1"
}
for _, env := range supportedKeys {
if val, ok := os.LookupEnv(env); ok {
var key string
Expand Down
4 changes: 4 additions & 0 deletions pkg/solace/subcode/subcode_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The integration tests are stored in this directory. These integration tests are

## Running the tests

First, docker and docker-compose must be installed and accessible to the current user. Second, `go generate` must be run from the `./test/sempclient` directory. The tests can be run by navigating to the test directory and running `go test`. This will start by spinning up a docker container containing the broker and then running the tests on that container. To run against an external broker, `go test -tags remote` can be used to instruct the tests to target an environment variable based broker. See the [Environment Variables](#environment-variables) section below for more information.
First, docker and docker-compose must be installed and accessible to the current user. Second, `go generate` must be run from the `./test/sempclient` directory. The tests can be run by navigating to the test directory and running `ginkgo` or 'go test'. 'ginkgo' is preferable as the pre-configured timeout (for the whole test suite) is 1hr whereas the default timeout using 'go test' is 10mins. This will start by spinning up a docker container containing the broker and then running the tests on that container. To run against an external broker, `go test -tags remote` can be used to instruct the tests to target an environment variable based broker. See the [Environment Variables](#environment-variables) section below for more information.

To run an individual test, first install the ginkgo command line tool with `go install github.com/onsi/ginkgo/v2/ginkgo@latest`, then run the tests with `ginkgo --focus="mytestregex"` from the test directory. This regex will match describe/context/it strings. For more information, see the [ginkgo documentation](https://onsi.github.io/ginkgo/#the-spec-runner).

Expand Down
2 changes: 1 addition & 1 deletion test/data/config/config_testcontainers.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"testcontainers": {
"broker_hostname": "solbroker",
"broker_tag": "10.3",
"broker_tag": "10.4",
"broker_repo": "solace/solace-pubsub",
"broker_edition": "standard",
"toxiproxy_hostname": "toxiproxy",
Expand Down
22 changes: 22 additions & 0 deletions test/helpers/resource_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@ func CreateNonExclusiveQueue(queueName string, topics ...string) {
}
}

// CreatePartitionedQueue function
func CreatePartitionedQueue(queueName string, partitionCount int32, partitionRebalanceDelay int64, topics ...string) {
_, _, err := testcontext.SEMP().Config().QueueApi.CreateMsgVpnQueue(testcontext.SEMP() .ConfigCtx(), sempconfig.MsgVpnQueue{
QueueName: queueName,
AccessType: "non-exclusive",
Permission: "modify-topic",
IngressEnabled: True,
EgressEnabled: True,
PartitionCount: partitionCount,
PartitionRebalanceDelay: partitionRebalanceDelay,
Owner: "default",
}, testcontext.Messaging().VPN, nil)
ExpectWithOffset(1, err).ToNot(HaveOccurred(), "Failed to create queue with name "+queueName)
for _, topic := range topics {
_, _, err = testcontext.SEMP().Config().QueueApi.CreateMsgVpnQueueSubscription(testcontext.SEMP().ConfigCtx(),
sempconfig.MsgVpnQueueSubscription{
SubscriptionTopic: topic,
}, testcontext.Messaging().VPN, queueName, nil)
ExpectWithOffset(1, err).ToNot(HaveOccurred(), "Failed to add subscription for topic "+topic)
}
}

// CreateQueueSubscription function
func CreateQueueSubscription(queueName string, topic string) {
_, _, err := testcontext.SEMP().Config().QueueApi.CreateMsgVpnQueueSubscription(testcontext.SEMP().ConfigCtx(),
Expand Down
29 changes: 19 additions & 10 deletions test/messaging_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,23 +453,32 @@ var _ = Describe("MessagingService Lifecycle", func() {
Expect(client.TlsCipherDescription).To(HavePrefix("AES128-SHA"))
})
})
// We need to explicitly enable TLS1.1 to test a few cases
Context("when allowing TLS1.1 connections", func() {
// Originially this explicitly test tls1.1
// on systems with new openssl (3.0 or later) tls1.1 is no longer supported from the client
// As a result this is adapted to explicitly verify tls1.2 in anticipation for tls1.3
// once openssl 1.1 support is deprecated this maybe
// We need to explicitly enable TLS1.2 to test a few cases
Context("when allowing TLS1.2 connections", func() {
BeforeEach(func() {
testcontext.SEMP().Config().AllApi.UpdateBroker(testcontext.SEMP().ConfigCtx(), sempconfig.Broker{
TlsBlockVersion11Enabled: helpers.False,
}, nil)
// semp configuration for tls version support
// revist for enabling support for tls 1.2 in the future
//testcontext.SEMP().Config().AllApi.UpdateBroker(testcontext.SEMP().ConfigCtx(), sempconfig.Broker{
// TlsBlockVersion11Enabled: helpers.False,
//}, nil)

})
AfterEach(func() {
testcontext.SEMP().Config().AllApi.UpdateBroker(testcontext.SEMP().ConfigCtx(), sempconfig.Broker{
TlsBlockVersion11Enabled: helpers.True,
}, nil)
// semp configuration for tls version support
// revist for disabling support for tls 1.2 in the future
//testcontext.SEMP().Config().AllApi.UpdateBroker(testcontext.SEMP().ConfigCtx(), sempconfig.Broker{
// TlsBlockVersion11Enabled: helpers.True,
//}, nil)
})
It("should be able to connect with excluded protocols", func() {
builder.WithTransportSecurityStrategy(config.NewTransportSecurityStrategy().
WithExcludedProtocols(config.TransportSecurityProtocolTLSv1_2))
WithExcludedProtocols(config.TransportSecurityProtocolSSLv3, config.TransportSecurityProtocolTLSv1, config.TransportSecurityProtocolTLSv1_1))
helpers.TestConnectDisconnectMessagingServiceClientValidation(builder, func(client *monitor.MsgVpnClient) {
Expect(client.TlsVersion).To(BeEquivalentTo(config.TransportSecurityProtocolTLSv1_1))
Expect(client.TlsVersion).To(BeEquivalentTo(config.TransportSecurityProtocolTLSv1_2))
})
})
})
Expand Down
Loading

0 comments on commit 339b370

Please sign in to comment.