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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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 5)
  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. PytestCmd "test_cache_map.py" "test_cache_map_split" 1
  49. HandleRcExit $? 0 0
  50. # DatasetCache parameter check
  51. PytestCmd "test_cache_map.py" "test_cache_map_parameter_check"
  52. HandleRcExit $? 0 0
  53. # Executing the same pipeline for twice under the same session
  54. # Executing the same pipeline for twice (from python)
  55. PytestCmd "test_cache_map.py" "test_cache_map_running_twice1"
  56. HandleRcExit $? 0 0
  57. # Executing the same pipeline for twice (from shell)
  58. PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
  59. HandleRcExit $? 0 0
  60. PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
  61. HandleRcExit $? 0 0
  62. # Executing the same pipeline for twice under the different session
  63. # Executing the same pipeline for twice (from shell)
  64. PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
  65. HandleRcExit $? 0 0
  66. DestroySession $session_id
  67. HandleRcExit $? 1 1
  68. GetSession
  69. HandleRcExit $? 1 1
  70. export SESSION_ID=$session_id
  71. PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
  72. HandleRcExit $? 0 0
  73. # Set size parameter of DatasetCache to a extra small value
  74. PytestCmd "test_cache_map.py" "test_cache_map_extra_small_size" 1
  75. HandleRcExit $? 0 0
  76. PytestCmd "test_cache_map.py" "test_cache_map_no_image"
  77. HandleRcExit $? 0 0
  78. PytestCmd "test_cache_map.py" "test_cache_map_parallel_workers"
  79. HandleRcExit $? 0 0
  80. PytestCmd "test_cache_map.py" "test_cache_map_num_connections" 1
  81. HandleRcExit $? 0 0
  82. PytestCmd "test_cache_map.py" "test_cache_map_prefetch_size" 1
  83. HandleRcExit $? 0 0
  84. PytestCmd "test_cache_map.py" "test_cache_map_to_device"
  85. HandleRcExit $? 0 0
  86. PytestCmd "test_cache_map.py" "test_cache_map_epoch_ctrl" 1
  87. HandleRcExit $? 0 0
  88. PytestCmd "test_cache_map.py" "test_cache_map_coco" 1
  89. HandleRcExit $? 0 0
  90. PytestCmd "test_cache_map.py" "test_cache_map_mnist" 1
  91. HandleRcExit $? 0 0
  92. PytestCmd "test_cache_map.py" "test_cache_map_celeba" 1
  93. HandleRcExit $? 0 0
  94. PytestCmd "test_cache_map.py" "test_cache_map_manifest" 1
  95. HandleRcExit $? 0 0
  96. PytestCmd "test_cache_map.py" "test_cache_map_cifar" 1
  97. HandleRcExit $? 0 0
  98. PytestCmd "test_cache_map.py" "test_cache_map_voc" 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. # Run two parallel pipelines (sharing cache)
  105. for i in $(seq 1 2)
  106. do
  107. test_name="test_cache_map_parallel_pipeline${i}"
  108. GetSession
  109. HandleRcExit $? 1 1
  110. export SESSION_ID=$session_id
  111. PytestCmd "test_cache_map.py" "${test_name} --shard 0" &
  112. pids+=("$!")
  113. PytestCmd "test_cache_map.py" "${test_name} --shard 1" &
  114. pids+=("$!")
  115. for pid in "${pids[@]}"; do
  116. wait ${pid}
  117. HandleRcExit $? 0 0
  118. done
  119. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  120. test_count=$(($test_count+1))
  121. DestroySession $session_id
  122. HandleRcExit $? 1 1
  123. done
  124. StopServer
  125. HandleRcExit $? 1 1
  126. sleep 1
  127. # test cache server with --workers 1
  128. cmd="${CACHE_ADMIN} --start --workers 1"
  129. CacheAdminCmd "${cmd}" 0
  130. sleep 1
  131. HandleRcExit $? 0 0
  132. GetSession
  133. HandleRcExit $? 1 1
  134. export SESSION_ID=$session_id
  135. PytestCmd "test_cache_map.py" "test_cache_map_server_workers_1"
  136. HandleRcExit $? 0 0
  137. StopServer
  138. HandleRcExit $? 0 1
  139. # test cache server with --workers 100
  140. cmd="${CACHE_ADMIN} --start --workers 100"
  141. CacheAdminCmd "${cmd}" 0
  142. sleep 1
  143. HandleRcExit $? 0 0
  144. GetSession
  145. HandleRcExit $? 1 1
  146. export SESSION_ID=$session_id
  147. PytestCmd "test_cache_map.py" "test_cache_map_server_workers_100"
  148. HandleRcExit $? 0 0
  149. StopServer
  150. HandleRcExit $? 0 1
  151. # The next set of testing is for the non-mappable cases.
  152. StartServer
  153. HandleRcExit $? 1 1
  154. # This runs all of the basic tests. These will all share the same and we do not destroy
  155. # the session in between each.
  156. GetSession
  157. HandleRcExit $? 1 1
  158. export SESSION_ID=$session_id
  159. PytestCmd "test_cache_nomap.py" "test_cache_nomap_basic" 1
  160. HandleRcExit $? 0 0
  161. DestroySession $session_id
  162. HandleRcExit $? 1 1
  163. # run the small shared cache tests
  164. for i in $(seq 1 4)
  165. do
  166. test_name="test_cache_nomap_allowed_share${i}"
  167. GetSession
  168. HandleRcExit $? 1 1
  169. export SESSION_ID=$session_id
  170. PytestCmd "test_cache_nomap.py" "${test_name}"
  171. HandleRcExit $? 0 0
  172. DestroySession $session_id
  173. HandleRcExit $? 1 1
  174. done
  175. GetSession
  176. HandleRcExit $? 1 1
  177. export SESSION_ID=$session_id
  178. PytestCmd "test_cache_nomap.py" "test_cache_nomap_disallowed_share" 1
  179. HandleRcExit $? 0 0
  180. DestroySession $session_id
  181. HandleRcExit $? 1 1
  182. GetSession
  183. HandleRcExit $? 1 1
  184. export SESSION_ID=$session_id
  185. # Executing the same pipeline for twice under the same session
  186. # Executing the same pipeline for twice (from python)
  187. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice1"
  188. HandleRcExit $? 0 0
  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. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  193. HandleRcExit $? 0 0
  194. # Executing the same pipeline for twice under the different session
  195. # Executing the same pipeline for twice (from shell)
  196. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  197. HandleRcExit $? 0 0
  198. DestroySession $session_id
  199. HandleRcExit $? 1 1
  200. GetSession
  201. HandleRcExit $? 1 1
  202. export SESSION_ID=$session_id
  203. PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
  204. HandleRcExit $? 0 0
  205. # Set size parameter of DatasetCache to a extra small value
  206. GetSession
  207. HandleRcExit $? 1 1
  208. export SESSION_ID=$session_id
  209. PytestCmd "test_cache_nomap.py" "test_cache_nomap_extra_small_size" 1
  210. HandleRcExit $? 0 0
  211. DestroySession $session_id
  212. HandleRcExit $? 1 1
  213. # Run two parallel pipelines (sharing cache)
  214. for i in $(seq 1 2)
  215. do
  216. test_name="test_cache_nomap_parallel_pipeline${i}"
  217. GetSession
  218. HandleRcExit $? 1 1
  219. export SESSION_ID=$session_id
  220. PytestCmd "test_cache_nomap.py" "${test_name} --shard 0" &
  221. pids+=("$!")
  222. PytestCmd "test_cache_nomap.py" "${test_name} --shard 1" &
  223. pids+=("$!")
  224. PytestCmd "test_cache_nomap.py" "${test_name} --shard 2" &
  225. pids+=("$!")
  226. for pid in "${pids[@]}"; do
  227. wait ${pid}
  228. HandleRcExit $? 0 0
  229. done
  230. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  231. test_count=$(($test_count+1))
  232. DestroySession $session_id
  233. HandleRcExit $? 1 1
  234. done
  235. GetSession
  236. HandleRcExit $? 1 1
  237. export SESSION_ID=$session_id
  238. PytestCmd "test_cache_nomap.py" "test_cache_nomap_parallel_workers"
  239. HandleRcExit $? 0 0
  240. PytestCmd "test_cache_nomap.py" "test_cache_nomap_num_connections" 1
  241. HandleRcExit $? 0 0
  242. PytestCmd "test_cache_nomap.py" "test_cache_nomap_prefetch_size" 1
  243. HandleRcExit $? 0 0
  244. PytestCmd "test_cache_nomap.py" "test_cache_nomap_to_device"
  245. HandleRcExit $? 0 0
  246. PytestCmd "test_cache_nomap.py" "test_cache_nomap_epoch_ctrl" 1
  247. HandleRcExit $? 0 0
  248. PytestCmd "test_cache_nomap.py" "test_cache_nomap_clue" 1
  249. HandleRcExit $? 0 0
  250. PytestCmd "test_cache_nomap.py" "test_cache_nomap_csv" 1
  251. HandleRcExit $? 0 0
  252. PytestCmd "test_cache_nomap.py" "test_cache_nomap_textfile" 1
  253. HandleRcExit $? 0 0
  254. PytestCmd "test_cache_nomap.py" "test_cache_nomap_nested_repeat"
  255. HandleRcExit $? 0 0
  256. for i in $(seq 1 3)
  257. do
  258. test_name="test_cache_nomap_multiple_cache${i}"
  259. GetSession
  260. HandleRcExit $? 1 1
  261. export SESSION_ID=$session_id
  262. PytestCmd "test_cache_nomap.py" "${test_name}"
  263. HandleRcExit $? 0 0
  264. DestroySession $session_id
  265. HandleRcExit $? 1 1
  266. done
  267. # Create session, run train and eval pipeline concurrently with different cache
  268. GetSession
  269. HandleRcExit $? 1 1
  270. export SESSION_ID=$session_id
  271. PytestCmd "test_cache_nomap.py" "test_cache_nomap_multiple_cache_train" &
  272. pids+=("$!")
  273. PytestCmd "test_cache_nomap.py" "test_cache_nomap_multiple_cache_eval" &
  274. pids+=("$!")
  275. for pid in "${pids[@]}"; do
  276. wait ${pid}
  277. HandleRcExit $? 0 0
  278. done
  279. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  280. test_count=$(($test_count+1))
  281. DestroySession $session_id
  282. HandleRcExit $? 1 1
  283. # Create session, use it to run a pipeline, and destroy the session while pipeline is running
  284. GetSession
  285. HandleRcExit $? 1 1
  286. export SESSION_ID=$session_id
  287. PytestCmd "test_cache_nomap.py" "test_cache_nomap_session_destroy" &
  288. pid=("$!")
  289. sleep 10
  290. DestroySession $session_id
  291. HandleRcExit $? 1 1
  292. wait ${pid}
  293. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  294. test_count=$(($test_count+1))
  295. # Stop cache server while pipeline is running
  296. GetSession
  297. HandleRcExit $? 1 1
  298. export SESSION_ID=$session_id
  299. PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_stop" &
  300. pid=("$!")
  301. sleep 10
  302. StopServer
  303. HandleRcExit $? 1 1
  304. sleep 1
  305. wait ${pid}
  306. # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
  307. test_count=$(($test_count+1))
  308. # test cache server with --workers 1
  309. cmd="${CACHE_ADMIN} --start --workers 1"
  310. CacheAdminCmd "${cmd}" 0
  311. sleep 1
  312. HandleRcExit $? 0 0
  313. GetSession
  314. HandleRcExit $? 1 1
  315. export SESSION_ID=$session_id
  316. PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_workers_1"
  317. HandleRcExit $? 0 0
  318. StopServer
  319. HandleRcExit $? 0 1
  320. # test cache server with --workers 100
  321. cmd="${CACHE_ADMIN} --start --workers 100"
  322. CacheAdminCmd "${cmd}" 0
  323. sleep 1
  324. HandleRcExit $? 0 0
  325. GetSession
  326. HandleRcExit $? 1 1
  327. export SESSION_ID=$session_id
  328. PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_workers_100"
  329. HandleRcExit $? 0 0
  330. StopServer
  331. HandleRcExit $? 0 1
  332. unset RUN_CACHE_TEST
  333. unset SESSION_ID
  334. exit ${failed_tests}