SatelliteQE / robottelo

Robottelo is a test suite that exercises The Foreman.
GNU General Public License v3.0
61 stars 112 forks source link

"custom" is not by itself a valid sync interval #6663

Closed swadeley closed 5 years ago

swadeley commented 5 years ago

I see error in "SyncPlanUpdateTestCase.test_positive_update_interval_custom_cron":

"for interval in valid_sync_interval(): sync_plan = entities.SyncPlan( description=gen_string('alpha'), organization=self.org, > interval=interval ).create()"

tests/foreman/api/test_syncplan.py:403:

I used pdb: pytest -pdb tests/foreman/api/test_syncplan.py::SyncPlanUpdateTestCase::test_positive_update_interval_custom_cron

client.py 103 DEBUG Making HTTP POST request to https://sat-6-5-qa-rhel7.localhost.example.com/katello/api/v2/organizations/8/sync_plans with options {'auth': ('admin', 'changeme'), 'verify': False, 'headers': {'content-type': 'application/json'}}, no params and data {"description": "OAMIghYMSm", "interval": "custom cron", "enabled": true, "name": "eckYZsSejY", "sync_date": "2912-03-17 17:22:10", "organization_id": 8}. client.py 122 WARNING Received HTTP 500 response: {"displayMessage":"Cron expression is not valid!","errors":["Cron expression is not valid!"]} The real error is that in the above POST request, no cron expression is supplied.

The fail on line 403 I think is because the code to handle the custom cron case comes on lines 406 to 411, which is too late.

This change affects any test that uses valid_sync_interval(): https://github.com/SatelliteQE/robottelo/pull/6603/commits

Looking at the test above, test_positive_update_interval, custom cron is handled differently. If that test is creating a sync plan and then updating it, also with custom cron, do we need both tests?

ldjebran commented 5 years ago

Think the cron_expression was not supplied

swadeley commented 5 years ago

If I delete "test_positive_update_interval_custom_cron" then all the other tests in "SyncPlanUpdateTestCase" pass:

robottelo]$ pytest -pdb tests/foreman/api/test_syncplan.py::SyncPlanUpdateTestCase ======================= test session starts ============================== platform linux -- Python 3.6.6, pytest-4.0.2, py-1.6.0, pluggy-0.8.1 shared_function enabled - OFF - scope: - storage: file rootdir: /home/sjw/Downloads/robottelo, inifile: plugins: xdist-1.23.2, services-1.3.1, mock-1.10.0, forked-0.2, cov-2.6.0 collecting ... 2019-01-22 11:48:24 - conftest - DEBUG - BZ deselect is disabled in settings

collected 7 items

tests/foreman/api/test_syncplan.py ....... [100%]

================== 7 passed in 10.44 seconds ================================

swadeley commented 5 years ago

After reading:

":expectedresults: A sync plan is created and its interval can be updated to custom cron."

not attempting to create a custom cron sync plan at first, seems valid:

\ for interval in valid_sync_interval(): - sync_plan = entities.SyncPlan( + if interval != 'custom cron': + sync_plan = entities.SyncPlan(

That works. It also updates a custom cron plan from one expression to another.

I will create a pull request.

swadeley commented 5 years ago

Created the pull request: https://github.com/SatelliteQE/robottelo/pull/6678

swadeley commented 5 years ago

Thank you @oshtaier for the merge.