def deleteTestQueues(testRequest, testResponse):
    # 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()

    # af_support_tools.rmq_purge_queue(host=host, port=port, rmq_username=rmq_username, rmq_password=rmq_password,
    #                                  queue=testRequest)
    # af_support_tools.rmq_purge_queue(host=host, port=port, rmq_username=rmq_username, rmq_password=rmq_password,
    #                                  queue=testResponse)

    af_support_tools.rmq_purge_queue(host=hostTLS, port=portTLS, ssl_enabled=True, queue=testRequest)
    af_support_tools.rmq_purge_queue(host=hostTLS, port=portTLS, ssl_enabled=True, queue=testResponse)
    af_support_tools.rmq_delete_queue(host=hostTLS, port=portTLS, ssl_enabled=True, queue=testRequest)
    af_support_tools.rmq_delete_queue(host=hostTLS, port=portTLS, ssl_enabled=True, queue=testResponse)
    # channel.queue_delete(queue=testRequest)
    # channel.queue_delete(queue=testResponse)
    time.sleep(2)
Example #2
0
def deleteTestQueues(testRequest, testResponse):
    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_purge_queue(host=hostTLS,
                                     port=portTLS,
                                     ssl_enabled=True,
                                     queue=testRequest)
    af_support_tools.rmq_purge_queue(host=hostTLS,
                                     port=portTLS,
                                     ssl_enabled=True,
                                     queue=testResponse)
    af_support_tools.rmq_delete_queue(host=hostTLS,
                                      port=portTLS,
                                      ssl_enabled=True,
                                      queue=testRequest)
    af_support_tools.rmq_delete_queue(host=hostTLS,
                                      port=portTLS,
                                      ssl_enabled=True,
                                      queue=testResponse)
Example #3
0
def resetTestQueues(testRequest, testResponse):
    messageReqHeader = {
        '__TypeId__':
        'com.dell.cpsd.rfds.rcm.definition.service.list.rcm.definitions'
    }
    messageResHeader = {
        '__TypeId__':
        'com.dell.cpsd.rcm.definition.service.rcm.definitions.summary'
    }

    af_support_tools.rmq_purge_queue(host=hostTLS,
                                     port=portTLS,
                                     ssl_enabled=True,
                                     queue=testRequest)
    af_support_tools.rmq_purge_queue(host=hostTLS,
                                     port=portTLS,
                                     ssl_enabled=True,
                                     queue=testResponse)

    af_support_tools.rmq_bind_queue(
        host=hostTLS,
        port=portTLS,
        ssl_enabled=True,
        queue='testListRCMDefinitionsRequest',
        exchange='exchange.dell.cpsd.rfds.rcm.definition.request',
        routing_key='#')
    af_support_tools.rmq_bind_queue(
        host=hostTLS,
        port=portTLS,
        ssl_enabled=True,
        queue='testListRCMDefinitionsResponse',
        exchange='exchange.dell.cpsd.rfds.rcm.definition.response',
        routing_key='#')
Example #4
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)
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)
Example #6
0
def resetTestQueues():
    # credentials = pika.PlainCredentials(rmq_username, rmq_password)
    # parameters = pika.ConnectionParameters(host, port, '/', credentials)
    # connection = pika.BlockingConnection(parameters)
    # channel = connection.channel()

    af_support_tools.rmq_purge_queue(host=hostTLS,
                                     port=portTLS,
                                     queue='testDownloadFWRequest',
                                     ssl_enabled=True)
    af_support_tools.rmq_purge_queue(host=hostTLS,
                                     port=portTLS,
                                     queue='testDownloadFWResponse',
                                     ssl_enabled=True)
    af_support_tools.rmq_purge_queue(host=hostTLS,
                                     port=portTLS,
                                     queue='testCredentialsRequest',
                                     ssl_enabled=True)
    af_support_tools.rmq_purge_queue(host=hostTLS,
                                     port=portTLS,
                                     queue='testCredentialsResponse',
                                     ssl_enabled=True)

    time.sleep(0.5)
    print("Old test queues successfully purged.")

    af_support_tools.rmq_bind_queue(
        host=hostTLS,
        port=portTLS,
        queue='testDownloadFWRequest',
        exchange='exchange.dell.cpsd.prepositioning.downloader.request',
        routing_key='#',
        ssl_enabled=True)
    af_support_tools.rmq_bind_queue(
        host=hostTLS,
        port=portTLS,
        queue='testDownloadFWResponse',
        exchange='exchange.dell.cpsd.prepositioning.downloader.response',
        routing_key='#',
        ssl_enabled=True)
    af_support_tools.rmq_bind_queue(host=hostTLS,
                                    port=portTLS,
                                    queue='testCredentialsRequest',
                                    exchange='exchange.dell.cpsd.esrs.request',
                                    routing_key='#',
                                    ssl_enabled=True)
    af_support_tools.rmq_bind_queue(
        host=hostTLS,
        port=portTLS,
        queue='testCredentialsResponse',
        exchange='exchange.dell.cpsd.esrs.response',
        routing_key='#',
        ssl_enabled=True)
    print("New test queues successfully initialized.")
Example #7
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_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')
Example #9
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."
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 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
Example #12
0
def test_registerscaleio():
    # Until consul is  working properly & integrated with the scaleio 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 capabilities

    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":"2017-06-14T12:00:00Z","correlationId":"manually-reg-scaleio-3fb0-9696-3f7d28e17f72"},"registrationInfo":{"address":"https://' + scaleio_IP + '","username":"******","password":"******"}}'

    af_support_tools.rmq_publish_message(
        host='amqp',
        port=5671,
        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,
        ssl_enabled=True)

    # Verify the scaleio account can be validated
    assert waitForMsg('test.controlplane.scaleio.response'
                      ), 'Error: No scaleio validation message received'
    return_message = af_support_tools.rmq_consume_message(
        host='amqp',
        port=5671,
        ssl_enabled=True,
        queue='test.controlplane.scaleio.response',
        remove_message=True)
    time.sleep(10)
    return_json = json.loads(return_message, encoding='utf-8')

    assert return_json['responseInfo'][
        'message'] == 'SUCCESS', 'ERROR: scaleio validation failure'

    # Verify that an event to register the scaleio 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')
    ## Disabled ---- need to talk to test Author as functionality is working manually
    #assert return_json['endpoint']['type'] == 'scaleio', 'scaleio not registered with endpoint'

    cleanup('test.controlplane.scaleio.response')
    cleanup('test.endpoint.registration.event')