From 1c83a5144d655c75b873fa3b2ea9067ef6858f21 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 17 Dec 2014 17:37:11 -0300 Subject: performance tests for read/write concurrency on our encrypted whoosh #194 --- service/test/perf/search/Search.conf | 33 +++++++++++++++++ service/test/perf/search/__init__.py | 15 ++++++++ service/test/perf/search/run | 26 ++++++++++++++ service/test/perf/search/test_Search.py | 64 +++++++++++++++++++++++++++++++++ 4 files changed, 138 insertions(+) create mode 100644 service/test/perf/search/Search.conf create mode 100644 service/test/perf/search/__init__.py create mode 100755 service/test/perf/search/run create mode 100644 service/test/perf/search/test_Search.py (limited to 'service') diff --git a/service/test/perf/search/Search.conf b/service/test/perf/search/Search.conf new file mode 100644 index 00000000..27ca8ab6 --- /dev/null +++ b/service/test/perf/search/Search.conf @@ -0,0 +1,33 @@ +# +# Copyright (c) 2014 ThoughtWorks, Inc. +# +# Pixelated is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pixelated is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Pixelated. If not, see . + +[main] +title=Search +description=Testing search concurrency +url=http://localhost:4567 +nb_time=20 + +[bench] +cycles = 1:3:6:10:15 +duration = 10 +startup_delay = 0.01 +sleep_time = 0.01 +cycle_time = 1 +log_to = +log_path = results/search-bench.log +result_path = results/search-bench.xml +sleep_time_min = 0 +sleep_time_max = 0.5 diff --git a/service/test/perf/search/__init__.py b/service/test/perf/search/__init__.py new file mode 100644 index 00000000..2756a319 --- /dev/null +++ b/service/test/perf/search/__init__.py @@ -0,0 +1,15 @@ +# +# Copyright (c) 2014 ThoughtWorks, Inc. +# +# Pixelated is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pixelated is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Pixelated. If not, see . diff --git a/service/test/perf/search/run b/service/test/perf/search/run new file mode 100755 index 00000000..4ccb2797 --- /dev/null +++ b/service/test/perf/search/run @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Copyright (c) 2014 ThoughtWorks, Inc. +# +# Pixelated is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pixelated is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Pixelated. If not, see . + +if ! which gnuplot +then + echo "You must install gnuplot to run perf tests" + exit 1 +fi + +mkdir -p results +fl-run-bench test_Search.py Search.test_search +LC_ALL=en_US.ascii fl-build-report --html results/search-bench.xml diff --git a/service/test/perf/search/test_Search.py b/service/test/perf/search/test_Search.py new file mode 100644 index 00000000..63636789 --- /dev/null +++ b/service/test/perf/search/test_Search.py @@ -0,0 +1,64 @@ +# +# Copyright (c) 2014 ThoughtWorks, Inc. +# +# Pixelated is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pixelated is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Pixelated. If not, see . +import unittest +import json + +from funkload.FunkLoadTestCase import FunkLoadTestCase +from funkload.utils import Data +from test.support.integration import AppTestClient + + +class Search(FunkLoadTestCase): + + def setUpBench(self): + client = AppTestClient() + + # setup data + client.add_multiple_to_mailbox(10, 'INBOX', to='to@inbox.com', cc='cc@inbox.com', bcc='bcc@inbox.com', tags=['inbox']) + client.add_multiple_to_mailbox(10, 'TRASH', to='to@trash.com', cc='cc@trash.com', bcc='bcc@trash.com', tags=['trash']) + client.add_multiple_to_mailbox(10, 'DRAFTS', to='to@drafts.com', cc='cc@drafts.com', bcc='bcc@drafts.com', tags=['drafts']) + + self.call_to_terminate = client.run_on_a_thread(logfile='results/app.log') + + def tearDownBench(self): + self.call_to_terminate() + + def setUp(self): + """Setting up test.""" + self.server_url = self.conf_get('main', 'url') + self.mails_by_tag_url = self.server_url + '/mails?q=%%22tag:%s%%22&w=25&p=0' + + def idents_by_tag(self, tag): + return list(mail['ident'] for mail in json.loads(self.get(self.mails_by_tag_url % tag, description='Query mails by tag').body)['mails']) + + def test_search(self): + """ Query contacts and tags. Write a new tag, updating index. Query again. """ + contacts_url = self.server_url + '/contacts?q=rec' + mail_tags_url = self.server_url + '/mail/%s/tags' + all_tags_url = self.server_url + '/tags' + tags = ['inbox', 'trash', 'drafts'] + nb_time = self.conf_getInt('main', 'nb_time') + + for i in range(nb_time): + self.get(contacts_url, description='Query for contacts') + idents = self.idents_by_tag(tags[i % 3]) + tag_data = Data('application/json', '{"newtags":["newtag%s"]}' % i) + self.post(mail_tags_url % idents[i % 3], tag_data, description='Change tags on a mail') + self.idents_by_tag(tags[i % 3]) + self.get(all_tags_url, description='Query for all tags listing') + +if __name__ in ('main', '__main__'): + unittest.main() -- cgit v1.2.3