Example #1
0
def test_cap_reg_install(setup):
    """
    Title: Verify the sds service can be installed
    Description: This test verifies that the sds service can be installed successfully
    Params: dell-cpsd-capability-registry-service
    Returns: None

    """
    service = "dell-cpsd-capability-registry-service"

    print(test_cap_reg_install.__doc__)

    expirecache = "yum clean expire-cache"
    makecache = "yum makecache fast"
    sendcommand = "yum install -y " + service

    af_support_tools.send_ssh_command(host=setup['IP'],
                                      username=setup['user'],
                                      password=setup['password'],
                                      command=expirecache,
                                      return_output=True)

    af_support_tools.send_ssh_command(host=setup['IP'],
                                      username=setup['user'],
                                      password=setup['password'],
                                      command=makecache,
                                      return_output=True)

    my_return_status = af_support_tools.send_ssh_command(
        host=setup['IP'],
        username=setup['user'],
        password=setup['password'],
        command=sendcommand,
        return_output=False)
    assert my_return_status == 0, "capability Reg did not install"
Example #2
0
def deletePreviousDownloadFiles(filename, filepath):
    sendCommand = "find /opt/dell/cpsd -name downloads"
    dirStatus = af_support_tools.send_ssh_command(host=host,
                                                  username=cli_username,
                                                  password=cli_password,
                                                  command=sendCommand,
                                                  return_output=True)

    if dirStatus is not "":
        dirStatus = dirStatus.rstrip() + "/"
    else:
        print("Downloads directory is missing.")

    if filepath in dirStatus:
        sendCommand = "rm -rf " + dirStatus + "*"
        fileDelete = af_support_tools.send_ssh_command(host=host,
                                                       username=cli_username,
                                                       password=cli_password,
                                                       command=sendCommand,
                                                       return_output=True)
        sendCommand = 'find / -name "' + filename + '"'
        fileStatus = af_support_tools.send_ssh_command(host=host,
                                                       username=cli_username,
                                                       password=cli_password,
                                                       command=sendCommand,
                                                       return_output=True)
        assert filepath not in fileStatus, "File was not removed successfully."
    else:
        print(filename + "not found in the repo directory.")
Example #3
0
def test_sysdef_install(setup):
    #this test is working (TW)
    """
    Title: Verify the dell-cpsd-hal-rackhd-adapter service can be installed
    Description: This test verifies that the dell-cpsd-hal-rackhd-adapter service can be installed successfully
    Params: dell-cpsd-hal-rackhd-adapter
    Returns: None

    """
    service = "dell-cpsd-hal-rackhd-adapter"

    print(test_sysdef_install.__doc__)

    expirecache = "yum clean expire-cache"
    makecache = "yum makecache fast"
    sendcommand = "yum install -y " + service

    af_support_tools.send_ssh_command(host=setup['IP'], username=setup['user'],
                                                         password=setup['password'],
                                                         command=expirecache, return_output=True)

    af_support_tools.send_ssh_command(host=setup['IP'], username=setup['user'],
                                                         password=setup['password'],
                                                         command=makecache, return_output=True)


    my_return_status = af_support_tools.send_ssh_command(host=setup['IP'], username=setup['user'],
                                                             password=setup['password'],
                                                             command=sendcommand, return_output=False)
    assert my_return_status == 0, " %s did not install" % service
def insertNodeIntoDB(elementId, nodeId, nodeStatus, setup):
    """ Insert a new node entry, DISCOVERED state, into the compute_node table in the postgres database.

    :parameter: elementId - symphonyUUID (eg. '44f0d5ac-44a6-48e0-bf98-93eaa7f452d3')
    :parameter: nodeId - rackHD-node-ID (eg. '443819a2dc8f96b33e08569d')
    :parameter: nodeStatus - state (eg. RESERVED or DISCOVERED or ADDED ...)
    :return: The result of the psql command (success result is 'INSERT 0 1')
    """

    nodeSerial = "88888888"
    nodeProduct = "R730 Base"
    nodeVendor = ""

    # write the INSERT command into a file on the remote host for ease of execution
    # then copy that file into the postgres docker container
    # then  ask postgres to execute the command in the file
    insertCmd = "insert into compute_node(ELEMENT_ID, NODE_ID, NODE_STATUS, NODE_SERIAL, NODE_PRODUCT, NODE_VENDOR, LOCKING_VERSION) values (\'" + \
                elementId + "\', \'" + nodeId + "\', \'" + nodeStatus + "\', \'" + nodeSerial + "\',\'" + nodeProduct + "\',\'" + nodeVendor + "\', 0);"


    writeToFileCmd = "echo \"" + insertCmd + "\" > /tmp/sqlInsert.txt"

    copyFileToContainerCmd = "docker cp /tmp/sqlInsert.txt postgres:/tmp/sqlInsert.txt"

    execSQLCommand = "docker exec -i postgres sh -c \'su - postgres sh -c \"psql \\\"dbname=node-discovery-service\\\" -f /tmp/sqlInsert.txt\"\'"

    try:
        result = af_support_tools.send_ssh_command(
           host=setup['IP'],
           username=setup['cli_user'],
           password=setup['cli_password'],
           command=writeToFileCmd,
           return_output=True)

    
        result = af_support_tools.send_ssh_command(
           host=setup['IP'],
           username=setup['cli_user'],
           password=setup['cli_password'],
           command=copyFileToContainerCmd,
           return_output=True)


        result = af_support_tools.send_ssh_command(
            host=setup['IP'],
            username=setup['cli_user'],
            password=setup['cli_password'],
            command=execSQLCommand,
            return_output=True)

        sleeptime = 10

        return result

    except Exception as err:
        # Return code error
        print(err, '\n')
        raise Exception(err)
def clearLogFiles():
    sendCommand = 'docker ps | grep credentials-service | awk \'{system("docker exec -i "$1" sh -c \\"echo > /opt/dell/cpsd/credentials/logs/credentials-service-error.log\\"") }\''
    af_support_tools.send_ssh_command(host=ipaddress,
                                      username=cli_username,
                                      password=cli_password,
                                      command=sendCommand,
                                      return_output=False)

    time.sleep(2)
def test_capabilityRegistry_log_files_free_of_exceptions(setup):
    """
    Title           :       Verify there are no exceptions in the log files
    Description     :       This method tests that the Capability Registry log files contain no Exceptions.
                            It will fail:
                                If the the error and/or info log files do not exists
                                If the error log file contains AuthenticationFailureException, RuntimeException or NullPointerException.
    Parameters      :       None
    Returns         :       None
    """

    filePath = '/opt/dell/cpsd/capability-registry-service/logs/'
    errorLogFile = 'capability-registry-error.log'
    excep1 = 'AuthenticationFailureException'
    excep2 = 'RuntimeException'
    excep3 = 'NullPointerException'

    error_list = []

    # Verify there are no Authentication errors
    sendCommand = 'cat ' + filePath + errorLogFile + ' | grep \'' + excep1 + '\''
    my_return_status = af_support_tools.send_ssh_command(
        host=setup['IP'],
        username=setup['user'],
        password=setup['password'],
        command=sendCommand,
        return_output=True)
    if (excep1 in my_return_status):
        error_list.append(excep1)

    # Verify there are no RuntimeException errors
    sendCommand = 'cat ' + filePath + errorLogFile + ' | grep \'' + excep2 + '\''
    my_return_status = af_support_tools.send_ssh_command(
        host=setup['IP'],
        username=setup['user'],
        password=setup['password'],
        command=sendCommand,
        return_output=True)
    if (excep2 in my_return_status):
        error_list.append(excep2)

    # Verify there are no NullPointerException errors
    sendCommand = 'cat ' + filePath + errorLogFile + ' | grep \'' + excep3 + '\''
    my_return_status = af_support_tools.send_ssh_command(
        host=setup['IP'],
        username=setup['user'],
        password=setup['password'],
        command=sendCommand,
        return_output=True)
    if (excep3 in my_return_status):
        error_list.append(excep3)

    assert not error_list, 'Exceptions in log files, Review the ' + errorLogFile + ' file'

    print(
        'No Authentication, RuntimeException or NullPointerException in log files\n'
    )
def test_dne_log_files_free_of_exceptions(setup):
    """
    Description     :       This method tests that the ESS log files exist and contain no Exceptions.
                            It will fail:
                                If the the error and/or info log files do not exists
                                If the error log file contains AuthenticationFailureException, RuntimeException or NullPointerException.
    Parameters      :       None
    Returns         :       None
    """

    service = 'dell-cpsd-dne-node-expansion-service'
    filePath = '/opt/dell/cpsd/dne/node-expansion-service/logs/'
    errorLogFile = 'node-expansion-service-error.log'

    excep1 = 'AuthenticationFailureException'
    excep2 = 'RuntimeException'
    excep3 = 'NullPointerException'
    excep4 = 'BeanCreationException'

    error_list = []

    # Verify there are no Authentication errors
    sendCommand = 'docker ps | grep ' + service + ' | awk \'{system("docker exec -i "$1" cat ' + filePath + errorLogFile + ' | grep ' + excep1 +'")}\''
    my_return_status = af_support_tools.send_ssh_command(host=setup['IP'], username=setup['cli_user'],
                                                         password=setup['cli_password'],
                                                         command=sendCommand, return_output=True)
    if (excep1 in my_return_status):
        error_list.append(excep1)

    # Verify there are no RuntimeException errors
    sendCommand = 'docker ps | grep ' + service + ' | awk \'{system("docker exec -i "$1" cat ' + filePath + errorLogFile + ' | grep ' + excep2 +'")}\''
    my_return_status = af_support_tools.send_ssh_command(host=setup['IP'], username=setup['cli_user'],
                                                         password=setup['cli_password'],
                                                         command=sendCommand, return_output=True)
    if (excep2 in my_return_status):
        error_list.append(excep2)

    # Verify there are no NullPointerException errors
    sendCommand = 'docker ps | grep ' + service + ' | awk \'{system("docker exec -i "$1" cat ' + filePath + errorLogFile + ' | grep ' + excep3 +'")}\''
    my_return_status = af_support_tools.send_ssh_command(host=setup['IP'], username=setup['cli_user'],
                                                         password=setup['cli_password'],
                                                         command=sendCommand, return_output=True)
    if (excep3 in my_return_status):
        error_list.append(excep3)

    # Verify there are no BeanCreationException errors
    sendCommand = 'docker ps | grep ' + service + ' | awk \'{system("docker exec -i "$1" cat ' + filePath + errorLogFile + ' | grep ' + excep4 +'")}\''
    my_return_status = af_support_tools.send_ssh_command(host=setup['IP'], username=setup['cli_user'],
                                                         password=setup['cli_password'],
                                                         command=sendCommand, return_output=True)
    if (excep4 in my_return_status):
        error_list.append(excep4)

    assert not error_list, 'Exceptions in log files, Review the ' + errorLogFile + ' file'

    print('\nNo Authentication, RuntimeException or NullPointerException in log files\n')
def test_enable_rabbitmq_management_plugin():
    """ A function to enable the rabbitmq_management plugin
    It won't cause any errrors if it is already enabled"""
    command = 'docker exec -d amqp rabbitmq-plugins enable rabbitmq_management'
    af_support_tools.send_ssh_command(
        host=ipaddress,
        username=cli_username,
        password=cli_password,
        command=command,
        return_output=False)
Example #9
0
def test_common_ui_serviceremove(core_services, setup):
    """
    Title: Verify that the common-ui service and it's dependent containers are uninstalled correctly
    Description: This test verifies that the common-ui service is uninstalled correctly
    Params: List of service names
    Returns: None
    """
    err = []
    core_rm_ui = []

    sendcommand = "yum remove -y dell-cpsd-common-ui"
    my_return_status = af_support_tools.send_ssh_command(
        host=setup['IP'],
        username=setup['user'],
        password=setup['password'],
        command=sendcommand,
        return_output=True)
    for service in core_services:
        core_rm_ui.append(service)

    ui = core_rm_ui.pop(0)
    print('common UI dell ' + ui)

    sendcommand = "docker ps --filter name=" + ui + "  --format '{{.Status}}' | awk '{print $1}'"
    my_return_status = af_support_tools.send_ssh_command(
        host=setup['IP'],
        username=setup['user'],
        password=setup['password'],
        command=sendcommand,
        return_output=True)

    if "Up" not in my_return_status:
        print(ui + ' is stopped')
    else:
        err.append(ui + " is still running")
    assert not err

    # ## 'dell-cpsd-common-ui' service is stopped at this point ans the list 'core_rm_ui' won't have this service any more in it
    #
    # ## check if all other services are still running
    for service in core_rm_ui:

        sendcommand = "docker ps --filter name=" + service + "  --format '{{.Status}}' | awk '{print $1}'"
        my_return_status = af_support_tools.send_ssh_command(
            host=setup['IP'],
            username=setup['user'],
            password=setup['password'],
            command=sendcommand,
            return_output=True)

        if "Up" not in my_return_status:
            err.append(service + " not running")
    assert not err
Example #10
0
def test_dne_log_files_free_of_exceptions():
    """
    Description     :       This method tests that the ESS log files exist and contain no Exceptions.
                            It will fail:
                                If the the error and/or info log files do not exists
                                If the error log file contains AuthenticationFailureException, RuntimeException or NullPointerException.
    Parameters      :       None
    Returns         :       None
    """

    filePath = '/opt/dell/cpsd/dne-paqx/logs/'
    errorLogFile = 'dne-paqx-error.log'
    infoLogFile = 'dne-paqx-info.log'

    excep1 = 'AuthenticationFailureException'
    excep2 = 'RuntimeException'
    excep3 = 'NullPointerException'
    excep4 = 'BeanCreationException'

    error_list = []

    # Verify there are no Authentication errors
    sendCommand = 'cat ' + filePath + errorLogFile + ' | grep \'' + excep1 + '\''
    my_return_status = af_support_tools.send_ssh_command(host=ipaddress, username=cli_username, password=cli_password,
                                                         command=sendCommand, return_output=True)
    if (excep1 in my_return_status):
        error_list.append(excep1)

    # Verify there are no RuntimeException errors
    sendCommand = 'cat ' + filePath + errorLogFile + ' | grep \'' + excep2 + '\''
    my_return_status = af_support_tools.send_ssh_command(host=ipaddress, username=cli_username, password=cli_password,
                                                         command=sendCommand, return_output=True)
    if (excep2 in my_return_status):
        error_list.append(excep2)

    # Verify there are no NullPointerException errors
    sendCommand = 'cat ' + filePath + errorLogFile + ' | grep \'' + excep3 + '\''
    my_return_status = af_support_tools.send_ssh_command(host=ipaddress, username=cli_username, password=cli_password,
                                                         command=sendCommand, return_output=True)
    if (excep3 in my_return_status):
        error_list.append(excep3)

    # Verify there are no BeanCreationException errors
    sendCommand = 'cat ' + filePath + errorLogFile + ' | grep \'' + excep4 + '\''
    my_return_status = af_support_tools.send_ssh_command(host=ipaddress, username=cli_username, password=cli_password,
                                                         command=sendCommand, return_output=True)
    if (excep4 in my_return_status):
        error_list.append(excep4)

    assert not error_list, 'Exceptions in log files, Review the ' + errorLogFile + ' file'

    print('No Authentication, RuntimeException or NullPointerException in log files\n')
def test_db(query, dbname):
    """
            Title: sds DB test
            Description: This test verify DB connection for SDS
            Params: query
            Returns: db Response
    """
    readFromCommand = query
    writetofilecmd = "echo \"" + readFromCommand + "\" > /tmp/sqlRead.txt"
    writetodockerfilecommand = 'docker cp /tmp/sqlRead.txt postgres:/tmp/sqlRead.txt'
    execSQLCommand = "docker exec -i postgres sh -c \'su - postgres sh -c \"psql \\\"dbname=" + dbname + " options=--search_path=public\\\" -t -f /tmp/sqlRead.txt\"\'"
    # Set config ini file name
    env_file = 'env.ini'
    # Test VM Details
    ipaddress = af_support_tools.get_config_file_property(config_file=env_file,
                                                          heading='Base_OS',
                                                          property='hostname')
    cli_username = af_support_tools.get_config_file_property(
        config_file=env_file, heading='Base_OS', property='username')
    cli_password = af_support_tools.get_config_file_property(
        config_file=env_file, heading='Base_OS', property='password')
    try:

        af_support_tools.send_ssh_command(host=ipaddress,
                                          username=cli_username,
                                          password=cli_password,
                                          command=writetofilecmd,
                                          return_output=True)

        af_support_tools.send_ssh_command(host=ipaddress,
                                          username=cli_username,
                                          password=cli_password,
                                          command=writetodockerfilecommand,
                                          return_output=True)

        result = af_support_tools.send_ssh_command(host=ipaddress,
                                                   username=cli_username,
                                                   password=cli_password,
                                                   command=execSQLCommand,
                                                   return_output=True)

        print(result)

        return result

    except Exception as err:
        # Return code error
        print(err, '\n')
        raise Exception(err)
