[ 
https://issues.apache.org/jira/browse/DISPATCH-1453?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16961982#comment-16961982
 ] 

ASF GitHub Bot commented on DISPATCH-1453:
------------------------------------------

kgiusti commented on pull request #602: DISPATCH-1453 - Fix the code so the 
correct error message shows up wh…
URL: https://github.com/apache/qpid-dispatch/pull/602#discussion_r340056525
 
 

 ##########
 File path: tests/system_tests_one_router.py
 ##########
 @@ -3160,6 +3159,86 @@ def on_message(self, event):
             self.receiver.close()
             self.recv_conn.close()
 
+class OneRouterUnavailableCoordinatorTest(TestCase):
+    @classmethod
+    def setUpClass(cls):
+        super(OneRouterUnavailableCoordinatorTest, cls).setUpClass()
+        name = "test-router"
+        OneRouterTest.listen_port = cls.tester.get_port()
+        config = Qdrouterd.Config([
+            ('router', {'mode': 'standalone', 'id': 'QDR',  
'defaultDistribution': 'unavailable'}),
+            ('listener', {'port': cls.tester.get_port() }),
+            ('address', {'prefix': 'closest', 'distribution': 'closest'}),
+            ('address', {'prefix': 'balanced', 'distribution': 'balanced'}),
+            ('address', {'prefix': 'multicast', 'distribution': 'multicast'}),
+        ])
+        cls.router = cls.tester.qdrouterd(name, config)
+        cls.router.wait_ready()
+        cls.address = cls.router.addresses[0]
+
+    def test_46_coordinator_linkroute_unavailable_DISPATCH_1453(self):
+        # The defaultDistribution on the router is unavailable. We try to 
connect a tx sender
+        # to make sure a good detailed message saying "the link route to a 
coordinator must be
+        # configured" is sent back.
+        test = RejectCoordinatorGoodMessageTest(self.address)
+        test.run()
+        self.assertTrue(test.passed)
+
+    def test_47_coordinator_linkroute_available_DISPATCH_1453(self):
+        # The defaultDistribution on the router is unavailable. We create a 
link route with $coordinator address
+        # The link route is not attached to any broker. When the attach comes 
in, the reject message must be
+        # condition=:"qd:no-route-to-dest", description="No route to the 
destination node"
+        COORDINATOR = "$coordinator"
+        long_type = 'org.apache.qpid.dispatch.router.config.linkRoute'
+        qd_manager = QdManager(self, address=self.address)
+        args = {"prefix": COORDINATOR, "connection": "broker", "dir": "in"}
+        qd_manager.create(long_type, args)
+        link_route_created = False
+
+        # Verify that the link route was created by querying for it.
+        outs = qd_manager.query(long_type)[0]
+        if outs:
+            try:
+                if outs['prefix'] == COORDINATOR:
+                    link_route_created = True
+            except:
+                pass
+
+        self.assertTrue(link_route_created)
+
+        # We have verified that the link route has been created but there is 
no broker connections.
+        # Now let's try to open a transaction. We should get a no route to 
destination error
+        test = RejectCoordinatorGoodMessageTest(self.address, 
link_route_present=True)
+        test.run()
+        self.assertTrue(test.passed)
+
+
+class RejectCoordinatorGoodMessageTest(RejectCoordinatorTest):
+    def __init__(self, url, link_route_present=False):
+        super(RejectCoordinatorGoodMessageTest, self).__init__(url)
+        self.link_route_present = link_route_present
+        self.error_with_link_route = "No route to the destination node"
+
+    def on_link_error(self, event):
 
 Review comment:
   Duplicate def of on_link_error (see next def below)
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Adding "defaultDistribution: unavailable" overrides the regular handling of 
> transaction coordinator link refusal
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: DISPATCH-1453
>                 URL: https://issues.apache.org/jira/browse/DISPATCH-1453
>             Project: Qpid Dispatch
>          Issue Type: Bug
>    Affects Versions: 1.9.0
>            Reporter: Robbie Gemmell
>            Assignee: Ganesh Murthy
>            Priority: Minor
>
>  DISPATCH-802 added handling to refuse links to the transaction coordinator 
> (which has no address, but is a specific target) if a link route to e.g a 
> broker isnt configured (using DISPATCH-195), and help clarify the reasons for 
> the refusal.
> DISPATCH-803 was added to provide a way for links to adressses that are 
> otherwise unknown to be refused rather than message routed, by setting 
> "defaultDistribution: unavailable". This functionality overrides the 
> behaviour from DISPATCH-802, making it less clear again why a transaction 
> usage attempt has failed.
> From a JMS client trying to create a transacted session, the failure with 
> "defaultDistribution: unavailable" config present looks like:
> {noformat}
> javax.jms.JMSException: No route to the destination node [condition = 
> qd:no-route-to-dest]
>  at 
> org.apache.qpid.jms.provider.ProviderException.toJMSException(ProviderException.java:34)
>  at 
> org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:80)
>  at 
> org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:112)
>  at org.apache.qpid.jms.JmsConnection.createResource(JmsConnection.java:698)
>  at 
> org.apache.qpid.jms.JmsLocalTransactionContext.begin(JmsLocalTransactionContext.java:140)
>  at org.apache.qpid.jms.JmsSession.<init>(JmsSession.java:172)
>  at org.apache.qpid.jms.JmsConnection.createSession(JmsConnection.java:316)
>  at org.apache.qpid.jms.example.HelloWorld.main(HelloWorld.java:52)
> {noformat}
> While without it,the router sends a more specific error condition, and so the 
> failure normally looks like:
> {noformat}
> javax.jms.JMSException: The router can't coordinate transactions by itself, a 
> linkRoute to a coordinator must be configured to use transactions. [condition 
> = amqp:precondition-failed]
>  at 
> org.apache.qpid.jms.provider.ProviderException.toJMSException(ProviderException.java:34)
>  at 
> org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:80)
>  at 
> org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:112)
>  at org.apache.qpid.jms.JmsConnection.createResource(JmsConnection.java:698)
>  at 
> org.apache.qpid.jms.JmsLocalTransactionContext.begin(JmsLocalTransactionContext.java:140)
>  at org.apache.qpid.jms.JmsSession.<init>(JmsSession.java:172)
>  at org.apache.qpid.jms.JmsConnection.createSession(JmsConnection.java:316)
>  at org.apache.qpid.jms.example.HelloWorld.main(HelloWorld.java:52)
> {noformat}
> It would be nicer if the regular coordinator refusal error condition was sent 
> in both cases.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to