You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ch...@apache.org on 2016/03/28 23:32:54 UTC

qpid-dispatch git commit: Self test to exercise policyFolder conf option to load N policy rulesets.

Repository: qpid-dispatch
Updated Branches:
  refs/heads/crolke-DISPATCH-188-1 5b214a9b7 -> e349218c9


Self test to exercise policyFolder conf option to load N policy rulesets.


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/e349218c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/e349218c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/e349218c

Branch: refs/heads/crolke-DISPATCH-188-1
Commit: e349218c9607c6f7aba00f90a41696a0849bab9c
Parents: 5b214a9
Author: Chuck Rolke <cr...@redhat.com>
Authored: Mon Mar 28 17:29:01 2016 -0400
Committer: Chuck Rolke <cr...@redhat.com>
Committed: Mon Mar 28 17:29:01 2016 -0400

----------------------------------------------------------------------
 tests/CMakeLists.txt            |   2 +-
 tests/system_tests_policy.py    |  71 ----------------------
 tests/system_tests_policy.py.in | 111 +++++++++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e349218c/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c779b9a..925c50d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -63,7 +63,7 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/system_tests_qdmanage.py DESTINATION ${CMA
 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/system_tests_qdstat.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/system_tests_two_routers.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/system_tests_link_routes.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/system_tests_policy.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/system_tests_policy.py.in ${CMAKE_CURRENT_BINARY_DIR}/system_tests_policy.py)
 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_system_tests.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/system_test.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e349218c/tests/system_tests_policy.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_policy.py b/tests/system_tests_policy.py
deleted file mode 100644
index 30f1158..0000000
--- a/tests/system_tests_policy.py
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# 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.
-#
-
-import unittest
-from system_test import TestCase, Qdrouterd, main_module
-from proton import ConnectionException
-from proton.utils import BlockingConnection, LinkDetached
-
-class AbsoluteConnectionCountLimit(TestCase):
-    """
-    Verify that connections beyond the absolute limit are denied
-    """
-    @classmethod
-    def setUpClass(cls):
-        """Start the router"""
-        super(AbsoluteConnectionCountLimit, cls).setUpClass()
-        config = Qdrouterd.Config([
-            ('container', {'workerThreads': 4, 'containerName': 'Qpid.Dispatch.Router.Policy'}),
-            ('router', {'mode': 'standalone', 'routerId': 'QDR.Policy'}),
-            ('listener', {'port': cls.tester.get_port()}),
-            ('policy', {'maximumConnections': 2})
-        ])
-
-        cls.router = cls.tester.qdrouterd('conn-limit-router', config, wait=True)
-
-    def address(self):
-        return self.router.addresses[0]
-
-    def test_verify_maximum_connections(self):
-        addr = self.address()
-
-        # two connections should be ok
-        denied = False
-        try:
-            bc1 = BlockingConnection(addr)
-            bc2 = BlockingConnection(addr)
-        except ConnectionException:
-            denied = True
-
-        self.assertFalse(denied) # assert if connections that should open did not open
-
-        # third connection should be denied
-        denied = False
-        try:
-            bc3 = BlockingConnection(addr)
-        except ConnectionException:
-            denied = True
-
-        self.assertTrue(denied) # assert if connection that should not open did open
-
-        bc1.close()
-        bc2.close()
-
-if __name__ == '__main__':
-    unittest.main(main_module())

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e349218c/tests/system_tests_policy.py.in
----------------------------------------------------------------------
diff --git a/tests/system_tests_policy.py.in b/tests/system_tests_policy.py.in
new file mode 100644
index 0000000..3304f60
--- /dev/null
+++ b/tests/system_tests_policy.py.in
@@ -0,0 +1,111 @@
+#
+# 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.
+#
+
+import unittest, json
+from system_test import TestCase, Qdrouterd, main_module, Process, TIMEOUT
+from subprocess import PIPE, STDOUT
+from proton import ConnectionException
+from proton.utils import BlockingConnection, LinkDetached
+
+class AbsoluteConnectionCountLimit(TestCase):
+    """
+    Verify that connections beyond the absolute limit are denied
+    """
+    @classmethod
+    def setUpClass(cls):
+        """Start the router"""
+        super(AbsoluteConnectionCountLimit, cls).setUpClass()
+        config = Qdrouterd.Config([
+            ('container', {'workerThreads': 4, 'containerName': 'Qpid.Dispatch.Router.Policy'}),
+            ('router', {'mode': 'standalone', 'routerId': 'QDR.Policy'}),
+            ('listener', {'port': cls.tester.get_port()}),
+            ('policy', {'maximumConnections': 2})
+        ])
+
+        cls.router = cls.tester.qdrouterd('conn-limit-router', config, wait=True)
+
+    def address(self):
+        return self.router.addresses[0]
+
+    def test_verify_maximum_connections(self):
+        addr = self.address()
+
+        # two connections should be ok
+        denied = False
+        try:
+            bc1 = BlockingConnection(addr)
+            bc2 = BlockingConnection(addr)
+        except ConnectionException:
+            denied = True
+
+        self.assertFalse(denied) # assert if connections that should open did not open
+
+        # third connection should be denied
+        denied = False
+        try:
+            bc3 = BlockingConnection(addr)
+        except ConnectionException:
+            denied = True
+
+        self.assertTrue(denied) # assert if connection that should not open did open
+
+        bc1.close()
+        bc2.close()
+
+class LoadPolicyFromFolder(TestCase):
+    """
+    Verify that specifying a policy folder from the router conf file
+    effects loading the policies in that folder.
+    This test relies on qdmanage utility.
+    """
+    @classmethod
+    def setUpClass(cls):
+        """Start the router"""
+        super(LoadPolicyFromFolder, cls).setUpClass()
+        config = Qdrouterd.Config([
+            ('container', {'workerThreads': 4, 'containerName': 'Qpid.Dispatch.Router.Policy2'}),
+            ('router', {'mode': 'standalone', 'routerId': 'QDR.Policy'}),
+            ('listener', {'port': cls.tester.get_port()}),
+            ('policy', {'maximumConnections': 2, 'policyFolder': '${CMAKE_CURRENT_BINARY_DIR}/policy-1/', 'enableAccessRules': 'true'})
+        ])
+
+        cls.router = cls.tester.qdrouterd('conn-limit-router', config, wait=True)
+
+    def address(self):
+        return self.router.addresses[0]
+
+    def run_qdmanage(self, cmd, input=None, expect=Process.EXIT_OK):
+        p = self.popen(
+            ['qdmanage'] + cmd.split(' ') + ['--bus', 'u1:password@' + self.address(), '--indent=-1', '--timeout', str(TIMEOUT)],
+            stdin=PIPE, stdout=PIPE, stderr=STDOUT, expect=expect)
+        out = p.communicate(input)[0]
+        try:
+            p.teardown()
+        except Exception, e:
+            raise Exception("%s\n%s" % (e, out))
+        return out
+
+    def test_verify_policies_are_loaded(self):
+        addr = self.address()
+
+        rulesets = json.loads(self.run_qdmanage('query --type=policyRuleset'))
+        self.assertEqual(len(rulesets), 3)
+
+if __name__ == '__main__':
+    unittest.main(main_module())


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org