File: testserver

package info (click to toggle)
calendarserver 9.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 25,688 kB
  • sloc: python: 195,037; sql: 78,794; xml: 16,936; sh: 2,502; ansic: 66; makefile: 26
file content (164 lines) | stat: -rwxr-xr-x 4,884 bytes parent folder | download
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/sh
# -*- sh-basic-offset: 2 -*-

##
# Copyright (c) 2005-2017 Apple Inc. All rights reserved.
#
# 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.
##

set -e;
set -u;

wd="$(cd "$(dirname "$0")/.." && pwd -L)";

. "${wd}/bin/_build.sh";

init_build > /dev/null;

cdt="${py_virtualenv}/src/caldavtester";

##
# Command line handling
##

   verbose="";
serverinfo="${cdt}/scripts/server/serverinfo.xml";
  pretests="";
  printres="";
    subdir="";
    random="--random";
      seed="";
       ssl="";
  cdtdebug="";

usage ()
{
  program="$(basename "$0")";
  echo "Usage: ${program} [-v] [-s serverinfo]";
  echo "Options:";
  echo "        -d  Set the script subdirectory";
  echo "        -h  Print this help and exit";
  echo "        -o  Execute tests in order";
  echo "        -p  Run pretests";
  echo "        -r  Print request and response";
  echo "        -s  Set the serverinfo.xml";
  echo "        -t  Set the CalDAVTester directory";
  echo "        -x  Random seed to use.";
  echo "        -v  Verbose.";
  echo "        -z  Use SSL.";
  echo "        -D  Turn on CalDAVTester debugging";

  if [ "${1-}" = "-" ]; then return 0; fi;
  exit 64;
}

while getopts 'Dhvprozt:s:d:x:' option; do
  case "$option" in
    '?') usage; ;;
    'h') usage -; exit 0; ;;
    't') cdt="${OPTARG}"; serverinfo="${OPTARG}/scripts/server/serverinfo.xml"; ;;
    'd') subdir="--subdir=${OPTARG}"; ;;
    'p') pretests="--pretest CalDAV/pretest.xml --posttest CalDAV/pretest.xml"; ;;
    's') serverinfo="${OPTARG}"; ;;
    'r') printres="--always-print-request --always-print-response"; ;;
    'v') verbose="v"; ;;
    'o') random=""; ;;
    'x') seed="--random-seed ${OPTARG}"; ;;
    'z') ssl="--ssl"; ;;
    'D') cdtdebug="--debug"; ;;
  esac;
done;

shift $((${OPTIND} - 1));

if [ $# = 0 ]; then
  set - "--all";
fi;

##
# Do The Right Thing
##

do_setup="false";
develop > /dev/null;

# Set up sandbox

sandboxdir="/tmp/cdt_server_sandbox💣"
sandboxdir_u="/tmp/cdt_server_sandbox\ud83d\udca3"

if [ -d "${sandboxdir}" ]; then
  rm -rf "${sandboxdir}"
fi;

configdir="${sandboxdir}/Config"
datadir="${sandboxdir}/Data"

configdir_u="${sandboxdir_u}/Config"
datadir_u="${sandboxdir_u}/Data"

mkdir -p "${sandboxdir}/Config" "${sandboxdir}/Logs" "${sandboxdir}/Run" "${datadir}/Documents"

cp conf/caldavd-test.plist "${configdir}/caldavd-cdt.plist"
cp conf/auth/proxies-test.xml "${datadir}/proxies-cdt.xml"
cp conf/auth/resources-test.xml "${datadir}/resources-cdt.xml"
cp conf/auth/augments-test.xml "${datadir}/augments-cdt.xml"
cp conf/auth/accounts-test.xml "${datadir}/accounts-cdt.xml"

# Modify the plist

python -c "import plistlib; f=plistlib.readPlist('${configdir}/caldavd-cdt.plist'); f['HTTPPort'] = 18008; f['BindHTTPPorts'] = [18008]; f['SSLPort'] = 18443; f['BindSSLPorts'] = [18443]; f['Notifications']['Services']['AMP']['Port'] = 62312; f['ServerRoot'] = u'${sandboxdir_u}'; f['ConfigRoot'] = 'Config'; f['RunRoot'] = 'Run'; f['ProxyLoadFromFile'] = u'${datadir_u}/proxies-cdt.xml'; f['ResourceService']['params']['xmlFile'] = u'${datadir_u}/resources-cdt.xml'; f['DirectoryService']['params']['xmlFile'] = u'${datadir_u}/accounts-cdt.xml'; f['AugmentService']['params']['xmlFiles'] = [u'${datadir_u}/augments-cdt.xml']; f['Authentication']['Kerberos']['Enabled'] = False; plistlib.writePlist(f, '${configdir}/caldavd-cdt.plist');"

# Modify serverinfo to update ports

sed "s/8008/18008/g;s/8443/18443/g" "${serverinfo}" > "${configdir}/serverinfo-cdt.xml"
serverinfo="${configdir}/serverinfo-cdt.xml"

# Start the server

"${wd}/bin/run" -nd -c "${configdir}/caldavd-cdt.plist"

/bin/echo -n "Waiting for server to start up..."

while [ ! -f "${sandboxdir}/Run/caldav-instance-0.pid" ]; do
  sleep 1
  /bin/echo -n "."
done;

echo "Server has started"

# Don't exit if testcaldav.py fails, because we need to clean up afterwards.

set +e

# Run CDT

echo "Starting CDT run"

cd "${cdt}" && "${python}" testcaldav.py ${random} ${seed} ${ssl} ${cdtdebug} ${pretests} --print-details-onfail ${printres} -s "${serverinfo}" ${subdir} "$@";

# Capture exit status of testcaldav.py to use as this script's exit status.

STATUS=$?

# Re-enable exit on failure incase run -nk fails

set -e

echo "Stopping server"
"${wd}/bin/run" -nk -c "${configdir}/caldavd-cdt.plist"

# Exit with the exit status of testcaldav.py, to reflect the test suite's result

exit $STATUS