hue_file_tester.sh 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. # Licensed to Cloudera, Inc. under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. Cloudera, Inc. licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # NOTE: This script requires curl to be installed. Also, it does not have to run on the Hue server, it can run anywhere that curl is installed. As long as that host can reach the Hue server.
  18. # Please change USERS to contain a list of users that you would like to use to generate load
  19. USERS="cconner test1 test2 test3 test4 test5 test6 test7 test8 test9 test10"
  20. #Please enter the Hue server name below
  21. HUE_SERVER="cdh412-1"
  22. #Please enter the Hue server port below
  23. HUE_PORT="8888"
  24. #Please enter the base name of each file. They will be called ${HUE_FILE_BASE}${count}.txt. So hue_file_test_ = hue_file_test_1.txt .... NOTE: this must match HUE_FILE_BASE in hue_file_tester_setup.sh
  25. HUE_FILE_BASE="hue_file_test_"
  26. #Plase enter the directory in HDFS where the above files were stored. NOTE: this must match HDFS_LOCATION in hue_file_tester_setup.sh
  27. HDFS_LOCATION="/tmp/hue_file_test"
  28. #Please enter the number of files that were created in $HDFS_LOCATION. NOTE: this must match or be less than the value of FILE_COUNT in hue_file_tester_setup.sh
  29. FILE_COUNT=10
  30. #Please create an entry below for every user that you added to USERS above. After the = replace "password" with the correct password for each user. If you have more or less than the number of entries below, add or delete rows as necessary.
  31. declare -A password_hash
  32. password_hash[cconner]="password"
  33. password_hash[test1]="password"
  34. password_hash[test2]="password"
  35. password_hash[test3]="password"
  36. password_hash[test4]="password"
  37. password_hash[test5]="password"
  38. password_hash[test6]="password"
  39. password_hash[test7]="password"
  40. password_hash[test8]="password"
  41. password_hash[test9]="password"
  42. password_hash[test10]="password"
  43. HUE_PASS_URL="${HUE_SERVER}:${HUE_PORT}/accounts/login/"
  44. HUE_FILE_URL="${HUE_SERVER}:${HUE_PORT}/filebrowser/view${HDFS_LOCATION}"
  45. for user in $USERS
  46. do
  47. echo "Running Command:"
  48. echo "curl -i -c /tmp/${user}_cookie.txt -d \"username=${user}&password=${password_hash[${user}]}\" \"${HUE_PASS_URL}\""
  49. curl -i -c /tmp/${user}_cookie.txt -d "username=${user}&password=${password_hash[${user}]}" "${HUE_PASS_URL}"
  50. done
  51. while [ 1 ]
  52. do
  53. for user in $USERS
  54. do
  55. rand_data=$((RANDOM%${FILE_COUNT}+1))
  56. rand_sleep=$((RANDOM%10+1))
  57. rand_offset=$((RANDOM%32000+1))
  58. hue_file="${HUE_FILE_BASE}${rand_data}.txt"
  59. echo "Running Command:"
  60. echo "curl -i -b /tmp/${user}_cookie.txt \"$HUE_FILE_URL/${hue_file}?offset=${rand_offset}&length=4096&compression=none&mode=text\" > /dev/null"
  61. curl -i -b /tmp/${user}_cookie.txt "$HUE_FILE_URL/${hue_file}?offset=${rand_offset}&length=4096&compression=none&mode=text" > /dev/null
  62. sleep ${rand_sleep}
  63. done
  64. done