def verifyHALEidsMessage():
    # We need to verify that the triggered eids.identity.request is valid.
    # Check the EIDS request messages
    print('Verifying EIDS returns UIDS for all discovered subcomponents')
    waitForMsg('test.eids.identity.request')
    return_message = af_support_tools.rmq_consume_message(host=ipaddress, port=port, rmq_username=rmq_username,
                                                          rmq_password=rmq_password,
                                                          queue='test.eids.identity.request')

    return_json = json.loads(return_message, encoding='utf-8')

    assert return_json['correlationId']
    # assert return_json['replyTo']
    assert return_json['timestamp']
    assert return_json['elementUuids'][0]

    # Test the 2nd message
    waitForMsg('test.eids.identity.request')
    return_message = af_support_tools.rmq_consume_message(host=ipaddress, port=port, rmq_username=rmq_username,
                                                          rmq_password=rmq_password,
                                                          queue='test.eids.identity.request')

    return_json = json.loads(return_message, encoding='utf-8')

    assert return_json['correlationId']
    # assert return_json['replyTo']
    assert return_json['timestamp']
    assert return_json['elementIdentities'][0]['correlationUuid']
    assert return_json['elementIdentities'][0]['identity']['elementType']
    assert return_json['elementIdentities'][0]['identity']['contextualKeyAccuracy']

    # Check the EIDS response message
    waitForMsg('test.eids.identity.response')
    return_message = af_support_tools.rmq_consume_message(host=ipaddress, port=port, rmq_username=rmq_username,
                                                          rmq_password=rmq_password,
                                                          queue='test.eids.identity.response')

    return_json = json.loads(return_message, encoding='utf-8')

    assert return_json['correlationId']
    # assert return_json['replyTo']
    assert return_json['timestamp']
    assert return_json['elementDescriptions'][0]['elementUuid']

    # Test the 2nd message
    waitForMsg('test.eids.identity.response')
    return_message = af_support_tools.rmq_consume_message(host=ipaddress, port=port, rmq_username=rmq_username,
                                                          rmq_password=rmq_password,
                                                          queue='test.eids.identity.response')

    return_json = json.loads(return_message, encoding='utf-8')

    assert return_json['correlationId']
    # assert return_json['replyTo']
    assert return_json['timestamp']
    assert return_json['elementIdentifications'][0]['correlationUuid']
    assert return_json['elementIdentifications'][0]['elementUuid']

    print('Step 5f: EIDS requests & receives messages for all discovered subcomponents \n')
    time.sleep(1)
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 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)
Beispiel #5
0
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 verifyEidsMessage():
    # We need to verify that the triggered eids.identity.request is valid.
    # Check the EIDS request messages
    print('\nVerifying Identity Service request & response for UUID')

    waitForMsg('test.eids.identity.request')
    return_message = af_support_tools.rmq_consume_message(
        host=ipaddress,
        port=port,
        rmq_username=rmq_username,
        rmq_password=rmq_password,
        queue='test.eids.identity.request')

    return_json = json.loads(return_message, encoding='utf-8')

    assert return_json['correlationId']
    # assert return_json['replyTo']
    assert return_json['timestamp']
    assert return_json['elementIdentities'][0]['correlationUuid']
    assert return_json['elementIdentities'][0]['identity'][
        'elementType'] == 'computeServer'
    assert return_json['elementIdentities'][0]['identity'][
        'contextualKeyAccuracy'] == 1

    # Check the EIDS response message
    waitForMsg('test.eids.identity.response')
    return_message = af_support_tools.rmq_consume_message(
        host=ipaddress,
        port=port,
        rmq_username=rmq_username,
        rmq_password=rmq_password,
        queue='test.eids.identity.response')

    return_json = json.loads(return_message, encoding='utf-8')

    assert return_json['correlationId']
    # assert return_json['replyTo']
    assert return_json['timestamp']
    assert return_json['elementIdentifications'][0]['correlationUuid']
    assert return_json['elementIdentifications'][0]['elementUuid']

    uuid = return_json['elementIdentifications'][0]['elementUuid']

    print(
        '\nTest Pass: EIDS requests & response messages received for new node')
    print('New Node UUID:', uuid)

    return uuid
