コード例 #1
0
def test_event_attributes(application, managed_cluster):
    """
    Check that all common event attributes are as expected
    """
    """
    :step:
      Log in to Web UI and get the cluster identified by cluster_member.
      Get the list of events associated with this cluster.
    :result:
      Event objects are initiated and their attributes are read from Tasks page
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    assert test_cluster.managed == "Yes"
    events = test_cluster.events.get_events()
    """
    :step:
      Check that events list is not empty and that each event has description
      of reasonable length and date within reasonable range.
    :result:
      Attributes of all events in the event list are as expected.
    """
    pytest.check(events != [], "Check that events list in UI isn't empty")
    for event in events:
        pytest.check(
            len(event.description) > 15,
            "Description: {}. Should be more than 15 chars".format(
                event.description))
        pytest.check(
            int(event.date.split(" ")[2]) > 2018,
            "Event date: {}. Year should be greater than 2018".format(
                event.date))
コード例 #2
0
def test_cluster_import_unmanage_naming(application, unmanaged_cluster):
    """
    Import cluster and give it a custom name. Then unmanage it.
    """
    """
    :step:
      Log in to Web UI and import the first cluster from the clusters list.
      Give it custom name 'TestClusterName'
    :result:
      Cluster is imported and its name is shown in the clusters list
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        unmanaged_cluster["cluster_id"],
                                        unmanaged_cluster["short_name"])
    if test_cluster.managed == "Yes":
        test_cluster.unmanage()
    original_id = test_cluster.name
    import_success = test_cluster.cluster_import(
        cluster_name="TestClusterName")
    if not import_success:
        pytest.check(False, "Import failed")
    """
    :step:
      Unmanage the cluster
    :result:
      Cluster is unmanaged and its name is no longer shown in the clusters list.
      Its id is shown instead.
    """
    unmanage_success = test_cluster.unmanage(original_id=original_id)
    if not unmanage_success:
        pytest.check(False, "Unmanage failed")
        test_cluster.unmanage()
コード例 #3
0
def test_cluster_import_unmanage_view_progress(application, unmanaged_cluster):
    """
    Import cluster and view import progress. Then unmanage the cluster and view unmanage progress.
    """
    """
    :step:
      Log in to Web UI.
      Import the first cluster from the clusters list viewing import progress.
    :result:
      Cluster is imported and its name is shown in the clusters list
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        unmanaged_cluster["cluster_id"],
                                        unmanaged_cluster["short_name"])
    if test_cluster.managed == "Yes":
        test_cluster.unmanage()
    import_success = test_cluster.cluster_import(view_progress=True)
    if not import_success:
        pytest.check(False, "Import failed")
    """
    :step:
      Unmanage the cluster and view unmanage progress.
    :result:
      Cluster is unmanaged
    """
    unmanage_success = test_cluster.unmanage(view_progress=True)
    if not unmanage_success:
        pytest.check(False, "Unmanage failed")
        test_cluster.unmanage()
コード例 #4
0
def test_cluster_disable_profiling(application, managed_cluster,
                                   gluster_volume):
    """
    Disable cluster profiling in Web UI
    """
    """
    :step:
      Log in to Web UI and get the first cluster from the cluster list.
      Check that its profiling is enabled
    :result:
      Cluster is in the correct state to disable profiling
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    if test_cluster.profiling != "Enabled":
        test_cluster.enable_profiling()
    gluster_cluster = gluster.GlusterVolume()
    pytest.check(
        gluster_cluster.get_clusterwide_profiling() == "enabled",
        "Check that all volumes have profiling enabled according to gluster command"
    )
    """
    :step:
      Disable profiling in Web UI and check its state has changed in both Web UI and API
    :result:
      Cluster profiling has been disabled
    """
    test_cluster.disable_profiling()
    pytest.check(
        gluster_cluster.get_clusterwide_profiling() == "disabled",
        "Check that all profiling has been disabled according to gluster command"
    )
コード例 #5
0
ファイル: test_volume_ui.py プロジェクト: usmqe/usmqe-tests
def test_volume_attributes(application, valid_session_credentials,
                           managed_cluster, gluster_volume):
    """
    Test that all volumes are listed on cluster's Volumes page.
    Check all common volume attributes
    """
    """
    :step:
      Log in to Web UI and get the cluster identified by cluster_member.
      Get the list of its volumes.
    :result:
      Volume objects are initiated and their attributes are read from the page
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    assert test_cluster.managed == "Yes"
    volumes = test_cluster.volumes.get_volumes()
    """
    :step:
      Get the list of volumes using Gluster command and check it's the same as in UI
    :result:
      The list of volumes in UI and in Gluster command are equal
    """
    glv_cmd = gluster.GlusterVolume()
    g_volume_names = glv_cmd.get_volume_names()
    pytest.check(
        set([volume.volname for volume in volumes]) == set(g_volume_names),
        "Check that UI volumes list is the same as in gluster volume info")
    LOGGER.debug("UI volume names: {}".format(
        [volume.volname for volume in volumes]))
    LOGGER.debug("Gluster command volume names: {}".format(g_volume_names))
    """
    :step:
      Check common volume attributes
    :result:
      Common volume attributes have expected values
    """
    for volume in volumes:
        pytest.check(
            volume.volname.find("olume_") == 1,
            "Check that volume name contains ``olume_``")
        pytest.check(
            volume.running == "Yes",
            "Check that volume ``Running`` attribute has value ``Yes``")
        pytest.check(
            volume.rebalance == "Not Started",
            "Check that volume ``Rebalance`` attribute has value ``Not Started``"
        )
        pytest.check(
            int(volume.alerts) >= 0,
            "Check that volume's number of alerts is a non-negative integer")
コード例 #6
0
ファイル: test_volume_ui.py プロジェクト: usmqe/usmqe-tests
def test_volume_dashboard(application, managed_cluster, gluster_volume):
    """
    Check that dashboard button opens correct volume dashboard with correct data on bricks
    """
    """
    :step:
      Log in to Web UI and get the cluster identified by cluster_member.
      Get the list of its volumes.
    :result:
      Volume objects are initiated and their attributes are read from the page.
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    assert test_cluster.managed == "Yes"
    volumes = test_cluster.volumes.get_volumes()
    """
    :step:
      For each volume in the volume list, click its Dashboard button and check
      cluster name, volume name, bricks count and volume health
    :result:
      Volume dashboard shows the correct information
    """
    for volume in volumes:
        dashboard_values = volume.get_values_from_dashboard()
        LOGGER.debug("Cluster name in grafana: {}".format(
            dashboard_values["cluster_name"]))
        LOGGER.debug("Cluster name in main UI: {}".format(volume.cluster_name))
        pytest.check(
            dashboard_values["cluster_name"] == volume.cluster_name,
            "Check that cluster name in the volume dashboard is the same as in main UI"
        )
        LOGGER.debug("Volume name in grafana: {}".format(
            dashboard_values["volume_name"]))
        LOGGER.debug("Volume name in main UI: {}".format(volume.volname))
        pytest.check(
            dashboard_values["volume_name"] == volume.volname,
            "Check that volume name in grafana is the same as in main UI")
        LOGGER.debug("Bricks count in grafana: {}".format(
            dashboard_values["brick_count"]))
        LOGGER.debug("Bricks count in main UI: {}".format(volume.bricks_count))
        pytest.check(
            dashboard_values["brick_count"] == volume.bricks_count,
            "Check that brick count in grafana is the same as in main UI")
        LOGGER.debug("Volume health in grafana: {}".format(
            dashboard_values["volume_health"]))
        LOGGER.debug("Volume health in main UI: {}".format(volume.health))
        pytest.check(
            dashboard_values["volume_health"] == volume.health,
            "Check that volume health in grafana is the same as in main UI")
