Skip to content

Commit

Permalink
Added smoke test for puppet end_to_end.
Browse files Browse the repository at this point in the history
*) Added locators to assign_orgs to hosts.
*) Added `fetch_hostname` under vm module to fetch client hostname.
*) Added `configure_puppet` under vm module for clients.
*) Added `configure_rhel_repo` under vm module for clients.
*) Installs puppet RPM on clients and configures puppet.
*) Updated ui/rhai.py to use vm.configure_rhel_repo()
  • Loading branch information
kbidarkar committed Aug 21, 2015
1 parent 75b8a9b commit cdeee56
Show file tree
Hide file tree
Showing 7 changed files with 362 additions and 57 deletions.
7 changes: 7 additions & 0 deletions robottelo.properties.sample
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ provisioning_server=
# provisioning server.
image_dir=/opt/robottelo/images

# Provide link to rhel6/7 repo here, as puppet rpm
# would require packages from RHEL 6/7 repo and syncing the entire repo
# on the fly would take longer for tests to run
# Specify the link to an internal repo for tests to execute properly
rhel6_repo=http://example.org/RHEL-6/6.7/Server/x86_64/os/
rhel7_repo=http://example.org/RHEL-7/7.1/Server/x86_64/os/

[docker]
# External docker URL in the format http[s]://<server>:<port>. The
# {server_hostname} variable can be used and will be replaced by
Expand Down
15 changes: 15 additions & 0 deletions robottelo/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
),
# TODO: Remove 'Beta' after release
'rhst7': 'Red Hat Satellite Tools 6 Beta (for RHEL 7 Server) (RPMs)',
'rhst6': 'Red Hat Satellite Tools 6.1 (for RHEL 6 Server) (RPMs)',
}

