Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

[1LP][RFR] New Test: Test overwrite domain using rake command #9756

Merged
merged 4 commits into from
Dec 18, 2019

Conversation

ganeshhubale
Copy link
Member

Signed-off-by: Ganesh Hubale [email protected]

Purpose or Intent

  • Test overwrite domain using rake

PRT Run

{{ pytest: cfme/tests/automate/test_file_import.py -k 'test_overwrite_import_domain' --use-template-cache -qsvv }}

@ganeshhubale ganeshhubale added the test-automation To be applied on PR's which are automating existing manual cases label Dec 11, 2019
    - Test overwrite domain using rake

Signed-off-by: Ganesh Hubale <[email protected]>
@ganeshhubale ganeshhubale changed the title [WIPTEST] New Test: Test overwrite domain using rake command [RFR] New Test: Test overwrite domain using rake command Dec 17, 2019
Copy link
Contributor

@valaparthvi valaparthvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes and questions :)


@pytest.fixture(scope='module')
def local_domain(appliance):
"""This fixture used to create automate domain - Datastore/Domain"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixture is used...

Comment on lines 212 to 215
domain = appliance.collections.domains.create(
name="bz_1753860",
description=fauxfactory.gen_alpha(),
enabled=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you improve the formatting here?


@pytest.mark.tier(2)
@pytest.mark.meta(automates=[1753860])
@pytest.mark.parametrize("file_name", ["bz_1753860.zip"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case you decide to use a different file name in the future, the test name would also change. Can you use ids here, so that the test name remains consistent?

caseposneg: positive
casecomponent: Automate
testSteps:
1. Create custom domain, namespace, class, instance, method. Do not delete this domain.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it is a part of the setup.
Also, I'm curious, you're only creating domain here, I don't see namespace, class, instance and method creation, where is it happening?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These things needs to create manually by exporting datastore which is not possible in automation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so the datastore you're importing creates all these, correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Comment on lines 276 to 278
for domain in view.domains.read():
if domain['Name'] == local_domain.name:
assert domain['Enabled'] == "true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for domain in view.domains.read():
if domain['Name'] == local_domain.name:
assert domain['Enabled'] == "true"
assert view.domains.row(name__contains=local_domain.name)["Enabled"].text == "true"

Comment on lines 266 to 268
for domain in view.domains.read():
if domain['Name'] == f"{local_domain.name} (Disabled)":
assert domain['Enabled'] == "false"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for domain in view.domains.read():
if domain['Name'] == f"{local_domain.name} (Disabled)":
assert domain['Enabled'] == "false"
assert view.domains.row(name__contains=local_domain.name)["Enabled"].text == "false"

Comment on lines 254 to 257
cmd = [(
f"evm:automate:import PREVIEW=false DOMAIN=bz_1753860 IMPORT_AS=bz_1753860 "
f"ZIP_FILE={file_path} SYSTEM=false ENABLED={enable} OVERWRITE=true"
) for enable, file_path in [{file_path, 'false'}, {file_path, 'true'}]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something is wrong with these commands, perhaps it should be something like this -

Suggested change
cmd = [(
f"evm:automate:import PREVIEW=false DOMAIN=bz_1753860 IMPORT_AS=bz_1753860 "
f"ZIP_FILE={file_path} SYSTEM=false ENABLED={enable} OVERWRITE=true"
) for enable, file_path in [{file_path, 'false'}, {file_path, 'true'}]]
cmd = [(
f"evm:automate:import PREVIEW=false DOMAIN=bz_1753860 IMPORT_AS=bz_1753860 "
f"ZIP_FILE={file_path} SYSTEM=false ENABLED={enable} OVERWRITE=true"
) for enable in ['false', 'true']]

description=fauxfactory.gen_alpha(),
enabled=True)
yield domain
domain.delete_if_exists()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better if you use REST to delete the domain.

if domain.rest_api_entity.exists:
    domain.rest_api_entity.action.delete()

The reason being, if the test case fails/errors out/stops after disabling the domain, it will not be able to delete the domain via UI, since domain name in the tree would change to domain_name (Disabled), and its tree path would also change to `["Datastore", "domain_name (Disabled)"].

To delete a domain, it first checks the path in the bootstrap tree. Since .enabled property of local_domain does not get updated when you enable or disable it and since the original domain.enabled value is True, it tries to search for ["Datastore", local_domain.name] in the bootstrap tree path, but does not find it and hence is not able to delete the domain.

With REST this problem does not arise, so it doesn't matter whether a domain is enabled or disabled, it will delete it if it exists as long as it is not locked.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for detailed solution @valaparthvi
It is very helpful. But it worked with 5.11 and givin some error in 5.10 as below:

ipdb> domain.rest_api_entity.action.all                                                              
['refresh_from_source']

It does not have delete action in 5.10 via REST

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, so maybe in that case, instead of using REST, you could make sure that the domain is enabled before deleting it, or maybe modify the delete() method to delete a domain no matter it's status.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another solution would be something like this -

Suggested change
domain.delete_if_exists()
@pytest.fixture(scope='module')
def local_domain(appliance):
"""This fixture used to create automate domain - Datastore/Domain"""
# Domain name should be static to match with name of domain imported using rake command
domain = appliance.collections.domains.create(
name="bz_1753860", description=fauxfactory.gen_alpha(), enabled=True
)
yield domain
domain.enabled = domain.rest_api_entity.enabled
domain.delete()

The reason being, treepath of a domain is decided on the basis of it's enabled status. We can change domain.enabled to whatever it's current value is, that way the domain will be deleted for sure.

@valaparthvi valaparthvi changed the title [RFR] New Test: Test overwrite domain using rake command [WIPTEST] New Test: Test overwrite domain using rake command Dec 17, 2019
@ganeshhubale ganeshhubale changed the title [WIPTEST] New Test: Test overwrite domain using rake command [RFR] New Test: Test overwrite domain using rake command Dec 18, 2019
Copy link
Contributor

@valaparthvi valaparthvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for being patient and working on all the changes. :)

@valaparthvi valaparthvi changed the title [RFR] New Test: Test overwrite domain using rake command [1LP][RFR] New Test: Test overwrite domain using rake command Dec 18, 2019
Copy link
Contributor

@digitronik digitronik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 thanks for PR

Please try to avoid repetition by creating data dict for state and cmd as per enable and disable status.

expectedResults:
1. Description and enabled status of existing domain should update.
"""
file = FTPClientWrapper(cfme_data.ftpserver.entities.datastores).get_file(file_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would try to avoid overwrite of python builtin.

assert appliance.ssh_client.run_command(f"curl -o {file_path} ftp://{file.link}").success

# Rake command to update domain
cmd = [(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: we need to use indexing (:, I would unpack here only enable_cmd, disable_cmd =

@digitronik digitronik self-assigned this Dec 18, 2019
@digitronik digitronik changed the title [1LP][RFR] New Test: Test overwrite domain using rake command [1LP][WIPTEST] New Test: Test overwrite domain using rake command Dec 18, 2019
@dajoRH
Copy link
Contributor

dajoRH commented Dec 18, 2019

I detected some fixture changes in commit f702429

The local fixture local_domain is used in the following files:

  • cfme/tests/automate/test_file_import.py
    • test_overwrite_import_domain

Please, consider creating a PRT run to make sure your fixture changes do not break existing usage 😃

@ganeshhubale ganeshhubale changed the title [1LP][WIPTEST] New Test: Test overwrite domain using rake command [1LP][RFR] New Test: Test overwrite domain using rake command Dec 18, 2019
Copy link
Contributor

@digitronik digitronik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for PR 👍

@digitronik digitronik merged commit 47f4f89 into ManageIQ:master Dec 18, 2019
spusateri pushed a commit to spusateri/integration_tests that referenced this pull request Jan 27, 2020
…IQ#9756)

* New Test:
    - Test overwrite domain using rake

Signed-off-by: Ganesh Hubale <[email protected]>

* Updated with requested

* Updated teardown of domain

* Updated code to remove repetition
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lint-ok test-automation To be applied on PR's which are automating existing manual cases WIP-testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants