Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: Duplicated remote workspaces in tests #6279

Open
elioschmutz opened this issue Feb 24, 2020 · 1 comment
Open

testing: Duplicated remote workspaces in tests #6279

elioschmutz opened this issue Feb 24, 2020 · 1 comment
Labels

Comments

@elioschmutz
Copy link
Member

The PR #6254 introduced the creation of linked workspaces.

The tests will sometimes fail due to a slient ConflictError. Means, the error will be catched and the request will be performed again. I created a hotfix for this: https://github.com/4teamwork/opengever.core/pull/6254/files#diff-bef4e20bde1bc9f2466eeca643603098R12

We should dig more to find out why this really happens.

Current state of debugging

  1. Run the test test_create_linked_workspace of opengever.api.tests.test_linked_workspaces.py without the fix_publisher_test_bug
  2. The WorkpsaceClient will set up the session with a new JWT and will then perform a POST request to create a new workspace
  3. The ZPublisher tries to commit the transaction (at this moment, the request which created the teamraum is already committed successfully. So the new teamraum already exists): https://github.com/zopefoundation/Zope/blob/2.13/src/ZPublisher/Publish.py#L146
    This will fail due to a ConflictError.
  4. The ZPublisher republishes the request once again: https://github.com/zopefoundation/Zope/blob/2.13/src/ZPublisher/Publish.py#L207
  5. This time, the transaction will be published successfully, but the teamraum is created ones again

Unfortunately I can't reproduce it anymore on my local machine. But you can enforce the issue with this adjustments on the ZPublisher/Publisher.py. Use the diff and run the test test_create_linked_workspace.

--- Clipboard
+++ Selection
@@ -30,6 +30,7 @@
 from pubevents import PubStart, PubSuccess, PubFailure, \
      PubBeforeCommit, PubAfterTraversal, PubBeforeAbort
 
+
 class Retry(Exception):
     """Raise this to retry a request
     """
@@ -72,6 +73,7 @@
             missing_name=missing_name,
             dont_publish_class=dont_publish_class,
             mapply=mapply,
+            raiseconflict=True
             ):
 
     (bobo_before, bobo_after, object, realm, debug_mode, err_hook,
@@ -143,6 +145,9 @@
         notify(PubBeforeCommit(request))
 
         if transactions_manager:
+            if raiseconflict:
+                from ZODB.POSException import ConflictError
+                raise ConflictError
             transactions_manager.commit()
         endInteraction()
 
@@ -204,7 +209,7 @@
             if ISkinnable.providedBy(newrequest):
                 setDefaultSkin(newrequest)
             try:
-                return publish(newrequest, module_name, after_list, debug)
+                return publish(newrequest, module_name, after_list, debug, raiseconflict=False)
             finally:
                 newrequest.close()
 
@@ -385,7 +390,7 @@
 def install_profiling(filename):
     global _pfile
     _pfile = filename
-    
+
 def pm(module_name, stdin, stdout, stderr,
        environ, debug, request, response):
     try:
@@ -454,3 +459,4 @@
         return publish_module_standard(module_name, stdin, stdout, stderr,
                                        environ, debug, request, response)
 
+

Bildschirmfoto 2020-02-24 um 10 34 27

@elioschmutz
Copy link
Member Author

@lukasgraf FYI, I hope it helps you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants