| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
set -ex |
| 4 |
|
| 5 |
if [ "$1" = "compile" ]; then |
| 6 |
# First check that NATS builds. |
| 7 |
go build -v; |
| 8 |
|
| 9 |
# Now run the linters. |
| 10 |
go install github.com/golangci/golangci-lint/cmd/[email protected]; |
| 11 |
golangci-lint run; |
| 12 |
if [ "$TRAVIS_TAG" != "" ]; then |
| 13 |
go test -v -run=TestVersionMatchesTag ./server -ldflags="-X=github.com/nats-io/nats-server/v2/server.serverVersion=$TRAVIS_TAG" -count=1 -vet=off |
| 14 |
fi |
| 15 |
|
| 16 |
elif [ "$1" = "build_only" ]; then |
| 17 |
go build -v; |
| 18 |
|
| 19 |
elif [ "$1" = "no_race_1_tests" ]; then |
| 20 |
|
| 21 |
# Run tests without the `-race` flag. By convention, those tests start |
| 22 |
# with `TestNoRace`. This will include all test files that have the |
| 23 |
# "&& !skip_no_race_1_tests" in the go build directive. |
| 24 |
|
| 25 |
go test -v -p=1 -run=TestNoRace ./... -tags=skip_no_race_2_tests -count=1 -vet=off -timeout=30m -failfast |
| 26 |
|
| 27 |
elif [ "$1" = "no_race_2_tests" ]; then |
| 28 |
|
| 29 |
# Run tests without the `-race` flag. By convention, those tests start |
| 30 |
# with `TestNoRace`. This will include all test files that have the |
| 31 |
# "&& !skip_no_race_2_tests" in the go build directive. |
| 32 |
|
| 33 |
go test -v -p=1 -run=TestNoRace ./... -tags=skip_no_race_1_tests -count=1 -vet=off -timeout=30m -failfast |
| 34 |
|
| 35 |
elif [ "$1" = "store_tests" ]; then |
| 36 |
|
| 37 |
# Run store tests. By convention, all file store tests start with `TestFileStore`, |
| 38 |
# and memory store tests start with `TestMemStore`. |
| 39 |
|
| 40 |
go test $RACE -v -p=1 -run=Test\(Store\|FileStore\|MemStore\) ./server -count=1 -vet=off -timeout=30m -failfast |
| 41 |
|
| 42 |
elif [ "$1" = "js_tests" ]; then |
| 43 |
|
| 44 |
# Run JetStream non-clustered tests. By convention, all JS tests start |
| 45 |
# with `TestJetStream`. We exclude the clustered, super-clustered and |
| 46 |
# consumer tests by using the appropriate tags. |
| 47 |
|
| 48 |
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 |
| 49 |
|
| 50 |
elif [ "$1" = "js_consumer_tests" ]; then |
| 51 |
|
| 52 |
# Run JetStream consumer tests. All tests start with TestJetStreamConsumer prefix. |
| 53 |
|
| 54 |
go test $RACE -v -p=1 -run=TestJetStreamConsumer ./server -count=1 -vet=off -timeout=30m -failfast |
| 55 |
|
| 56 |
elif [ "$1" = "raft_tests" ]; then |
| 57 |
|
| 58 |
# Run the RAFT tests. All tests start with TestNRG prefix. |
| 59 |
|
| 60 |
go test $RACE -v -p=1 ./server/... -run="^TestNRG" -count=1 -vet=off -timeout=30m -failfast |
| 61 |
|
| 62 |
elif [ "$1" = "js_cluster_tests_1" ]; then |
| 63 |
|
| 64 |
# Run JetStream clustered tests. By convention, all JS cluster tests |
| 65 |
# start with `TestJetStreamCluster`. Will run the first batch of tests, |
| 66 |
# excluding others with use of proper tags. |
| 67 |
|
| 68 |
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 |
| 69 |
|
| 70 |
elif [ "$1" = "js_cluster_tests_2" ]; then |
| 71 |
|
| 72 |
# Run JetStream clustered tests. By convention, all JS cluster tests |
| 73 |
# start with `TestJetStreamCluster`. Will run the second batch of tests, |
| 74 |
# excluding others with use of proper tags. |
| 75 |
|
| 76 |
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 |
| 77 |
|
| 78 |
elif [ "$1" = "js_cluster_tests_3" ]; then |
| 79 |
|
| 80 |
# Run JetStream clustered tests. By convention, all JS cluster tests |
| 81 |
# start with `TestJetStreamCluster`. Will run the third batch of tests, |
| 82 |
# excluding others with use of proper tags. |
| 83 |
# |
| 84 |
|
| 85 |
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 |
| 86 |
|
| 87 |
elif [ "$1" = "js_cluster_tests_4" ]; then |
| 88 |
|
| 89 |
# Run JetStream clustered tests. By convention, all JS cluster tests |
| 90 |
# start with `TestJetStreamCluster`. Will run the third batch of tests, |
| 91 |
# excluding others with use of proper tags. |
| 92 |
# |
| 93 |
|
| 94 |
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 |
| 95 |
|
| 96 |
elif [ "$1" = "js_super_cluster_tests" ]; then |
| 97 |
|
| 98 |
# Run JetStream super clustered tests. By convention, all JS super cluster |
| 99 |
# tests start with `TestJetStreamSuperCluster`. |
| 100 |
|
| 101 |
go test $RACE -v -p=1 -run=TestJetStreamSuperCluster ./server -count=1 -vet=off -timeout=30m -failfast |
| 102 |
|
| 103 |
elif [ "$1" = "mqtt_tests" ]; then |
| 104 |
|
| 105 |
# Run MQTT tests. By convention, all MQTT tests start with `TestMQTT`. |
| 106 |
|
| 107 |
go test $RACE -v -p=1 -run=TestMQTT ./server -count=1 -vet=off -timeout=30m -failfast |
| 108 |
|
| 109 |
elif [ "$1" = "msgtrace_tests" ]; then |
| 110 |
|
| 111 |
# Run Message Tracing tests. By convention, all message tracing tests start with `TestMsgTrace`. |
| 112 |
|
| 113 |
go test $RACE -v -p=1 -run=TestMsgTrace ./server -count=1 -vet=off -timeout=30m -failfast |
| 114 |
|
| 115 |
elif [ "$1" = "srv_pkg_non_js_tests" ]; then |
| 116 |
|
| 117 |
# Run all non JetStream tests in the server package. We exclude the |
| 118 |
# store tests by using the `skip_store_tests` build tag, the JS tests |
| 119 |
# by using `skip_js_tests`, MQTT tests by using `skip_mqtt_tests` and |
| 120 |
# message tracing tests by using `skip_msgtrace_tests`. |
| 121 |
# Ignore JWT and NRG tests here as they have their own matrix run. |
| 122 |
|
| 123 |
# Also including the ldflag with the version since this includes the `TestVersionMatchesTag`. |
| 124 |
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 |
| 125 |
|
| 126 |
elif [ "$1" = "jwt_tests" ]; then |
| 127 |
|
| 128 |
# Run the JWT tests. All tests start with TestJWT. |
| 129 |
|
| 130 |
go test $RACE -v -p=1 ./server/... -run="^TestJWT" -count=1 -vet=off -timeout=30m -failfast |
| 131 |
|
| 132 |
elif [ "$1" = "non_srv_pkg_tests" ]; then |
| 133 |
|
| 134 |
# Run all tests of all non server package. |
| 135 |
|
| 136 |
go test $RACE -v -p=1 $(go list ./... | grep -v "/server") -count=1 -vet=off -timeout=30m -failfast |
| 137 |
|
| 138 |
fi |