Example #1
0
    def testStart2Servers(self):

        numServers = 2

        self.createConfFolders(numServers)

        hostname = gethostname()

        node0HttpsPort = 13807
        node1HttpsPort = 13808
        node0HttpPort = 14807
        node1HttpPort = 14808

        for i in range(numServers):
            args = [
                '../../../../cpc-server', '-c', self.serverConfs[i], 'start'
            ]  #doing cpc.server.server.forkAndRun(cf, debug ) directly here will will for some strange reason mess up things when shutting down, the process wont shutdown
            subprocess.call(args)

        time.sleep(2)

        #connect node 0 to node 1
        args = [
            '../../../../cpc-server', '-c', self.serverConfs[0],
            'connnect-server', hostname,
            str(node1HttpPort)
        ]  #doing cpc.server.server.forkAndRun(cf, debug ) directly here will will for some strange reason mess up things when shutting down, the process wont shutdown
        subprocess.call(args)

        args = [
            '../../../../cpc-server', '-c', self.serverConfs[1], 'trust',
            hostname,
            str(node0HttpsPort)
        ]  #doing cpc.server.server.forkAndRun(cf, debug ) directly here will will for some strange reason mess up things when shutting down, the process wont shutdown
        subprocess.call(args)

        #verify existense of of nodes in each conf file
        conf1 = ServerConf(confdir=self.serverConfs[0], reload=True)
        node0Nodes = conf1.getNodes()
        self.assertTrue(node0Nodes.exists(hostname, node1HttpsPort))

        conf2 = ServerConf(confdir=self.serverConfs[1], reload=True)
        node1Nodes = conf2.getNodes()
        self.assertTrue(node1Nodes.exists(hostname, node0HttpsPort))

        #do a network topology call
        conf = ConnectionBundle(confdir=self.serverConfs[0], reload=True)
        client = ClientMessage()
        topology = ProcessedResponse(client.networkTopology()).getData()

        self.assertEquals(topology.size(), 2)
 def testStartServer(self):    
     
     self.createConfFolder(0)
         
     args = ['../../../../cpc','-c',self.serverConfs[0],'start']  #doing cpc.server.server.forkAndRun(cf, debug ) directly here will will for some strange reason mess up things when shutting down, the process wont shutdown 
     subprocess.call(args)
        
     time.sleep(2)
     conf = ServerConf(self.serverConfs[0],True)
     
     #create a custom request message that sends a file and a parameter
     #verifty 
     
     client = ClientMessage()
     ProcessedResponse(client.pingServer()).pprint()
     client.closeClient()
Example #3
0
 def testNetworkRoute(self):
     self.create5NodeNetwork()
     
     #send message from node 0 to 2 http
     conf = ConnectionBundle(confdir=self.serverConfs[0],reload=True)
     client = ClientMessage()                  
     response = ProcessedResponse(client.pingServer(self.hostname,self.node2HttpsPort))
     print response.pprint()
     
     #send message from node 0 to 4 https
     response = ProcessedResponse(client.pingServer(self.hostname,self.node4HttpsPort))
     print response.pprint()
     
     #send message from node 0 to 4 http
     #this throws an exception since we should not route with http
     response = ProcessedResponse(client.pingServer(self.hostname,self.node4Port))
     print response.pprint()
Example #4
0
 def testNetworkTopology(self):        
     self.create5NodeNetwork()           
     conf = ConnectionBundle(confdir=self.serverConfs[0],reload=True)
     client = ClientMessage()        
     topology =ProcessedResponse(client.networkTopology()).getData()
     
      
     self.assertEquals(topology.size() ,5)
     
     #verify that the topology is correct
     
     #node 0 should have 2 connections one to node 1 and one to node 2
     node0 = "%s:%s"%(self.hostname,str(self.node0HttpsPort))
     node = topology.get(node0)
     self.assertEquals(node.nodes.size(),2)
     
     self.assertTrue(node.nodes.exists(self.hostname,self.node1HttpsPort))
     
     self.assertTrue(node.nodes.exists(self.hostname,self.node2HttpsPort))
         
     #node 1 should have 1 connection to node 2
     node1 = "%s:%s"%(self.hostname,str(self.node1HttpsPort))
     node = topology.get(node1)
     self.assertEquals(node.nodes.size(),2)
     self.assertTrue(node.nodes.exists(self.hostname,self.node2HttpsPort))
     
     #node2 should have 4 connections one to each other node
     node2 = "%s:%s"%(self.hostname,str(self.node2HttpsPort))
     node = topology.get(node2)
     self.assertEquals(node.nodes.size(),4)
     self.assertTrue(node.nodes.exists(self.hostname,self.node0HttpsPort))
     self.assertTrue(node.nodes.exists(self.hostname,self.node1HttpsPort))
     self.assertTrue(node.nodes.exists(self.hostname,self.node3HttpsPort))
     self.assertTrue(node.nodes.exists(self.hostname,self.node4HttpsPort))
             
     #node 3 should have 1 connection to node 2
     node3 = "%s:%s"%(self.hostname,str(self.node3HttpsPort))
     node = topology.get(node3)
     self.assertEquals(node.nodes.size(),1)
     self.assertTrue(node.nodes.exists(self.hostname,self.node2HttpsPort))
     
     #node 4 should have 1 connection to node 2
     node4 = "%s:%s"%(self.hostname,str(self.node4HttpsPort))
     node = topology.get(node4)
     self.assertEquals(node.nodes.size(),1)
     self.assertTrue(node.nodes.exists(self.hostname,self.node2HttpsPort))
