Skip to content

Commit

Permalink
added views and entities to fetch the dynflow console output (#1576)
Browse files Browse the repository at this point in the history
  • Loading branch information
amolpati30 committed Sep 28, 2024
1 parent c397b5d commit c57b597
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
18 changes: 18 additions & 0 deletions airgun/entities/job_invocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
from airgun.entities.base import BaseEntity
from airgun.navigation import NavigateStep, navigator
from airgun.utils import retry_navigation
from airgun.views.dynflowconsole import DynflowConsoleView
from airgun.views.job_invocation import (
JobInvocationCreateView,
JobInvocationStatusView,
JobInvocationsView,
)
from airgun.views.task import TaskDetailsView


class JobInvocationEntity(BaseEntity):
Expand Down Expand Up @@ -71,6 +73,22 @@ def get_targeted_hosts(self):
time.sleep(3)
return view.target_hosts_and_inputs.read()

def read_dynflow_output(self, entity_name, host_name):
"""Read dynflow console output"""
view = self.navigate_to(self, 'Job Status', entity_name=entity_name, host_name=host_name)
wait_for(lambda: view.overview.hosts_table.is_displayed, timeout=10)
view.overview.hosts_table.row(host=host_name)['Actions'].widget.fill('Host task')
view = TaskDetailsView(self.browser)
wait_for(lambda: view.task.dynflow_console.is_displayed, timeout=10)
view.task.dynflow_console.click()
self.browser.switch_to_window(self.browser.window_handles[1])
console = DynflowConsoleView(self.browser)
wait_for(lambda: console.is_displayed, timeout=100)
result = console.output.read()
self.browser.switch_to_window(self.browser.window_handles[0])
self.browser.close_window(self.browser.window_handles[1])
return result


@navigator.register(JobInvocationEntity, 'All')
class ShowAllJobs(NavigateStep):
Expand Down
15 changes: 15 additions & 0 deletions airgun/views/dynflowconsole.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from widgetastic.widget import Text
from widgetastic_patternfly4 import Pagination as PF4Pagination

from airgun.views.common import BaseLoggedInView


class DynflowConsoleView(BaseLoggedInView):
title = Text("//a[@class='navbar-brand']//img")
output = Text("//div[@class='action']/pre[2]")

pagination = PF4Pagination()

@property
def is_displayed(self):
return self.browser.wait_for_element(self.title, exception=False) is not None
2 changes: 1 addition & 1 deletion airgun/views/job_invocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class overview(SatTab):
'.//table',
column_widgets={
'Host': Text('./a'),
'Actions': ActionsDropdown("./div[contains(@class, 'btn-group')]"),
'Actions': ActionsDropdown('.//div[contains(@class, "btn-group")]'),
},
)
total_hosts = Text(
Expand Down
3 changes: 2 additions & 1 deletion airgun/views/task.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from wait_for import wait_for
from widgetastic.widget import Table, Text, View
from widgetastic_patternfly import BreadCrumb
from widgetastic_patternfly import BreadCrumb, Button
from widgetastic_patternfly4 import Pagination as PF4Pagination

from airgun.views.common import BaseLoggedInView, SatTab, SearchableViewMixinPF4
Expand Down Expand Up @@ -97,6 +97,7 @@ class task(SatTab):
progressbar = ProgressBar(locator='//div[contains(@class,"progress-bar")]')
output = TaskReadOnlyEntry(name='Output')
errors = TaskReadOnlyEntryError(name='Errors')
dynflow_console = Button('Dynflow console')

def wait_for_result(self, timeout=60, delay=1):
"""Wait for invocation job to finish"""
Expand Down

0 comments on commit c57b597

Please sign in to comment.