def install_amqpapi(setup):
    err = []

    amqpapi = "dell-cpsd-amqp-rest-api"

    sendcommand_install = "yum install -y " + amqpapi
    my_return_status = af_support_tools.send_ssh_command(
        host=setup['IP'],
        username=setup['user'],
        password=setup['password'],
        command=sendcommand_install,
        return_output=True)

    rpm_check = af_support_tools.check_for_installed_rpm(
        host=setup['IP'],
        username=setup['user'],
        password=setup['password'],
        rpm_name=amqpapi)

    if rpm_check != True:
        err.append(amqpapi + " did not install properly")
    # assert not err

    if err == []:
        return 1
    else:
        return 0
Example #13
0
def test_common_ui_install(setup):
    """
    Title: Verify that the common-ui rpm is installed correctly
    Description: This test verifies that the common-ui service is installed correctly
    Params: List of service names
    Returns: None
    """
    print(test_common_ui_install.__doc__)

    err = []

    common_ui = "dell-cpsd-common-ui"

    sendcommand = "yum install -y " + common_ui
    my_return_status = af_support_tools.send_ssh_command(
        host=setup['IP'],
        username=setup['user'],
        password=setup['password'],
        command=sendcommand,
        return_output=True)

    rpmcheck_ui = af_support_tools.check_for_installed_rpm(
        host=setup['IP'],
        username=setup['user'],
        password=setup['password'],
        rpm_name=common_ui)

    if rpmcheck_ui != True:
        err.append(common_ui + " did not install properly")
    assert not err
Example #14
0
def core_services(setup):
    ''' Fixture to get names of service containers'''
    err = []
    core_dir = [
        "common-ui", "consul", "hal-orchestrator-service", "rabbitmq",
        "identity-service", "capability-registry-service",
        "endpoint-registration-service", "vault", "system-definition-service"
    ]
    core_list = []

    for service in core_dir:
        sendcommand_core = "cat /opt/dell/cpsd/" + service + "/install/docker-compose.yml | grep container_name| cut -f 2 -d ':'"
        my_return_status_core = af_support_tools.send_ssh_command(
            host=setup['IP'],
            username=setup['user'],
            password=setup['password'],
            command=sendcommand_core,
            return_output=True)
        containerName = my_return_status_core.strip()
        num_of_services = containerName.count('\n')
        if num_of_services > 1:
            containerName = my_return_status_core.splitlines()
            for container in map(str.strip, containerName):
                core_list.append(container)
        else:
            core_list.append(containerName)

    return core_list
Example #15
0
def test_dne_log_files_exist():
    """
    Description     :       This method tests that the ESS log files exist and contain no Exceptions.
                            It will fail:
                                If the the error and/or info log files do not exists
                                If the error log file contains AuthenticationFailureException, RuntimeException or NullPointerException.
    Parameters      :       None
    Returns         :       None
    """

    filePath = '/opt/dell/cpsd/dne-paqx/logs/'
    errorLogFile = 'dne-paqx-error.log'
    infoLogFile = 'dne-paqx-info.log'

    # Verify the log files exist
    sendCommand = 'ls ' + filePath
    my_return_status = af_support_tools.send_ssh_command(host=ipaddress, username=cli_username, password=cli_password,
                                                         command=sendCommand, return_output=True)
    error_list = []

    if (errorLogFile not in my_return_status):
        error_list.append(errorLogFile)

    if (infoLogFile not in my_return_status):
        error_list.append(infoLogFile)

    assert not error_list, 'Log file missing'

    print('Valid log files exist')
Example #16
0
def test_scaleio_adapter_log_files_exist():
    """
    Title           :       Verify scaleio_adapter log files exist
    Description     :       This method tests that the scaleio Adapter log files exist.
                            It will fail:
                                If the the error and/or info log files do not exists
    Parameters      :       None
    Returns         :       None
    """

    filePath = '/opt/dell/cpsd/scaleio-adapter/logs/'
    errorLogFile = 'scaleio-adapter-error.log'
    infoLogFile = 'scaleio-adapter-info.log'

    sendCommand = 'docker exec dell-cpsd-hal-scaleio-adapter ls ' + filePath

    my_return_status = af_support_tools.send_ssh_command(host=ipaddress,
                                                         username=cli_username,
                                                         password=cli_password,
                                                         command=sendCommand,
                                                         return_output=True)
    error_list = []

    if (errorLogFile not in my_return_status):
        error_list.append(errorLogFile)

    if (infoLogFile not in my_return_status):
        error_list.append(infoLogFile)

    assert not error_list, 'Log file missing'

    print('Valid log files exist')
