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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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_mindrecord" 1
  99. HandleRcExit $? 0 0
  100. PytestCmd "test_cache_map.py" "test_cache_map_python_sampler" 1
  101. HandleRcExit $? 0 0
  102. PytestCmd "test_cache_map.py" "test_cache_map_nested_repeat"
  103. HandleRcExit $? 0 0
  104. GetSession
  105. HandleRcExit $? 1 1
  106. export SESSION_ID=$session_id
  107. PytestCmd "test_cache_map.py" "test_cache_map_interrupt_and_rerun"
  108. HandleRcExit $? 0 0
  109. DestroySession $session_id
  110. HandleRcExit $? 1 1
  111. # Run two parallel pipelines (sharing cache)
  112. for i in $(seq 1 2)
  113. do
  114. test_name="test_cache_map_parallel_pipeline${i}"
  115. GetSession
  116. HandleRcExit $? 1 1
  117. export SESSION_ID=$session_id
  118. PytestCmd "test_cache_map.py" "${test_name} --shard 0" &
  119. pids+=("$!")
  120. PytestCmd "test_cache_map.py" "${test_name} --shard 1" &
  121. pids+=("$!")
  122. for pid in "${pids[@]}"; do
  123. wait ${pid}
  124. HandleRcExit $? 0 0
  125. done
  126. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  127. test_count=$(($test_count+1))
  128. DestroySession $session_id
  129. HandleRcExit $? 1 1
  130. done
  131. StopServer
  132. HandleRcExit $? 1 1
  133. sleep 1
  134. # test cache server with --workers 1
  135. cmd="${CACHE_ADMIN} --start --workers 1"
  136. CacheAdminCmd "${cmd}" 0
  137. sleep 1
  138. HandleRcExit $? 0 0
  139. GetSession
  140. HandleRcExit $? 1 1
  141. export SESSION_ID=$session_id
  142. PytestCmd "test_cache_map.py" "test_cache_map_server_workers_1"
  143. HandleRcExit $? 0 0
  144. StopServer
  145. HandleRcExit $? 0 1
  146. # test cache server with --workers 100
  147. cmd="${CACHE_ADMIN} --start --workers 100"
  148. CacheAdminCmd "${cmd}" 0
  149. sleep 1
  150. HandleRcExit $? 0 0
  151. GetSession
  152. HandleRcExit $? 1 1
  153. export SESSION_ID=$session_id
  154. PytestCmd "test_cache_map.py" "test_cache_map_server_workers_100"
  155. HandleRcExit $? 0 0
  156. StopServer
  157. HandleRcExit $? 0 1
  158. # The next set of testing is for the non-mappable cases.
  159. StartServer
  160. HandleRcExit $? 1 1
  161. # This runs all of the basic tests. These will all share the same and we do not destroy
  162. # the session in between each.
  163. GetSession
  164. HandleRcExit $? 1 1
  165. export SESSION_ID=$session_id
  166. PytestCmd "test_cache_nomap.py" "test_cache_nomap_basic" 1
  167. HandleRcExit $? 0 0
  168. DestroySession $session_id
  169. HandleRcExit $? 1 1
  170. # run the small shared cache tests
  171. for i in $(seq 1 4)
  172. do
  173. test_name="test_cache_nomap_allowed_share${i}"
  174. GetSession
  175. HandleRcExit $? 1 1
  176. export SESSION_ID=$session_id
  177. PytestCmd "test_cache_nomap.py" "${test_name}"
  178. HandleRcExit $? 0 0
  179. DestroySession $session_id
  180. HandleRcExit $? 1 1
  181. done
  182. GetSession
  183. HandleRcExit $? 1 1
  184. export SESSION_ID=$session_id
  185. PytestCmd "test_cache_nomap.py" "test_cache_nomap_disallowed_share" 1
  186. HandleRcExit $? 0 0
  187. DestroySession $session_id
  188. HandleRcExit $? 1 1
  189. GetSession
  190. HandleRcExit $? 1 1
  191. export SESSION_ID=$session_id
  192. # Executing the same pipeline for twice under the same session
  193. # Executing the same pipeline for twice (from python)
  194. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice1"
  195. HandleRcExit $? 0 0
  196. # Executing the same pipeline for twice (from shell)
  197. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  198. HandleRcExit $? 0 0
  199. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  200. HandleRcExit $? 0 0
  201. # Executing the same pipeline for twice under the different session
  202. # Executing the same pipeline for twice (from shell)
  203. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  204. HandleRcExit $? 0 0
  205. DestroySession $session_id
  206. HandleRcExit $? 1 1
  207. GetSession
  208. HandleRcExit $? 1 1
  209. export SESSION_ID=$session_id
  210. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  211. HandleRcExit $? 0 0
  212. # Run two parallel pipelines (sharing cache)
  213. for i in $(seq 1 2)
  214. do
  215. test_name="test_cache_nomap_parallel_pipeline${i}"
  216. GetSession
  217. HandleRcExit $? 1 1
  218. export SESSION_ID=$session_id
  219. PytestCmd "test_cache_nomap.py" "${test_name} --shard 0" &
  220. pids+=("$!")
  221. PytestCmd "test_cache_nomap.py" "${test_name} --shard 1" &
  222. pids+=("$!")
  223. PytestCmd "test_cache_nomap.py" "${test_name} --shard 2" &
  224. pids+=("$!")
  225. for pid in "${pids[@]}"; do
  226. wait ${pid}
  227. HandleRcExit $? 0 0
  228. done
  229. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  230. test_count=$(($test_count+1))
  231. DestroySession $session_id
  232. HandleRcExit $? 1 1
  233. done
  234. GetSession
  235. HandleRcExit $? 1 1
  236. export SESSION_ID=$session_id
  237. PytestCmd "test_cache_nomap.py" "test_cache_nomap_parallel_workers"
  238. HandleRcExit $? 0 0
  239. PytestCmd "test_cache_nomap.py" "test_cache_nomap_num_connections" 1
  240. HandleRcExit $? 0 0
  241. PytestCmd "test_cache_nomap.py" "test_cache_nomap_prefetch_size" 1
  242. HandleRcExit $? 0 0
  243. PytestCmd "test_cache_nomap.py" "test_cache_nomap_to_device"
  244. HandleRcExit $? 0 0
  245. PytestCmd "test_cache_nomap.py" "test_cache_nomap_epoch_ctrl" 1
  246. HandleRcExit $? 0 0
  247. PytestCmd "test_cache_nomap.py" "test_cache_nomap_clue" 1
  248. HandleRcExit $? 0 0
  249. PytestCmd "test_cache_nomap.py" "test_cache_nomap_csv" 1
  250. HandleRcExit $? 0 0
  251. PytestCmd "test_cache_nomap.py" "test_cache_nomap_textfile" 1
  252. HandleRcExit $? 0 0
  253. PytestCmd "test_cache_nomap.py" "test_cache_nomap_nested_repeat"
  254. HandleRcExit $? 0 0
  255. PytestCmd "test_cache_nomap.py" "test_cache_nomap_get_repeat_count"
  256. HandleRcExit $? 0 0
  257. PytestCmd "test_cache_nomap.py" "test_cache_nomap_long_file_list"
  258. HandleRcExit $? 0 0
  259. PytestCmd "test_cache_nomap.py" "test_cache_nomap_failure" 1
  260. HandleRcExit $? 0 0
  261. PytestCmd "test_cache_nomap.py" "test_cache_nomap_pyfunc" 1
  262. HandleRcExit $? 0 0
  263. GetSession
  264. HandleRcExit $? 1 1
  265. export SESSION_ID=$session_id
  266. PytestCmd "test_cache_nomap.py" "test_cache_nomap_all_rows_cached"
  267. HandleRcExit $? 0 0
  268. DestroySession $session_id
  269. HandleRcExit $? 1 1
  270. GetSession
  271. HandleRcExit $? 1 1
  272. export SESSION_ID=$session_id
  273. PytestCmd "test_cache_nomap.py" "test_cache_nomap_interrupt_and_rerun"
  274. HandleRcExit $? 0 0
  275. DestroySession $session_id
  276. HandleRcExit $? 1 1
  277. for i in $(seq 1 3)
  278. do
  279. test_name="test_cache_nomap_multiple_cache${i}"
  280. GetSession
  281. HandleRcExit $? 1 1
  282. export SESSION_ID=$session_id
  283. PytestCmd "test_cache_nomap.py" "${test_name}"
  284. HandleRcExit $? 0 0
  285. DestroySession $session_id
  286. HandleRcExit $? 1 1
  287. done
  288. # Create session, run train and eval pipeline concurrently with different cache
  289. GetSession
  290. HandleRcExit $? 1 1
  291. export SESSION_ID=$session_id
  292. PytestCmd "test_cache_nomap.py" "test_cache_nomap_multiple_cache_train" &
  293. pids+=("$!")
  294. PytestCmd "test_cache_nomap.py" "test_cache_nomap_multiple_cache_eval" &
  295. pids+=("$!")
  296. for pid in "${pids[@]}"; do
  297. wait ${pid}
  298. HandleRcExit $? 0 0
  299. done
  300. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  301. test_count=$(($test_count+1))
  302. DestroySession $session_id
  303. HandleRcExit $? 1 1
  304. # Create session, use it to run a pipeline, and destroy the session while pipeline is running
  305. GetSession
  306. HandleRcExit $? 1 1
  307. export SESSION_ID=$session_id
  308. PytestCmd "test_cache_nomap.py" "test_cache_nomap_session_destroy" &
  309. pid=$!
  310. sleep 10
  311. DestroySession $session_id
  312. HandleRcExit $? 1 1
  313. wait ${pid}
  314. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  315. test_count=$(($test_count+1))
  316. # Stop cache server while pipeline is running
  317. GetSession
  318. HandleRcExit $? 1 1
  319. export SESSION_ID=$session_id
  320. PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_stop" &
  321. pid=$!
  322. sleep 10
  323. StopServer
  324. HandleRcExit $? 1 1
  325. sleep 1
  326. wait ${pid}
  327. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  328. test_count=$(($test_count+1))
  329. # test cache server with --workers 1
  330. cmd="${CACHE_ADMIN} --start --workers 1"
  331. CacheAdminCmd "${cmd}" 0
  332. sleep 1
  333. HandleRcExit $? 0 0
  334. GetSession
  335. HandleRcExit $? 1 1
  336. export SESSION_ID=$session_id
  337. PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_workers_1"
  338. HandleRcExit $? 0 0
  339. StopServer
  340. HandleRcExit $? 0 1
  341. # test cache server with --workers 100
  342. cmd="${CACHE_ADMIN} --start --workers 100"
  343. CacheAdminCmd "${cmd}" 0
  344. sleep 1
  345. HandleRcExit $? 0 0
  346. GetSession
  347. HandleRcExit $? 1 1
  348. export SESSION_ID=$session_id
  349. PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_workers_100"
  350. HandleRcExit $? 0 0
  351. StopServer
  352. HandleRcExit $? 0 1
  353. # start cache server with a spilling path
  354. cmd="${CACHE_ADMIN} --start -s /tmp"
  355. CacheAdminCmd "${cmd}" 0
  356. sleep 1
  357. HandleRcExit $? 0 0
  358. GetSession
  359. HandleRcExit $? 1 1
  360. export SESSION_ID=$session_id
  361. # Set size parameter of mappable DatasetCache to a extra small value
  362. PytestCmd "test_cache_map.py" "test_cache_map_extra_small_size" 1
  363. HandleRcExit $? 0 0
  364. # Set size parameter of non-mappable DatasetCache to a extra small value
  365. PytestCmd "test_cache_nomap.py" "test_cache_nomap_extra_small_size" 1
  366. HandleRcExit $? 0 0
  367. StopServer
  368. HandleRcExit $? 0 1
  369. unset RUN_CACHE_TEST
  370. unset SESSION_ID
  371. exit ${failed_tests}