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 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 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 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)