REPOS = {
Expand All @@ -168,6 +169,12 @@
'Red Hat Satellite Tools 6 Beta for RHEL 7 Server RPMs x86_64'
),
},
'rhst6': {
'id': 'rhel-6-server-satellite-tools-6-rpms',
'name': (
'Red Hat Satellite Tools 6.1 for RHEL 6 Server RPMs x86_64'
),
},
'rhva6': {
'name': (
'Red Hat Enterprise Virtualization Agents for RHEL 6 Server RPMs '
Expand Down Expand Up @@ -203,6 +210,13 @@
('rhel', 'rhva6', 'rhva6S', 'repo_ver', '6Server')
]

SAT6_TOOLS_TREE = [
('rhel', 'rhst6', 'rhst6', 'repo_name',
'Red Hat Satellite Tools 6.1 for RHEL 6 Server RPMs x86_64'),
('rhel', 'rhst6', 'rhst6', 'repo_arch', 'x86_64'),
('rhel', 'rhst6', 'rhst6', 'repo_ver', '6.1'),
]

#: Name (not label!) of the default organization.
DEFAULT_ORG = "Default Organization"
#: Name (not label!) of the default location.
Expand Down Expand Up @@ -236,6 +250,7 @@
FAKE_3_PUPPET_REPO = "http://omaciel.fedorapeople.org/fakepuppet03"
FAKE_4_PUPPET_REPO = "http://omaciel.fedorapeople.org/fakepuppet04"
FAKE_5_PUPPET_REPO = "http://omaciel.fedorapeople.org/fakepuppet05"
FAKE_6_PUPPET_REPO = "http://kbidarka.fedorapeople.org/repos/puppet-modules/"
REPO_DISCOVERY_URL = "http://omaciel.fedorapeople.org/"
FAKE_0_CUSTOM_PACKAGE = 'bear-4.1-1.noarch'
FAKE_0_CUSTOM_PACKAGE_NAME = 'bear'
Expand Down
138 changes: 83 additions & 55 deletions robottelo/ui/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,82 +12,98 @@ def _configure_hosts(self, arch=None, custom_ptable=None, cv=None,
domain=None, env=None, host_group=None, ip_addr=None,
lifecycle_env=None, mac=None, media=None, os=None,
ptable=None, puppet_ca=None, puppet_master=None,
puppet_module=None, reset_puppetenv=True,
resource=None, root_pwd=None, subnet=None):
strategy1, value1 = locators['host.select_puppetmodule']
strategy2, value2 = locators['host.select_puppetclass']
# Host tab
if lifecycle_env is not None:
if lifecycle_env:
Select(
self.wait_until_element(locators['host.lifecycle_env'])
).select_by_visible_text(lifecycle_env)
if cv is not None:
if cv:
Select(
self.wait_until_element(locators['host.cv'])
).select_by_visible_text(cv)
if host_group is not None:
if reset_puppetenv:
self.click(locators['host.reset_puppetenv'])
if host_group:
Select(
self.wait_until_element(locators['host.group'])
).select_by_visible_text(host_group)
elif env is not None and host_group is None:
elif env and not host_group:
# As selecting hostgroup changes env
Select(
self.wait_until_element(locators['host.environment'])
).select_by_visible_text(env)
if puppet_ca is not None:
if puppet_ca:
Select(
self.wait_until_element(locators['host.puppet_ca'])
).select_by_visible_text(puppet_ca)
if puppet_master is not None:
if puppet_master:
Select(
self.wait_until_element(locators['host.puppet_master'])
).select_by_visible_text(puppet_master)
# Network tab
self.wait_until_element(tab_locators['host.tab_network']).click()
if domain is not None:
if domain or mac or subnet or ip_addr:
self.click(tab_locators['host.tab_network'])
if domain:
Select(
self.wait_until_element(locators['host.domain'])
).select_by_visible_text(domain)
if mac is not None:
if mac:
self.wait_until_element(locators['host.mac']).send_keys(mac)
if subnet is not None:
if subnet:
Select(
self.wait_until_element(locators['host.subnet'])
).select_by_visible_text(subnet)
if ip_addr is not None:
if ip_addr:
self.wait_until_element(locators['host.ip']).send_keys(ip_addr)
# Operating system tab
self.wait_until_element(tab_locators['host.tab_os']).click()
if arch is not None:
if arch or os or media or ptable or custom_ptable or root_pwd:
self.click(tab_locators['host.tab_os'])
if arch:
Select(
self.wait_until_element(locators['host.arch'])
).select_by_visible_text(arch)
self.wait_for_ajax()
if os is not None:
if os:
Select(
self.wait_until_element(locators['host.os'])
).select_by_visible_text(os)
self.wait_for_ajax()
if media is not None:
if media:
Select(
self.wait_until_element(locators['host.media'])
).select_by_visible_text(media)
if ptable is not None:
if ptable:
Select(
self.wait_until_element(locators['host.ptable'])
).select_by_visible_text(ptable)
if custom_ptable is not None:
if custom_ptable:
self.wait_until_element(
locators['host.custom_ptables']).send_keys(custom_ptable)
if root_pwd is not None:
if root_pwd:
self.wait_until_element(
locators['host.root_pass']).send_keys(root_pwd)
# Puppet tab
if puppet_module:
self.click(tab_locators['host.tab_puppet'])
self.wait_until_element(
(strategy1, value1 % puppet_module)
).click()
self.wait_until_element(
(strategy2, value2 % puppet_module)
).click()

def create(self, arch=None, cpus='1', cv=None, custom_ptable=None,
domain=None, env=None, host_group=None, ip_addr=None,
lifecycle_env=None, loc=None, mac=None, media=None,
memory='768 MB', name=None, org=None, os=None, ptable=None,
puppet_ca=None, puppet_master=None, resource=None,
root_pwd=None, subnet=None):
puppet_ca=None, puppet_master=None, reset_puppetenv=True,
resource=None, root_pwd=None, subnet=None):
"""Creates a host."""
self.wait_until_element(locators['host.new']).click()
self.click(locators['host.new'])
self.wait_until_element(locators['host.name']).send_keys(name)
if org is not None:
Select(
Expand Down Expand Up @@ -124,53 +140,52 @@ def create(self, arch=None, cpus='1', cv=None, custom_ptable=None,
subnet=subnet,
)
if resource != RESOURCE_DEFAULT:
self.wait_until_element(tab_locators['host.tab_vm']).click()
self.click(tab_locators['host.tab_vm'])
Select(
self.wait_until_element(locators['host.vm_cpus'])
).select_by_visible_text(cpus)
Select(
self.wait_until_element(locators['host.vm_memory'])
).select_by_visible_text(memory)
self.wait_until_element(common_locators['submit']).click()
self.wait_for_ajax()
self.click(common_locators['submit'])

def update(self, arch=None, cv=None, custom_ptable=None, domain=None,
env=None, host_group=None, ip_addr=None, mac=None,
lifecycle_env=None, media=None, name=None, new_name=None,
os=None, ptable=None, puppet_ca=None, puppet_master=None,
resource=None, root_pwd=None, subnet=None):
puppet_module=None, reset_puppetenv=False, resource=None,
root_pwd=None, subnet=None):
"""Updates a Host."""
element = self.search(name)
if element is not None:
element.click()
self.wait_until_element(locators['host.edit']).click()
self.wait_for_ajax()
if new_name is not None:
self.wait_until_element(locators['host.name'])
self.field_update('host.name', new_name)
self._configure_hosts(
arch=arch,
cv=cv,
custom_ptable=custom_ptable,
domain=domain,
env=env,
host_group=host_group,
ip_addr=ip_addr,
lifecycle_env=lifecycle_env,
mac=mac,
media=media,
os=os,
ptable=ptable,
puppet_ca=puppet_ca,
puppet_master=puppet_master,
resource=resource,
root_pwd=root_pwd,
subnet=subnet,
)
self.find_element(common_locators['submit']).click()
self.wait_for_ajax()
else:
raise UIError('Could not update the host "{0}"'.format(name))
if element is None:
raise UIError(u'Could not update the host {0}'.format(name))
element.click()
self.click(locators['host.edit'])
if new_name:
self.wait_until_element(locators['host.name'])
self.field_update('host.name', new_name)
self._configure_hosts(
arch=arch,
cv=cv,
custom_ptable=custom_ptable,
domain=domain,
env=env,
host_group=host_group,
ip_addr=ip_addr,
lifecycle_env=lifecycle_env,
mac=mac,
media=media,
os=os,
ptable=ptable,
puppet_ca=puppet_ca,
puppet_master=puppet_master,
puppet_module=puppet_module,
reset_puppetenv=reset_puppetenv,
resource=resource,
root_pwd=root_pwd,
subnet=subnet,
)
self.click(common_locators['submit'])