Example #17
0
def getDockerNetworkConnectionPorts(containerName, label="ports"):
    """ A function to determine the docker network ipaddress of a PAQX container.

    Docker commands are used to determine the IP Address of the PAQX container.
    'netstat' is then used to return the connection details for that IP Address.
    If a second parameter is  passed to this function, and is equal to 'processId', then the connection details
    are further broken down to return just the processID.
    Eg. from the sample data below, the process ID = 987 would be returned
    tcp6       0      0 172.17.0.1:5671         172.21.0.2:47338        ESTABLISHED 987/beam.smp"""

    containerId = getContainerId(containerName)
    ipAddressText = getContainerIPAddress(containerId)

    commandGetContainerConnectionPort = "docker exec -i " + containerId.rstrip(
    ) + " netstat -tupn | grep " + ipAddressText.rstrip(
    ) + ": | grep -v 8500 | grep -v 8071"
    connectionPorts = af_support_tools.send_ssh_command(
        host=ipaddress,
        username=cli_username,
        password=cli_password,
        command=commandGetContainerConnectionPort,
        return_output=True)

    if label == "processId":
        processtext = connectionPorts.split("ESTABLISHED")
        process_raw = processtext[1].split('/')
        processId = process_raw[0]
        return processId
    else:
        return connectionPorts
Example #18
0
def test_vcenter_adapter_log_files_exist():
    """
    Title           :       Verify vcenter-adapter log files exist
    Description     :       This method tests that the vCenter Adapter log files exist.
                            It will fail:
                                If the the error and/or info log files do not exists
    Parameters      :       None
    Returns         :       None
    """

    service = 'dell-cpsd-hal-vcenter-adapter'
    filePath = '/opt/dell/cpsd/vcenter-adapter/logs/'
    errorLogFile = 'vcenter-adapter-error.log'
    infoLogFile = 'vcenter-adapter-info.log'

    sendCommand = 'docker ps | grep ' + service + ' | awk \'{system("docker exec -i "$1" ls ' + filePath + '") }\''

    my_return_status = af_support_tools.send_ssh_command(host=ipaddress, username=cli_username, password=cli_password,
                                                         command=sendCommand, return_output=True)
    error_list = []

    if (errorLogFile not in my_return_status):
        error_list.append(errorLogFile)

    if (infoLogFile not in my_return_status):
        error_list.append(infoLogFile)

    assert not error_list, 'Log file missing'

    print('Valid log files exist')
def test_capabilityRegistry_log_files_exist(setup):
    """
    Title           :       Verify Capability Registry log files exist
    Description     :       This method tests that the Capability Registry log files exist.
                            It will fail:
                                If the the error and/or info log files do not exists
                                If the error log file contains AuthenticationFailureException, RuntimeException or NullPointerException.
    Parameters      :       None
    Returns         :       None
    """

    filePath = '/opt/dell/cpsd/capability-registry-service/logs/'
    errorLogFile = 'capability-registry-error.log'
    infoLogFile = 'capability-registry-info.log'

    # Verify the log files exist
    sendCommand = 'ls ' + filePath
    my_return_status = af_support_tools.send_ssh_command(
        host=setup['IP'],
        username=setup['user'],
        password=setup['password'],
        command=sendCommand,
        return_output=True)

    error_list = []

    if (errorLogFile not in my_return_status):
        error_list.append(errorLogFile)

    if (infoLogFile not in my_return_status):
        error_list.append(infoLogFile)

    assert not error_list, 'Log file missing'

    print('Valid log files exist')
def test_dne_services_up(service_name, setup):
    """
    Title: Verify DNE services containers are UP
    Description: This test verifies that each DNE service containers are up
    Params: List of DNE service names
    Returns: None

    """
    print(test_dne_services_up.__doc__)

    err = []

    # for service_name in dne_dir:
    sendcommand = "docker ps --filter name=" + service_name + "  --format '{{.Status}}' | awk '{print $1}'"
    my_return_status = af_support_tools.send_ssh_command(host=setup['IP'], username=setup['cli_user'],
                                                         password=setup['cli_password'],
                                                         command=sendcommand, return_output=True)
    my_return_status = my_return_status.strip()

    if "Up" not in my_return_status:
        err.append(service_name + " not running")

    print('\n' + service_name + ' Docker Container is:', my_return_status, '\n')
    assert my_return_status == 'Up', (service_name + " not running")

    assert not err
