HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
ftest_AdminProcessorDataHandler.py
Go to the documentation of this file.
1 '''
2 Created on Mar 10, 2014
3 
4 @author: scorp
5 '''
6 from admin.Command import Command
7 from admin.Constants import ADMIN_HANDLER_TYPES as ADMIN_HANDLERS
8 from admin.Node import Node
9 from admin.NodeManager import NodeManager
10 from time import sleep
11 import admin.AdminExceptions as AdminExceptions
12 import unittest
13 import ftest_AdminConstants as F_CONSTANTS
14 import admin.Constants as CONSTANTS
15 
16 
17 class TestAdminProcessorDataHandler(unittest.TestCase):
18 
19 
20  def setUp(self):
22 
23 
24  def tearDown(self):
25  pass
26 
27 
30  nodes = [Node(F_CONSTANTS.TEST_LOCAL_HOST, 1120), Node(F_CONSTANTS.TEST_LOCAL_HOST, 2120)]
31  commands = []
32  params = ["param1", "param2"]
33 # Last param (10 value) is Command timeout, if it not specified, that we use timeout from Node
34  command = Command("PROPERTIES", params, ADMIN_HANDLERS.DATA_PROCESSOR_DATA)
35  commands.append(command)
36  command = Command("ECHO", params, ADMIN_HANDLERS.ADMIN)
37  commands.append(command)
38  command = Command("DRCE", params, ADMIN_HANDLERS.DATA_PROCESSOR_DATA)
39  commands.append(command)
40  command = Command("BAD_COMMAND", params, ADMIN_HANDLERS.ADMIN)
41  commands.append(command)
42 
43 # with self.assertRaises(AdminExceptions.AdminTimeoutException):
44 # list(self.nodeManager.execute(commands, nodes))
45 
46  nodes = [Node(F_CONSTANTS.TEST_REAL_HOST), Node(F_CONSTANTS.TEST_REAL_HOST, 5530, 20)]
47  self.nodeManager.execute(commands, nodes)
48  print("Responses count = " + str(len(self.nodeManager.getResponses())))
49  print("Responses Dict count = " + str(len(self.nodeManager.getResponsesDicts())))
50  for response in self.nodeManager.getResponses():
51  print(response[CONSTANTS.STRING_RESPONSE_MARKER].getBody())
52 
53  if len(self.nodeManager.getResponsesDicts()) >=5 and self.nodeManager.getResponsesDicts()[4] != None:
54  localDict = self.nodeManager.getResponsesDicts()[4]
55  print(localDict[CONSTANTS.RESPONSE_FIELDS_NAME])
56  if localDict[CONSTANTS.RESPONSE_CODE_NAME] == "OK":
57  print("fields count = " + str(len(localDict[CONSTANTS.RESPONSE_FIELDS_NAME])))
58  print("\"name\" field value = " + localDict[CONSTANTS.RESPONSE_FIELDS_NAME]["name"])
59  sleep(1)
60  '''
61  try:
62  raise AdminExceptions.AdminTimeoutException("WWWWWW")
63  except Exception, e:
64  print(e.__doc__ + ":")
65  '''
66 
67 if __name__ == "__main__":
68 #import sys;sys.argv = ['', 'Test.testName']
69  unittest.main()
def execute(self, commands, nodes)
execute method execute incoming commands on nodes, keepts reult in responses and responsesDicts field...
Definition: NodeManager.py:63
NodeManager represents API for interraction with user-side (execute method)
Definition: NodeManager.py:18
def testAdminProcessorDataHandler(self)
Test method, creates request with 2 nodes and 4 commands So really we have 8 requests/responses.