-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-130907 / 25.04 / Removed REST from test_150_cronjob (#14399)
- Loading branch information
Showing
2 changed files
with
40 additions
and
71 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from time import sleep | ||
|
||
import pytest | ||
|
||
from middlewared.test.integration.utils import call, ssh | ||
|
||
TESTFILE = '/tmp/.testFileCreatedViaCronjob' | ||
|
||
|
||
def test_create_check_update_verify_cron_job(): | ||
cronjob_dict = {} | ||
|
||
# create job | ||
results = call("cronjob.create", { | ||
'user': 'root', | ||
'command': f'touch "{TESTFILE}"', | ||
'schedule': {'minute': '*/1'} | ||
}) | ||
cronjob_dict.update(results) | ||
|
||
# verify job creation | ||
id = cronjob_dict['id'] | ||
results = call('cronjob.query', [['id', '=', id]], {"get": True}) | ||
assert results['enabled'] is True | ||
|
||
# wait so job can run | ||
sleep(65) | ||
|
||
# disable job | ||
id = cronjob_dict['id'] | ||
call('cronjob.update', id, {'enabled': False}) | ||
|
||
# remove test file | ||
results = ssh(f'rm "{TESTFILE}"', complete_response=True) | ||
assert results['result'] is True, results['output'] | ||
|
||
# delete job | ||
call('cronjob.delete', cronjob_dict['id']) | ||
results = call('cronjob.query', [['id', '=', id]], {"get": True}) | ||
assert results.json() == [] |