def rmqNodeDiscover():
    # Step 1: Verify the Node Discovered Event
    # Receive the node discover message

    waitForMsg('test.rackhd.node.discovered.event')
    return_message = af_support_tools.rmq_consume_message(
        host=ipaddress,
        port=port,
        rmq_username=rmq_username,
        rmq_password=rmq_password,
        queue='test.rackhd.node.discovered.event')

    print('from: dell.cpsd.adapter.rackhd.node.discovered.event')
    checkForErrors(return_message)
    checkForFailures(return_message)

    return_json = json.loads(return_message, encoding='utf-8')

    #TODO verify the message
    assert return_json['action'] == 'discovered'
    assert return_json['type'] == 'node'
    assert return_json['data']['ipMacAddresses']
    assert return_json['data']['nodeId']
    assert return_json['data']['nodeType'] == 'compute'

    nodeIPAddress = return_json['data']['ipMacAddresses'][0]['ipAddress']
    nodeMACAddress = return_json['data']['ipMacAddresses'][0]['macAddress']

    print('\nNew Node IP Addres', nodeIPAddress, '\nNew Node MAC Addres',
          nodeMACAddress)

    # Step 2: Verify the EIDS Messages sequence and get UUID for new node
    uuid = verifyEidsMessage()
    return uuid
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 verifyHalContent():

    print('Verifying content of the HAL response message...')
    # Get the payload data from the config symphony-sds.ini file.
    originalSys = af_support_tools.get_config_file_property(config_file=payload_file,
                                                            heading=payload_header,
                                                            property=payload_property_sys)

    originalSys_json = json.loads(originalSys, encoding='utf-8')

    orignumComponents = 0
    for x in originalSys_json['convergedSystem']['components']:
        orignumComponents += 1

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

    returnnumDevices = 0
    for x in return_json['devices']:
        returnnumDevices += 1

    print('Original: ',orignumComponents, ' Returned: ', returnnumDevices)

    if orignumComponents != returnnumDevices:
        print('ERROR: Not all components have returned values. Possible h/w or credential issue.')
        assert orignumComponents == returnnumDevices

    print('Step 5e: All devices have been returned\n')
def checkForErrorMsg():
    print('Checking for error messages...')
    msg_count = af_support_tools.rmq_message_count(
        host=ipaddress,
        port=port,
        rmq_username=rmq_username,
        rmq_password=rmq_password,
        queue='test.system.list.found')

    if msg_count == 1:
        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')

        error_msg = return_json['errors'][0]['message']
        print('\nRMQ Error Message:: ', error_msg)
        assert False

    msg_count = af_support_tools.rmq_message_count(
        host=ipaddress,
        port=port,
        rmq_username=rmq_username,
        rmq_password=rmq_password,
        queue='test.system.definition.response')

    if msg_count == 1:
        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')

        return_json = json.loads(return_message, encoding='utf-8')

        error_msg = return_json['errors'][0]['message']
        print('\nRMQ Error Message:: ', error_msg)
        assert False

    else:
        print('No specific error looked for.')
        assert False
