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

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