snapshot of https://github.com/nats-io/nats-server.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
NATS Server Tests / Lint (push) Failing after 3s
NATS Server Tests / Build (Latest Go) (push) Has been skipped
NATS Server Tests / Build (Minimum Go) (push) Has been skipped
NATS Server Tests / Build (Minimum Go, windows-2022) (push) Has been skipped
NATS Server Tests / Build (Minimum Go, windows-2025) (push) Has been skipped
NATS Server Tests / Test Stores (push) Has been skipped
NATS Server Tests / Test JetStream (push) Has been skipped
NATS Server Tests / Test Raft (push) Has been skipped
NATS Server Tests / Test JetStream Consumers (push) Has been skipped
NATS Server Tests / Test JetStream Cluster 1 (push) Has been skipped
NATS Server Tests / Test JetStream Cluster 2 (push) Has been skipped
NATS Server Tests / Test JetStream Cluster 3 (push) Has been skipped
NATS Server Tests / Test JetStream Cluster 4 (push) Has been skipped
NATS Server Tests / Test JetStream Supercluster (push) Has been skipped
NATS Server Tests / Test No-Race 1 (push) Has been skipped
NATS Server Tests / Test No-Race 2 (push) Has been skipped
NATS Server Tests / Test MQTT (push) Has been skipped
NATS Server Tests / Test Message Tracing (push) Has been skipped
NATS Server Tests / Test JWT (push) Has been skipped
NATS Server Tests / Test Remaining Server Tests (push) Has been skipped
NATS Server Tests / Test Other Packages (push) Has been skipped
Vulnerability Scan / govulncheck (push) Failing after 12m2s

This commit is contained in:
upstream-mirror
2026-09-15 20:16:01 +05:00
commit 709385cbaa
455 changed files with 155508 additions and 0 deletions

62
scripts/cov.sh Executable file
View File

