Skip to content

Commit

Permalink
[Merge from dev] nats v2.10 support (#684)
Browse files Browse the repository at this point in the history
* [CHANGED] Travis build changes (#680)

* [CHANGED] Travis build changes

- Use Ubuntu focal 20.04
- Added testing against nats-server latest release, and against the `dev` branch
- Changed gcc `sanitize=address` builds to Debug to get line numbers in the output
- Added `NATS_TEST_VALGRIND=yes` to `sanitize=thread` to reduce repeat counts and avoid timeouts

* Update buildOnTravis.sh

Co-authored-by: Ziya Suzen <[email protected]>

* Fixed flapping test_ServerPoolUpdatedOnClusterUpdate

* PR feedback: test _checkPool to retry # subjects

* PR feedback: refactored _checkPool

---------

Co-authored-by: Ziya Suzen <[email protected]>

* [ADDED] Support for (multiple) ConsumerConfig.FilterSubjects (#679)

* [CHANGED] Travis build changes

- Use Ubuntu focal 20.04
- Added testing against nats-server latest release, and against the `dev` branch
- Changed gcc `sanitize=address` builds to Debug to get line numbers in the output
- Added `NATS_TEST_VALGRIND=yes` to `sanitize=thread` to reduce repeat counts and avoid timeouts

* Update buildOnTravis.sh

Co-authored-by: Ziya Suzen <[email protected]>

* Fixed flapping test_ServerPoolUpdatedOnClusterUpdate

* [ADDED] Support for (multiple) ConsumerConfig.FilterSubjects

* PR feedback: took out a redundant check

* point travis to build with NATS main, not dev

---------

Co-authored-by: Ziya Suzen <[email protected]>

* [Added] More v2.10 related changes (#682)

* Added Metadata to Stream, Consumer configs
Merged some other fixes from go PR

* leak

* Added jsStreamConfig.Compression

* Added jsStreamConfig.FirstSeq

* Added jsStreamConfig.SubjectTransform

* Added jsStreamSourceInfo.SubjectTransforms and .FilterSubjects

* Added jsStreamConfig.ConsumerLimits

* PR feedback: nits

* PR feedback: verify metadata values in test

* PR feedback: fix a cast

* Fixed the broken test (order of values)

---------

Co-authored-by: Ziya Suzen <[email protected]>
  • Loading branch information
levb and mtmk authored Oct 12, 2023
1 parent 0ac5cd4 commit b7e825e
Show file tree
Hide file tree
Showing 15 changed files with 827 additions and 180 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ cmake-build*/
install/
html/
!doc/html/
test/datastore_*/
test/conf_*

# Emacs
*~
Expand Down
36 changes: 32 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: cpp
dist: bionic
dist: focal
os: linux

cache:
Expand All @@ -25,6 +25,34 @@ env:
jobs:
include:

- name: "NATS server - latest release"
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: ppa:ubuntu-toolchain-r/test
packages:
- g++-9
env:
- NATS_TEST_SERVER_VERSION=latest
- MATRIX_EVAL="CC=gcc-9"
- BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Release" DO_COVERAGE="no"

- name: "NATS server - main"
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: ppa:ubuntu-toolchain-r/test
packages:
- g++-9
env:
- NATS_TEST_SERVER_VERSION=main
- MATRIX_EVAL="CC=gcc-9"
- BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Release" DO_COVERAGE="no"

- name: "gcc-9 - TLS OFF"
compiler: gcc
addons:
Expand Down Expand Up @@ -62,7 +90,7 @@ jobs:
- g++-9
env:
- MATRIX_EVAL="CC=gcc-9"
- BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fsanitize=address" NATS_TEST_VALGRIND=yes DO_COVERAGE="no"
- BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-fsanitize=address" NATS_TEST_VALGRIND=yes DO_COVERAGE="no"

- name: "gcc-9 - Lib msg delivery - sanitize address"
compiler: gcc
Expand All @@ -75,7 +103,7 @@ jobs:
- g++-9
env:
- MATRIX_EVAL="CC=gcc-9"
- NATS_DEFAULT_TO_LIB_MSG_DELIVERY=yes BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fsanitize=address" NATS_TEST_VALGRIND=yes DO_COVERAGE="no"
- NATS_DEFAULT_TO_LIB_MSG_DELIVERY=yes BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-fsanitize=address" NATS_TEST_VALGRIND=yes DO_COVERAGE="no"

- name: "gcc-9 - Write deadline - sanitize address"
compiler: gcc
Expand All @@ -101,7 +129,7 @@ jobs:
- g++-9
env:
- MATRIX_EVAL="CC=gcc-9"
- BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fsanitize=thread" DO_COVERAGE="no"
- BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fsanitize=thread" NATS_TEST_VALGRIND=yes DO_COVERAGE="no"

- name: "clang-8 - TLS OFF"
compiler: clang
Expand Down
21 changes: 20 additions & 1 deletion buildOnTravis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ echo "coverage = " $2
echo "build opts = " $3
echo "test opts = " $4

if [ "$NATS_TEST_SERVER_VERSION" != "" ]; then
rel=$NATS_TEST_SERVER_VERSION
mkdir -p $HOME/nats-server-$rel
if [ "$rel" = "latest" ]; then
rel=$(curl -s https://api.github.com/repos/nats-io/nats-server/releases/latest | jq -r '.tag_name')
fi

if [ "$rel" != "${rel#v}" ] && wget https://github.com/nats-io/nats-server/releases/download/$rel/nats-server-$rel-linux-amd64.tar.gz; then
tar -xzf nats-server-$rel-linux-amd64.tar.gz
mv nats-server-$rel-linux-amd64 $HOME/nats-server-$rel
else
curl -sf "https://binaries.nats.dev/nats-io/nats-server/v2@$rel" | PREFIX=. sh
mv nats-server $HOME/nats-server-$rel
fi
PATH=$HOME/nats-server-$rel:$PATH
fi

if [ "$1" != "gcc" ]; then
if [ "$2" = "coverage" ]; then
# only coverage for gcc compiler
Expand All @@ -35,8 +52,10 @@ res=$?
if [ $res -ne 0 ]; then
exit $res
fi
export NATS_TEST_SERVER_VERSION="$(nats-server -v)"

export NATS_TEST_TRAVIS=yes
export NATS_TEST_SERVER_VERSION="$(nats-server -v)"
echo "Using NATS server version: $NATS_TEST_SERVER_VERSION"
ctest --timeout 60 --output-on-failure $4
res=$?
if [ $res -ne 0 ]; then
Expand Down
28 changes: 22 additions & 6 deletions src/js.c
Original file line number Diff line number Diff line change
Expand Up @@ -2201,18 +2201,34 @@ _processConsInfo(const char **dlvSubject, jsConsumerInfo *info, jsConsumerConfig
jsConsumerConfig *ccfg = info->Config;
const char *dg = NULL;
natsStatus s = NATS_OK;
bool matches = false;
int i;

*dlvSubject = NULL;

// Make sure this new subject matches or is a subset.
if (!nats_IsStringEmpty(subj)
&& !nats_IsStringEmpty(ccfg->FilterSubject)
&& (strcmp(subj, ccfg->FilterSubject) != 0))
if (!nats_IsStringEmpty(subj))
{
return nats_setError(NATS_ERR, "subject '%s' does not match consumer filter subject '%s'",
subj, ccfg->FilterSubject);
if (nats_IsStringEmpty(ccfg->FilterSubject) && (ccfg->FilterSubjectsLen == 0))
{
matches = true;
}
else if (!nats_IsStringEmpty(ccfg->FilterSubject) && nats_HasPrefix(subj, ccfg->FilterSubject))
{
matches = true;
}
else if (ccfg->FilterSubjectsLen > 0)
{
for (i = 0; (i < ccfg->FilterSubjectsLen) && !matches; i++)
{
matches = nats_HasPrefix(subj, ccfg->FilterSubjects[i]);
}
}
if (!matches)
{
return nats_setError(NATS_ERR, "subject '%s' does not match any consumer filter subjects.", subj);
}
}

// Check that if user wants to create a queue sub,
// the consumer has no HB nor FC.
queue = (nats_IsStringEmpty(queue) ? NULL : queue);
Expand Down
3 changes: 3 additions & 0 deletions src/js.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ extern const int64_t jsDefaultRequestWait;
#define jsStorageTypeFileStr "file"
#define jsStorageTypeMemStr "memory"

#define jsStorageCompressionNoneStr "none"
#define jsStorageCompressionS2Str "s2"

#define jsDeliverAllStr "all"
#define jsDeliverLastStr "last"
#define jsDeliverNewStr "new"
Expand Down
Loading

0 comments on commit b7e825e

Please sign in to comment.