-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtestcluster
executable file
·57 lines (55 loc) · 2.3 KB
/
testcluster
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# please start the standlone redis and rediscluster first before run this unitest
#source venv/bin/activate && python manage.py test authome --keepdb
if [[ "$1" == "" ]]
then
mode="debug"
elif [[ "$1" == "release" ]]
then
mode="release"
else
mode="debug"
fi
if [[ "$mode" == "release" ]]
then
echo "Running in release mode"
echo "Backup the source code via renaming authome to authome.bak"
mv authome authome.bak
if [[ "$?" != "0" ]]
then
echo "Failed to rename authome to authome.bak"
exit 1
fi
echo "Get the test code via copying authome.bak to authome"
cp -rf authome.bak authome
if [[ "$?" != "0" ]]
then
echo "Failed to copy authome.bak to authome"
exit 1
fi
cd authome
echo "prepare the test code via comment out the debug.log, Debug.log and performance related code"
find ./ -type f -iname '*.py' -exec sed -i 's/logger\.debug/#logger.debug/g' "{}" +;
find ./ -type f -iname '*.py' -exec sed -i 's/from \. import performance/#from . import performance/g' "{}" +;
find ./ -type f -iname '*.py' -exec sed -i 's/from \.\. import performance/#from .. import performance/g' "{}" +;
find ./ -type f -iname '*.py' -exec sed -i 's/performance\.start_processingstep/#performance.start_processingstep/g' "{}" +;
find ./ -type f -iname '*.py' -exec sed -i 's/performance\.end_processingstep/#performance.end_processingstep/g' "{}" +;
find ./ -type f -iname '*.py' -exec sed -i 's/from \.models import DebugLog/#from .models import DebugLog/g' "{}" +;
find ./ -type f -iname '*.py' -exec sed -i 's/from \.\.models import DebugLog/#from ..models import DebugLog/g' "{}" +;
find ./ -type f -iname '*.py' -exec sed -i 's/DebugLog\.log/#DebugLog.log/g' "{}" +;
find ./ -type f -iname '*.py' -exec sed -i 's/DebugLog\.attach_request/#DebugLog.attach_request/g' "{}" +;
cd ..
else
echo "Running in debug mode"
fi
echo "Running unit test"
TEST_RUNNER=authome.testrunners.NoDatabaseTestRunner
export TEST_RUNNER
export IGNORE_LOADING_ERROR=True ; poetry run python manage.py test authome --keepdb --pattern="testcluster.py"
if [[ "$mode" == "release" ]]
then
echo "remove the test code"
rm -rf authome
echo "Recovery the source code vi renameing authome.bak to authome"
mv authome.bak authome
fi