def publish_list_capability_msg(): """ Description : Publish a msg to RMQ that requests a list of all the current capabilities registered. Parameters : none Returns : The response message. """ originalcorrelationID = 'capability-registry-list-test' the_payload = '{}' af_support_tools.rmq_publish_message( host='amqp', port=5671, exchange='exchange.dell.cpsd.hdp.capability.registry.request', routing_key='dell.cpsd.hdp.capability.registry.request', headers={ '__TypeId__': 'com.dell.cpsd.hdp.capability.registry.list.capability.providers' }, payload=the_payload, payload_type='json', correlation_id={originalcorrelationID}, ssl_enabled=True) # Wait for and consume the Capability Response Message waitForMsg('test.capability.registry.response') return_message = af_support_tools.rmq_consume_message( host='amqp', port=5671, queue='test.capability.registry.response', ssl_enabled=True) checkForErrors(return_message) checkForFailures(return_message) return (return_message)
def test_dne_discovered_node_handled(setup): """ Title : Verify that dne/nodes API has discovered Dell nodes Description : A dummy node discovered message is published to trigger the node discovery process It will fail if : A node is already present The NodeID in the API doesn't match what RackHD sent The UUID in the api doesnt match the EIDS generated value Parameters : none Returns : None """ print('\nRunning Test on system: ', setup['IP']) cleanup('test.rackhd.node.discovered.event') cleanup('test.eids.identity.request') cleanup('test.eids.identity.response') bindQueues('exchange.dell.cpsd.adapter.rackhd.node.discovered.event', 'test.rackhd.node.discovered.event') bindQueues('exchange.dell.cpsd.eids.identity.request', 'test.eids.identity.request') bindQueues('exchange.dell.cpsd.eids.identity.response', 'test.eids.identity.response') time.sleep(2) # Step 1: Publish a message to dummy a node discovery. Values used here are all dummy values. the_payload = '{"data":{"ipMacAddresses":[{"ipAddress":"172.31.128.12","macAddress":"fb-43-62-54-d4-3a"},{"macAddress":"b9-ce-c4-73-10-35"},{"macAddress":"4d-63-c5-48-9f-5c"},{"macAddress":"1d-97-c3-a0-42-1a"},{"macAddress":"ce-1d-b5-a6-65-ad"},{"macAddress":"30-e5-72-6f-78-79"}],"nodeId":"123456789012345678909777","nodeType":"compute","serial":"XXTESTX","product":"R730 Base","vendor":""},"messageProperties":{"timestamp":"2017-06-27T08:58:32.437+0000"},"action":"discovered","createdAt":"2017-06-27T08:58:31.871Z","nodeId":"123456789012345678909777","severity":"information","type":"node","typeId":"123456789012345678909777","version":"1.0"}' af_support_tools.rmq_publish_message(host='amqp', port=5671, ssl_enabled=True, exchange='exchange.dell.cpsd.adapter.rackhd.node.discovered.event', routing_key='', headers={'__TypeId__': 'com.dell.cpsd.component.events.Alert'}, payload=the_payload) # Keeping this here for reference as type has changed. '__TypeId__': 'com.dell.cpsd.NodeEventDiscovered'}, # Step 2: Verify the node was discovered and returned a nodeID nodeID = rmqNodeDiscover() # Step 3: Verify the EIDS Messages sequence and get the UUID for the new node global element_id element_id = verifyEidsMessage() # Step 4: Verify the Node is in Postgres currentNodes = readEntryInNodeComputeTable(setup) print(currentNodes) error_list = [] if nodeID not in currentNodes: error_list.append(nodeID) if element_id not in currentNodes: error_list.append(nodeID) assert not error_list, 'ERROR: Node not in Postgres' cleanup('test.rackhd.node.discovered.event') cleanup('test.eids.identity.request') cleanup('test.eids.identity.response')
def test_describe_element(): cleanup() bind_queues() describe_errors = [] # Define Describe message using elementUuid from previous test describeelement = '{"timestamp":"2017-01-27T14:51:00.570Z","correlationId":"5d7f6d34-4271-4593-9bad-1b95589e5189","reply-to":"dell.cpsd.eids.identity.request.hal.gouldc-mint","elementUuids":["' + elementUuid + '"]}' print("Sending Describe Element for elementUUID: {}...".format(elementUuid)) af_support_tools.rmq_publish_message(host='amqp', port=5671, ssl_enabled= True, exchange='exchange.dell.cpsd.eids.identity.request', routing_key='dell.cpsd.eids.identity.request', headers={'__TypeId__': 'dell.cpsd.core.identity.describe.element'}, payload=describeelement, payload_type='json') return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, ssl_enabled=True , queue='test.identity.request') return_json = json.loads(return_message, encoding='utf-8') published_json = json.loads(describeelement, encoding='utf-8') # Compare the 2 files. If they match the message was successfully published & received. print("Verifying Message sent to RabbitMQ...") assert published_json == return_json print('Published Message Received.') print('\nConsuming Response Message...') # At this stage we have verified that a message was published & received. # Next we need to check that we got the expected Response to our request. assert waitForMsg('test.identity.response'), "Message took too long to return" return_message = af_support_tools.rmq_consume_message(host = 'amqp', port=5671, ssl_enabled= True, queue='test.identity.response') return_json = json.loads(return_message, encoding='utf-8') # Verify the response message has the expected format & parameters print("Checking Response Message attributes...") if not return_json['timestamp']: describe_errors.append("No timestamp in message") if return_json['correlationId'] not in describeelement: describe_errors.append("correlationId error") classification = return_json['elementDescriptions'][0]['classification'] elementType = return_json['elementDescriptions'][0]['elementType'] # Check values from elementdescribed response against IdentifyElements message, except for 'ELEMENT_UUID' for _ in range(len(return_json['elementDescriptions'][0]['businessKeys'])): if return_json['elementDescriptions'][0]['businessKeys'][_]['key'] != 'ELEMENT_UUID': value = return_json['elementDescriptions'][0]['businessKeys'][_]['value'] if classification and elementType and value not in identifyelement: describe_errors.append('Element Described Message Error') assert not describe_errors print('TEST: All requested CorrelationUuid have had element description values returned: PASSED') print('\n*******************************************************')
def getRCMRequest(payLoad, requestFile, responseFile): # credentials = pika.PlainCredentials(rmq_username, rmq_password) # parameters = pika.ConnectionParameters(host, port, '/', credentials) messageReqHeader = {'__TypeId__': 'com.dell.cpsd.rfds.rcm.definition.service.get.rcm.details'} # propsRequest = pika.BasicProperties(headers=messageReqHeader, content_type='application/json', # content_encoding='UTF-8') messageResHeader = {'__TypeId__': 'com.dell.cpsd.rcm.definition.service.api.RcmDefinitionsDetailsMessage'} # propsResponse = pika.BasicProperties(headers=messageResHeader, content_type='application/json', # content_encoding='UTF-8') # connection = pika.BlockingConnection(parameters) # channel = connection.channel() # deleteTestQueues('testGetRCMDetailsRequest', 'testGetRCMDetailsResponse') # af_support_tools.rmq_bind_queue(host=host, port=port, rmq_username=rmq_username, rmq_password=rmq_password, # queue='testGetRCMDetailsRequest', # exchange='exchange.dell.cpsd.rfds.rcm.definition.request', # routing_key='#') # af_support_tools.rmq_bind_queue(host=host, port=port, rmq_username=rmq_username, rmq_password=rmq_password, # queue='testGetRCMDetailsResponse', # exchange='exchange.dell.cpsd.rfds.rcm.definition.response', # routing_key='#') # af_support_tools.rmq_publish_message(host=host, port=port, rmq_username=rmq_username, rmq_password=rmq_password, # exchange="exchange.dell.cpsd.rfds.rcm.definition.request", # routing_key="dell.cpsd.rfds.rcm.definition.request", # headers=messageReqHeader, payload=payLoad, payload_type='json') # time.sleep(2) # my_request_body = af_support_tools.rmq_consume_message(host=host, port=port, rmq_username=rmq_username, # rmq_password=rmq_password, queue='testGetRCMDetailsRequest') # my_response_body = af_support_tools.rmq_consume_message(host=host, port=port, rmq_username=rmq_username, # rmq_password=rmq_password, # queue='testGetRCMDetailsResponse') af_support_tools.rmq_bind_queue(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testGetRCMDetailsRequest', exchange='exchange.dell.cpsd.rfds.rcm.definition.request', routing_key='#') af_support_tools.rmq_bind_queue(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testGetRCMDetailsResponse', exchange='exchange.dell.cpsd.rfds.rcm.definition.response', routing_key='#') af_support_tools.rmq_publish_message(host=hostTLS, port=portTLS, ssl_enabled=True, exchange="exchange.dell.cpsd.rfds.rcm.definition.request", routing_key="dell.cpsd.rfds.rcm.definition.request", headers=messageReqHeader, payload=payLoad, payload_type='json') time.sleep(2) my_request_body = af_support_tools.rmq_consume_message(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testGetRCMDetailsRequest') my_response_body = af_support_tools.rmq_consume_message(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testGetRCMDetailsResponse') af_support_tools.rmq_payload_to_file(my_request_body, path + requestFile) af_support_tools.rmq_payload_to_file(my_response_body, path + responseFile) time.sleep(1) deleteTestQueues('testGetRCMDetailsRequest', 'testGetRCMDetailsResponse')
def test_registerVcenter(): # Until consul is working properly & integrated with the vcenter adapter in the same environment we need to register # it manually by sending this message. cleanup('test.controlplane.vcenter.response') cleanup('test.endpoint.registration.event') bindQueues('exchange.dell.cpsd.controlplane.vcenter.response', 'test.controlplane.vcenter.response') bindQueues('exchange.dell.cpsd.endpoint.registration.event', 'test.endpoint.registration.event') time.sleep(2) af_support_tools.rmq_purge_queue(host='amqp', port=5671, ssl_enabled=True, queue='test.controlplane.vcenter.response') af_support_tools.rmq_purge_queue(host='amqp', port=5671, ssl_enabled=True, queue='test.endpoint.registration.event') the_payload = '{"messageProperties":{"timestamp":"2010-01-01T12:00:00Z","correlationId":"vcenter-registtration-corr-id","replyTo":"localhost"},"registrationInfo":{"address":"https://' + vcenter_IP + ':' + vcenter_port + '","username":"******","password":"******"}}' af_support_tools.rmq_publish_message(host='amqp', port=5671, ssl_enabled=True, exchange='exchange.dell.cpsd.controlplane.vcenter.request', routing_key='controlplane.hypervisor.vcenter.endpoint.register', headers={ '__TypeId__': 'com.dell.cpsd.vcenter.registration.info.request'}, payload=the_payload) # Verify the vcenter is validated assert waitForMsg('test.controlplane.vcenter.response'), 'ERROR: No validation Message Returned' return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, ssl_enabled=True, queue='test.controlplane.vcenter.response', remove_message=True) return_json = json.loads(return_message, encoding='utf-8') assert return_json['responseInfo']['message'] == 'SUCCESS', 'ERROR: Vcenter validation failure' #May remove the below commented test due to test cases already existing for consul registration further down # # Verify the system triggers a msg to register vcenter with consul # assert waitForMsg('test.endpoint.registration.event'), 'ERROR: No message to register with Consul sent' # return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, # ssl_enabled=True, # queue='test.endpoint.registration.event', # remove_message=True) # # return_json = json.loads(return_message, encoding='utf-8') # print (return_json) # assert return_json['endpoint']['type'] == 'vcenter', 'vcenter not registered with endpoint' cleanup('test.controlplane.vcenter.response') cleanup('test.endpoint.registration.event') time.sleep(3)
def simulate_validateScaleIORequest_message(my_payload, my_routing_key): print(" Publishing a scaleio request message .. ") print(my_payload) af_support_tools.rmq_publish_message(host='amqp', port=5671, ssl_enabled=True, exchange='exchange.dell.cpsd.service.ess.request', routing_key=my_routing_key, headers={ '__TypeId__': 'com.dell.cpsd.service.engineering.standards.EssValidateStoragePoolRequestMessage'}, payload=my_payload, payload_type='json')
def verifySystemExists(): # Check that the system exists print('\n*******************************************************') print('Step 4. Verifying System has been configured...') # Get the payload data from the config symphony-sds.ini file. the_payload = af_support_tools.get_config_file_property(config_file=payload_file, heading=payload_header, property=payload_property_req) time.sleep(1) af_support_tools.rmq_publish_message(host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, exchange='exchange.dell.cpsd.syds.system.definition.request', routing_key='dell.cpsd.syds.converged.system.list.requested', headers={'__TypeId__': 'com.dell.cpsd.syds.converged.system.list.requested'}, payload=the_payload, payload_type='json') waitForMsg('test.system.list.request') return_message = af_support_tools.rmq_consume_message(host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, queue='test.system.list.request') published_json = json.loads(the_payload, encoding='utf-8') return_json = json.loads(return_message, encoding='utf-8') # Checking the "Message received" matches the "Message published" assert published_json == return_json print('\nTEST: Published Message Received: PASSED') # We need to wait until the queue gets the response message waitForMsg('test.system.list.found') return_message = af_support_tools.rmq_consume_message(host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, queue='test.system.list.found') return_json = json.loads(return_message, encoding='utf-8') # Here we verify that a system is returned. Cannot be overly specific checking parameters as values will vary. assert return_json['messageProperties']['correlationId'] assert return_json['messageProperties']['replyTo'] assert return_json['messageProperties']['timestamp'] assert return_json['convergedSystems'] assert return_json['convergedSystems'][0]['uuid'] assert not return_json['convergedSystems'][0]['groups'] assert not return_json['convergedSystems'][0]['endpoints'] assert not return_json['convergedSystems'][0]['subSystems'] assert not return_json['convergedSystems'][0]['components'] my_systemUuid = return_json['convergedSystems'][0]['uuid'] print('\nTEST: System Exists - System UUID: ', my_systemUuid, ': PASSED\n') time.sleep(1)
def publishMessageCredReq(the_payload): af_support_tools.rmq_publish_message( host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, exchange='exchange.dell.cpsd.cms.credentials.request', routing_key='dell.cpsd.cms.credentials.requested', headers={ '__TypeId__': 'com.dell.cpsd.cms.component.credentials.requested' }, payload=the_payload, payload_type='json')
def publishMessageCredAdd(the_payload): # Publish the message to system.addition.requested using the json file af_support_tools.rmq_publish_message( host=ipaddress, rmq_username=rmq_username, rmq_password=rmq_password, exchange='exchange.dell.cpsd.cms.credentials.request', routing_key='dell.cpsd.cms.component.credentials.addition.requested', headers={ '__TypeId__': 'com.dell.cpsd.cms.component.credentials.addition.requested' }, payload=the_payload)
def simulate_validateVcenterClusterRequest_message(my_payload): print(" Publishing a vcenterCluster request message .. ") af_support_tools.rmq_publish_message( host='amqp', port=5671, ssl_enabled=True, exchange='exchange.dell.cpsd.service.ess.request', routing_key='ess.service.request', headers={'__TypeId__': 'com.dell.cpsd.vcenter.validateClusterRequest'}, payload=my_payload, payload_type='json')
def insertDummyRCMRequest(payLoad, requestFile, responseFile): messageHeaderResponse = { '__TypeId__': 'com.dell.cpsd.rcm.definition.service.rcm.definition.inserted' } messageHeaderRequest = { '__TypeId__': 'com.dell.cpsd.rcm.definition.service.insert.rcm.definition' } af_support_tools.rmq_bind_queue( host=hostTLS, port=portTLS, ssl_enabled=True, queue='testInsertRCMDefinitionsRequest', exchange='exchange.dell.cpsd.rfds.rcm.definition.request', routing_key='#') af_support_tools.rmq_bind_queue( host=hostTLS, port=portTLS, ssl_enabled=True, queue='testInsertRCMDefinitionsResponse', exchange='exchange.dell.cpsd.rfds.rcm.definition.response', routing_key='#') af_support_tools.rmq_publish_message( host=hostTLS, port=portTLS, ssl_enabled=True, exchange="exchange.dell.cpsd.rfds.rcm.definition.request", routing_key="dell.cpsd.rfds.rcm.definition.request", headers=messageHeaderRequest, payload=payLoad, payload_type='json') time.sleep(2) my_request_body = af_support_tools.rmq_consume_message( host=hostTLS, port=portTLS, ssl_enabled=True, queue='testInsertRCMDefinitionsRequest') my_response_body = af_support_tools.rmq_consume_message( host=hostTLS, port=portTLS, ssl_enabled=True, queue='testInsertRCMDefinitionsResponse') af_support_tools.rmq_payload_to_file(my_request_body, path + requestFile) af_support_tools.rmq_payload_to_file(my_response_body, path + responseFile) time.sleep(1)
def verify_SystemExists(): # Check that the system exists print('Verifying system does exist...') time.sleep(2) # Get the payload data from the config symphony-sds.ini file. the_payload = af_support_tools.get_config_file_property(config_file=payload_file, heading=payload_header, property=payload_property_req) af_support_tools.rmq_purge_queue(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testSystemListFound') af_support_tools.rmq_purge_queue(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testSystemListFound') af_support_tools.rmq_publish_message(host=hostTLS, port=portTLS, ssl_enabled=True, exchange='exchange.dell.cpsd.syds.system.definition.request', routing_key='dell.cpsd.syds.converged.system.list.requested', headers={'__TypeId__': 'com.dell.cpsd.syds.converged.system.list.requested'}, payload=the_payload, payload_type='json') q_len = 0 timeout = 0 while q_len < 1: time.sleep(1) timeout += 1 q_len = af_support_tools.rmq_message_count(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testSystemListFound') if timeout > 10: print('ERROR: Sys Found Response Message took to long to return. Something is wrong') cleanupSDS() break return_message = af_support_tools.rmq_consume_all_messages(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testSystemListFound') return_json = json.loads(return_message[0], encoding='utf-8') assert return_json['messageProperties']['correlationId'] assert return_json['messageProperties']['replyTo'] assert return_json['messageProperties']['timestamp'] assert return_json['convergedSystems'] assert return_json['convergedSystems'][0]['uuid'] assert not return_json['convergedSystems'][0]['groups'] assert not return_json['convergedSystems'][0]['endpoints'] assert not return_json['convergedSystems'][0]['subSystems'] assert not return_json['convergedSystems'][0]['components'] config = json.loads(return_message[0], encoding='utf-8') my_systemUuid = config['convergedSystems'][0]['uuid'] print('\nTEST: System Exists - System UUID: ', my_systemUuid)
def simulate_node_discovery(): print("Publishing a node event with node id as ", node_id) my_routing_key = 'node.discovered.information.' + node_id + '.' + node_id filePath = os.environ[ 'AF_TEST_SUITE_PATH'] + '/dne_paqx_parent/fixtures/nodeEvent.json' with open(filePath) as fixture: my_payload = fixture.read() af_support_tools.rmq_publish_message(host=ipaddress, rmq_username=rmq_username, rmq_password=rmq_password, exchange='on.events', routing_key=my_routing_key, headers={'__TypeId__': ''}, payload=my_payload)
def consulBypassMsg(): # Until consul is working properly & integrated with the rackhd adapter in the same environment we need to register # it manually by sending this message. url = 'http://' + rackhd_ip + ':8080' the_payload = '{"endpoint":{"type":"rackhd","instances":[{"url":url}]}}' af_support_tools.rmq_publish_message( host=ipaddress, rmq_username=rmq_username, rmq_password=rmq_password, exchange='exchange.dell.cpsd.endpoint.registration.event', routing_key='dell.cpsd.endpoint.discovered', headers={ '__TypeId__': 'com.dell.cpsd.endpoint-registry.endpointsdiscoveredevent' }, payload=the_payload)
def insertListRequest(payLoad, requestFile, responseFile): messageReqHeader = { '__TypeId__': 'com.dell.cpsd.rfds.rcm.definition.service.list.rcm.definitions' } messageResHeader = { '__TypeId__': 'com.dell.cpsd.rcm.definition.service.rcm.definitions.summary' } resetTestQueues('testListRCMDefinitionsRequest', 'testListRCMDefinitionsResponse') time.sleep(2) global PAYLoad PAYLoad = payLoad print("Payload A: %s" % payLoad) af_support_tools.rmq_publish_message( host=hostTLS, port=portTLS, ssl_enabled=True, exchange="exchange.dell.cpsd.rfds.rcm.definition.request", routing_key="dell.cpsd.rfds.rcm.definition.request", headers=messageReqHeader, payload=payLoad, payload_type='json') time.sleep(2) my_request_body = af_support_tools.rmq_consume_message( host=hostTLS, port=portTLS, ssl_enabled=True, queue='testListRCMDefinitionsRequest') my_response_body = af_support_tools.rmq_consume_message( host=hostTLS, port=portTLS, ssl_enabled=True, queue='testListRCMDefinitionsResponse') af_support_tools.rmq_payload_to_file(my_request_body, path + requestFile) af_support_tools.rmq_payload_to_file(my_response_body, path + responseFile) time.sleep(1) resetTestQueues('testListRCMDefinitionsRequest', 'testListRCMDefinitionsResponse')
def publishNodeDiscoveredEvents(nodeList): """ publish a node discovery event for each node in a list of rackhd-discovered nodes The nodes in the nodeList are of the form [id, serial tag, mac address] Returns : Nothing """ count = 0 for node in nodeList : if len(node) == 3 : cleanup('test.rackhd.node.discovered.event') cleanup('test.eids.identity.request') cleanup('test.eids.identity.response') bindQueues('exchange.dell.cpsd.adapter.rackhd.node.discovered.event', 'test.rackhd.node.discovered.event') bindQueues('exchange.dell.cpsd.eids.identity.request', 'test.eids.identity.request') bindQueues('exchange.dell.cpsd.eids.identity.response', 'test.eids.identity.response') time.sleep(2) # Step 1: Publish a node discovery event to the amqp bus. Some Values used here are dummy values # For each node in nodeList the format is [id, serial tag, mac address] # The Count variable is used to provide a different string for certain fields (eg. IP address) at each loop # the_payload = '{"data":{"ipMacAddresses":[{"ipAddress":"172.31.128.' + str(count) + '","macAddress":"' + node[2] + '"},' \ '{"macAddress":"b9-ce-c4-73-10-3' + str(count) + '"},{"macAddress":"4d-63-c5-48-9f-5' + str(count) + '"},' \ '{"macAddress":"1d-97-c3-a0-42-1' + str(count) + '"},{"macAddress":"ce-1d-b5-a6-65-a' + str(count) + '"},' \ '{"macAddress":"30-e5-72-6f-78-7' + str(count) + '"}],' \ '"nodeId":"' + node[0] + '",' \ '"nodeType":"compute",' \ '"serial":"' + node[1] + '","product":"R730 Base","vendor":""},' \ '"messageProperties":{"timestamp":"2017-06-27T08:5' + str(count) + ':32.437+0000"},"action":"discovered",' \ '"createdAt":"2017-06-27T08:5' + str(count) + ':31.871Z",' \ '"nodeId":"' + node[0] + '",' \ '"severity":"information","type":"node","typeId":"12345678901234567890977' + str(count) + '","version":"1.0"}' af_support_tools.rmq_publish_message(host='amqp', port=5671, ssl_enabled=True, exchange='exchange.dell.cpsd.adapter.rackhd.node.discovered.event', routing_key='', headers={'__TypeId__': 'com.dell.cpsd.component.events.Alert'}, payload=the_payload) time.sleep(10) count += 1 return None
def sendNodeAllocationRequestMessage(node, state, setup): """ Use the AMQP bus to send a start/cancel/fail/complete/lookup message to the node-discovery paqx for a specific node. :parameter: node - the symphonyUUID of a Node (eg. dc38f716-8d9e-42d6-a61b-fddf0269f5ac) :parameter: state - a string equal to DISCOVERED/FAILED/ADDED/LOOKUP or RESERVED""" if state == "DISCOVERED" : messageType = "cancel" elif state == "FAILED" : messageType = "fail" elif state == "ADDED" : messageType = "complete" elif state == "RESERVED" : messageType = "start" elif state == "LOOKUP" : messageType = "lookup" elif state == "LISTING": messageType = "list" my_exchange = "exchange.dell.cpsd.paqx.node.discovery.request" my_routing_key = "dell.cpsd.paqx.node.discovery.request" if messageType == "list" : my_type_id = "dell.converged.discovered." + messageType + ".nodes" my_payload = {"messageProperties": { "timestamp":"2017-09-07T03:54:39.500Z", \ "correlationId":"90035098-3cd2-3fb0-9696-3f7d28e17f72", \ "replyTo": "reply.to.queue.binding"}} else : my_type_id = "dell.converged.discovered.nodes." + messageType + ".node.allocation.request" my_payload = {"messageProperties": { "timestamp":"2017-09-07T03:54:39.500Z", \ "correlationId":"90035098-3cd2-3fb0-9696-3f7d28e17f72", \ "replyTo": "reply.to.queue.binding"}, \ "elementIdentifier": node} try: # publish the AMQP message to set the state of the node af_support_tools.rmq_publish_message(host='amqp', port=5671, ssl_enabled=True, exchange=my_exchange, routing_key=my_routing_key, headers={ '__TypeId__': my_type_id}, payload=json.dumps(my_payload)) return None except Exception as err: # Return code error print(err, '\n') raise Exception(err)
def verifyUniqueUuids(): print('*******************************************************') print('Step 5. Verifying all UUIDs are Unique...') # Get the payload data from the config symphony-sds.ini file. the_payload = af_support_tools.get_config_file_property(config_file=payload_file, heading=payload_header, property=payload_property_req_config) time.sleep(1) af_support_tools.rmq_publish_message(host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, exchange='exchange.dell.cpsd.syds.system.definition.request', routing_key='dell.cpsd.syds.converged.system.list.requested', headers={'__TypeId__': 'com.dell.cpsd.syds.converged.system.list.requested'}, payload=the_payload, payload_type='json') waitForMsg('test.system.list.request') return_message = af_support_tools.rmq_consume_message(host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, queue='test.system.list.request') published_json = json.loads(the_payload, encoding='utf-8') return_json = json.loads(return_message, encoding='utf-8') # Checking the "Message received" matches the "Message published" assert published_json == return_json print('\nTEST: Published Message Received: PASSED') # We need to wait until the queue gets the response message waitForMsg('test.system.list.found') return_message = af_support_tools.rmq_consume_message(host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, queue='test.system.list.found') return_json = json.loads(return_message, encoding='utf-8') found_list = return_json['convergedSystems'] uuid_found_list = [] for node in found_list: element_data = node['groups'] for element in element_data: uuid = element.get('uuid') uuid_found_list.append(uuid) for node in found_list: element_data = node['endpoints'] for element in element_data: uuid = element.get('uuid') uuid_found_list.append(uuid) for node in found_list: element_data = node['subSystems'] for element in element_data: uuid = element.get('uuid') uuid_found_list.append(uuid) for node in found_list: element_data = node['components'] for element in element_data: uuid = element.get('uuid') uuid_found_list.append(uuid) # Call the function to check for duplicates in the list dups_found = af_support_tools.check_for_dups_in_list(uuid_found_list) unique_ids = False # If the function says there were no duplicates in the list then we can change the unique_ids flag to True if dups_found == False: unique_ids = True if unique_ids == True: print('\nTest: Verify all UUID values are unique: PASSED') assert unique_ids
def test_scaleio_adapter_full_ListCapabilities(): """ Title : Verify the registry.list.capability Message returns all scaleio-adapter capabilities Description : A registry.list.capability message is sent. It is expected that a response is returned that includes a list of all the scaleio-adapter capabilities. It will fail if : No capability.registry.response is received. The scaleio-adapter is not in the response. The scaleio-adapter capabilites are not in the response. Parameters : none Returns : None """ cleanup('test.capability.registry.response') bindQueues('exchange.dell.cpsd.hdp.capability.registry.response', 'test.capability.registry.response') print( "\nTest: Send in a list capabilities message and to verify all scaleio Adapter capabilities are present" ) # Send in a "list capabilities message" originalcorrelationID = 'capability-registry-list-scaleio-adapter-corID' the_payload = '{}' af_support_tools.rmq_publish_message( host=cpsd.props.base_hostname, port=5671, exchange='exchange.dell.cpsd.hdp.capability.registry.request', routing_key='dell.cpsd.hdp.capability.registry.request', headers={ '__TypeId__': 'com.dell.cpsd.hdp.capability.registry.list.capability.providers' }, payload=the_payload, payload_type='json', correlation_id={originalcorrelationID}, ssl_enabled=True) # Wait for and consume the Capability Response Message assert waitForMsg('test.capability.registry.response' ), 'Error: No List Capability Responce message received' return_message = af_support_tools.rmq_consume_message( host='amqp', port=5671, queue='test.capability.registry.response', ssl_enabled=True) time.sleep(5) # Verify the scaleio Apapter Response identity = 'scaleio-adapter' capabilities1 = 'scaleio-consul-register' capabilities2 = 'scaleio-discover' capabilities3 = 'scaleio-sds-remove' capabilities4 = 'scaleio-sdc-remove' capabilities5 = 'scaleio-list-components' capabilities6 = 'scaleio-add-host-to-protection-domain' capabilities7 = 'scaleio-update-sdc-performance-profile' error_list = [] if (identity not in return_message): error_list.append(identity) if (capabilities1 not in return_message): error_list.append(capabilities1) if (capabilities2 not in return_message): error_list.append(capabilities2) if (capabilities3 not in return_message): error_list.append(capabilities3) if (capabilities4 not in return_message): error_list.append(capabilities4) if (capabilities5 not in return_message): error_list.append(capabilities5) if (capabilities6 not in return_message): error_list.append(capabilities6) if (capabilities7 not in return_message): error_list.append(capabilities7) assert not error_list, ('Missing some scaleio capabilities') print('All expected scaleio-adapter Capabilities Returned\n') cleanup('test.capability.registry.response')
def test_key_accuracy(my_test_type): cleanup() bind_queues() accuracy_errors = [] global assigned_uuid payload_message = af_support_tools.get_config_file_property(config_file=config_file, heading='identity_service_payloads', property=my_test_type) print('Sending Identify Element Key Accuracy Messages\n') # Publish the message af_support_tools.rmq_publish_message(host='amqp', port = 5671, ssl_enabled=True, exchange='exchange.dell.cpsd.eids.identity.request', routing_key='dell.cpsd.eids.identity.request', headers={'__TypeId__': 'dell.cpsd.core.identity.identify.element'}, payload=payload_message, payload_type='json') assert waitForMsg('test.identity.request'), "Message took too long to return" return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, ssl_enabled=True, queue='test.identity.request') return_json = json.loads(return_message, encoding='utf-8') published_json = json.loads(payload_message, encoding='utf-8') # Compare the 2 files. If they match the message was successfully published & received. print("Verifying Message sent to RabbitMQ...") assert published_json == return_json print('Published Message Received.') print('\nConsuming Response Message...') # At this stage we have verified that a message was published & received. # Next we need to check that we got the expected Response to our request. assert waitForMsg('test.identity.response'), "Message took too long to return" return_message = af_support_tools.rmq_consume_message(host='amqp', port = 5671, ssl_enabled=True, queue='test.identity.response') return_json = json.loads(return_message, encoding='utf-8') # Verify the response message has the expected format & parameters print("Checking Response Message attributes...") if not return_json['timestamp']: accuracy_errors.append("No timestamp in message") if return_json['correlationId'] not in payload_message: accuracy_errors.append("correlationId error") for _ in range(len(return_json['elementIdentifications'])): if return_json['elementIdentifications'][_]['correlationUuid'] not in payload_message: accuracy_errors.append("correlationUuid error") assert return_json['elementIdentifications'][_]['elementUuid'] if my_test_type == 'keyaccuracyid_abc': assigned_uuid = return_json['elementIdentifications'][_]['elementUuid'] print('Response UUID Generated: ', assigned_uuid) else: identified_uuid = return_json['elementIdentifications'][_]['elementUuid'] print('Identified UUID: ', identified_uuid) if my_test_type == 'keyaccuracyid_neg': if identified_uuid == assigned_uuid: accuracy_errors.append("Error: ElementUuid match for Key Accuracy negative") elif my_test_type != 'keyaccuracyid_abc': if identified_uuid != assigned_uuid: accuracy_errors.append("ElementUuid Mismatch for Key Accuracy") assert not accuracy_errors print('TEST: KeyAccuracy test pass.') print('\n*******************************************************')
def test_vcenter_adapter_full_ListCapabilities(): """ Title : Verify the registry.list.capability Message returns all vcenter-adapter capabilities Description : A registry.list.capability message is sent. It is expected that a response is returned that includes a list of all the vcenter-adapter capabilities. It will fail if : No capability.registry.response is received. The vcenter-adapter is not in the response. The vcenter-adapter capabilites are not in the response. Parameters : none Returns : None """ cleanup('test.capability.registry.response') bindQueues('exchange.dell.cpsd.hdp.capability.registry.response', 'test.capability.registry.response') print("\nTest: Send in a list capabilities message and to verify all vCenter Adapter capabilities are present") # Send in a "list capabilities message" originalcorrelationID = 'capability-registry-list-vcenter-adapter-corID' the_payload = '{}' af_support_tools.rmq_publish_message(host='amqp', port=5671, exchange='exchange.dell.cpsd.hdp.capability.registry.request', routing_key='dell.cpsd.hdp.capability.registry.request', headers={ '__TypeId__': 'com.dell.cpsd.hdp.capability.registry.list.capability.providers'}, payload=the_payload, payload_type='json', correlation_id={originalcorrelationID}, ssl_enabled=True) # Wait for and consume the Capability Response Message assert waitForMsg('test.capability.registry.response'), 'ERROR: No List Capabilities Message returned' time.sleep(10) return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, queue='test.capability.registry.response', ssl_enabled=True) # Verify the vcenter Apapter Response identity = 'vcenter-adapter' capabilities1 = 'vcenter-consul-register' capabilities2 = 'vcenter-discover' capabilities3 = 'vcenter-enterMaintenance' capabilities4 = 'vcenter-destroy-virtualMachine' capabilities5 = 'vcenter-powercommand' capabilities6 = 'vcenter-discover-cluster' capabilities7 = 'vcenter-remove-host' capabilities8 = 'vcenter-addhostvcenter' capabilities9 = 'vcenter-install-software-vib' capabilities10 = 'vcenter-configure-software-vib' capabilities11 = 'vcenter-setPCIpassthrough' capabilities12 = 'vcenter-addhostlicense' capabilities13 = 'vcenter-deployvmfromtemplate' capabilities14 = 'vcenter-enablePCIpassthroughHost' capabilities15 = 'vcenter-addhostdvswitch' capabilities16 = 'vcenter-rename-datastore' capabilities17 = 'vcenter-list-components' capabilities18 = 'esxi-credential-details' capabilities21 = 'vcenter-update-software-acceptance' capabilities22 = 'vcenter-vm-powercommand' capabilities23 = 'vcenter-configure-vm-network' capabilities24 = 'vcenter-execute-remote-ssh-commands' error_list = [] if (identity not in return_message): error_list.append(identity) if (capabilities1 not in return_message): error_list.append(capabilities1) if (capabilities2 not in return_message): error_list.append(capabilities2) if (capabilities3 not in return_message): error_list.append(capabilities3) if (capabilities4 not in return_message): error_list.append(capabilities4) if (capabilities5 not in return_message): error_list.append(capabilities5) if (capabilities6 not in return_message): error_list.append(capabilities6) if (capabilities7 not in return_message): error_list.append(capabilities7) if (capabilities8 not in return_message): error_list.append(capabilities8) if (capabilities9 not in return_message): error_list.append(capabilities9) if (capabilities10 not in return_message): error_list.append(capabilities10) if (capabilities11 not in return_message): error_list.append(capabilities11) if (capabilities12 not in return_message): error_list.append(capabilities12) if (capabilities13 not in return_message): error_list.append(capabilities13) if (capabilities14 not in return_message): error_list.append(capabilities14) if (capabilities15 not in return_message): error_list.append(capabilities15) if (capabilities16 not in return_message): error_list.append(capabilities16) if (capabilities17 not in return_message): error_list.append(capabilities17) if (capabilities18 not in return_message): error_list.append(capabilities18) if (capabilities21 not in return_message): error_list.append(capabilities21) if (capabilities22 not in return_message): error_list.append(capabilities22) if (capabilities23 not in return_message): error_list.append(capabilities23) if (capabilities24 not in return_message): error_list.append(capabilities24) assert not error_list, ('Missing some vcenter-adapter capabilities') print('All expected vcenter-adapter Capabilities Returned\n') cleanup('test.capability.registry.response')
def test_negative_messages(my_test_type): cleanup() bind_queues() negative_errors = [] if my_test_type == 'describe_no_element': payload_message = af_support_tools.get_config_file_property(config_file=config_file, heading='identity_service_payloads', property='describe_no_element') headers = {'__TypeId__': 'dell.cpsd.core.identity.describe.element'} if my_test_type == 'ident_no_element_type': payload_message = af_support_tools.get_config_file_property(config_file=config_file, heading='identity_service_payloads', property='ident_no_element_type') headers = {'__TypeId__': 'dell.cpsd.core.identity.identify.element'} # Publish the message print('Sending Negative test Messages\n') af_support_tools.rmq_publish_message(host='amqp', port= 5671, ssl_enabled=True, exchange='exchange.dell.cpsd.eids.identity.request', routing_key='dell.cpsd.eids.identity.request', headers= headers, payload=payload_message, payload_type='json') assert waitForMsg('test.identity.request'), "Message took too long to return" return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, ssl_enabled=True, queue='test.identity.request') return_json = json.loads(return_message, encoding='utf-8') published_json = json.loads(payload_message, encoding='utf-8') # Compare the 2 files. If they match the message was successfully published & received. print("Verifying Message sent to RabbitMQ...") assert published_json == return_json print('Published Message Received.') print('\nConsuming Response Message...') # At this stage we have verified that a message was published & received. # Next we need to check that we got the expected Response to our request. return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, ssl_enabled=True, queue='test.identity.response') return_json = json.loads(return_message, encoding='utf-8') # Convert the returned message to json format and run asserts on the expected output. print("Checking Response Message attributes...") # Verify the response message has the expected format & parameters if not return_json['timestamp']: negative_errors.append("No timestamp in message") if return_json['correlationId'] not in payload_message: negative_errors.append("correlationId error") if my_test_type == 'ident_no_element_type': if return_json['errorMessage'] != 'EIDS1004E Invalid request message': negative_errors.append("Error message incorrect") print("Incorrect error message responce" + return_json) assert not negative_errors print("Negative Message Test Passed")
def test_rackHD_adapter_full_ListCapabilities(): """ Title : Verify the registry.list.capability Message returns all rackhd-adapter capabilities Description : A registry.list.capability message is sent. It is expected that a response is returned that includes a list of all the rackhd-adapter capabilities. It will fail if : No capability.registry.response is received. The rackhd-adapter is not in the response. The rackhd-adapter capabilites are not in the response. Parameters : none Returns : None """ cleanup('test.capability.registry.response') bindQueues('exchange.dell.cpsd.hdp.capability.registry.response', 'test.capability.registry.response') print( "\nTest: Send in a list capabilities message and to verify all RackHD Adapter capabilities are present" ) # Send in a "list capabilities message" originalcorrelationID = 'capability-registry-list-rackhd-adapter-corID' the_payload = '{}' af_support_tools.rmq_publish_message( host='amqp', port=5671, exchange='exchange.dell.cpsd.hdp.capability.registry.request', routing_key='dell.cpsd.hdp.capability.registry.request', headers={ '__TypeId__': 'com.dell.cpsd.hdp.capability.registry.list.capability.providers' }, payload=the_payload, payload_type='json', correlation_id={originalcorrelationID}, ssl_enabled=True) # Wait for and consume the Capability Response Message assert waitForMsg('test.capability.registry.response' ), 'Error: No List Capability Responce message received' return_message = af_support_tools.rmq_consume_message( host='amqp', port=5671, queue='test.capability.registry.response', ssl_enabled=True) time.sleep(5) print(return_message) # Verify the RackHD Apapter Response identity = 'rackhd-adapter' capabilities1 = 'rackhd-consul-register' # capabilities2 = 'rackhd-list-nodes' # capabilities3 = 'rackhd-upgrade-firmware-dellr730-server' # capabilities4 = 'rackhd-upgrade-firmware-dell-idrac' # capabilities5 = 'node-discovered-event' # capabilities6 = 'rackhd-install-esxi' # capabilities7 = 'rackhd-configure-raid-controller' # capabilities8 = 'rackhd-list-node-catalogs' # capabilities9 = 'rackhd-configure-idrac-network' # capabilities10 = 'rackhd-configure-boot-device-idrac' # capabilities11 = 'rackhd-set-node-obm-setting' # capabilities12 = 'rackhd-configure-bmc-settings' # capabilities13 = 'rackhd-set-idrac-credentials' # capabilities14 = 'rackhd-node-inventory' # capabilities15 = 'update-switch-firmware' error_list = [] if (identity not in return_message): error_list.append(identity) if (capabilities1 not in return_message): error_list.append(capabilities1) # if (capabilities2 not in return_message): # error_list.append(capabilities2) # if (capabilities3 not in return_message): # error_list.append(capabilities3) # if (capabilities4 not in return_message): # error_list.append(capabilities4) # if (capabilities5 not in return_message): # error_list.append(capabilities5) # if (capabilities6 not in return_message): # error_list.append(capabilities6) # if (capabilities7 not in return_message): # error_list.append(capabilities7) # if (capabilities8 not in return_message): # error_list.append(capabilities8) # if (capabilities9 not in return_message): # error_list.append(capabilities9) # if (capabilities10 not in return_message): # error_list.append(capabilities10) # if (capabilities11 not in return_message): # error_list.append(capabilities11) # if (capabilities12 not in return_message): # error_list.append(capabilities12) # if (capabilities13 not in return_message): # error_list.append(capabilities13) # if (capabilities14 not in return_message): # error_list.append(capabilities14) # if (capabilities15 not in return_message): # error_list.append(capabilities15) assert not error_list, ('Missing some rackHD capabilities') print('All expected rackhd-adapter Capabilities Returned\n') cleanup('test.capability.registry.response')
def registerRackHD(setup): # Until consul is working properly & integrated with the rackhd adapter in the same environment we need to register # it manually by sending this message. This test is a prerequisite to getting the full list of cleanup('test.controlplane.rackhd.response') cleanup('test.endpoint.registration.event') bindQueues('exchange.dell.cpsd.controlplane.rackhd.response', 'test.controlplane.rackhd.response') bindQueues('exchange.dell.cpsd.endpoint.registration.event', 'test.endpoint.registration.event') time.sleep(2) af_support_tools.rmq_purge_queue(host='amqp', port=5671, ssl_enabled=True, queue='test.controlplane.rackhd.response') af_support_tools.rmq_purge_queue(host='amqp', port=5671, ssl_enabled=True, queue='test.endpoint.registration.event') the_payload = '{"messageProperties":{"timestamp":"2017-06-14T12:00:00Z","correlationId":"manually-reg-rackhd-3fb0-9696-3f7d28e17f72"},"registrationInfo":{"address":"http://' + \ setup['rackHD_IP'] + setup['rackHD_body'] + '","username":"******","password":"******"}}' af_support_tools.rmq_publish_message( host='amqp', port=5671, ssl_enabled=True, exchange='exchange.dell.cpsd.controlplane.rackhd.request', routing_key='controlplane.rackhd.endpoint.register', headers={ '__TypeId__': 'com.dell.cpsd.rackhd.registration.info.request' }, payload=the_payload) # Verify the RackHD account can be validated assert waitForMsg('test.controlplane.rackhd.response' ), 'Error: No RackHD validation message received' return_message = af_support_tools.rmq_consume_message( host='amqp', port=5671, ssl_enabled=True, queue='test.controlplane.rackhd.response', remove_message=True) return_json = json.loads(return_message, encoding='utf-8') print(return_json) assert return_json['responseInfo'][ 'message'] == 'SUCCESS', 'ERROR: RackHD validation failure' # Verify that an event to register the rackHD with endpoint registry is triggered assert waitForMsg( 'test.endpoint.registration.event' ), 'Error: No message to register with Consul sent by system' return_message = af_support_tools.rmq_consume_message( host='amqp', port=5671, ssl_enabled=True, queue='test.endpoint.registration.event', remove_message=True) return_json = json.loads(return_message, encoding='utf-8') print(return_json) endpointType = return_json['endpoint']['type'] timeout = 0 # We need to check that we received the registration msg for rackHd and not something else while endpointType != 'rackhd' and timeout < 20: assert waitForMsg( 'test.endpoint.registration.event' ), 'Error: No message to register with Consul sent by system' return_message = af_support_tools.rmq_consume_message( host='amqp', port=5671, ssl_enabled=True, queue='test.endpoint.registration.event', remove_message=True) return_json = json.loads(return_message, encoding='utf-8') print(return_json) endpointType = return_json['endpoint']['type'] timeout += 1 #assert return_json['endpoint']['type'] == 'rackhd', 'rackhd not registered with endpoint' cleanup('test.controlplane.rackhd.response') cleanup('test.endpoint.registration.event') print('rackHD registerd') time.sleep(3) return 1
def registerVcenter(payLoad, responseRegVcenter): messageReqHeader = { '__TypeId__': 'com.dell.cpsd.vcenter.registration.info.request' } af_support_tools.rmq_purge_queue(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testRegisterVcenterRequest') af_support_tools.rmq_purge_queue(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testRegisterVcenterResponse') time.sleep(2) af_support_tools.rmq_bind_queue( host=hostTLS, port=portTLS, ssl_enabled=True, queue='testRegisterVcenterRequest', exchange='exchange.dell.cpsd.controlplane.vcenter.request', routing_key='#') af_support_tools.rmq_bind_queue( host=hostTLS, port=portTLS, ssl_enabled=True, queue='testRegisterVcenterResponse', exchange='exchange.dell.cpsd.controlplane.vcenter.response', routing_key='#') af_support_tools.rmq_publish_message( host=hostTLS, port=portTLS, ssl_enabled=True, exchange="exchange.dell.cpsd.controlplane.vcenter.request", routing_key="controlplane.hypervisor.vcenter.endpoint.register", headers=messageReqHeader, payload=payLoad, payload_type='json') print("\nVcenter register request published.") time.sleep(5) q_len = 0 timeout = 0 # We need to wait until the queue gets the response message while q_len < 1: time.sleep(1) timeout += 1 q_len = af_support_tools.rmq_message_count( host=hostTLS, port=portTLS, ssl_enabled=True, queue='testRegisterVcenterResponse') # If the test queue doesn't get a message then something is wrong if timeout > 180: print( 'ERROR: Sys Found Response Message took to long to return. Something is wrong' ) break my_response_credentials_body = af_support_tools.rmq_consume_message( host=hostTLS, port=portTLS, ssl_enabled=True, queue='testRegisterVcenterResponse') print(my_response_credentials_body) af_support_tools.rmq_payload_to_file(my_response_credentials_body, path + responseRegVcenter) print("\nRegister response consumed.") data_Vcenter = open(path + responseRegVcenter, 'rU') dataVcenter = json.load(data_Vcenter) af_support_tools.rmq_purge_queue(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testRegisterVcenterRequest') af_support_tools.rmq_purge_queue(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testRegisterVcenterResponse') if dataVcenter is not None: assert "timestamp" in dataVcenter[ "messageProperties"], "No timestamp included in consumed response." assert "message" in dataVcenter[ "responseInfo"], "No message included in consumed response." assert dataVcenter["responseInfo"][ "message"] == "SUCCESS", "Registration attempt not returned as success." print("\nAll verification steps executed successfully.....") print("\nVcenter successfully registered....") return assert False, "Consumed message not as expected."
def test_SystemAdditionRequested(): print('Running Sanity on system: ', ipaddress) checkRMQStatus() cleanup() bindSDSQueus() print('\n*******************************************************') print( 'Step 1. Sending RMQ System-Definition Message to configure system...') # Get the payload data from the config symphony-sds.ini file. the_payload = af_support_tools.get_config_file_property( config_file=payload_file, heading=payload_header, property=payload_property_sys) time.sleep(1) # Publish the message af_support_tools.rmq_publish_message( host=ipaddress, rmq_username=rmq_username, rmq_password=rmq_password, exchange='exchange.dell.cpsd.syds.system.definition.request', routing_key='dell.cpsd.syds.converged.system.addition.requested', headers={ '__TypeId__': 'com.dell.cpsd.syds.converged.system.addition.requested' }, payload=the_payload) waitForMsg('test.system.list.request') return_message = af_support_tools.rmq_consume_message( host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, queue='test.system.list.request') published_json = json.loads(the_payload, encoding='utf-8') return_json = json.loads(return_message, encoding='utf-8') # Checking the "Message received" matches the "Message published" assert published_json == return_json print('\nTEST: Published Message Received: PASSED') # Step 2: Call the function to verify the generated credentials.addition.requested message is correct. verifyCSmessage() # Step 3: Call the function to verify the generated eids.identity.request & response message is correct. verifySDSEidsMessage() # Give the system time to be fully configured time.sleep(2) # Step 4: Call the function to verify the system exists. This will return the system UUID. verifySystemExists() # Step 5: Call the function to verify that all the UUIDs in the system are unique. verifyUniqueUuids() print('\n*******************************************************') cleanup()
def test_HAL_CollectComponentVersion(): #af_support_tools.mark_defect(defect_id='', user_id='', comments='', date_marked='') bindHALQueus() print('\n*******************************************************') print('Step 5: Sending RMQ HAL CollectComponentVersions Message') # Get the collectComponentVersions payload data from the config symphony-sds.ini file. the_payload = af_support_tools.get_config_file_property( config_file=payload_file, heading=payload_header, property=payload_property_hal) time.sleep(1) # Publish the HAL message to collectcomponentversions af_support_tools.rmq_publish_message( host=ipaddress, rmq_username=rmq_username, rmq_password=rmq_password, exchange='exchange.dell.cpsd.hal.orchestrator.request', routing_key='dell.cpsd.hal.orchestrator.collect.component.versions', headers={ '__TypeId__': 'com.dell.cpsd.hal.orchestrator.service.collect.component.versions' }, payload=the_payload) waitForMsg('test.hal.orchestrator.request') return_message = af_support_tools.rmq_consume_message( host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, queue='test.hal.orchestrator.request') published_json = json.loads(the_payload, encoding='utf-8') return_json = json.loads(return_message, encoding='utf-8') # Checking the "Message received" matches the "Message published" assert published_json == return_json print('\nTEST: Published Message Received: PASSED\n') #################################################################################################################### # # Verifying all Messages in the sequence are triggered correctly. # # 1. Verify that a System is returned waitForMsg('test.system.definition.response') return_message = af_support_tools.rmq_consume_message( host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, queue='test.system.definition.response') checklist = '"uuid":[]' if checklist in return_message: print('\nBUG: No System is returned in system.list.found Message\n') assert False return_json = json.loads(return_message, encoding='utf-8') assert return_json['convergedSystems'][0]['uuid'] print('Step 5a: A System has been returned') # 2. Verify that a List of components for that system is returned waitForMsg('test.system.definition.response') return_message = af_support_tools.rmq_consume_message( host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, queue='test.system.definition.response') checklist = '"components":[]' if checklist in return_message: print( '\nBUG: No Components are returned in component.configuration.found Message\n' ) assert False return_json = json.loads(return_message, encoding='utf-8') assert return_json['convergedSystems'][0]['components'][0] assert return_json['convergedSystems'][0]['endpoints'][0] print('Step 5b: The components for the System have been returned') # 3. Verify that a Component Credentials are returned waitForMsg('test.cms.credentials.response') return_message = af_support_tools.rmq_consume_message( host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, queue='test.cms.credentials.response') checklist = 'errors' if checklist in return_message: print('\nBUG: Error in cms.credentials.response Message\n') assert False return_json = json.loads(return_message, encoding='utf-8') assert return_json['credentials'][0]['credentialElement'] print( 'Step 5c: The credentials for the components belonging to the System have been returned' ) print('\nPlease wait. This next process can take a few minutes...\n') #################################################################################################################### # # We need to wait until the queue gets the response message and timeout if it never arrives q_len = 0 timeout = 0 while q_len < 1: time.sleep(1) timeout += 1 q_len = af_support_tools.rmq_message_count( host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, queue='test.hal.orchestrator.response') # If the test queue doesn't get a message them something is wrong. Time out needs to be high as msg can take 3+ minutes if timeout > 500: print( 'ERROR: HAL Response Message took to long to return. Something is wrong' ) cleanup() assert False # We are deliberately not removing the message from the queue as it will be consumed in a later test. ref: Joe return_message = af_support_tools.rmq_consume_message( host=ipaddress, port=port, rmq_username=rmq_username, rmq_password=rmq_password, queue='test.hal.orchestrator.response', remove_message=False) return_json = json.loads(return_message, encoding='utf-8') # Only if the message sequence successfully ran will the returned json message have the following attributes. assert return_json['messageProperties']['timestamp'] assert return_json['messageProperties']['correlationId'] assert return_json['messageProperties']['replyTo'] assert return_json['systems'][0]['uuid'] assert return_json['groups'] devices = return_json['devices'] #print(devices) if devices == None: print("No devices returned") assert return_json['devices'] assert return_json['subComponents'] assert return_json['groups'][0]['parentSystemUuids'] assert return_json['devices'][0]['uuid'] print("Step 5d: HAL has returned a valid response\n") verifyHalContent() # 4, Verify the EIDS message verifyHALEidsMessage() print('TEST: HAL CollectComponentVersions Completed: PASSED') print('\n*******************************************************') cleanup()
def registerScaleIO(setup): # Until consul is working properly & integrated with the vcenter adapter in the same environment we need to register # it manually by sending this message. cleanup('test.controlplane.scaleio.response') cleanup('test.endpoint.registration.event') bindQueues('exchange.dell.cpsd.controlplane.scaleio.response', 'test.controlplane.scaleio.response') bindQueues('exchange.dell.cpsd.endpoint.registration.event', 'test.endpoint.registration.event') time.sleep(2) af_support_tools.rmq_purge_queue( host='amqp', port=5671, ssl_enabled=True, queue='test.controlplane.scaleio.response') af_support_tools.rmq_purge_queue(host='amqp', port=5671, ssl_enabled=True, queue='test.endpoint.registration.event') the_payload = '{"messageProperties":{"timestamp":"2010-01-01T12:00:00Z","correlationId":"scaleio-full-abcd-abcdabcdabcd"},"registrationInfo":{"address":"https://' + \ setup['scaleIO_IP'] + '","username":"******","password":"******"}}' print(the_payload) af_support_tools.rmq_publish_message( host='amqp', port=5671, ssl_enabled=True, exchange='exchange.dell.cpsd.controlplane.scaleio.request', routing_key='dell.cpsd.scaleio.consul.register.request', headers={ '__TypeId__': 'com.dell.cpsd.scaleio.registration.info.request' }, payload=the_payload) # Verify the vcenter is validated assert waitForMsg('test.controlplane.scaleio.response' ), 'ERROR: No validation Message Returned' return_message = af_support_tools.rmq_consume_message( host='amqp', port=5671, ssl_enabled=True, queue='test.controlplane.scaleio.response', remove_message=True) return_json = json.loads(return_message, encoding='utf-8') print(return_json) assert return_json['responseInfo'][ 'message'] == 'SUCCESS', 'ERROR: ScaleIO validation failure' # Verify the system triggers a msg to register vcenter with consul assert waitForMsg('test.endpoint.registration.event' ), 'ERROR: No message to register with Consul sent' return_message = af_support_tools.rmq_consume_message( host='amqp', port=5671, ssl_enabled=True, queue='test.endpoint.registration.event', remove_message=True) return_json = json.loads(return_message, encoding='utf-8') print(return_json) endpointType = return_json['endpoint']['type'] timeout = 0 # We need to check that we received the registration msg for scaleio and not something else while endpointType != 'scaleio' and timeout < 20: assert waitForMsg( 'test.endpoint.registration.event' ), 'Error: No message to register with Consul sent by system' return_message = af_support_tools.rmq_consume_message( host='amqp', port=5671, ssl_enabled=True, queue='test.endpoint.registration.event', remove_message=True) return_json = json.loads(return_message, encoding='utf-8') print(return_json) endpointType = return_json['endpoint']['type'] timeout += 1 #assert return_json['endpoint']['type'] == 'scaleio', 'scaleio not registered with endpoint' cleanup('test.controlplane.scaleio.response') cleanup('test.endpoint.registration.event') print('scaleio registerd') time.sleep(3) return 1
def test_registerRackHD(): # Until consul is working properly & integrated with the rackhd adapter in the same environment we need to register # it manually by sending this message. This test is a prerequisite to getting the full list of cleanup('test.controlplane.rackhd.response') cleanup('test.endpoint.registration.event') bindQueues('exchange.dell.cpsd.controlplane.rackhd.response', 'test.controlplane.rackhd.response') bindQueues('exchange.dell.cpsd.endpoint.registration.event', 'test.endpoint.registration.event') time.sleep(2) af_support_tools.rmq_purge_queue(host='amqp', port=5671, ssl_enabled=True, queue='test.controlplane.rackhd.response') af_support_tools.rmq_purge_queue(host='amqp', port=5671, ssl_enabled=True, queue='test.endpoint.registration.event') the_payload = '{"messageProperties":{"timestamp":"2017-06-14T12:00:00Z","correlationId":"manually-reg-rackhd-3fb0-9696-3f7d28e17f72"},"registrationInfo":{"address":"http://' + rackHD_IP + ':8080/swagger-ui/","username":"******","password":"******"}}' print(the_payload) af_support_tools.rmq_publish_message( host='amqp', port=5671, exchange='exchange.dell.cpsd.controlplane.rackhd.request', routing_key='controlplane.rackhd.endpoint.register', headers={ '__TypeId__': 'com.dell.cpsd.rackhd.registration.info.request' }, payload=the_payload, ssl_enabled=True) # Verify the RackHD account can be validated assert waitForMsg('test.controlplane.rackhd.response' ), 'Error: No RackHD validation message received' return_message = af_support_tools.rmq_consume_message( host='amqp', port=5671, ssl_enabled=True, queue='test.controlplane.rackhd.response', remove_message=True) return_json = json.loads(return_message, encoding='utf-8') print(return_json) assert return_json['responseInfo'][ 'message'] == 'SUCCESS', 'ERROR: RackHD validation failure' #Following commented as it is failing and this is already being tested by another test case further down # Verify that an event to register the rackHD with endpoint registry is triggered # assert waitForMsg('test.endpoint.registration.event'), 'Error: No message to register with Consul sent by system' # return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, # ssl_enabled=True, # queue='test.endpoint.registration.event', # remove_message=True) # # return_json = json.loads(return_message, encoding='utf-8') # print (return_json) # assert return_json['endpoint']['type'] == 'rackhd', 'rackhd not registered with endpoint' cleanup('test.controlplane.rackhd.response') cleanup('test.endpoint.registration.event') time.sleep(3)
def test_identify_element(): cleanup() bind_queues() identified_errors = [] global elementUuid print('Sending Identify Element Message\n') af_support_tools.rmq_publish_message(host = 'amqp', port = 5671, ssl_enabled=True, exchange='exchange.dell.cpsd.eids.identity.request', routing_key='dell.cpsd.eids.identity.request', headers={'__TypeId__': 'dell.cpsd.core.identity.identify.element'}, payload=identifyelement, payload_type='json') return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, ssl_enabled=True, queue='test.identity.request') published_json = json.loads(identifyelement, encoding='utf-8') return_json = json.loads(return_message, encoding='utf-8') # Compare the 2 files. If they match the message was successfully published & received to rabbitMQ test queue. print("Verifying Message sent to RabbitMQ...") assert published_json == return_json, "Message Not Published to RabbitMQ" print('Published Message Received.') print('\nConsuming Response Message...') # At this stage we have verified that a message was published & received. # Next we need to check that we got the expected Response to our request. assert waitForMsg('test.identity.response'), "Message took too long to return" return_message = af_support_tools.rmq_consume_message(host='amqp', queue='test.identity.response') return_json = json.loads(return_message) # Verify the response message has the expected format & parameters print("Checking Response Message attributes...") if not return_json['timestamp']: identified_errors.append("No timestamp in message") if return_json['correlationId'] not in identifyelement: identified_errors.append("correlationId error") # Get number of element identifications in response total_ele_idents = len(return_json['elementIdentifications']) for _ in range(total_ele_idents): if return_json['elementIdentifications'][_]['correlationUuid'] not in identifyelement: identified_errors.append("correlationUuid error") assert return_json['elementIdentifications'][_]['elementUuid'] # Collect random element uuid for describe, from the total number of identified elements # We Subtract one from total_ele_idents to give use a random number from 0 to n total_ele_idents -= 1 elementUuid = return_json['elementIdentifications'][random.randint(0, total_ele_idents)]['elementUuid'] assert not identified_errors print('TEST: All requested CorrelationUuid have had elementUuid values returned: PASSED') print('\n*******************************************************')