You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cachetest_py.sh 11 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. #!/bin/bash
  2. # Copyright 2019 Huawei Technologies Co., Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # ============================================================================
  16. # source the globals and functions for use with cache testing
  17. SKIP_ADMIN_COUNTER=true
  18. . cachetest_lib.sh
  19. echo
  20. ################################################################################
  21. # Cache testing: cache python test driver #
  22. # Summary: Various tests for running the python testcases for caching #
  23. ################################################################################
  24. StartServer
  25. HandleRcExit $? 1 1
  26. # Set the environment variable to enable these pytests
  27. export RUN_CACHE_TEST=TRUE
  28. # Each of these tests will create session, use it, then destroy it after the test
  29. for i in $(seq 1 6)
  30. do
  31. test_name="test_cache_map_basic${i}"
  32. GetSession
  33. HandleRcExit $? 1 1
  34. export SESSION_ID=$session_id
  35. PytestCmd "test_cache_map.py" "${test_name}"
  36. HandleRcExit $? 0 0
  37. DestroySession $session_id
  38. HandleRcExit $? 1 1
  39. done
  40. GetSession
  41. HandleRcExit $? 1 1
  42. export SESSION_ID=$session_id
  43. # use pytest pattern match to run all the tests that match the name test_cache_map_failure.
  44. # All of these tests will interact with the same cache session and may result in multiple
  45. # caches under the common session handle (although these are failure tests so probably not)
  46. PytestCmd "test_cache_map.py" "test_cache_map_failure" 1
  47. HandleRcExit $? 0 0
  48. # DatasetCache parameter check
  49. PytestCmd "test_cache_map.py" "test_cache_map_parameter_check"
  50. HandleRcExit $? 0 0
  51. # Executing the same pipeline for twice under the same session
  52. # Executing the same pipeline for twice (from python)
  53. PytestCmd "test_cache_map.py" "test_cache_map_running_twice1"
  54. HandleRcExit $? 0 0
  55. # Executing the same pipeline for twice (from shell)
  56. PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
  57. HandleRcExit $? 0 0
  58. PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
  59. HandleRcExit $? 0 0
  60. # Executing the same pipeline for twice under the different session
  61. # Executing the same pipeline for twice (from shell)
  62. PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
  63. HandleRcExit $? 0 0
  64. DestroySession $session_id
  65. HandleRcExit $? 1 1
  66. GetSession
  67. HandleRcExit $? 1 1
  68. export SESSION_ID=$session_id
  69. PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
  70. HandleRcExit $? 0 0
  71. # Set size parameter of DatasetCache to a extra small value
  72. PytestCmd "test_cache_map.py" "test_cache_map_extra_small_size" 1
  73. HandleRcExit $? 0 0
  74. PytestCmd "test_cache_map.py" "test_cache_map_no_image"
  75. HandleRcExit $? 0 0
  76. PytestCmd "test_cache_map.py" "test_cache_map_parallel_workers"
  77. HandleRcExit $? 0 0
  78. PytestCmd "test_cache_map.py" "test_cache_map_num_connections" 1
  79. HandleRcExit $? 0 0
  80. PytestCmd "test_cache_map.py" "test_cache_map_prefetch_size" 1
  81. HandleRcExit $? 0 0
  82. PytestCmd "test_cache_map.py" "test_cache_map_to_device"
  83. HandleRcExit $? 0 0
  84. PytestCmd "test_cache_map.py" "test_cache_map_epoch_ctrl" 1
  85. HandleRcExit $? 0 0
  86. # Run two parallel pipelines (sharing cache)
  87. for i in $(seq 1 2)
  88. do
  89. test_name="test_cache_map_parallel_pipeline${i}"
  90. GetSession
  91. HandleRcExit $? 1 1
  92. export SESSION_ID=$session_id
  93. PytestCmd "test_cache_map.py" "${test_name} --shard 0" &
  94. pids+=("$!")
  95. PytestCmd "test_cache_map.py" "${test_name} --shard 1" &
  96. pids+=("$!")
  97. for pid in "${pids[@]}"; do
  98. wait ${pid}
  99. HandleRcExit $? 0 0
  100. done
  101. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  102. test_count=$(($test_count+1))
  103. DestroySession $session_id
  104. HandleRcExit $? 1 1
  105. done
  106. StopServer
  107. HandleRcExit $? 1 1
  108. sleep 1
  109. # test cache server with --workers 1
  110. cmd="${CACHE_ADMIN} --start --workers 1"
  111. CacheAdminCmd "${cmd}" 0
  112. sleep 1
  113. HandleRcExit $? 0 0
  114. GetSession
  115. HandleRcExit $? 1 1
  116. export SESSION_ID=$session_id
  117. PytestCmd "test_cache_map.py" "test_cache_map_server_workers_1"
  118. HandleRcExit $? 0 0
  119. StopServer
  120. HandleRcExit $? 0 1
  121. # test cache server with --workers 100
  122. cmd="${CACHE_ADMIN} --start --workers 100"
  123. CacheAdminCmd "${cmd}" 0
  124. sleep 1
  125. HandleRcExit $? 0 0
  126. GetSession
  127. HandleRcExit $? 1 1
  128. export SESSION_ID=$session_id
  129. PytestCmd "test_cache_map.py" "test_cache_map_server_workers_100"
  130. HandleRcExit $? 0 0
  131. StopServer
  132. HandleRcExit $? 0 1
  133. # The next set of testing is for the non-mappable cases.
  134. StartServer
  135. HandleRcExit $? 1 1
  136. # This runs all of the basic tests. These will all share the same and we do not destroy
  137. # the session in between each.
  138. GetSession
  139. HandleRcExit $? 1 1
  140. export SESSION_ID=$session_id
  141. PytestCmd "test_cache_nomap.py" "test_cache_nomap_basic" 1
  142. HandleRcExit $? 0 0
  143. DestroySession $session_id
  144. HandleRcExit $? 1 1
  145. # run the small shared cache tests
  146. for i in $(seq 1 4)
  147. do
  148. test_name="test_cache_nomap_allowed_share${i}"
  149. GetSession
  150. HandleRcExit $? 1 1
  151. export SESSION_ID=$session_id
  152. PytestCmd "test_cache_nomap.py" "${test_name}"
  153. HandleRcExit $? 0 0
  154. DestroySession $session_id
  155. HandleRcExit $? 1 1
  156. done
  157. GetSession
  158. HandleRcExit $? 1 1
  159. export SESSION_ID=$session_id
  160. PytestCmd "test_cache_nomap.py" "test_cache_nomap_disallowed_share" 1
  161. HandleRcExit $? 0 0
  162. DestroySession $session_id
  163. HandleRcExit $? 1 1
  164. GetSession
  165. HandleRcExit $? 1 1
  166. export SESSION_ID=$session_id
  167. # Executing the same pipeline for twice under the same session
  168. # Executing the same pipeline for twice (from python)
  169. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice1"
  170. HandleRcExit $? 0 0
  171. # Executing the same pipeline for twice (from shell)
  172. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  173. HandleRcExit $? 0 0
  174. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  175. HandleRcExit $? 0 0
  176. # Executing the same pipeline for twice under the different session
  177. # Executing the same pipeline for twice (from shell)
  178. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  179. HandleRcExit $? 0 0
  180. DestroySession $session_id
  181. HandleRcExit $? 1 1
  182. GetSession
  183. HandleRcExit $? 1 1
  184. export SESSION_ID=$session_id
  185. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  186. HandleRcExit $? 0 0
  187. # Set size parameter of DatasetCache to a extra small value
  188. GetSession
  189. HandleRcExit $? 1 1
  190. export SESSION_ID=$session_id
  191. PytestCmd "test_cache_nomap.py" "test_cache_nomap_extra_small_size" 1
  192. HandleRcExit $? 0 0
  193. DestroySession $session_id
  194. HandleRcExit $? 1 1
  195. # Run two parallel pipelines (sharing cache)
  196. for i in $(seq 1 2)
  197. do
  198. test_name="test_cache_nomap_parallel_pipeline${i}"
  199. GetSession
  200. HandleRcExit $? 1 1
  201. export SESSION_ID=$session_id
  202. PytestCmd "test_cache_nomap.py" "${test_name} --shard 0" &
  203. pids+=("$!")
  204. PytestCmd "test_cache_nomap.py" "${test_name} --shard 1" &
  205. pids+=("$!")
  206. PytestCmd "test_cache_nomap.py" "${test_name} --shard 2" &
  207. pids+=("$!")
  208. for pid in "${pids[@]}"; do
  209. wait ${pid}
  210. HandleRcExit $? 0 0
  211. done
  212. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  213. test_count=$(($test_count+1))
  214. DestroySession $session_id
  215. HandleRcExit $? 1 1
  216. done
  217. GetSession
  218. HandleRcExit $? 1 1
  219. export SESSION_ID=$session_id
  220. PytestCmd "test_cache_nomap.py" "test_cache_nomap_parallel_workers"
  221. HandleRcExit $? 0 0
  222. PytestCmd "test_cache_nomap.py" "test_cache_nomap_num_connections" 1
  223. HandleRcExit $? 0 0
  224. PytestCmd "test_cache_nomap.py" "test_cache_nomap_prefetch_size" 1
  225. HandleRcExit $? 0 0
  226. PytestCmd "test_cache_nomap.py" "test_cache_nomap_to_device"
  227. HandleRcExit $? 0 0
  228. PytestCmd "test_cache_nomap.py" "test_cache_nomap_epoch_ctrl" 1
  229. HandleRcExit $? 0 0
  230. for i in $(seq 1 3)
  231. do
  232. test_name="test_cache_nomap_multiple_cache${i}"
  233. GetSession
  234. HandleRcExit $? 1 1
  235. export SESSION_ID=$session_id
  236. PytestCmd "test_cache_nomap.py" "${test_name}"
  237. HandleRcExit $? 0 0
  238. DestroySession $session_id
  239. HandleRcExit $? 1 1
  240. done
  241. # Create session, run train and eval pipeline concurrently with different cache
  242. GetSession
  243. HandleRcExit $? 1 1
  244. export SESSION_ID=$session_id
  245. PytestCmd "test_cache_nomap.py" "test_cache_nomap_multiple_cache_train" &
  246. pids+=("$!")
  247. PytestCmd "test_cache_nomap.py" "test_cache_nomap_multiple_cache_eval" &
  248. pids+=("$!")
  249. for pid in "${pids[@]}"; do
  250. wait ${pid}
  251. HandleRcExit $? 0 0
  252. done
  253. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  254. test_count=$(($test_count+1))
  255. DestroySession $session_id
  256. HandleRcExit $? 1 1
  257. # Create session, use it to run a pipeline, and destroy the session while pipeline is running
  258. GetSession
  259. HandleRcExit $? 1 1
  260. export SESSION_ID=$session_id
  261. PytestCmd "test_cache_nomap.py" "test_cache_nomap_session_destroy" &
  262. pid=("$!")
  263. sleep 10
  264. DestroySession $session_id
  265. HandleRcExit $? 1 1
  266. wait ${pid}
  267. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  268. test_count=$(($test_count+1))
  269. # Stop cache server while pipeline is running
  270. GetSession
  271. HandleRcExit $? 1 1
  272. export SESSION_ID=$session_id
  273. PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_stop" &
  274. pid=("$!")
  275. sleep 10
  276. StopServer
  277. HandleRcExit $? 1 1
  278. sleep 1
  279. wait ${pid}
  280. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  281. test_count=$(($test_count+1))
  282. # test cache server with --workers 1
  283. cmd="${CACHE_ADMIN} --start --workers 1"
  284. CacheAdminCmd "${cmd}" 0
  285. sleep 1
  286. HandleRcExit $? 0 0
  287. GetSession
  288. HandleRcExit $? 1 1
  289. export SESSION_ID=$session_id
  290. PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_workers_1"
  291. HandleRcExit $? 0 0
  292. StopServer
  293. HandleRcExit $? 0 1
  294. # test cache server with --workers 100
  295. cmd="${CACHE_ADMIN} --start --workers 100"
  296. CacheAdminCmd "${cmd}" 0
  297. sleep 1
  298. HandleRcExit $? 0 0
  299. GetSession
  300. HandleRcExit $? 1 1
  301. export SESSION_ID=$session_id
  302. PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_workers_100"
  303. HandleRcExit $? 0 0
  304. StopServer
  305. HandleRcExit $? 0 1
  306. unset RUN_CACHE_TEST
  307. unset SESSION_ID
  308. exit ${failed_tests}