runtests.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #!/usr/bin/env bash
  2. # shellcheck disable=SC2034
  3. # unused variables are global in nature and used in testsupport.sh
  4. test
  5. set -eo pipefail
  6. # Licensed to the Apache Software Foundation (ASF) under one or more
  7. # contributor license agreements. See the NOTICE file distributed with
  8. # this work for additional information regarding copyright ownership.
  9. # The ASF licenses this file to You under the Apache License, Version 2.0
  10. # (the "License"); you may not use this file except in compliance with
  11. # the License. You may obtain a copy of the License at
  12. #
  13. # http://www.apache.org/licenses/LICENSE-2.0
  14. #
  15. # Unless required by applicable law or agreed to in writing, software
  16. # distributed under the License is distributed on an "AS IS" BASIS,
  17. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. # See the License for the specific language governing permissions and
  19. # limitations under the License.
  20. # shellcheck disable=SC1091
  21. . dev-support/testrun-scripts/testsupport.sh
  22. init
  23. resourceDir=src/test/resources/
  24. logdir=dev-support/testlogs/
  25. azureTestXml=azure-auth-keys.xml
  26. azureTestXmlPath=$resourceDir$azureTestXml
  27. processCount=8
  28. ## SECTION: TEST COMBINATION METHODS
  29. runHNSOAuthTest()
  30. {
  31. accountName=$(xmlstarlet sel -t -v '//property[name = "fs.azure.hnsTestAccountName"]/value' -n $azureTestXmlPath)
  32. PROPERTIES=("fs.azure.account.auth.type")
  33. VALUES=("OAuth")
  34. triggerRun "HNS-OAuth" "$accountName" "$runTest" $processCount "$cleanUpTestContainers"
  35. }
  36. runHNSSharedKeyTest()
  37. {
  38. accountName=$(xmlstarlet sel -t -v '//property[name = "fs.azure.hnsTestAccountName"]/value' -n $azureTestXmlPath)
  39. PROPERTIES=("fs.azure.account.auth.type")
  40. VALUES=("SharedKey")
  41. triggerRun "HNS-SharedKey" "$accountName" "$runTest" $processCount "$cleanUpTestContainers"
  42. }
  43. runNonHNSSharedKeyTest()
  44. {
  45. accountName=$(xmlstarlet sel -t -v '//property[name = "fs.azure.nonHnsTestAccountName"]/value' -n $azureTestXmlPath)
  46. PROPERTIES=("fs.azure.account.auth.type")
  47. VALUES=("SharedKey")
  48. triggerRun "NonHNS-SharedKey" "$accountName" "$runTest" $processCount "$cleanUpTestContainers"
  49. }
  50. runAppendBlobHNSOAuthTest()
  51. {
  52. accountName=$(xmlstarlet sel -t -v '//property[name = "fs.azure.hnsTestAccountName"]/value' -n $azureTestXmlPath)
  53. PROPERTIES=("fs.azure.account.auth.type" "fs.azure.test.appendblob.enabled")
  54. VALUES=("OAuth" "true")
  55. triggerRun "AppendBlob-HNS-OAuth" "$accountName" "$runTest" $processCount "$cleanUpTestContainers"
  56. }
  57. runTest=false
  58. cleanUpTestContainers=false
  59. echo 'Ensure below are complete before running script:'
  60. echo '1. Account specific settings file is present.'
  61. echo ' Copy accountName_settings.xml.template to accountName_settings.xml'
  62. echo ' where accountName in copied file name should be the test account name without domain'
  63. echo ' (accountName_settings.xml.template is present in src/test/resources/accountName_settings'
  64. echo ' folder. New account settings file to be added to same folder.)'
  65. echo ' Follow instructions in the template to populate settings correctly for the account'
  66. echo '2. In azure-auth-keys.xml, update properties fs.azure.hnsTestAccountName and fs.azure.nonHnsTestAccountName'
  67. echo ' where accountNames should be the test account names without domain'
  68. echo ' '
  69. echo ' '
  70. echo 'Choose action:'
  71. echo '[Note - SET_ACTIVE_TEST_CONFIG will help activate the config for IDE/single test class runs]'
  72. select scriptMode in SET_ACTIVE_TEST_CONFIG RUN_TEST CLEAN_UP_OLD_TEST_CONTAINERS SET_OR_CHANGE_TEST_ACCOUNT PRINT_LOG4J_LOG_PATHS_FROM_LAST_RUN
  73. do
  74. case $scriptMode in
  75. SET_ACTIVE_TEST_CONFIG)
  76. runTest=false
  77. break
  78. ;;
  79. RUN_TEST)
  80. runTest=true
  81. read -r -p "Enter parallel test run process count [default - 8]: " processCount
  82. processCount=${processCount:-8}
  83. break
  84. ;;
  85. CLEAN_UP_OLD_TEST_CONTAINERS)
  86. runTest=false
  87. cleanUpTestContainers=true
  88. break
  89. ;;
  90. SET_OR_CHANGE_TEST_ACCOUNT)
  91. runTest=false
  92. cleanUpTestContainers=false
  93. accountSettingsFile="src/test/resources/azure-auth-keys.xml"
  94. if [[ ! -f "$accountSettingsFile" ]];
  95. then
  96. logOutput "No settings present. Creating new settings file ($accountSettingsFile) from template"
  97. cp src/test/resources/azure-auth-keys.xml.template $accountSettingsFile
  98. fi
  99. vi $accountSettingsFile
  100. exit 0
  101. break
  102. ;;
  103. PRINT_LOG4J_LOG_PATHS_FROM_LAST_RUN)
  104. runTest=false
  105. cleanUpTestContainers=false
  106. logFilePaths=/tmp/logPaths
  107. find target/ -name "*output.txt" > $logFilePaths
  108. logOutput "$(cat $logFilePaths)"
  109. rm $logFilePaths
  110. exit 0
  111. break
  112. ;;
  113. *) logOutput "ERROR: Invalid selection"
  114. ;;
  115. esac
  116. done
  117. ## SECTION: COMBINATION DEFINITIONS AND TRIGGER
  118. echo ' '
  119. echo 'Set the active test combination to run the action:'
  120. select combo in HNS-OAuth HNS-SharedKey nonHNS-SharedKey AppendBlob-HNS-OAuth AllCombinationsTestRun Quit
  121. do
  122. case $combo in
  123. HNS-OAuth)
  124. runHNSOAuthTest
  125. break
  126. ;;
  127. HNS-SharedKey)
  128. runHNSSharedKeyTest
  129. break
  130. ;;
  131. nonHNS-SharedKey)
  132. runNonHNSSharedKeyTest
  133. break
  134. ;;
  135. AppendBlob-HNS-OAuth)
  136. runAppendBlobHNSOAuthTest
  137. break
  138. ;;
  139. AllCombinationsTestRun)
  140. if [ $runTest == false ]
  141. then
  142. logOutput "ERROR: Invalid selection for SET_ACTIVE_TEST_CONFIG. This is applicable only for RUN_TEST."
  143. break
  144. fi
  145. runHNSOAuthTest
  146. runHNSSharedKeyTest
  147. runNonHNSSharedKeyTest
  148. runAppendBlobHNSOAuthTest ## Keep this as the last run scenario always
  149. break
  150. ;;
  151. Quit)
  152. exit 0
  153. ;;
  154. *) logOutput "ERROR: Invalid selection"
  155. ;;
  156. esac
  157. done
  158. if [ $runTest == true ]
  159. then
  160. printAggregate
  161. fi