コード例 #7
0
def test_cluster_import(application, valid_session_credentials,
                        unmanaged_cluster):
    """
    Check that Import button really imports the cluster
    """
    """
    :step:
      Log in to Web UI and get the first cluster from the cluster list.
      Check that it's not imported yet.
    :result:
      Cluster is in the correct state to start import
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        unmanaged_cluster["cluster_id"],
                                        unmanaged_cluster["short_name"])
    if test_cluster.managed == "Yes":
        test_cluster.unmanage()
    pytest.check(test_cluster.managed == "No",
                 "Value of cluster's Managed attribute: {}".format(
                     test_cluster.managed),
                 issue="No value in a freshly installed cluster")
    """
    :step:
      Get the cluster's details via API. Check that API shows the same state
    :result:
      Cluster state in API is the same as in Web UI
    """
    tendrl_api = glusterapi.TendrlApiGluster(auth=valid_session_credentials)
    api_cluster = tendrl_api.get_cluster(test_cluster.cluster_id)
    pytest.check(api_cluster["is_managed"] == "no",
                 "is_managed: {}\nThere should be ``no``.".format(
                     api_cluster["is_managed"]),
                 issue="No value in a freshly installed cluster")
    """
    :step:
      Import the cluster in Web UI and check its state has changed in both Web UI and API
    :result:
      Cluster is imported
    """
    import_success = test_cluster.cluster_import()
    if import_success:
        api_cluster = tendrl_api.get_cluster(test_cluster.cluster_id)
        pytest.check(
            api_cluster["is_managed"] == "yes",
            "is_managed: {}\nThere should be ``yes``.".format(
                api_cluster["is_managed"]))
    else:
        pytest.check(False, "Import failed")
        test_cluster.unmanage()
コード例 #8
0
ファイル: test_volume_ui.py プロジェクト: usmqe/usmqe-tests
def test_volume_profiling_switch(application, managed_cluster, gluster_volume):
    """
    Test disabling and enabling volume profiling in UI
    """
    """
    :step:
      Log in to Web UI and get the cluster identified by cluster_member.
      Get the list of its volumes.
    :result:
      Volume objects are initiated and their attributes are read from the page.
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    assert test_cluster.managed == "Yes"
    volumes = test_cluster.volumes.get_volumes()
    for volume in volumes:
        """
        :step:
          For each volume in the volume list, disable profiling and check its profiling status
          both in UI and using Gluster command.
        :result:
          Volume profiling is disabled.
        """
        glv_cmd = gluster.GlusterVolume(volume_name=volume.volname)
        volume.disable_profiling()
        pytest.check(
            not glv_cmd.is_profiling_enabled(),
            "Check that profiling status has changed to disabled usig gluster command"
        )
        pytest.check(volume.profiling == "Disabled",
                     "Check that profiling attribute in UI is ``Disabled``")
        """
        :step:
          For each volume in the volume list, enable profiling and check its profiling status
          both in UI and using Gluster command.
        :result:
          Volume profiling is enabled.
        """
        volume.enable_profiling()
        pytest.check(
            glv_cmd.is_profiling_enabled(),
            "Check that profiling status has changed to enabled usig gluster command"
        )
        pytest.check(volume.profiling == "Enabled",
                     "Check that profiling attribute in UI is ``Enabled``")
コード例 #9
0
def test_cluster_dashboard(application, managed_cluster):
    """
    Check that dashboard button opens cluster dashboard with correct data on hosts and volumes
    """
    """
    :step:
      Log in to Web UI and get the first cluster from the cluster list.
      Click its Dashboard button and check cluster name, hosts and volumes count on the dashboard.
    :result:
      Cluster dashboard shows the correct information
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    dashboard_values = test_cluster.get_values_from_dashboard()
    pytest.check(
        dashboard_values["cluster_name"] == test_cluster.name,
        "Check that cluster name in Grafana dashboard is as expected")
    LOGGER.debug("Cluster name in grafana: {}".format(
        dashboard_values["cluster_name"]))
    LOGGER.debug("Cluster name in main UI: {}".format(test_cluster.name))
    pytest.check(
        dashboard_values["host_count"] == test_cluster.hosts_number,
        "Check that total number of cluster's hosts in Grafana is the same as in main UI"
    )
    LOGGER.debug("Hosts count in grafana: '{}'".format(
        dashboard_values["host_count"]))
    LOGGER.debug("Hosts count in main UI: {}".format(
        test_cluster.hosts_number))
    pytest.check(
        dashboard_values["volume_count"] == test_cluster.volumes_number,
        "Check that total number of volumes in Grafana is the same as in main UI"
    )
    LOGGER.debug("Volume count in grafana: {}".format(
        dashboard_values["volume_count"]))
    LOGGER.debug("Volume count in main UI: {}".format(
        test_cluster.volumes_number))
    pytest.check(
        dashboard_values["cluster_health"].lower() ==
        test_cluster.health.lower(),
        "Check that cluster's health in Grafana is the same as in main UI")
    LOGGER.debug("Cluster health in grafana (lowercase): '{}"
                 "'".format(dashboard_values["cluster_health"].lower()))
    LOGGER.debug("Cluster health in main UI (lowercase): '{}'".format(
        test_cluster.health.lower()))
コード例 #10
0
def test_task_attributes(application, managed_cluster):
    """
    Check that all common task attributes are as expected
    """
    """
    :step:
      Log in to Web UI and get the cluster identified by cluster_member.
      Get the list of tasks associated with this cluster.
    :result:
      Task objects are initiated and their attributes are read from Tasks page
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    assert test_cluster.managed == "Yes"
    tasks = test_cluster.tasks.get_tasks()
    """
    :step:
      Check that tasks list is not empty and that each task has well-formed task id,
      correct status and date within reasonable range.
    :result:
      Attributes of all task in the task list are as expected.
    """
    pytest.check(tasks != [], "Check that cluster's Tasks list isn't empty")
    for task in tasks:
        pytest.check(
            len(task.task_id) == 36,
            "Task id: {} Should be of length 36".format(task.task_id))
        pytest.check(task.task_id[8] == "-",
                     "The 9th symbol of task id should be ``-``")
        pytest.check(
            task.status in {"New", "Completed", "Failed"},
            "Task status: {}. Should be New, Completed or Failed".format(
                task.status))
        pytest.check(
            int(task.submitted_date.split(" ")[2]) > 2018,
            "Task submitted on {}. Should be later than 2018".format(
                task.submitted_date))
        pytest.check(
            int(task.changed_date.split(" ")[2]) > 2018,
            "Task changed on {}. Should be later than 2018".format(
                task.changed_date))
