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

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