integration.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. ccm start -v
  30. ccm status
  31. ccm node1 nodetool status
  32. local proto=2
  33. if [[ $version == 1.2.* ]]; then
  34. proto=1
  35. elif [[ $version == 2.1.* ]]; then
  36. proto=3
  37. fi
  38. if [ "$auth" = true ]
  39. then
  40. ccm node1 cqlsh --version
  41. sleep 30s
  42. echo "list users;" | SSL_VALIDATE=false SSL_CERTFILE=$keypath/cassandra.crt ccm node1 cqlsh --ssl -u cassandra -p cassandra
  43. go test -v . -timeout 15s -run=TestAuthentication -tags integration -runssl -runauth -proto=$proto -cluster=$(ccm liveset) -clusterSize=$clusterSize -autowait=1000ms
  44. else
  45. 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
  46. if [ ${PIPESTATUS[0]} -ne 0 ]; then
  47. echo "--- FAIL: ccm status follows:"
  48. ccm status
  49. ccm node1 nodetool status
  50. ccm node1 showlog > status.log
  51. cat status.log
  52. echo "--- FAIL: Received a non-zero exit code from the go test execution, please investigate this"
  53. exit 1
  54. fi
  55. cover=`cat results.txt | grep coverage: | grep -o "[0-9]\{1,3\}" | head -n 1`
  56. if [[ $cover -lt "55" ]]; then
  57. echo "--- FAIL: expected coverage of at least 60 %, but coverage was $cover %"
  58. exit 1
  59. fi
  60. fi
  61. ccm remove
  62. }
  63. run_tests $1 $2