コード例 #1
0
 def setUp(self):
     DefaultTestFixture.setUp(self)
     try:
         self.root = as_internal_node('/')
         self.services = CompositeNode()
         self.services.configure({'parent': self.root, 'name': 'services'})
         self.rna_service = RNA_Tcp()
         # port = 0 indicates that the RNA Service should bind to any
         # available port.
         self.rna_service.configure({
             'parent': self.services,
             'name': 'rna',
             'port': 0,
             'enabled': 1,
             'debug': 0
         })
         self.rna_target = RNATargetNode()
         self.rna_target.configure({
             'parent': self.services,
             'name': 'RNA Target'
         })
         self.aliases = Aliases()
         self.aliases.configure({'parent': self.root, 'name': 'aliases'})
         self.root.start()
         # Determine what port the running RNA Service bound to.
         port = self.rna_service.bound_port()
         port_wait_expire_at = time.time() + 1.0
         while not port:
             self.failIf(time.time() > port_wait_expire_at,
                         "Failed to establish test's RNA port.")
             time.sleep(0.1)
             port = self.rna_service.bound_port()
         # Construct the URL explicitly using the port the RNA Service
         # bound to.
         self.rna_target_url = (
             'mpx://localhost:%d/services/RNA%%20Target' % port)
         self.alias1 = Alias()
         self.alias1.configure({
             'parent': self.aliases,
             'name': 'Remote Target',
             'node_url': self.rna_target_url
         })
     except:
         self.tearDown()
         raise
     return