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 13 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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. export SKIP_ADMIN_COUNTER=true
  18. declare session_id failed_tests
  19. . cachetest_lib.sh
  20. echo
  21. ################################################################################
  22. # Cache testing: cache python test driver #
  23. # Summary: Various tests for running the python testcases for caching #
  24. ################################################################################
  25. StartServer
  26. HandleRcExit $? 1 1
  27. # Set the environment variable to enable these pytests
  28. export RUN_CACHE_TEST=TRUE
  29. # Each of these tests will create session, use it, then destroy it after the test
  30. for i in $(seq 1 5)
  31. do
  32. test_name="test_cache_map_basic${i}"
  33. GetSession
  34. HandleRcExit $? 1 1
  35. export SESSION_ID=$session_id
  36. PytestCmd "test_cache_map.py" "${test_name}"
  37. HandleRcExit $? 0 0
  38. DestroySession $session_id
  39. HandleRcExit $? 1 1
  40. done
  41. GetSession
  42. HandleRcExit $? 1 1
  43. export SESSION_ID=$session_id
  44. # use pytest pattern match to run all the tests that match the name test_cache_map_failure.
  45. # All of these tests will interact with the same cache session and may result in multiple
  46. # caches under the common session handle (although these are failure tests so probably not)
  47. PytestCmd "test_cache_map.py" "test_cache_map_failure" 1
  48. HandleRcExit $? 0 0
  49. PytestCmd "test_cache_map.py" "test_cache_map_split" 1
  50. HandleRcExit $? 0 0
  51. # DatasetCache parameter check
  52. PytestCmd "test_cache_map.py" "test_cache_map_parameter_check"
  53. HandleRcExit $? 0 0
  54. # Executing the same pipeline for twice under the same session
  55. # Executing the same pipeline for twice (from python)
  56. PytestCmd "test_cache_map.py" "test_cache_map_running_twice1"
  57. HandleRcExit $? 0 0
  58. # Executing the same pipeline for twice (from shell)
  59. PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
  60. HandleRcExit $? 0 0
  61. PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
  62. HandleRcExit $? 0 0
  63. # Executing the same pipeline for twice under the different session
  64. # Executing the same pipeline for twice (from shell)
  65. PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
  66. HandleRcExit $? 0 0
  67. DestroySession $session_id
  68. HandleRcExit $? 1 1
  69. GetSession
  70. HandleRcExit $? 1 1
  71. export SESSION_ID=$session_id
  72. PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
  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. PytestCmd "test_cache_map.py" "test_cache_map_coco" 1
  87. HandleRcExit $? 0 0
  88. PytestCmd "test_cache_map.py" "test_cache_map_mnist" 1
  89. HandleRcExit $? 0 0
  90. PytestCmd "test_cache_map.py" "test_cache_map_celeba" 1
  91. HandleRcExit $? 0 0
  92. PytestCmd "test_cache_map.py" "test_cache_map_manifest" 1
  93. HandleRcExit $? 0 0
  94. PytestCmd "test_cache_map.py" "test_cache_map_cifar" 1
  95. HandleRcExit $? 0 0
  96. PytestCmd "test_cache_map.py" "test_cache_map_voc" 1
  97. HandleRcExit $? 0 0
  98. PytestCmd "test_cache_map.py" "test_cache_map_python_sampler" 1
  99. HandleRcExit $? 0 0
  100. PytestCmd "test_cache_map.py" "test_cache_map_nested_repeat"
  101. HandleRcExit $? 0 0
  102. GetSession
  103. HandleRcExit $? 1 1
  104. export SESSION_ID=$session_id
  105. PytestCmd "test_cache_map.py" "test_cache_map_interrupt_and_rerun"
  106. HandleRcExit $? 0 0
  107. DestroySession $session_id
  108. HandleRcExit $? 1 1
  109. # Run two parallel pipelines (sharing cache)
  110. for i in $(seq 1 2)
  111. do
  112. test_name="test_cache_map_parallel_pipeline${i}"
  113. GetSession
  114. HandleRcExit $? 1 1
  115. export SESSION_ID=$session_id
  116. PytestCmd "test_cache_map.py" "${test_name} --shard 0" &
  117. pids+=("$!")
  118. PytestCmd "test_cache_map.py" "${test_name} --shard 1" &
  119. pids+=("$!")
  120. for pid in "${pids[@]}"; do
  121. wait ${pid}
  122. HandleRcExit $? 0 0
  123. done
  124. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  125. test_count=$(($test_count+1))
  126. DestroySession $session_id
  127. HandleRcExit $? 1 1
  128. done
  129. StopServer
  130. HandleRcExit $? 1 1
  131. sleep 1
  132. # test cache server with --workers 1
  133. cmd="${CACHE_ADMIN} --start --workers 1"
  134. CacheAdminCmd "${cmd}" 0
  135. sleep 1
  136. HandleRcExit $? 0 0
  137. GetSession
  138. HandleRcExit $? 1 1
  139. export SESSION_ID=$session_id
  140. PytestCmd "test_cache_map.py" "test_cache_map_server_workers_1"
  141. HandleRcExit $? 0 0
  142. StopServer
  143. HandleRcExit $? 0 1
  144. # test cache server with --workers 100
  145. cmd="${CACHE_ADMIN} --start --workers 100"
  146. CacheAdminCmd "${cmd}" 0
  147. sleep 1
  148. HandleRcExit $? 0 0
  149. GetSession
  150. HandleRcExit $? 1 1
  151. export SESSION_ID=$session_id
  152. PytestCmd "test_cache_map.py" "test_cache_map_server_workers_100"
  153. HandleRcExit $? 0 0
  154. StopServer
  155. HandleRcExit $? 0 1
  156. # The next set of testing is for the non-mappable cases.
  157. StartServer
  158. HandleRcExit $? 1 1
  159. # This runs all of the basic tests. These will all share the same and we do not destroy
  160. # the session in between each.
  161. GetSession
  162. HandleRcExit $? 1 1
  163. export SESSION_ID=$session_id
  164. PytestCmd "test_cache_nomap.py" "test_cache_nomap_basic" 1
  165. HandleRcExit $? 0 0
  166. DestroySession $session_id
  167. HandleRcExit $? 1 1
  168. # run the small shared cache tests
  169. for i in $(seq 1 4)
  170. do
  171. test_name="test_cache_nomap_allowed_share${i}"
  172. GetSession
  173. HandleRcExit $? 1 1
  174. export SESSION_ID=$session_id
  175. PytestCmd "test_cache_nomap.py" "${test_name}"
  176. HandleRcExit $? 0 0
  177. DestroySession $session_id
  178. HandleRcExit $? 1 1
  179. done
  180. GetSession
  181. HandleRcExit $? 1 1
  182. export SESSION_ID=$session_id
  183. PytestCmd "test_cache_nomap.py" "test_cache_nomap_disallowed_share" 1
  184. HandleRcExit $? 0 0
  185. DestroySession $session_id
  186. HandleRcExit $? 1 1
  187. GetSession
  188. HandleRcExit $? 1 1
  189. export SESSION_ID=$session_id
  190. # Executing the same pipeline for twice under the same session
  191. # Executing the same pipeline for twice (from python)
  192. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice1"
  193. HandleRcExit $? 0 0
  194. # Executing the same pipeline for twice (from shell)
  195. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  196. HandleRcExit $? 0 0
  197. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  198. HandleRcExit $? 0 0
  199. # Executing the same pipeline for twice under the different session
  200. # Executing the same pipeline for twice (from shell)
  201. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  202. HandleRcExit $? 0 0
  203. DestroySession $session_id
  204. HandleRcExit $? 1 1
  205. GetSession
  206. HandleRcExit $? 1 1
  207. export SESSION_ID=$session_id
  208. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  209. HandleRcExit $? 0 0
  210. # Run two parallel pipelines (sharing cache)
  211. for i in $(seq 1 2)
  212. do
  213. test_name="test_cache_nomap_parallel_pipeline${i}"
  214. GetSession
  215. HandleRcExit $? 1 1
  216. export SESSION_ID=$session_id
  217. PytestCmd "test_cache_nomap.py" "${test_name} --shard 0" &
  218. pids+=("$!")
  219. PytestCmd "test_cache_nomap.py" "${test_name} --shard 1" &
  220. pids+=("$!")
  221. PytestCmd "test_cache_nomap.py" "${test_name} --shard 2" &
  222. pids+=("$!")
  223. for pid in "${pids[@]}"; do
  224. wait ${pid}
  225. HandleRcExit $? 0 0
  226. done
  227. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  228. test_count=$(($test_count+1))
  229. DestroySession $session_id
  230. HandleRcExit $? 1 1
  231. done
  232. GetSession
  233. HandleRcExit $? 1 1
  234. export SESSION_ID=$session_id
  235. PytestCmd "test_cache_nomap.py" "test_cache_nomap_parallel_workers"
  236. HandleRcExit $? 0 0
  237. PytestCmd "test_cache_nomap.py" "test_cache_nomap_num_connections" 1
  238. HandleRcExit $? 0 0
  239. PytestCmd "test_cache_nomap.py" "test_cache_nomap_prefetch_size" 1
  240. HandleRcExit $? 0 0
  241. PytestCmd "test_cache_nomap.py" "test_cache_nomap_to_device"
  242. HandleRcExit $? 0 0
  243. PytestCmd "test_cache_nomap.py" "test_cache_nomap_epoch_ctrl" 1
  244. HandleRcExit $? 0 0
  245. PytestCmd "test_cache_nomap.py" "test_cache_nomap_clue" 1
  246. HandleRcExit $? 0 0
  247. PytestCmd "test_cache_nomap.py" "test_cache_nomap_csv" 1
  248. HandleRcExit $? 0 0
  249. PytestCmd "test_cache_nomap.py" "test_cache_nomap_textfile" 1
  250. HandleRcExit $? 0 0
  251. PytestCmd "test_cache_nomap.py" "test_cache_nomap_nested_repeat"
  252. HandleRcExit $? 0 0
  253. PytestCmd "test_cache_nomap.py" "test_cache_nomap_get_repeat_count"
  254. HandleRcExit $? 0 0
  255. PytestCmd "test_cache_nomap.py" "test_cache_nomap_long_file_list"
  256. HandleRcExit $? 0 0
  257. PytestCmd "test_cache_nomap.py" "test_cache_nomap_failure" 1
  258. HandleRcExit $? 0 0
  259. PytestCmd "test_cache_nomap.py" "test_cache_nomap_pyfunc" 1
  260. HandleRcExit $? 0 0
  261. GetSession
  262. HandleRcExit $? 1 1
  263. export SESSION_ID=$session_id
  264. PytestCmd "test_cache_nomap.py" "test_cache_nomap_all_rows_cached"
  265. HandleRcExit $? 0 0
  266. DestroySession $session_id
  267. HandleRcExit $? 1 1
  268. GetSession
  269. HandleRcExit $? 1 1
  270. export SESSION_ID=$session_id
  271. PytestCmd "test_cache_nomap.py" "test_cache_nomap_interrupt_and_rerun"
  272. HandleRcExit $? 0 0
  273. DestroySession $session_id
  274. HandleRcExit $? 1 1
  275. for i in $(seq 1 3)
  276. do
  277. test_name="test_cache_nomap_multiple_cache${i}"
  278. GetSession
  279. HandleRcExit $? 1 1
  280. export SESSION_ID=$session_id
  281. PytestCmd "test_cache_nomap.py" "${test_name}"
  282. HandleRcExit $? 0 0
  283. DestroySession $session_id
  284. HandleRcExit $? 1 1
  285. done
  286. # Create session, run train and eval pipeline concurrently with different cache
  287. GetSession
  288. HandleRcExit $? 1 1
  289. export SESSION_ID=$session_id
  290. PytestCmd "test_cache_nomap.py" "test_cache_nomap_multiple_cache_train" &
  291. pids+=("$!")
  292. PytestCmd "test_cache_nomap.py" "test_cache_nomap_multiple_cache_eval" &
  293. pids+=("$!")
  294. for pid in "${pids[@]}"; do
  295. wait ${pid}
  296. HandleRcExit $? 0 0
  297. done
  298. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  299. test_count=$(($test_count+1))
  300. DestroySession $session_id
  301. HandleRcExit $? 1 1
  302. # Create session, use it to run a pipeline, and destroy the session while pipeline is running
  303. GetSession
  304. HandleRcExit $? 1 1
  305. export SESSION_ID=$session_id
  306. PytestCmd "test_cache_nomap.py" "test_cache_nomap_session_destroy" &
  307. pid=$!
  308. sleep 10
  309. DestroySession $session_id
  310. HandleRcExit $? 1 1
  311. wait ${pid}
  312. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  313. test_count=$(($test_count+1))
  314. # Stop cache server while pipeline is running
  315. GetSession
  316. HandleRcExit $? 1 1
  317. export SESSION_ID=$session_id
  318. PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_stop" &
  319. pid=$!
  320. sleep 10
  321. StopServer
  322. HandleRcExit $? 1 1
  323. sleep 1
  324. wait ${pid}
  325. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  326. test_count=$(($test_count+1))
  327. # test cache server with --workers 1
  328. cmd="${CACHE_ADMIN} --start --workers 1"
  329. CacheAdminCmd "${cmd}" 0
  330. sleep 1
  331. HandleRcExit $? 0 0
  332. GetSession
  333. HandleRcExit $? 1 1
  334. export SESSION_ID=$session_id
  335. PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_workers_1"
  336. HandleRcExit $? 0 0
  337. StopServer
  338. HandleRcExit $? 0 1
  339. # test cache server with --workers 100
  340. cmd="${CACHE_ADMIN} --start --workers 100"
  341. CacheAdminCmd "${cmd}" 0
  342. sleep 1
  343. HandleRcExit $? 0 0
  344. GetSession
  345. HandleRcExit $? 1 1
  346. export SESSION_ID=$session_id
  347. PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_workers_100"
  348. HandleRcExit $? 0 0
  349. StopServer
  350. HandleRcExit $? 0 1
  351. # start cache server with a spilling path
  352. cmd="${CACHE_ADMIN} --start -s /tmp"
  353. CacheAdminCmd "${cmd}" 0
  354. sleep 1
  355. HandleRcExit $? 0 0
  356. GetSession
  357. HandleRcExit $? 1 1
  358. export SESSION_ID=$session_id
  359. # Set size parameter of mappable DatasetCache to a extra small value
  360. PytestCmd "test_cache_map.py" "test_cache_map_extra_small_size" 1
  361. HandleRcExit $? 0 0
  362. # Set size parameter of non-mappable DatasetCache to a extra small value
  363. PytestCmd "test_cache_nomap.py" "test_cache_nomap_extra_small_size" 1
  364. HandleRcExit $? 0 0
  365. StopServer
  366. HandleRcExit $? 0 1
  367. unset RUN_CACHE_TEST
  368. unset SESSION_ID
  369. exit ${failed_tests}