def test_get_collected_version():
    auth_token = retrieveRHDToken()
    json_data = get_rackhd_api_response('nodes', auth_token)

    assert json_data != ''
    print("get Firmware version")
    time.sleep(5)
    firm_ver = "7.0"

    pcmd = "select version from rcds.version"
    sendcommand = "docker exec -t postgres psql -U postgres -d rcm-compliance-data-service -c '" + pcmd + "'"
    print(sendcommand)

    rc = af_support_tools.send_ssh_command(host=ipaddress, username=cli_username,
                                                         password=cli_password,
                                                         command=sendcommand, return_output=True)
    print(rc)

    if rc != '':
        if firm_ver not in rc:
            print("no_version retrieved")
            assert False
        return

    assert False
Example #22
0
def test_rackHD_adapter_servicerunning():
    """
    Title           :       Verify the RackHD-Adapter service is running
    Description     :       This method tests docker service for a container
                            It will fail if :
                                Docker service is not running for the container
    Parameters      :       none
    Returns         :       None
    """

    print('\n* * * Testing the Node Discovery PAQX on system:', ipaddress,
          '* * *\n')

    service_name = 'dell-cpsd-hal-rackhd-adapter'

    # 1. Test the service is running
    sendCommand = "docker ps --filter name=" + service_name + "  --format '{{.Status}}' | awk '{print $1}'"
    my_return_status = af_support_tools.send_ssh_command(host=ipaddress,
                                                         username=cli_username,
                                                         password=cli_password,
                                                         command=sendCommand,
                                                         return_output=True)
    my_return_status = my_return_status.strip()
    print('\nDocker Container is:', my_return_status, '\n')
    assert my_return_status == 'Up', (service_name + " not running")
def test_dne_log_files_exist(setup):
    """
    Description     :       This method tests that the ESS log files exist and contain no Exceptions.
                            It will fail:
                                If the the error and/or info log files do not exists
                                If the error log file contains AuthenticationFailureException, RuntimeException or NullPointerException.
    Parameters      :       None
    Returns         :       None
    """
    service = 'dell-cpsd-dne-node-expansion-service'
    filePath = '/opt/dell/cpsd/dne/node-expansion-service/logs/'
    errorLogFile = 'node-expansion-service-error.log'
    infoLogFile = 'node-expansion-service-info.log'

    sendCommand = 'docker ps | grep ' + service + ' | awk \'{system("docker exec -i "$1" ls ' + filePath + '") }\''

    my_return_status = af_support_tools.send_ssh_command(host=setup['IP'], username=setup['cli_user'],
                                                         password=setup['cli_password'],
                                                         command=sendCommand, return_output=True)
    error_list = []

    # Verify the log files exist in the returned data
    if (errorLogFile not in my_return_status):
        error_list.append(errorLogFile)

    if (infoLogFile not in my_return_status):
        error_list.append(infoLogFile)

    assert not error_list, 'Log file missing'

    print('\nValid log files exist')
Example #24
0
def container_verify(container, attrib, pos):
    """
    Description	:	This method verifies if the container name is up or not.
    Parameters	:	1. container	-	Name of the container (STRING)
    				2. expected		-	expected output to be obtained from container_verify function(STRING).
    				3. pos			-	position of the string to be extracted from the formatted 'docker ps' command(STRING)
    Returns		: 	output			-	"Up\n" or "Down\n" string coming from 'docker ps' command(STRING).
    """
    print('Getting Values Specified Container')

    ipaddress = af_support_tools.get_config_file_property(config_file=env_file,
                                                          heading='Base_OS',
                                                          property='hostname')
    username = af_support_tools.get_config_file_property(config_file=env_file,
                                                         heading='Base_OS',
                                                         property='username')
    password = af_support_tools.get_config_file_property(config_file=env_file,
                                                         heading='Base_OS',
                                                         property='password')

    cmd = 'docker ps -f name=' + str(container) + ' --format "{{.' + str(
        attrib) + '}}" | awk \'{print $' + str(pos) + '}\''
    output = af_support_tools.send_ssh_command(host=ipaddress,
                                               username=username,
                                               password=password,
                                               command=cmd,
                                               return_output=True).strip()

    return output