def CS_CredReq_invalidMsgProp():
    print(
        "Running test No. 8 - Request Credentials with Invalid message properties..."
    )

    clearLogFiles()

    the_payload = af_support_tools.get_config_file_property(
        config_file=payload_file,
        heading=payload_heading,
        property=payload_property_neg4)

    publishMessageCredReq(the_payload)

    return_message = af_support_tools.rmq_consume_message(
        host=ipaddress,
        port=port,
        rmq_username=rmq_username,
        rmq_password=rmq_password,
        queue='test.component.credential.request')

    validJson(return_message)
    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('Published Message Received: PASSED')

    # There will be no response message. We can verify the "test.component.credential.response" queue is empty.
    q_len = af_support_tools.rmq_message_count(
        host=ipaddress,
        port=port,
        rmq_username=rmq_username,
        rmq_password=rmq_password,
        queue='test.component.credential.response')
    assert q_len == 0

    sendCommand = 'docker ps | grep credentials-service | awk \'{system("docker exec -i "$1" cat /opt/dell/cpsd/credentials/logs/credentials-service-error.log") }\''
    error1 = "VAMQP2004E Message property [correlationId] is empty.]"
    error2 = "VAMQP1008E AMQP error"
    error3 = "(attempt 3)"

    my_return_text = af_support_tools.send_ssh_command(host=ipaddress,
                                                       username=cli_username,
                                                       password=cli_password,
                                                       command=sendCommand,
                                                       return_output=True)
    time.sleep(2)

    assert error1 in my_return_text
    assert error2 in my_return_text
    assert error3 not in my_return_text

    print('Test 8 of 9: Invalid Message Format: TEST PASSED\n')
    print('************************************************')
    time.sleep(1)
def consumeResponse(testqueue):
    """ Consume the next message received on the testqueue and return the message in json format"""
    waitForMsg('test.dne.paqx.node.response')
    rxd_message = af_support_tools.rmq_consume_message(host='amqp', port=5671,
                                                              queue=testqueue,
                                                              ssl_enabled=True)

    rxd_json = json.loads(rxd_message, encoding='utf-8')
    return rxd_json
Beispiel #13
0
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')
Beispiel #14
0
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)
Beispiel #15
0
def verifyEidsMessage():
    # We need to verify that the triggered eids.identity.request is valid.
    # Check the EIDS request messages
    # Return the EIDS UUID generated value

    assert waitForMsg('test.eids.identity.request'), 'Error: No request sent to EIDS'
    return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, ssl_enabled=True,
                                                          queue='test.eids.identity.request')

    # Check the EIDS response message
    assert waitForMsg('test.eids.identity.response'), 'Error: Mor response for EIDS'
    return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, ssl_enabled=True,
                                                          queue='test.eids.identity.response')

    return_json = json.loads(return_message, encoding='utf-8')

    uuid = return_json['elementIdentifications'][0]['elementUuid']

    return uuid
def CS_CredAdd_noCompUuid():
    print("Running test No. 4 - No componentUuid value set...")

    # Calling and using the payload from symphony-sds.ini file
    the_payload = af_support_tools.get_config_file_property(
        config_file=payload_file,
        heading=payload_heading,
        property=payload_property_neg1)

    publishMessageCredAdd(the_payload)

    time.sleep(2)

    # Consume received
    return_message = af_support_tools.rmq_consume_message(
        host=ipaddress,
        port=port,
        rmq_username=rmq_username,
        rmq_password=rmq_password,
        queue='test.component.credential.request')

    validJson(return_message)
    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('Published Message Received: PASSED')

    return_message = af_support_tools.rmq_consume_message(
        host=ipaddress,
        port=port,
        rmq_username=rmq_username,
        rmq_password=rmq_password,
        queue='test.component.credential.response')

    return_json = json.loads(return_message, encoding='utf-8')

    # TODO - Find out the expected behaviour. Currently there is a defect. DE11732

    print('Test 4 of 9: THIS TEST IS INCOMPLETE. THERE IS A DEFECT\n')
    print('************************************************')
    time.sleep(1)