コード例 #11
0
def test_task_log(application, managed_cluster):
    """
    Test that clicking task name opens task log page
    and all events in the log have expected attributes

    This test case expects that events list is not empty, which trivially holds
    under normal circumstances in CI.
    """
    """
    :step:
      Log in to Web UI and get the cluster identified by cluster_member.
      Get the list of tasks associated with this cluster.
    :result:
      Task objects are initiated and their attributes are read from Tasks page
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    assert test_cluster.managed == "Yes"
    tasks = test_cluster.tasks.get_tasks()
    pytest.check(tasks != [], "Check that cluster's Tasks list isn't empty")
    """
    :step:
      For each task get its log and check the attributes of the events in the log
    :result:
      Attributes of all events in all task logs are as expected.
    """
    for task in tasks:
        events = task.task_events.get_events()
        pytest.check(events != [], "Check that task's Events list isn't empty")
        for event in events:
            pytest.check(
                event.event_type in {"info", "warning", "error"},
                "Event type: {}. ".format(event.event_type) +
                "Should be 'info', 'warning' or 'error'")
            pytest.check(
                len(event.description) > 10,
                "Description: {}. Should be more than 10 char".format(
                    event.description))
            pytest.check(
                int(event.date.split(" ")[2]) > 2018,
                "Date: {}. Should be later than 2018".format(event.date))
コード例 #12
0
def test_cluster_import_unmanage_profiling_disabled(application,
                                                    unmanaged_cluster):
    """
    Import cluster with profiling disabled. Then unmanage it.
    """
    """
    :step:
      Log in to Web UI and import the first cluster from the clusters list.
      Set profiling to Disabled during import
    :result:
      Cluster is imported and its name is shown in the clusters list
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        unmanaged_cluster["cluster_id"],
                                        unmanaged_cluster["short_name"])
    if test_cluster.managed == "Yes":
        test_cluster.unmanage()
    import_success = test_cluster.cluster_import(profiling="disable")
    if not import_success:
        pytest.check(False, "Import failed")
    """
    :step:
      Check that cluster profiling is disabled
    :result:
      Check fails due to BZ 1670389
    """
    pytest.check(test_cluster.profiling == "Disabled",
                 issue='https://bugzilla.redhat.com/show_bug.cgi?id=1670389')
    """
    :step:
      Unmanage the cluster
    :result:
      Cluster is unmanaged
    """
    unmanage_success = test_cluster.unmanage()
    if not unmanage_success:
        pytest.check(False, "Unmanage failed")
        test_cluster.unmanage()
