2
# Copyright (c) 2007-2010 Apple Inc. All rights reserved.
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
8
# http://www.apache.org/licenses/LICENSE-2.0
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.
17
from calendarserver.tap.util import computeProcessCount, directoryFromConfig
18
from twistedcaldav.test.util import TestCase
19
from twistedcaldav.config import config
20
from twistedcaldav.directory.augment import AugmentXMLDB
22
class ProcessCountTestCase(TestCase):
27
# minimum, perCPU, perGB, cpu, memory (in GB), expected:
39
(2, 1, 2, 2, 2, 2), # 2 cores, 2GB = 2
40
(2, 1, 2, 2, 4, 2), # 2 cores, 4GB = 2
41
(2, 1, 2, 8, 6, 8), # 8 cores, 6GB = 8
42
(2, 1, 2, 8, 16, 8), # 8 cores, 16GB = 8
45
for min, perCPU, perGB, cpu, mem, expected in data:
46
mem *= (1024 * 1024 * 1024)
50
computeProcessCount(min, perCPU, perGB, cpuCount=cpu, memSize=mem)
53
class UtilTestCase(TestCase):
55
def test_directoryFromConfig(self):
57
Ensure augments service is on by default
59
dir = directoryFromConfig(config)
60
for service in dir._recordTypes.values():
61
# all directory services belonging to the aggregate have
62
# augmentService set to AugmentXMLDB
63
if hasattr(service, "augmentService"):
64
self.assertTrue(isinstance(service.augmentService, AugmentXMLDB))