@@ -0,0 +1,62 @@
#!/bin/bash
# Run from directory above via ./scripts/cov.sh
check_file () {
# If the content of the file is simply "mode: atomic", then it means that the
# code coverage did not complete due to a panic in one of the tests.
if [[ $(cat ./cov/$2) == "mode: atomic" ]]; then
echo "#############################################"
echo "## Code coverage for $1 package failed ##"
echo "#############################################"
exit 1
fi
}
# Do not globally set the -e flag because we don't a flapper to prevent the push to coverall.
export GO111MODULE="on"
go install github.com/wadey/gocovmerge@latest
# Fail fast by checking if we can run gocovmerge
gocovmerge
if [[ $? != 0 ]]; then
echo "Unable to run gocovmerge"
exit 1
fi
rm -rf ./cov
mkdir cov
#
# Since it is difficult to get a full run without a flapper, do not use `-failfast`.
# It is better to have one flapper or two and still get the report than have
# to re-run the whole code coverage. One or two failed tests should not affect
# so much the code coverage.
#
# However, we need to take into account that if there is a panic in one test, all
# other tests in that package will not run, which then would cause the code coverage
# to drastically be lowered. In that case, we don't want the code coverage to be
# uploaded.
#
go test -v -covermode=atomic -coverprofile=./cov/conf.out ./conf -timeout=1h -tags=skip_no_race_tests
check_file "conf" "conf.out"
go test -v -covermode=atomic -coverprofile=./cov/internal.out ./internal/ldap -timeout=1h -tags=skip_no_race_tests
check_file "internal" "internal.out"
go test -v -covermode=atomic -coverprofile=./cov/log.out ./logger -timeout=1h -tags=skip_no_race_tests
check_file "logger" "log.out"
go test -v -covermode=atomic -coverprofile=./cov/server_avl.out ./server/avl -timeout=1h -tags=skip_no_race_tests
check_file "server_avl" "server_avl.out"
go test -v -covermode=atomic -coverprofile=./cov/server.out ./server -timeout=1h -tags=skip_no_race_tests
check_file "server" "server.out"
go test -v -covermode=atomic -coverprofile=./cov/test.out -coverpkg=./server ./test -timeout=1h -tags=skip_no_race_tests
check_file "test" "test.out"
# At this point, if that fails, we want the caller to know about the failure.
set -e
gocovmerge ./cov/*.out > acc.out
rm -rf ./cov
# If no argument passed, launch a browser to see the results.
if [[ $1 == "" ]]; then
go tool cover -html=acc.out
fi
set +e

138
scripts/runTestsOnTravis.sh Executable file
View File

@@ -0,0 +1,138 @@
#!/bin/sh
set -ex
if [ "$1" = "compile" ]; then
# First check that NATS builds.
go build -v;
# Now run the linters.
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.4;
golangci-lint run;
if [ "$TRAVIS_TAG" != "" ]; then
go test -v -run=TestVersionMatchesTag ./server -ldflags="-X=github.com/nats-io/nats-server/v2/server.serverVersion=$TRAVIS_TAG" -count=1 -vet=off
fi
elif [ "$1" = "build_only" ]; then
go build -v;
elif [ "$1" = "no_race_1_tests" ]; then
# Run tests without the `-race` flag. By convention, those tests start
# with `TestNoRace`. This will include all test files that have the
# "&& !skip_no_race_1_tests" in the go build directive.
go test -v -p=1 -run=TestNoRace ./... -tags=skip_no_race_2_tests -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "no_race_2_tests" ]; then
# Run tests without the `-race` flag. By convention, those tests start
# with `TestNoRace`. This will include all test files that have the
# "&& !skip_no_race_2_tests" in the go build directive.
go test -v -p=1 -run=TestNoRace ./... -tags=skip_no_race_1_tests -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "store_tests" ]; then
# Run store tests. By convention, all file store tests start with `TestFileStore`,
# and memory store tests start with `TestMemStore`.
go test $RACE -v -p=1 -run=Test\(Store\|FileStore\|MemStore\) ./server -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "js_tests" ]; then
# Run JetStream non-clustered tests. By convention, all JS tests start
# with `TestJetStream`. We exclude the clustered, super-clustered and
# consumer tests by using the appropriate tags.
go test $RACE -v -p=1 -run=TestJetStream ./server -tags=skip_js_cluster_tests,skip_js_cluster_tests_2,skip_js_cluster_tests_3,skip_js_cluster_tests_4,skip_js_super_cluster_tests,skip_js_consumer_tests -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "js_consumer_tests" ]; then
# Run JetStream consumer tests. All tests start with TestJetStreamConsumer prefix.
go test $RACE -v -p=1 -run=TestJetStreamConsumer ./server -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "raft_tests" ]; then
# Run the RAFT tests. All tests start with TestNRG prefix.
go test $RACE -v -p=1 ./server/... -run="^TestNRG" -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "js_cluster_tests_1" ]; then
# Run JetStream clustered tests. By convention, all JS cluster tests
# start with `TestJetStreamCluster`. Will run the first batch of tests,
# excluding others with use of proper tags.
go test $RACE -v -p=1 -run=TestJetStreamCluster ./server -tags=skip_js_cluster_tests_2,skip_js_cluster_tests_3,skip_js_cluster_tests_4 -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "js_cluster_tests_2" ]; then
# Run JetStream clustered tests. By convention, all JS cluster tests
# start with `TestJetStreamCluster`. Will run the second batch of tests,
# excluding others with use of proper tags.
go test $RACE -v -p=1 -run=TestJetStreamCluster ./server -tags=skip_js_cluster_tests,skip_js_cluster_tests_3,skip_js_cluster_tests_4 -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "js_cluster_tests_3" ]; then
# Run JetStream clustered tests. By convention, all JS cluster tests
# start with `TestJetStreamCluster`. Will run the third batch of tests,
# excluding others with use of proper tags.
#
go test $RACE -v -p=1 -run=TestJetStreamCluster ./server -tags=skip_js_cluster_tests,skip_js_cluster_tests_2,skip_js_cluster_tests_4 -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "js_cluster_tests_4" ]; then
# Run JetStream clustered tests. By convention, all JS cluster tests
# start with `TestJetStreamCluster`. Will run the third batch of tests,
# excluding others with use of proper tags.
#
go test $RACE -v -p=1 -run=TestJetStreamCluster ./server -tags=skip_js_cluster_tests,skip_js_cluster_tests_2,skip_js_cluster_tests_3 -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "js_super_cluster_tests" ]; then
# Run JetStream super clustered tests. By convention, all JS super cluster
# tests start with `TestJetStreamSuperCluster`.
go test $RACE -v -p=1 -run=TestJetStreamSuperCluster ./server -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "mqtt_tests" ]; then
# Run MQTT tests. By convention, all MQTT tests start with `TestMQTT`.
go test $RACE -v -p=1 -run=TestMQTT ./server -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "msgtrace_tests" ]; then
# Run Message Tracing tests. By convention, all message tracing tests start with `TestMsgTrace`.
go test $RACE -v -p=1 -run=TestMsgTrace ./server -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "srv_pkg_non_js_tests" ]; then
# Run all non JetStream tests in the server package. We exclude the
# store tests by using the `skip_store_tests` build tag, the JS tests
# by using `skip_js_tests`, MQTT tests by using `skip_mqtt_tests` and
# message tracing tests by using `skip_msgtrace_tests`.
# Ignore JWT and NRG tests here as they have their own matrix run.
# Also including the ldflag with the version since this includes the `TestVersionMatchesTag`.
go test $RACE -v -p=1 ./server/... -run="^Test(N[^R]|NR[^G]|J[^W]|JW[^T]|[^JN])" -ldflags="-X=github.com/nats-io/nats-server/v2/server.serverVersion=$TRAVIS_TAG" -tags=skip_store_tests,skip_js_tests,skip_mqtt_tests,skip_msgtrace_tests,skip_no_race_tests -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "jwt_tests" ]; then
# Run the JWT tests. All tests start with TestJWT.
go test $RACE -v -p=1 ./server/... -run="^TestJWT" -count=1 -vet=off -timeout=30m -failfast
elif [ "$1" = "non_srv_pkg_tests" ]; then
# Run all tests of all non server package.
go test $RACE -v -p=1 $(go list ./... | grep -v "/server") -count=1 -vet=off -timeout=30m -failfast
fi

39
scripts/updateCopyrights.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
# Ensure script is run at the root of a git repository
git rev-parse --is-inside-work-tree &>/dev/null || { echo "Not inside a git repository"; exit 1; }
# Find all .go files tracked by git
git ls-files "*.go" | while read -r file; do
# Skip files that don't have a copyright belonging to "The NATS Authors"
current_copyright=$(grep -oE "^// Copyright [0-9]{4}(-[0-9]{4})? The NATS Authors" "$file" || echo "")
[[ -z "$current_copyright" ]] && continue
# Get the last commit year for the file, ignore commit messages containing the word "copyright"
last_year=$(git log --follow --format="%ad" --date=format:%Y --grep="(C|c)opyright" --invert-grep -n 1 -- "$file")
existing_years=$(echo "$current_copyright" | grep -oE "[0-9]{4}(-[0-9]{4})?")
# Determine the new copyright range
if [[ "$existing_years" =~ ^([0-9]{4})-([0-9]{4})$ ]]; then
first_year=${BASH_REMATCH[1]}
new_copyright="// Copyright $first_year-$last_year The NATS Authors"
elif [[ "$existing_years" =~ ^([0-9]{4})$ ]]; then
first_year=${BASH_REMATCH[1]}
if [[ "$first_year" == "$last_year" ]]; then
new_copyright="// Copyright $first_year The NATS Authors"
else
new_copyright="// Copyright $first_year-$last_year The NATS Authors"
fi
else
continue # If the format is somehow incorrect, skip the file
fi
# Update the first line
if sed --version &>/dev/null; then
# Linux sed
sed -i "1s|^// Copyright.*|$new_copyright|" "$file"
else
# BSD/macOS sed, needs -i ''
sed -i '' "1s|^// Copyright.*|$new_copyright|" "$file"
fi
done