def test_SystemAdditionRequested():
    q_len = 0
    timeout = 0
    cleanupSDS()

    bindSDSQueus()

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

    urldefine = 'http://' + host + ':5500/v1/amqp/'
    headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
    requests.post(urldefine, data=the_payload, headers=headers)

    time.sleep(30)

    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='testSystemListRequest')

        print(q_len)

        if timeout > 30:
            print('ERROR: System list Request Message took to long to return. Something is wrong')
            cleanupSDS()
            break

    return_message = af_support_tools.rmq_consume_message(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testSystemListRequest')

    return_json = json.loads(return_message)

    assert return_json['messageProperties']
    assert return_json['convergedSystem']['groups']
    assert return_json['convergedSystem']['definition']
    assert return_json['convergedSystem']['components']
    assert return_json['convergedSystem']['endpoints']

    # Call the function to verify the generated credentials.addition.requested message is correct.
    time.sleep(60)
    verifyCSmessage()

    mess_count = af_support_tools.rmq_message_count(host=hostTLS, port=portTLS, ssl_enabled=True, queue='testSystemDefinitionEvent')
    assert mess_count >= 2, "Unexpected number of components defined."

    # Call the function to verify the system exists. This is not a necessary step but it will return the system UUID.
    verify_SystemExists()
    #verifyConsulUpdate("rcm-fitness-paqx", "rcm-fitness-api")

    cleanupSDS()
def consumeResponse():
    """ Consume the next message received on the testqueue and return the message in json format"""

    waitForMsg('test.ess.service.response')

    return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, ssl_enabled=True,
                                                          queue='test.ess.service.response')

    return_message = json.loads(return_message, encoding='utf-8')

    return return_message
def CS_CredReq_invalidJson():
    print("Running test No. 7 - Invalid json file...")

    clearLogFiles()

    print('check log file')
    time.sleep(30)

    the_payload = af_support_tools.get_config_file_property(
        config_file=payload_file,
        heading=payload_heading,
        property=payload_property_neg3)

    publishMessageCredReq(the_payload)

    return_message = af_support_tools.rmq_consume_message(
        host=ipaddress,
        port=port,
        rmq_username=rmq_username,
        rmq_password=rmq_password,
        queue='test.component.credential.request')

    try:
        return_json = json.loads(return_message, encoding='utf-8')
        i_am_json = True
    except Exception:
        i_am_json = False

    assert i_am_json == False
    if i_am_json == False:
        print('Verified json is invalid')

    sendCommand = 'docker ps | grep credentials-service | awk \'{system("docker exec -i "$1" cat /opt/dell/cpsd/credentials/logs/credentials-service-error.log") }\''
    error1 = "VAMQP1008E AMQP error (attempt 1)"
    error2 = "expected close marker for Object"
    error3 = "(attempt 3)"

    # Return contents of the credentials-service-error.log
    my_return_text = af_support_tools.send_ssh_command(host=ipaddress,
                                                       username=cli_username,
                                                       password=cli_password,
                                                       command=sendCommand,
                                                       return_output=True)

    time.sleep(3)

    assert error1 in my_return_text
    assert error2 in my_return_text
    assert error3 not in my_return_text

    print('Test 7 of 9: Invalid JSON: TEST PASSED\n')
    print('************************************************')
    time.sleep(1)
Beispiel #20
0
def rmqNodeDiscover():
    # Verify the Node Discovered Event message
    # Return the newly discovered nodeID value

    assert waitForMsg('test.rackhd.node.discovered.event'), 'Error: No Node Discovered Msg Recieved'
    return_message = af_support_tools.rmq_consume_message(host='amqp', port=5671, ssl_enabled=True,
                                                          queue='test.rackhd.node.discovered.event')

    return_json = json.loads(return_message, encoding='utf-8')

    nodeID = return_json['data']['nodeId']

    return nodeID
