-
Notifications
You must be signed in to change notification settings - Fork 165
[1LP][RFR] New Test: Test overwrite domain using rake command #9756
Conversation
8678484
to
3c77c30
Compare
- Test overwrite domain using rake Signed-off-by: Ganesh Hubale <[email protected]>
3c77c30
to
a1df91e
Compare
There was a problem hiding this 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""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixture is used...
domain = appliance.collections.domains.create( | ||
name="bz_1753860", | ||
description=fauxfactory.gen_alpha(), | ||
enabled=True) |
There was a problem hiding this comment.
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"]) |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
for domain in view.domains.read(): | ||
if domain['Name'] == local_domain.name: | ||
assert domain['Enabled'] == "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
for domain in view.domains.read(): | ||
if domain['Name'] == f"{local_domain.name} (Disabled)": | ||
assert domain['Enabled'] == "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
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'}]] |
There was a problem hiding this comment.
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 -
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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 -
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.
There was a problem hiding this 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. :)
There was a problem hiding this 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) |
There was a problem hiding this comment.
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 = [( |
There was a problem hiding this comment.
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 =
I detected some fixture changes in commit f702429 The local fixture
Please, consider creating a PRT run to make sure your fixture changes do not break existing usage 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for PR 👍
…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
Signed-off-by: Ganesh Hubale [email protected]
Purpose or Intent
PRT Run
{{ pytest: cfme/tests/automate/test_file_import.py -k 'test_overwrite_import_domain' --use-template-cache -qsvv }}