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

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