Example #25
0
def test_cap_reg_serviceup(setup):
    """
    Title: Verify the Capability Reg service containers are UP
    Description: This test verifies that the capReg container is up
    Params: dell-cpsd-capability-registry-service
    Returns: None

    """
    service = "dell-cpsd-capability-registry-service"

    print(test_cap_reg_serviceup.__doc__)

    assert service, "container name not found"

    sendcommand = "docker ps --filter name=" + service + "  --format '{{.Status}}' | awk '{print $1}'"

    print(sendcommand)

    my_return_status = af_support_tools.send_ssh_command(
        host=setup['IP'],
        username=setup['user'],
        password=setup['password'],
        command=sendcommand,
        return_output=True)

    assert "Up" in my_return_status, " %s is not up" % service
def test_ident_status(setup):
    print('\nRunning Identity Status test on system: ', setup['IP'])
    status_command = 'docker ps | grep identity-service'
    status = af_support_tools.send_ssh_command(host = setup['IP'], username= setup['user'], password=setup['password'],
                                               command=status_command, return_output=True)
    assert "Up" in status, "Identity Service not Running"
    print("Identity Service Running")
Example #27
0
def checkContainerStats(service, ipaddress):
    #cpu_cmd = "docker stats --no-stream " + service + " | grep -v CPU | awk \'{print $2}\' | cut -f1 -d\'%\' "
    cpu_cmd = "docker stats --no-stream " + service + " | grep -v CPU | awk '{print $2}' | cut -f1 -d'%' "
    #mem_cmd = "docker stats --no-stream " + service + " | grep -v MEM | awk \'{print $8}\' | cut -f1 -d\'%\' "
    mem_cmd = "docker stats --no-stream " + service + " | grep -v MEM | awk '{print $8}' | cut -f1 -d'%' "
    cpu_resp = af_support_tools.send_ssh_command(host=symphony_hostname,
                                                 username=symphony_username,
                                                 password=symphony_password,
                                                 command=cpu_cmd,
                                                 return_output=True)
    mem_resp = af_support_tools.send_ssh_command(host=symphony_hostname,
                                                 username=symphony_username,
                                                 password=symphony_password,
                                                 command=mem_cmd,
                                                 return_output=True)
    return float(cpu_resp), float(mem_resp)
def checkRMQStatus():
    sendCommand = 'systemctl status rabbitmq-server'
    my_return_text = af_support_tools.send_ssh_command(host=ipaddress, username=cli_username, password=cli_password,
                                                       command=sendCommand, return_output=True)

    running = 'Active: active (running)'
    assert running in my_return_text
    print('Rabbit Status:', running)
def deleteEntryInNodeComputeTable(elementId, setup):

    """ A Function to clear the node associated with 'elementId' from the postgres table 'compute_node'.

    :parameter: elementId - symphonyUUID (eg. '44f0d5ac-44a6-48e0-bf98-93eaa7f452d3')
    :return: the result of the delete command (sample success result is 'DELETE #'
    where '#' is the number of entries deleted. """

    deleteCmd = "delete from compute_node where element_id=\'" + elementId + "\';"
    writeToFileCmd = "echo \"" + deleteCmd + "\" > /tmp/sqlDelete.txt"
    copyFileToContainerCmd = "docker cp /tmp/sqlDelete.txt postgres:/tmp/sqlDelete.txt"
    execSQLCommand = "docker exec -i postgres sh -c \'su - postgres sh -c \"psql \\\"dbname=node-discovery-service\\\" -f /tmp/sqlDelete.txt\"\'"

    try:
        result = af_support_tools.send_ssh_command(
           host=setup['IP'],
           username=setup['cli_user'],
           password=setup['cli_password'],
           command=writeToFileCmd,
           return_output=True)


        result = af_support_tools.send_ssh_command(
           host=setup['IP'],
           username=setup['cli_user'],
           password=setup['cli_password'],
           command=copyFileToContainerCmd,
           return_output=True)


        result = af_support_tools.send_ssh_command(
            host=setup['IP'],
            username=setup['cli_user'],
            password=setup['cli_password'],
            command=execSQLCommand,
            return_output=True)

        sleeptime = 10

        return result

    except Exception as err:
        # Return code error
        print(err, '\n')
        raise Exception(err)
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)