def search(self, name):
"""Searches existing host from UI."""
Expand All @@ -185,3 +200,16 @@ def delete(self, name, really):
locators['host.delete'],
drop_locator=locators['host.dropdown']
)

def update_host_bulkactions(self, host=None, org=None):
"""Updates host via bulkactions"""
strategy1, value1 = locators['host.checkbox']
self.wait_until_element((strategy1, value1 % host)).click()
self.click(locators['host.select_action'])
if org:
self.click(locators['host.assign_org'])
self.click(locators['host.fix_mismatch'])
Select(
self.wait_until_element(locators['host.select_org'])
).select_by_visible_text(org)
self.click(locators['host.bulk_submit'])
27 changes: 25 additions & 2 deletions robottelo/ui/locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def __iter__(self):
# Host
# Third level UI

"host.tab_puppet": (By.XPATH, "//a[@href='#puppet_klasses']"),
"host.tab_network": (By.XPATH, "//a[@href='#network']"),
"host.tab_os": (By.XPATH, "//a[@href='#os']"),
"host.tab_vm": (By.XPATH, "//a[@href='#compute_resource']"),
Expand Down Expand Up @@ -861,13 +862,14 @@ def __iter__(self):
"host.dropdown": (
By.XPATH,
("//a[contains(@href,'%s')]"
"/../../a[contains(@data-toggle,'dropdown')]")),
"/../../a[contains(@data-toggle,'dropdown')]")),
"host.select_name": (
By.XPATH,
("//input[contains(@id,'host_ids')]"
"/../../td[@class='ellipsis']/a[contains(@href,'%s')]")),
"/../../td[@class='ellipsis']/a[contains(@href,'%s')]")),
"host.lifecycle_env": (By.ID, "host_lifecycle_environment_id"),
"host.cv": (By.ID, "host_content_view_id"),
"host.reset_puppetenv": (By.ID, "reset_puppet_environment"),

# host.network
"host.mac": (By.ID, "host_mac"),
Expand Down Expand Up @@ -902,6 +904,27 @@ def __iter__(self):
"host.vm_addnic": (
By.XPATH, "//fieldset[@id='network_interfaces']/a"),

# Host 'Select Action'/'Bulk Action.'
"host.checkbox": (
By.XPATH,
"//span[contains(@data-original-title, '%s')]/../../../td/input"),
"host.select_action": (
By.XPATH,
"//div[@id='submit_multiple']/a[contains(@class, 'dropdown-toggle')]"),
"host.assign_org": (
By.XPATH, "//a[contains(@href, 'select_multiple_organization')]"),
"host.fix_mismatch": (By.ID, "organization_optimistic_import_yes"),
"host.select_org": (By.ID, "organization_id"),
"host.bulk_submit": (
By.XPATH,
("//form[contains(@action, 'multiple')]/../../../"
"div/button[contains(@class,'primary')]")),
"host.select_puppetmodule":
(By.XPATH, "//a[contains(.,'%s')]/i[contains(@class, 'glyphicon')]"),
"host.select_puppetclass": (
By.XPATH,
("//span[contains(.,'%s')]"
"/a[not(contains(@data-original-title, '::'))]")),

# Provisions

Expand Down
13 changes: 13 additions & 0 deletions robottelo/ui/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,19 @@ def enable_rh_repos(self, repos_tree):
poll_frequency=2,
)

def sync_noversion_rh_repos(self, prd, repos):
"""Syncs RedHat repositories which do not have version.
Selects Red Hat non version Repos to Synchronize from UI.
:param prd: The product which repositories belongs to.
:param repos: List of repositories to sync.
:return: Returns True if the sync was successful.
:rtype: bool
"""
return self.sync_custom_repos(prd, repos)

def sync_rh_repos(self, repos_tree):
"""Syncs RedHat repositories.
Expand Down
Loading

0 comments on commit cdeee56

Please sign in to comment.