|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- #!/bin/bash
- # Copyright 2019 Huawei Technologies Co., Ltd
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- # ============================================================================
-
- # source the globals and functions for use with cache testing
- export SKIP_ADMIN_COUNTER=true
- declare session_id failed_tests
- . cachetest_lib.sh
- echo
-
- ################################################################################
- # Cache testing: cache python test driver #
- # Summary: Various tests for running the python testcases for caching #
- ################################################################################
-
- StartServer
- HandleRcExit $? 1 1
-
- # Set the environment variable to enable these pytests
- export RUN_CACHE_TEST=TRUE
-
- # Each of these tests will create session, use it, then destroy it after the test
- for i in $(seq 1 5)
- do
- test_name="test_cache_map_basic${i}"
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- PytestCmd "test_cache_map.py" "${test_name}"
- HandleRcExit $? 0 0
-
- DestroySession $session_id
- HandleRcExit $? 1 1
- done
-
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- # use pytest pattern match to run all the tests that match the name test_cache_map_failure.
- # All of these tests will interact with the same cache session and may result in multiple
- # caches under the common session handle (although these are failure tests so probably not)
- PytestCmd "test_cache_map.py" "test_cache_map_failure" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_split" 1
- HandleRcExit $? 0 0
-
- # DatasetCache parameter check
- PytestCmd "test_cache_map.py" "test_cache_map_parameter_check"
- HandleRcExit $? 0 0
-
- # Executing the same pipeline for twice under the same session
- # Executing the same pipeline for twice (from python)
- PytestCmd "test_cache_map.py" "test_cache_map_running_twice1"
- HandleRcExit $? 0 0
- # Executing the same pipeline for twice (from shell)
- PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
- HandleRcExit $? 0 0
- PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
- HandleRcExit $? 0 0
-
- # Executing the same pipeline for twice under the different session
- # Executing the same pipeline for twice (from shell)
- PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
- HandleRcExit $? 0 0
- DestroySession $session_id
- HandleRcExit $? 1 1
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
- PytestCmd "test_cache_map.py" "test_cache_map_running_twice2"
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_no_image"
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_parallel_workers"
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_num_connections" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_prefetch_size" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_to_device"
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_epoch_ctrl" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_coco" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_mnist" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_celeba" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_manifest" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_cifar" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_voc" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_python_sampler" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_map.py" "test_cache_map_nested_repeat"
- HandleRcExit $? 0 0
-
- # Run two parallel pipelines (sharing cache)
- for i in $(seq 1 2)
- do
- test_name="test_cache_map_parallel_pipeline${i}"
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- PytestCmd "test_cache_map.py" "${test_name} --shard 0" &
- pids+=("$!")
- PytestCmd "test_cache_map.py" "${test_name} --shard 1" &
- pids+=("$!")
-
- for pid in "${pids[@]}"; do
- wait ${pid}
- HandleRcExit $? 0 0
- done
-
- # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
- test_count=$(($test_count+1))
- DestroySession $session_id
- HandleRcExit $? 1 1
- done
-
- StopServer
- HandleRcExit $? 1 1
- sleep 1
-
- # test cache server with --workers 1
- cmd="${CACHE_ADMIN} --start --workers 1"
- CacheAdminCmd "${cmd}" 0
- sleep 1
- HandleRcExit $? 0 0
-
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- PytestCmd "test_cache_map.py" "test_cache_map_server_workers_1"
- HandleRcExit $? 0 0
- StopServer
- HandleRcExit $? 0 1
-
- # test cache server with --workers 100
- cmd="${CACHE_ADMIN} --start --workers 100"
- CacheAdminCmd "${cmd}" 0
- sleep 1
- HandleRcExit $? 0 0
-
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- PytestCmd "test_cache_map.py" "test_cache_map_server_workers_100"
- HandleRcExit $? 0 0
- StopServer
- HandleRcExit $? 0 1
-
- # The next set of testing is for the non-mappable cases.
- StartServer
- HandleRcExit $? 1 1
-
- # This runs all of the basic tests. These will all share the same and we do not destroy
- # the session in between each.
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_basic" 1
- HandleRcExit $? 0 0
-
- DestroySession $session_id
- HandleRcExit $? 1 1
-
- # run the small shared cache tests
- for i in $(seq 1 4)
- do
- test_name="test_cache_nomap_allowed_share${i}"
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- PytestCmd "test_cache_nomap.py" "${test_name}"
- HandleRcExit $? 0 0
-
- DestroySession $session_id
- HandleRcExit $? 1 1
- done
-
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_disallowed_share" 1
- HandleRcExit $? 0 0
-
- DestroySession $session_id
- HandleRcExit $? 1 1
-
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- # Executing the same pipeline for twice under the same session
- # Executing the same pipeline for twice (from python)
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice1"
- HandleRcExit $? 0 0
- # Executing the same pipeline for twice (from shell)
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
- HandleRcExit $? 0 0
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
- HandleRcExit $? 0 0
-
- # Executing the same pipeline for twice under the different session
- # Executing the same pipeline for twice (from shell)
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
- HandleRcExit $? 0 0
- DestroySession $session_id
- HandleRcExit $? 1 1
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_running_twice2"
- HandleRcExit $? 0 0
-
- # Run two parallel pipelines (sharing cache)
- for i in $(seq 1 2)
- do
- test_name="test_cache_nomap_parallel_pipeline${i}"
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- PytestCmd "test_cache_nomap.py" "${test_name} --shard 0" &
- pids+=("$!")
- PytestCmd "test_cache_nomap.py" "${test_name} --shard 1" &
- pids+=("$!")
- PytestCmd "test_cache_nomap.py" "${test_name} --shard 2" &
- pids+=("$!")
-
- for pid in "${pids[@]}"; do
- wait ${pid}
- HandleRcExit $? 0 0
- done
-
- # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
- test_count=$(($test_count+1))
- DestroySession $session_id
- HandleRcExit $? 1 1
- done
-
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_parallel_workers"
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_num_connections" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_prefetch_size" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_to_device"
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_epoch_ctrl" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_clue" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_csv" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_textfile" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_nested_repeat"
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_get_repeat_count"
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_long_file_list"
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_failure" 1
- HandleRcExit $? 0 0
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_pyfunc" 1
- HandleRcExit $? 0 0
-
- for i in $(seq 1 3)
- do
- test_name="test_cache_nomap_multiple_cache${i}"
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- PytestCmd "test_cache_nomap.py" "${test_name}"
- HandleRcExit $? 0 0
-
- DestroySession $session_id
- HandleRcExit $? 1 1
- done
-
- # Create session, run train and eval pipeline concurrently with different cache
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_multiple_cache_train" &
- pids+=("$!")
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_multiple_cache_eval" &
- pids+=("$!")
-
- for pid in "${pids[@]}"; do
- wait ${pid}
- HandleRcExit $? 0 0
- done
-
- # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
- test_count=$(($test_count+1))
- DestroySession $session_id
- HandleRcExit $? 1 1
-
- # Create session, use it to run a pipeline, and destroy the session while pipeline is running
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_session_destroy" &
- pid=$!
-
- sleep 10
- DestroySession $session_id
- HandleRcExit $? 1 1
- wait ${pid}
- # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
- test_count=$(($test_count+1))
-
- # Stop cache server while pipeline is running
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_stop" &
- pid=$!
-
- sleep 10
- StopServer
- HandleRcExit $? 1 1
- sleep 1
- wait ${pid}
- # Running those PytestCmd in the background will not get our test_count updated. So we need to manually update it here.
- test_count=$(($test_count+1))
-
- # test cache server with --workers 1
- cmd="${CACHE_ADMIN} --start --workers 1"
- CacheAdminCmd "${cmd}" 0
- sleep 1
- HandleRcExit $? 0 0
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_workers_1"
- HandleRcExit $? 0 0
- StopServer
- HandleRcExit $? 0 1
-
- # test cache server with --workers 100
- cmd="${CACHE_ADMIN} --start --workers 100"
- CacheAdminCmd "${cmd}" 0
- sleep 1
- HandleRcExit $? 0 0
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_server_workers_100"
- HandleRcExit $? 0 0
- StopServer
- HandleRcExit $? 0 1
-
- # start cache server with a spilling path
- cmd="${CACHE_ADMIN} --start -s /tmp"
- CacheAdminCmd "${cmd}" 0
- sleep 1
- HandleRcExit $? 0 0
-
- GetSession
- HandleRcExit $? 1 1
- export SESSION_ID=$session_id
-
- # Set size parameter of mappable DatasetCache to a extra small value
- PytestCmd "test_cache_map.py" "test_cache_map_extra_small_size" 1
- HandleRcExit $? 0 0
- # Set size parameter of non-mappable DatasetCache to a extra small value
- PytestCmd "test_cache_nomap.py" "test_cache_nomap_extra_small_size" 1
- HandleRcExit $? 0 0
-
- StopServer
- HandleRcExit $? 0 1
-
- unset RUN_CACHE_TEST
- unset SESSION_ID
-
- exit ${failed_tests}
|