コード例 #13
0
def test_cluster_unmanage(application, valid_session_credentials,
                          managed_cluster):
    """
    Unmanage cluster in Web UI
    """
    """
    :step:
      Log in to Web UI and get the first cluster from the cluster list.
      Check that it's imported.
    :result:
      Cluster is in the correct state to start unmanage
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    tendrl_api = glusterapi.TendrlApiGluster(auth=valid_session_credentials)
    api_cluster = tendrl_api.get_cluster(test_cluster.cluster_id)
    pytest.check(
        api_cluster["is_managed"] == "yes",
        "is_managed: {}\nThere should be ``yes``.".format(
            api_cluster["is_managed"]))
    """
    :step:
      Unmanage the cluster in Web UI and check its state has changed in both Web UI and API
    :result:
      Cluster is unmanaged
    """
    unmanage_success = test_cluster.unmanage()
    if not unmanage_success:
        pytest.check(False, "Unmanage failed")
        test_cluster.unmanage()
    else:
        api_cluster = tendrl_api.get_cluster(test_cluster.cluster_id)
        pytest.check(
            api_cluster["is_managed"] == "no",
            "is_managed: {}\nThere should be ``no``.".format(
                api_cluster["is_managed"]))
コード例 #14
0
ファイル: test_host_ui.py プロジェクト: usmqe/usmqe-tests
def test_host_bricks(application, managed_cluster, gluster_volume):
    """
    Test that all hosts are listed on cluster's Hosts page.
    Check all common brick attributes
    """
    """
    :step:
      Log in to Web UI and get the cluster identified by cluster_member.
      Get the list of its hosts.
    :result:
      Host objects are initiated and their attributes are read from the page
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    assert test_cluster.managed == "Yes"
    volume_bricks = []
    for volume in test_cluster.volumes.get_volumes():
        for part in volume.parts.get_parts():
            volume_bricks += part.bricks.get_bricks()
    hosts = test_cluster.hosts.get_hosts()
    pytest.check(hosts != [], "Check that UI hosts list isn't empty.")
    for host in hosts:
        """
        :step:
          For each host, get the list of its bricks.
          Check that it has the correct number of bricks
        :result:
          Brick objects are initiated and their attributes are read from the page
        """
        bricks = host.bricks.get_bricks()
        pytest.check(
            len(bricks) == int(host.bricks_count),
            "Number of bricks in the table: {} ".format(len(bricks)) +
            "Should be equal to host's Bricks attribute: {} ".format(
                host.bricks_count))
        """
        :step:
          Check that bricks on the host's Brick details page are the same as
          all this host's bricks on all volume brick details pages combined together.
        :result:
          Volume details and host details show the same set of bricks
        """
        bricks_from_volumes = [
            brick.brick_path for brick in volume_bricks
            if brick.hostname == host.hostname
        ]
        bricks_from_host = [brick.brick_path for brick in bricks]
        LOGGER.debug(
            "Host's bricks from volumes: {} ".format(bricks_from_volumes))
        LOGGER.debug("Host's bricks: {}".format(bricks_from_host))
        pytest.check(
            set(bricks_from_host) == set(bricks_from_volumes),
            "All bricks from Host pages: {} ".format(set(bricks_from_host)) +
            "Should be equal to bricks from Volume " +
            "pages: {}".format(set(bricks_from_volumes)))
        for brick in bricks:
            """
            :step:
              For all bricks of each host, check common host attributes
            :result:
              Common brick attributes have expected values
            """
            pytest.check(
                brick.brick_path.find('/mnt/brick') == 0,
                "Check that Brick Path starts with ``/mnt/brick``")
            pytest.check(
                brick.hostname == host.hostname,
                "Brick's hostname: {}. ".format(brick.hostname) +
                "Should be equal to {}".format(host.hostname))
            pytest.check(
                brick.volume_name.split('_')[0] == 'volume',
                "Brick volume name {}. ".format(brick.volume_name) +
                "Should contain ``volume``")
            pytest.check(brick.utilization.find('% U') > 0)
            pytest.check(
                brick.disk_device_path.find('/dev/') == 0,
                "Brick's Disk Device Path: {}. ".format(
                    brick.disk_device_path) + "Should start with ``/dev/``")
            pytest.check(
                int(brick.port) > 1000,
                "Port: {}. Should be integer greater than 1000".format(
                    brick.port))
