forked from goharbor/harbor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JobService Dashboard API test cases (goharbor#18234)
Added test cases for the following APIs: 1. GET /jobservice/pools/{pool_id}/workers Get workers 2. PUT /jobservice/jobs/{job_id} Stop running jc 3. PUT /jobservice/queues/{job_type} stop and clean, pause, resume pending jobs in the queue 4. GET /jobservice/queues list job queues 5. GET /jobservice/pools Get worker pools 6. GET /schedules List schedules 7. GET /schedules/{job_type}/paused Get scheduler paused status Signed-off-by: Yang Jiao <[email protected]>
- Loading branch information
1 parent
36ab5e1
commit 6ad35a5
Showing
10 changed files
with
514 additions
and
13 deletions.
There are no files selected for viewing
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
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
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,67 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import base | ||
import v2_swagger_client | ||
from v2_swagger_client.rest import ApiException | ||
|
||
|
||
class Jobservice(base.Base): | ||
|
||
def __init__(self): | ||
super(Jobservice, self).__init__(api_type="jobservice") | ||
|
||
def get_job_queues(self, expect_status_code=200, expect_response_body=None, **kwargs): | ||
try: | ||
return_data, status_code, _ = self._get_client(**kwargs).list_job_queues_with_http_info() | ||
except ApiException as e: | ||
base._assert_status_code(expect_status_code, e.status) | ||
if expect_response_body is not None: | ||
base._assert_status_body(expect_response_body, e.body) | ||
return | ||
base._assert_status_code(expect_status_code, status_code) | ||
return dict(zip([job_queue.job_type for job_queue in return_data], return_data)) | ||
|
||
def action_pending_jobs(self, job_type, action, expect_status_code=200, expect_response_body=None, **kwargs): | ||
try: | ||
action_request = v2_swagger_client.ActionRequest(action=action) | ||
return_data, status_code, _ = self._get_client(**kwargs).action_pending_jobs_with_http_info(job_type, action_request) | ||
except ApiException as e: | ||
base._assert_status_code(expect_status_code, e.status) | ||
if expect_response_body is not None: | ||
base._assert_status_body(expect_response_body, e.body) | ||
return | ||
base._assert_status_code(expect_status_code, status_code) | ||
return return_data | ||
|
||
def get_worker_pools(self, expect_status_code=200, expect_response_body=None, **kwargs): | ||
try: | ||
return_data, status_code, _ = self._get_client(**kwargs).get_worker_pools_with_http_info() | ||
except ApiException as e: | ||
base._assert_status_code(expect_status_code, e.status) | ||
if expect_response_body is not None: | ||
base._assert_status_body(expect_response_body, e.body) | ||
return | ||
base._assert_status_code(expect_status_code, status_code) | ||
return return_data | ||
|
||
def get_workers(self, pool_id, expect_status_code=200, expect_response_body=None, **kwargs): | ||
try: | ||
return_data, status_code, _ = self._get_client(**kwargs).get_workers_with_http_info(pool_id) | ||
except ApiException as e: | ||
base._assert_status_code(expect_status_code, e.status) | ||
if expect_response_body is not None: | ||
base._assert_status_body(expect_response_body, e.body) | ||
return | ||
base._assert_status_code(expect_status_code, status_code) | ||
return return_data | ||
|
||
def stop_running_job(self, job_id, expect_status_code=200, expect_response_body=None, **kwargs): | ||
try: | ||
return_data, status_code, _ = self._get_client(**kwargs).stop_running_job_with_http_info(job_id) | ||
except ApiException as e: | ||
base._assert_status_code(expect_status_code, e.status) | ||
if expect_response_body is not None: | ||
base._assert_status_body(expect_response_body, e.body) | ||
return | ||
base._assert_status_code(expect_status_code, status_code) | ||
return return_data |
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
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
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
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
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,38 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import base | ||
from v2_swagger_client.rest import ApiException | ||
|
||
|
||
class Schedule(base.Base): | ||
|
||
def __init__(self): | ||
super(Schedule, self).__init__(api_type="schedule") | ||
|
||
def get_schedule_paused(self, job_type, expect_status_code=200, expect_response_body=None, **kwargs): | ||
try: | ||
return_data, status_code, _ = self._get_client(**kwargs).get_schedule_paused_with_http_info(job_type) | ||
except ApiException as e: | ||
base._assert_status_code(expect_status_code, e.status) | ||
if expect_response_body is not None: | ||
base._assert_status_body(expect_response_body, e.body) | ||
return | ||
base._assert_status_code(expect_status_code, status_code) | ||
return return_data | ||
|
||
def list_schedules(self, page_size=50, page=1, expect_status_code=200, expect_response_body=None, **kwargs): | ||
try: | ||
schedules, status_code, _ = self._get_client(**kwargs).list_schedules_with_http_info(page_size=50, page=1) | ||
except ApiException as e: | ||
base._assert_status_code(expect_status_code, e.status) | ||
if expect_response_body is not None: | ||
base._assert_status_body(expect_response_body, e.body) | ||
return | ||
base._assert_status_code(expect_status_code, status_code) | ||
schedule_dict = {} | ||
for schedule in schedules: | ||
if schedule.vendor_id in [ None, -1]: | ||
schedule_dict[schedule.vendor_type] = schedule | ||
else: | ||
schedule_dict["%s-%d" % (schedule.vendor_type, schedule.vendor_id)] = schedule | ||
return schedule_dict |
Oops, something went wrong.