Example #5
0
    def testNetworkTopology(self):
        self.create5NodeNetwork()
        conf = ConnectionBundle(confdir=self.serverConfs[0], reload=True)
        client = ClientMessage()
        topology = ProcessedResponse(client.networkTopology()).getData()

        self.assertEquals(topology.size(), 5)

        #verify that the topology is correct

        #node 0 should have 2 connections one to node 1 and one to node 2
        node0 = "%s:%s" % (self.hostname, str(self.node0HttpsPort))
        node = topology.get(node0)
        self.assertEquals(node.nodes.size(), 2)

        self.assertTrue(node.nodes.exists(self.hostname, self.node1HttpsPort))

        self.assertTrue(node.nodes.exists(self.hostname, self.node2HttpsPort))

        #node 1 should have 1 connection to node 2
        node1 = "%s:%s" % (self.hostname, str(self.node1HttpsPort))
        node = topology.get(node1)
        self.assertEquals(node.nodes.size(), 2)
        self.assertTrue(node.nodes.exists(self.hostname, self.node2HttpsPort))

        #node2 should have 4 connections one to each other node
        node2 = "%s:%s" % (self.hostname, str(self.node2HttpsPort))
        node = topology.get(node2)
        self.assertEquals(node.nodes.size(), 4)
        self.assertTrue(node.nodes.exists(self.hostname, self.node0HttpsPort))
        self.assertTrue(node.nodes.exists(self.hostname, self.node1HttpsPort))
        self.assertTrue(node.nodes.exists(self.hostname, self.node3HttpsPort))
        self.assertTrue(node.nodes.exists(self.hostname, self.node4HttpsPort))

        #node 3 should have 1 connection to node 2
        node3 = "%s:%s" % (self.hostname, str(self.node3HttpsPort))
        node = topology.get(node3)
        self.assertEquals(node.nodes.size(), 1)
        self.assertTrue(node.nodes.exists(self.hostname, self.node2HttpsPort))

        #node 4 should have 1 connection to node 2
        node4 = "%s:%s" % (self.hostname, str(self.node4HttpsPort))
        node = topology.get(node4)
        self.assertEquals(node.nodes.size(), 1)
        self.assertTrue(node.nodes.exists(self.hostname, self.node2HttpsPort))
    def testStartServer(self):

        self.createConfFolder(0)

        args = [
            '../../../../cpc', '-c', self.serverConfs[0], 'start'
        ]  #doing cpc.server.server.forkAndRun(cf, debug ) directly here will will for some strange reason mess up things when shutting down, the process wont shutdown
        subprocess.call(args)

        time.sleep(2)
        conf = ServerConf(self.serverConfs[0], True)

        #create a custom request message that sends a file and a parameter
        #verifty

        client = ClientMessage()
        ProcessedResponse(client.pingServer()).pprint()
        client.closeClient()
Example #7
0
    def testStart2Servers(self):            

        numServers = 2

        self.createConfFolders(numServers)

        hostname = gethostname()
        
        node0HttpsPort = 13807
        node1HttpsPort = 13808
        node0HttpPort = 14807
        node1HttpPort = 14808

        for i in range(numServers):
            args = ['../../../../cpc-server','-c',self.serverConfs[i],'start']  #doing cpc.server.server.forkAndRun(cf, debug ) directly here will will for some strange reason mess up things when shutting down, the process wont shutdown 
            subprocess.call(args)
        
        time.sleep(2)
        
        #connect node 0 to node 1
        args = ['../../../../cpc-server','-c',self.serverConfs[0],'connnect-server',hostname,str(node1HttpPort)]  #doing cpc.server.server.forkAndRun(cf, debug ) directly here will will for some strange reason mess up things when shutting down, the process wont shutdown
        subprocess.call(args)

        args = ['../../../../cpc-server','-c',self.serverConfs[1],'trust',hostname,str(node0HttpsPort)]  #doing cpc.server.server.forkAndRun(cf, debug ) directly here will will for some strange reason mess up things when shutting down, the process wont shutdown
        subprocess.call(args)


        #verify existense of of nodes in each conf file
        conf1 = ServerConf(confdir=self.serverConfs[0], reload=True)
        node0Nodes = conf1.getNodes()
        self.assertTrue(node0Nodes.exists(hostname,node1HttpsPort))

        conf2 = ServerConf(confdir=self.serverConfs[1],reload=True)
        node1Nodes = conf2.getNodes()
        self.assertTrue(node1Nodes.exists(hostname,node0HttpsPort))
                
        
        #do a network topology call        
        conf = ConnectionBundle(confdir=self.serverConfs[0],reload=True)
        client = ClientMessage()        
        topology =ProcessedResponse(client.networkTopology()).getData()
         
        self.assertEquals(topology.size() ,2)
Example #8
0
    def testNetworkRoute(self):
        self.create5NodeNetwork()

        #send message from node 0 to 2 http
        conf = ConnectionBundle(confdir=self.serverConfs[0], reload=True)
        client = ClientMessage()
        response = ProcessedResponse(
            client.pingServer(self.hostname, self.node2HttpsPort))
        print response.pprint()

        #send message from node 0 to 4 https
        response = ProcessedResponse(
            client.pingServer(self.hostname, self.node4HttpsPort))
        print response.pprint()

        #send message from node 0 to 4 http
        #this throws an exception since we should not route with http
        response = ProcessedResponse(
            client.pingServer(self.hostname, self.node4Port))
        print response.pprint()