コード例 #15
0
ファイル: test_volume_ui.py プロジェクト: usmqe/usmqe-tests
def test_volume_parts(application, managed_cluster, gluster_volume):
    """
    Test replica set/subvolume names and expanding/collapsing.
    """
    """
    :step:
      Log in to Web UI and get the cluster identified by cluster_member.
      Get the list of its volumes.
    :result:
      Volume objects are initiated and their attributes are read from the page.
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    assert test_cluster.managed == "Yes"
    volumes = test_cluster.volumes.get_volumes()
    pytest.check(
        volumes != [],
        "Check that there is at least one volume in the volumes list")
    for volume in volumes:
        """
        :step:
          For each volume in the volume list, get the list of its subvolumes/replica sets.
          Check it's not empty.
        :result:
          Subvolume/replica set objects are initiated and their attributes are read from the page.
        """
        volume_parts = volume.parts.get_parts()
        pytest.check(volume_parts != [],
                     "Check that there is at least one subvolume/replica set")
        """
        :step:
          Check all subvolumes/replica sets are collapsed. Expand them using Expand All option.
        :result:
          All subvolumes/replica sets are expanded.
        """
        for part in volume_parts:
            pytest.check(
                not part.is_expanded,
                "Check that each volume part is collapsed in the beginning")
        volume.parts.expand_all()
        for part in volume_parts:
            pytest.check(
                part.is_expanded,
                "Check that each volume part is expanded after Expand All action"
            )
        """
        :step:
          Collapse all subvolumes/replica sets using Collapse All option.
        :result:
          All subvolumes/replica sets are collapsed.
        """
        volume.parts.collapse_all()
        for part in volume_parts:
            pytest.check(
                not part.is_expanded,
                "Check that each volume part is collapsed after Collapse All action"
            )
        """
        :step:
          Check if volume part should be called Subvolume or Replica set depending on volume type.
        :result:
          Appropriate part name is chosen.
        """
        if volume.volname.split("_")[2] in {"arbiter", "distrep"}:
            part_name = "Replica Set "
        elif volume.volname.split("_")[2] == "disperse":
            part_name = "Subvolume "
        else:
            pytest.check(
                False,
                "Volume type isn't ``arbiter``, ``distrep`` or ``disperse``")
            LOGGER.debug("Unexpected volume type")
            part_name = ""
        for part in volume_parts:
            """
            :step:
              For each subvolume/replica set check its name is as expected.
            :result:
              All subvolume/replica set names are OK.
            """
            pytest.check(
                part.part_name == part_name + str(int(part.part_id) - 1),
                "Check that volume part name is as expected")
            LOGGER.debug(
                "Expected part name: {}".format(part_name +
                                                str(int(part.part_id) - 1)))
            LOGGER.debug("Real part name: {}".format(part.part_name))
            """
            :step:
              Expand each subvolume/replica set individually. Check it's expanded.
            :result:
              Subvolume/replica set is expanded.
            """
            part.expand()
            pytest.check(
                part.is_expanded,
                "Check that volume part is expanded after Expand action")
            """
            :step:
              Collapse each subvolume/replica set individually. Check it's collapsed.
            :result:
              Subvolume/replica set is collapsed.
            """
            part.collapse()
            pytest.check(
                not part.is_expanded,
                "Check that volume part is collapsed after Collapse action")
コード例 #16
0
ファイル: test_volume_ui.py プロジェクト: usmqe/usmqe-tests
def test_volume_bricks(application, managed_cluster, gluster_volume):
    """
    Test volume brick attributes and their division into replica sets/subvolumes.
    """
    """
    :step:
      Log in to Web UI and get the cluster identified by cluster_member.
      Get the list of its volumes.
    :result:
      Volume objects are initiated and their attributes are read from the page.
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    assert test_cluster.managed == "Yes"
    volumes = test_cluster.volumes.get_volumes()
    pytest.check(
        volumes != [],
        "Check that there is at least one volume in the UI volumes list")
    for volume in volumes:
        """
        :step:
          For each volume calculate the expected subvolume/replica set size
          from the volume name depending on volume type.
        :result:
          Subvolume/replica set size is calculated.
        """
        if volume.volname.split("_")[2] in {"arbiter", "disperse"}:
            part_size = int(volume.volname.split("_")[3]) + \
                        int(volume.volname.split("_")[5].split('x')[0])
        elif volume.volname.split("_")[2] == "distrep":
            part_size = int(volume.volname.split("_")[3].split('x')[1])
        else:
            pytest.check(
                False,
                "Volume type isn't ``arbiter``, ``distrep`` or ``disperse``")
            LOGGER.debug("Unexpected volume type")
            part_size = 0
        """
        :step:
          For each volume part get its bricks.
          Check that actual brick count per subvolume/replica set is as expected.
        :result:
          Each subvolume/replica set has the expected number of bricks.
        """
        volume_parts = volume.parts.get_parts()
        pytest.check(volume_parts != [],
                     "Check that there is at least one subvolume/replica set")
        all_bricks = []
        for part in volume_parts:
            bricks = part.bricks.get_bricks()
            pytest.check(
                len(bricks) == part_size,
                "Check that the number of bricks in the table is as expected")
            for brick in bricks:
                """
                :step:
                  Check each brick's attributes.
                :result:
                  All brick's attributes are as expected.
                """
                pytest.check(
                    brick.brick_path.find('/mnt/brick') == 0,
                    "Check that Brick Path starts with ``/mnt/brick``")
                pytest.check(
                    brick.utilization.find('% U') > 0,
                    "Check that Utilization column values inclusde ``%``")
                pytest.check(
                    brick.disk_device_path.find('/dev/') == 0,
                    "Check that Disk Device Path starts with ``/dev/``")
                pytest.check(
                    int(brick.port) > 1000,
                    "Check that Port number is an integer greater than 1000")
            all_bricks = all_bricks + bricks
        """
        :step:
          Check that the list of all bricks of the volume in UI is the same as the result
          of gluster volume info command.
        :result:
          The list of all volume's bricks in the UI is correct.
        """
        glv_cmd = gluster.GlusterVolume(volume_name=volume.volname)
        glv_cmd.info()
        LOGGER.debug("Gluster bricks: {}".format(glv_cmd.bricks))
        ui_brick_names = [b.hostname + ":" + b.brick_path for b in all_bricks]
        LOGGER.debug("UI bricks: {}".format(ui_brick_names))
        pytest.check(
            glv_cmd.bricks == ui_brick_names,
            "Check that volume bricks in UI are the same as in gluster CLI")
