<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[15082] CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/15082">15082</a></dd>
<dt>Author</dt> <dd>sredmond@apple.com</dd>
<dt>Date</dt> <dd>2015-08-31 13:42:50 -0700 (Mon, 31 Aug 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>adds missing files</pre>

<h3>Added Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserssredmondclientsimcontribperformanceloadtestsettingsconfigdistpy">CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest/settings/config-dist.py</a></li>
<li><a href="#CalendarServerbranchesuserssredmondclientsimcontribperformanceloadtestsettingsdefaultspy">CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest/settings/defaults.py</a></li>
<li><a href="#CalendarServerbranchesuserssredmondclientsimcontribperformanceloadtestteststest_recordspy">CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest/tests/test_records.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserssredmondclientsimcontribperformanceloadtestsettingsconfigdistpy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest/settings/config-dist.py (0 => 15082)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest/settings/config-dist.py                                (rev 0)
+++ CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest/settings/config-dist.py        2015-08-31 20:42:50 UTC (rev 15082)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+from contrib.performance.loadtest.settings.defaults import arrival, requestLogger, operationLogger, statisticsReporter, accounts
+
+from contrib.performance.loadtest.logger import EverythingLogger, MessageLogger
+
+NUM_WORKERS = 1
+
+config = {
+    &quot;server&quot;: 'https://127.0.0.1:8443',
+    &quot;webadminPort&quot;: 8080,
+    &quot;serverStatsPort&quot;: 8100,
+    &quot;serializationPath&quot;: '/tmp/sim',
+    &quot;arrival&quot;: arrival,
+    &quot;observers&quot;: [requestLogger, operationLogger, statisticsReporter, EverythingLogger(), MessageLogger()],
+    &quot;records&quot;: accounts,
+    &quot;workers&quot;: [&quot;./bin/python contrib/performance/loadtest/ampsim.py&quot;] * NUM_WORKERS,
+}
</ins></span></pre></div>
<a id="CalendarServerbranchesuserssredmondclientsimcontribperformanceloadtestsettingsdefaultspy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest/settings/defaults.py (0 => 15082)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest/settings/defaults.py                                (rev 0)
+++ CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest/settings/defaults.py        2015-08-31 20:42:50 UTC (rev 15082)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+from contrib.performance.loadtest.logger import ReportStatistics, RequestLogger, OperationLogger
+from contrib.performance.loadtest.records import recordsFromCSVFile
+from contrib.performance.loadtest.population import SmoothRampUp
+
+requestLogger = RequestLogger()
+operationLogger = OperationLogger(
+    thresholdsPath=&quot;contrib/performance/loadtest/thresholds.json&quot;,
+    lagCutoff=1.0,
+    failCutoff=1.0
+)
+statisticsReporter = ReportStatistics(
+    thresholdsPath=&quot;contrib/performance/loadtest/thresholds.json&quot;,
+    benchmarksPath=&quot;contrib/performance/loadtest/benchmarks.json&quot;,
+    failCutoff=1.0
+)
+
+arrival = SmoothRampUp(
+    groups=2,
+    groupSize=1,
+    interval=3,
+    clientsPerUser=1
+)
+
+accounts = recordsFromCSVFile(&quot;contrib/performance/loadtest/accounts.csv&quot;)
</ins></span></pre></div>
<a id="CalendarServerbranchesuserssredmondclientsimcontribperformanceloadtestteststest_recordspy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest/tests/test_records.py (0 => 15082)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest/tests/test_records.py                                (rev 0)
+++ CalendarServer/branches/users/sredmond/clientsim/contrib/performance/loadtest/tests/test_records.py        2015-08-31 20:42:50 UTC (rev 15082)
</span><span class="lines">@@ -0,0 +1,133 @@
</span><ins>+##
+# Copyright (c) 2010-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+# 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 &quot;AS IS&quot; 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.
+##
+&quot;&quot;&quot;
+Tests for loadtest.records
+&quot;&quot;&quot;
+
+from twisted.trial.unittest import TestCase
+
+from contrib.performance.loadtest.records import DirectoryRecord, recordsFromCSVFile
+
+class RecordTests(TestCase):
+    def test_loadAccountsFromFile(self):
+        &quot;&quot;&quot;
+        L{LoadSimulator.fromCommandLine} takes an account loader from the
+        config file and uses it to create user records for use in the
+        simulation.
+        &quot;&quot;&quot;
+        accounts = FilePath(self.mktemp())
+        accounts.setContent(&quot;foo,bar,baz,quux,goo\nfoo2,bar2,baz2,quux2,goo2\n&quot;)
+        config = VALID_CONFIG.copy()
+        config[&quot;accounts&quot;] = {
+            &quot;loader&quot;: &quot;contrib.performance.loadtest.sim.recordsFromCSVFile&quot;,
+            &quot;params&quot;: {
+                &quot;path&quot;: accounts.path
+            },
+        }
+        configpath = FilePath(self.mktemp())
+        configpath.setContent(writePlistToString(config))
+        io = StringIO()
+        sim = LoadSimulator.fromCommandLine(['--config', configpath.path], io)
+        self.assertEquals(io.getvalue(), &quot;Loaded 2 accounts.\n&quot;)
+        self.assertEqual(2, len(sim.records))
+        self.assertEqual(sim.records[0].uid, 'foo')
+        self.assertEqual(sim.records[0].password, 'bar')
+        self.assertEqual(sim.records[0].commonName, 'baz')
+        self.assertEqual(sim.records[0].email, 'quux')
+        self.assertEqual(sim.records[1].uid, 'foo2')
+        self.assertEqual(sim.records[1].password, 'bar2')
+        self.assertEqual(sim.records[1].commonName, 'baz2')
+        self.assertEqual(sim.records[1].email, 'quux2')
+
+
+    def test_loadDefaultAccountsFromFile(self):
+        &quot;&quot;&quot;
+        L{LoadSimulator.fromCommandLine} takes an account loader (with
+        empty path)from the config file and uses it to create user
+        records for use in the simulation.
+        &quot;&quot;&quot;
+        config = VALID_CONFIG.copy()
+        config[&quot;accounts&quot;] = {
+            &quot;loader&quot;: &quot;contrib.performance.loadtest.sim.recordsFromCSVFile&quot;,
+            &quot;params&quot;: {
+                &quot;path&quot;: &quot;&quot;
+            },
+        }
+        configpath = FilePath(self.mktemp())
+        configpath.setContent(writePlistToString(config))
+        sim = LoadSimulator.fromCommandLine(['--config', configpath.path],
+                                            StringIO())
+        self.assertEqual(99, len(sim.records))
+        self.assertEqual(sim.records[0].uid, 'user01')
+        self.assertEqual(sim.records[0].password, 'user01')
+        self.assertEqual(sim.records[0].commonName, 'User 01')
+        self.assertEqual(sim.records[0].email, 'user01@example.com')
+        self.assertEqual(sim.records[98].uid, 'user99')
+        self.assertEqual(sim.records[98].password, 'user99')
+        self.assertEqual(sim.records[98].commonName, 'User 99')
+        self.assertEqual(sim.records[98].email, 'user99@example.com')
+
+
+ormance.loadtest.sim.generateRecords&quot;,
+            &quot;params&quot;: {
+                &quot;count&quot;: 2
+            },
+        }
+        configpath = FilePath(self.mktemp())
+        configpath.setContent(writePlistToString(config))
+        sim = LoadSimulator.fromCommandLine(['--config', configpath.path],
+                                            StringIO())
+        self.assertEqual(2, len(sim.records))
+        self.assertEqual(sim.records[0].uid, 'user1')
+        self.assertEqual(sim.records[0].password, 'user1')
+        self.assertEqual(sim.records[0].commonName, 'User 1')
+        self.assertEqual(sim.records[0].email, 'user1@example.com')
+        self.assertEqual(sim.records[1].uid, 'user2')
+        self.assertEqual(sim.records[1].password, 'user2')
+        self.assertEqual(sim.records[1].commonName, 'User 2')
+        self.assertEqual(sim.records[1].email, 'user2@example.com')
+
+
+    def test_generateRecordsNonDefaultPatterns(self):
+        &quot;&quot;&quot;
+        L{LoadSimulator.fromCommandLine} takes an account loader from the
+        config file and uses it to generate user records for use in the
+        simulation.
+        &quot;&quot;&quot;
+        config = VALID_CONFIG.copy()
+        config[&quot;accounts&quot;] = {
+            &quot;loader&quot;: &quot;contrib.performance.loadtest.sim.generateRecords&quot;,
+            &quot;params&quot;: {
+                &quot;count&quot;: 3,
+                &quot;uidPattern&quot;: &quot;USER%03d&quot;,
+                &quot;passwordPattern&quot;: &quot;PASSWORD%03d&quot;,
+                &quot;namePattern&quot;: &quot;Test User %03d&quot;,
+                &quot;emailPattern&quot;: &quot;USER%03d@example2.com&quot;,
+            },
+        }
+        configpath = FilePath(self.mktemp())
+        configpath.setContent(writePlistToString(config))
+        sim = LoadSimulator.fromCommandLine(['--config', configpath.path],
+                                            StringIO())
+        self.assertEqual(3, len(sim.records))
+        self.assertEqual(sim.records[0].uid, 'USER001')
+        self.assertEqual(sim.records[0].password, 'PASSWORD001')
+        self.assertEqual(sim.records[0].commonName, 'Test User 001')
+        self.assertEqual(sim.records[0].email, 'USER001@example2.com')
+        self.assertEqual(sim.records[2].uid, 'USER003')
+        self.assertEqual(sim.records[2].password, 'PASSWORD003')
+        self.assertEqual(sim.records[2].commonName, 'Test User 003')
+        self.assertEqual(sim.records[2].email, 'USER003@example2.com')
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>