integration.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/bash
  2. set -e
  3. function run_tests() {
  4. local clusterSize=3
  5. local version=$1
  6. local auth=$2
  7. if [ "$auth" = true ]; then
  8. clusterSize=1
  9. fi
  10. local keypath="$(pwd)/testdata/pki"
  11. local conf=(
  12. "client_encryption_options.enabled: true"
  13. "client_encryption_options.keystore: $keypath/.keystore"
  14. "client_encryption_options.keystore_password: cassandra"
  15. "client_encryption_options.require_client_auth: true"
  16. "client_encryption_options.truststore: $keypath/.truststore"
  17. "client_encryption_options.truststore_password: cassandra"
  18. "concurrent_reads: 2"
  19. "concurrent_writes: 2"
  20. "rpc_server_type: sync"
  21. "rpc_min_threads: 2"
  22. "rpc_max_threads: 2"
  23. "write_request_timeout_in_ms: 5000"
  24. "read_request_timeout_in_ms: 5000"
  25. )
  26. ccm remove test || true
  27. ccm create test -v binary:$version -n $clusterSize -d --vnodes --jvm_arg="-Xmx256m -XX:NewSize=100m"
  28. ccm updateconf "${conf[@]}"
  29. if [ "$auth" = true ]
  30. then
  31. ccm updateconf 'authenticator: PasswordAuthenticator' 'authorizer: CassandraAuthorizer'
  32. rm -rf $HOME/.ccm/test/node1/data/system_auth
  33. fi
  34. ccm start -v
  35. ccm status
  36. ccm node1 nodetool status
  37. local proto=2
  38. if [[ $version == 1.2.* ]]; then
  39. proto=1
  40. elif [[ $version == 2.1.* ]]; then
  41. proto=3
  42. fi
  43. if [ "$auth" = true ]
  44. then
  45. sleep 30s
  46. go test -v . -timeout 15s -run=TestAuthentication -tags integration -runssl -runauth -proto=$proto -cluster=$(ccm liveset) -clusterSize=$clusterSize -autowait=1000ms
  47. else
  48. go test -timeout 5m -tags integration -cover -v -runssl -proto=$proto -rf=3 -cluster=$(ccm liveset) -clusterSize=$clusterSize -autowait=2000ms -compressor=snappy ./... | tee results.txt
  49. if [ ${PIPESTATUS[0]} -ne 0 ]; then
  50. echo "--- FAIL: ccm status follows:"
  51. ccm status
  52. ccm node1 nodetool status
  53. ccm node1 showlog > status.log
  54. cat status.log
  55. echo "--- FAIL: Received a non-zero exit code from the go test execution, please investigate this"
  56. exit 1
  57. fi
  58. cover=`cat results.txt | grep coverage: | grep -o "[0-9]\{1,3\}" | head -n 1`
  59. if [[ $cover -lt "55" ]]; then
  60. echo "--- FAIL: expected coverage of at least 60 %, but coverage was $cover %"
  61. exit 1
  62. fi
  63. fi
  64. ccm remove
  65. }
  66. run_tests $1 $2