コード例 #17
0
ファイル: test_host_ui.py プロジェクト: usmqe/usmqe-tests
def test_host_attributes(application, managed_cluster):
    """
    Test that all hosts are listed on cluster's Hosts page.
    Check all common host attributes
    """
    """
    :step:
      Log in to Web UI and get the cluster identified by cluster_member.
      Get the list of its hosts.
    :result:
      Host objects are initiated and their attributes are read from the page
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    assert test_cluster.managed == "Yes"
    hosts = test_cluster.hosts.get_hosts()
    """
    :step:
       Compare the set of hostnames in UI to set of nodes in API
    :result:
       UI shows the correct set of hostnames.
    """
    ui_hostnames = [host.hostname for host in hosts]
    api_hostnames = [node["fqdn"] for node in managed_cluster["nodes"]]
    LOGGER.debug("API cluster nodes: {}".format(api_hostnames))
    LOGGER.debug("UI cluster nodes: {}".format(ui_hostnames))
    pytest.check(
        set(ui_hostnames) == set(api_hostnames),
        "UI hostnames: {}. ".format(ui_hostnames) +
        "API hostnames: {}. Should be equal".format(api_hostnames))
    """
    :step:
      Check common host attributes
    :result:
      Common host attributes have expected values
    """
    for host in hosts:
        pytest.check(
            host.gluster_version.find("3.") == 0,
            "Gluster version is {}. Should be ``3.something``")
        pytest.check(
            host.managed == "Yes",
            "Host's Managed attribute is {}. Should be ``yes``".format(
                host.managed))
        pytest.check(
            host.role == "Gluster Peer",
            "Host's Role is {}. Should be ``Gluster Peer``".format(host.role))
        pytest.check(
            int(host.alerts) < 1000,
            "Host's alerts: {}. Should be integer, less than 1000".format(
                host.alerts))
        pytest.check(
            host.cluster_name == test_cluster.name,
            "Host's cluster name: {}".format(host.cluster_name) +
            ". Should be {}".format(test_cluster.name))
        for node in managed_cluster["nodes"]:
            if node["fqdn"] == host.hostname:
                pytest.check(
                    node["status"] == host.health,
                    "Host's health in UI: {} ".format(host.health) +
                    "Should be equal to {}".format(node["status"]))
コード例 #18
0
ファイル: test_host_ui.py プロジェクト: usmqe/usmqe-tests
def test_host_dashboard(application, managed_cluster):
    """
    Test each host's Dashboard button
    """
    """
    :step:
      Log in to Web UI and get the cluster identified by cluster_member.
      Get the list of its hosts.
    :result:
      Host objects are initiated and their attributes are read from the page
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    assert test_cluster.managed == "Yes"
    hosts = test_cluster.hosts.get_hosts()
    """
    :step:
      For each host, click its Dashboard button.
      Check that the correct Grafana dashboard appears
      and that it shows expected values of host health and brick count.
    :result:
      Grafana dashboard is opened, checked for its values and closed.
    """
    for host in hosts:
        dashboard_values = host.get_values_from_dashboard()
        pytest.check(
            dashboard_values["cluster_name"] == host.cluster_name,
            "Grafana cluster name: {} ".format(
                dashboard_values["cluster_name"]) +
            "Should be equal to {}".format(host.cluster_name))
        LOGGER.debug("Cluster name in grafana: {}".format(
            dashboard_values["cluster_name"]))
        LOGGER.debug("Cluster name in main UI: {}".format(host.cluster_name))
        hostname_grafanized = host.hostname.replace(".", "_")
        pytest.check(
            dashboard_values["host_name"] == hostname_grafanized,
            "Hostname in Grafana: {} ".format(dashboard_values["host_name"]) +
            "Should be equal to {}".format(hostname_grafanized))
        LOGGER.debug("Hostname in grafana: {}".format(
            dashboard_values["host_name"]))
        LOGGER.debug("Hostname in main UI "
                     "after dot replacement: '{}'".format(hostname_grafanized))
        if dashboard_values["brick_count"] == "0":
            pytest.check(
                dashboard_values["brick_count"] == host.bricks_count,
                "Bricks total in Grafana: {} ".format(
                    dashboard_values["brick_count"]) +
                "Should be equal to {}".format(host.bricks_count),
                issue='https://bugzilla.redhat.com/show_bug.cgi?id=1694982')
        else:
            pytest.check(
                dashboard_values["brick_count"] == host.bricks_count,
                "Bricks total in Grafana: {} ".format(
                    dashboard_values["brick_count"]) +
                "Should be equal to {}".format(host.bricks_count))
        LOGGER.debug("Brick count in grafana: {}".format(
            dashboard_values["brick_count"]))
        LOGGER.debug("Brick count in main UI: {}".format(host.bricks_count))
        pytest.check(
            dashboard_values["host_health"] == host.health.lower(),
            "Check that Host health in Grafana is the same as in main UI")
        LOGGER.debug("Host health in grafana: '{}'".format(
            dashboard_values["host_health"]))
        LOGGER.debug("Host health in main UI: '{}'".format(
            host.health.lower()))