def verifyCSmessage():
    # We need to verify that the triggered component.credentials.addition.requested is valid.
    time.sleep(1)
    print('\n*******************************************************')
    print(
        'Step 2. Verifying the trigged component.credentials.addition.requested is valid...'
    )

    # We need to wait until the queue gets the response message
    waitForMsg('test.component.credential.request')

    return_message = af_support_tools.rmq_consume_message(
        host=ipaddress,
        port=port,
        rmq_username=rmq_username,
        rmq_password=rmq_password,
        queue='test.component.credential.request')

    return_json = json.loads(return_message, encoding='utf-8')

    # These 3 values must be returned.
    if 'credentialUuid' not in return_message:
        print(
            '\nTEST FAIL: Invalid "credentials.addition.requested" message structure. credentialUuid missing'
        )
        assert False

    if 'endpointUuid' not in return_message:
        print(
            '\nTEST FAIL: Invalid "credentials.addition.requested" message structure. endpointUuid missing'
        )
        assert False

    if 'componentUuid' not in return_message:
        print(
            '\nTEST FAIL: Invalid "credentials.addition.requested" message structure. componentUuid missing'
        )
        assert False

    assert return_json['messageProperties']['correlationId']
    assert return_json['messageProperties']['replyTo']
    assert return_json['messageProperties']['timestamp']
    assert return_json['endpoints'][0]['credentials'][0]['credentialUuid']
    assert return_json['endpoints'][0]['endpointUuid']
    assert return_json['componentUuid']
    print('\nTEST: credentials.addition.requested is valid: PASSED')
    time.sleep(1)
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 verifySDSEidsMessage():
    # We need to verify that the triggered eids.identity.request is valid.
    time.sleep(1)
    print('\n*******************************************************')
    print('Step 3. Verifying the trigged eids.identity.request & response are valid...')

    # Check the EIDS request message
    # We need to wait until the queue gets the request message
    waitForMsg('test.eids.identity.request')

    return_message = af_support_tools.rmq_consume_message(host=ipaddress, port=port, rmq_username=rmq_username,
                                                          rmq_password=rmq_password,
                                                          queue='test.eids.identity.request')

    return_json = json.loads(return_message, encoding='utf-8')

    # Check how many Uuids are requested by EIDS this should match how many were originally configured at the start
    elementIdentities = 0
    for x in return_json['elementIdentities']:
        elementIdentities += 1

    originalNum = getNumItems()

    assert originalNum == elementIdentities
    print(elementIdentities, ' UUIDs requested. ', originalNum, ' Originally configured.')

    # These are commented out until RMQ refactoring happens
    # assert return_json['messageProperties']['correlationId']
    # assert return_json['messageProperties']['replyTo']
    # assert return_json['messageProperties']['timestamp']
    assert return_json['elementIdentities'][0]['correlationUuid']
    assert return_json['elementIdentities'][0]['identity']['elementType']
    assert return_json['elementIdentities'][0]['identity']['contextualKeyAccuracy']

    # Check the EIDS ressponse message
    # We need to wait until the queue gets the response message
    waitForMsg('test.eids.identity.response')

    return_message = af_support_tools.rmq_consume_message(host=ipaddress, port=port, rmq_username=rmq_username,
                                                          rmq_password=rmq_password,
                                                          queue='test.eids.identity.response')

    return_json = json.loads(return_message, encoding='utf-8')

    # Check how many Uuids are returned by EIDS this should match what were originally configured
    elementIdentifications = 0
    for x in return_json['elementIdentifications']:
        elementIdentifications += 1

    originalNum = getNumItems()

    assert originalNum == elementIdentifications
    print(elementIdentifications, ' UUIDs created. ', originalNum, ' Originally configured.')

    # These are commented out until RMQ refactoring happens
    # assert return_json['messageProperties']['correlationId']
    # assert return_json['messageProperties']['replyTo']
    # assert return_json['messageProperties']['timestamp']
    assert return_json['elementIdentifications'][0]['correlationUuid']
    assert return_json['elementIdentifications'][0]['elementUuid']

    print('\nTEST: trigged eids.identity.request & response: PASSED')
    time.sleep(1)
Beispiel #24
0
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."
Beispiel #25
0
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')
Beispiel #26
0
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')
Beispiel #27
0
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_capabilityRegistry_Control_and_Binding_Pong_Message_dne():
    """
    Title           :       Verify the Capability Registry Binding Pong Message
    Description     :       Every 7 seconds the Capability Registery sends out a message asking "who's out there?".
                            This is a "ping" message. Each service that is alive will respond with a "pong" message.
                            The correlationID value will be the same on all messages so this is used to track that we
                            are getting the correct message and not just "any" message.
                            It will fail if :
                               Not all expected services respond with their Pong message.
                               If a service responds twice (indicates multiple containers are running for the same service)
    Parameters      :       none
    Returns         :       None
    """
    print(
        "Test: The Capability Registry Binding. Verify the Pong message from each provider / adapter"
    )

    # This is the list of DNE Specific current/providers
    capabilityProvider_Node_Discovery_Paqx = 'dell-cpsd-dne-node-discovery-service'

    # Each provider/adapter is given a flag that will be set to True once its responded. This method is used as the order
    node_Discovery_Paqx_Tested = False

    allTested = False

    # To prevent the test waiting indefinitely we need to provide a timeout.  When new adapters/providers are added to
    # the test the expectedNumberOfBindings value will increase.
    errorTimeout = 0
    expectedNumberOfBindings = 9

    # Keep consuming messages until this condition is no longer true
    while allTested == False and errorTimeout <= expectedNumberOfBindings:

        # Only a message that comes in with the same correlationID as the Ping message is tested
        waitForMsg('test.capability.registry.binding')
        return_message = af_support_tools.rmq_consume_message(
            host='amqp',
            port=5671,
            queue='test.capability.registry.binding',
            ssl_enabled=True,
            remove_message=False,
            return_basic_properties=True)

        #testcorrelationID = return_message[0].correlation_id
        #testcorrelationID = json.dumps(testcorrelationID)
        testcorrelationID = return_message[0]['correlation_id']

        if testcorrelationID == correlationID:  # Only check messages that have the same CorrelationID as the ping message

            error_list = []
            return_message = af_support_tools.rmq_consume_message(
                host='amqp',
                port=5671,
                queue='test.capability.registry.binding',
                ssl_enabled=True)
            checkForErrors(return_message)

            if capabilityProvider_Node_Discovery_Paqx in return_message:
                if (node_Discovery_Paqx_Tested == True):
                    error_list.append(capabilityProvider_Node_Discovery_Paqx)
                else:
                    print('Test:', capabilityProvider_Node_Discovery_Paqx,
                          'Binding Message returned\n')
                    node_Discovery_Paqx_Tested = True

            assert not error_list, 'Multiple Containers Running'

            if node_Discovery_Paqx_Tested == True:
                allTested = True

        # A timeout is included to prevent an infinite loop waiting for a response.
        # If a response hasn't been received the flag will still be false and this can be used to return an error.
        if errorTimeout == expectedNumberOfBindings:

            error_list = []

            if node_Discovery_Paqx_Tested == False:
                print('ERROR:', capabilityProvider_Node_Discovery_Paqx,
                      'Binding Message is not returned')
                error_list.append(capabilityProvider_Node_Discovery_Paqx)

            assert not error_list, 'Not all expected bindings are replying'

        errorTimeout += 1

    print('\n*******************************************************\n')

    cleanup()
