allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/3] git commit: [#7647] ticket:669 Add test to reproduce race condition in artifact versioning
Date Thu, 23 Oct 2014 17:59:47 GMT
Repository: allura
Updated Branches:
  refs/heads/master 7ba07dc28 -> bb7c86e90


[#7647] ticket:669 Add test to reproduce race condition in artifact versioning


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/1e15eeeb
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1e15eeeb
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1e15eeeb

Branch: refs/heads/master
Commit: 1e15eeeb79dbba2920df4f3f1631ca1352a51a39
Parents: 7ba07dc
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Oct 17 16:05:18 2014 +0300
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Thu Oct 23 13:59:29 2014 -0400

----------------------------------------------------------------------
 ForgeWiki/forgewiki/tests/test_models.py | 59 +++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1e15eeeb/ForgeWiki/forgewiki/tests/test_models.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/test_models.py b/ForgeWiki/forgewiki/tests/test_models.py
new file mode 100644
index 0000000..619f5dd
--- /dev/null
+++ b/ForgeWiki/forgewiki/tests/test_models.py
@@ -0,0 +1,59 @@
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you 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.
+
+from allura.tests import TestController
+from allura.tests import decorators as td
+from alluratest.controller import setup_global_objects
+
+from forgewiki.model import Page
+
+
+class TestPageSnapshots(TestController):
+
+    # Note: test name starts with '_' makes nose don't pick it up automatically.
+    # This is done intentionally to avoid run this test on every commit.
+    # You can run it manually like this:
+    # nosetests forgewiki.tests.test_models:TestPageSnapshots._test_version_race
+    # You should check that threads does not throw `DuplicateKeyError`.
+    # It's hard to reproduce this mannually
+    @td.with_wiki
+    def _test_version_race(self):
+        import time
+        import random
+        from threading import Thread
+
+        page = Page.upsert('test-page')
+        page.commit()
+
+        def run(n):
+            setup_global_objects()
+            for i in range(10):
+                page = Page.query.get(title='test-page')
+                page.text = 'Test Page %s.%s' % (n, i)
+                time.sleep(random.random())
+                page.commit()
+
+        t1 = Thread(target=lambda: run(1))
+        t2 = Thread(target=lambda: run(2))
+        t1.start()
+        t2.start()
+        t1.join()
+        t2.join()
+
+        page = Page.query.get(title='test-page')
+        # 10 changes by each thread + initial upsert
+        assert page.history().count() == 21, page.history().count()


Mime
View raw message