コード例 #19
0
ファイル: test_host_ui.py プロジェクト: usmqe/usmqe-tests
def test_brick_dashboard(application, managed_cluster, gluster_volume):
    """
    Test Dashboard button of each brick of each host
    """
    """
    :step:
      Log in to Web UI and get the cluster identified by cluster_member.
      Get the list of its hosts.
    :result:
      Host objects are initiated and their attributes are read from the page
    """
    clusters = application.collections.clusters.get_clusters()
    test_cluster = tools.choose_cluster(clusters,
                                        managed_cluster["cluster_id"],
                                        managed_cluster["short_name"])
    assert test_cluster.managed == "Yes"
    hosts = test_cluster.hosts.get_hosts()
    """
    :step:
      For each host, get the list of its bricks.
      For each brick, click its Dashboard button.
      Check that the correct Grafana dashboard appears
      and that it shows expected value of brick status.
    :result:
      Grafana dashboard is opened, checked for its values and closed.
      Status check fails due to https://bugzilla.redhat.com/show_bug.cgi?id=1668900
    """
    for host in hosts:
        bricks = host.bricks.get_bricks()
        for brick in bricks:
            dashboard_values = brick.get_values_from_dashboard()
            brick_status = brick.status
            pytest.check(
                dashboard_values["cluster_name"] == brick.cluster_name,
                "Grafana cluster name: {}".format(
                    dashboard_values["cluster_name"]) +
                " Should be equal to {}".format(brick.cluster_name))
            LOGGER.debug("Cluster name in grafana: {}".format(
                dashboard_values["cluster_name"]))
            LOGGER.debug("Cluster name in main UI: {}".format(
                brick.cluster_name))
            hostname_grafanized = brick.hostname.replace(".", "_")
            pytest.check(
                dashboard_values["host_name"] == hostname_grafanized,
                "Hostname in Grafana: {} ".format(
                    dashboard_values["host_name"]) +
                "Should be equal to {}".format(hostname_grafanized))
            LOGGER.debug("Hostname in grafana: {}".format(
                dashboard_values["host_name"]))
            LOGGER.debug(
                "Hostname in main UI "
                "after dot replacement: '{}'".format(hostname_grafanized))
            path_grafanized = brick.brick_path.replace("/", ":")
            pytest.check(
                dashboard_values["brick_path"] == path_grafanized,
                "Brick path in Grafana: {} ".format(
                    dashboard_values["brick_path"]) +
                "Should be equal to {}".format(path_grafanized))
            LOGGER.debug("Brick path in grafana: {}".format(
                dashboard_values["brick_path"]))
            LOGGER.debug("Brick path in UI after slash replacement: {}".format(
                path_grafanized))
            pytest.check(
                dashboard_values["brick_status"] == brick_status,
                "Check that Brick status in Grafana is the same as in main UI")
            pytest.check(
                dashboard_values["brick_status"] in {"Started", "Stopped"},
                "Check that Brick status in Grafana is either Started or Stopped"
            )
            LOGGER.debug("Brick status in grafana: '{}'".format(
                dashboard_values["brick_status"]))
            LOGGER.debug("Brick status in main UI: '{}'".format(brick_status))