def test_capabilityRegistry_Control_and_Binding_Ping_Message_core():
    """
    Title           :       Verify the Capability Registry Control Ping Message of the Core services
    Description     :       Every 7 seconds the Capability Registery sends out a message asking "who's out there?".
                            This is a "ping" message. Each service that is alive will respond with a "pong" message.
                            The correlationID value will be the same on all messages so this is used to track that we
                            are getting the correct message and not just "any" message.
                            It will fail if :
                               No capability.registry.control message is published.
                               The containerID does not match the body of the message.
    Parameters      :       none
    Returns         :       None
    """

    print('\nRunning Test on system: ', ipaddress)

    cleanup()
    bindQueues()

    print('\n*******************************************************\n')

    global correlationID  # Set as a Global parameter as it will be used in the next test.

    # Ensure the Control & Binding Queues are empty to start
    af_support_tools.rmq_purge_queue(host='amqp',
                                     port=5671,
                                     queue='test.capability.registry.control',
                                     ssl_enabled=True)

    af_support_tools.rmq_purge_queue(host='amqp',
                                     port=5671,
                                     queue='test.capability.registry.binding',
                                     ssl_enabled=True)

    print('\nTest: The Capability Registry Control. Verify the Ping message')

    # Wait for & consume a "Ping" Message. The message is left in the queue to be consumed again. The correlationID is
    # in the header and the return_basic_properties flag is set to True in order to get the header value. When
    # basic_properties are returned the message cannot be converted to json which is the reason its "consumed" twice.
    waitForMsg('test.capability.registry.control')
    return_message = af_support_tools.rmq_consume_message(
        host='amqp',
        port=5671,
        queue='test.capability.registry.control',
        ssl_enabled=True,
        remove_message=False,
        return_basic_properties=True)

    # Save the correlationID to be used in next part of the test
    #correlationID = return_message[0].correlation_id
    #correlationID = json.dumps(correlationID)
    correlationID = return_message[0]['correlation_id']

    print('The CorrelationID for this Control Msg:', correlationID)

    # The message is consumed again, checked for errors and converted to JSON. The body of the message contains the
    # containerID under the "hostname" value. This value will be compared to the actual containerID value
    return_message = af_support_tools.rmq_consume_message(
        host='amqp',
        port=5671,
        queue='test.capability.registry.control',
        ssl_enabled=True)

    checkForErrors(return_message)
    return_json = json.loads(return_message, encoding='utf-8')
    retunedValue = return_json['hostname']

    # Get the actual Container ID value and compare it to the RMQ message body
    containerID = getdockerID(
        'capability-registry-service'
    )  # getdockerID() logs into vm and returns the dockerID

    # The value in the msg body should match the container ID. If they do not match indicates multiple containers
    assert containerID == retunedValue, 'ContainerID does not match RMQ mesage body. Check for multiple containers'

    print(
        'The Capability Registry Control Ping message is sent and has the correct containerID:',
        containerID)
    print('\n*******************************************************\n')
Beispiel #30
0
def test_HAL_CollectComponentVersion():
    bindHALQueus()
    registerRackHD(message_rackHD, "out_registerRackHDResp.json")
    time.sleep(2)
    registerVcenter(message_vcenter, "out_registerVcenterResp.json")
    print(host)
    # 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)

    urlcollect = 'http://' + host + ':5500/v1/amqp/'
    headers = {
        'Content-type': 'application/json',
        'Accept': 'application/json'
    }
    requests.post(urlcollect, data=the_payload, headers=headers)
    time.sleep(2)
    return_message = af_support_tools.rmq_consume_message(
        host=hostTLS,
        port=portTLS,
        ssl_enabled=True,
        queue='testHalOrchestratorRequest',
        remove_message=False)

    return_json = json.loads(return_message, encoding='utf-8')

    print(return_json)
    assert return_json['messageProperties']['correlationId']
    assert return_json['messageProperties']['replyTo']

    # 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=hostTLS,
            port=portTLS,
            ssl_enabled=True,
            queue='testHalOrchestratorResponse')

        if timeout > 500:
            print(
                'ERROR: HAL Responce Message took to long to return. Something is wrong'
            )
            cleanupHAL()
            break

    return_message = af_support_tools.rmq_consume_message(
        host=hostTLS,
        port=portTLS,
        ssl_enabled=True,
        queue='testHalOrchestratorResponse',
        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']['correlationId']
    assert return_json['messageProperties']['replyTo']
    assert return_json['systems']
    assert return_json['groups']
    assert return_json['devices']
    assert return_json['subComponents']

    print('\nTEST: CollectComponentVersions run: PASSED')

    cleanupHAL()