Merge pull request #13625 from danfengliu/fix-scan-all-py-test-script

Fix scan all python test script issue of missing test step
This commit is contained in:
danfengliu 2020-12-02 09:17:10 +08:00 committed by GitHub
commit 792a3c8c27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View File

@ -4991,6 +4991,10 @@ definitions:
'Success': 5
'Error': 2,
'Running': 3
ongoing:
type: boolean
description: A flag indicating job status of scan all .
SupportedWebhookEventTypes:
type: object
description: Supportted webhook event types and notify types.

View File

@ -117,6 +117,21 @@ class System(base.Base):
base._assert_status_code(expect_status_code, status_code)
return base._get_id_from_header(header)
def wait_until_scans_all_finish(self, **kwargs):
client = self._get_client(**kwargs)
timeout_count = 50
scan_status=""
while True:
time.sleep(5)
timeout_count = timeout_count - 1
if (timeout_count == 0):
break
stats = client.scans_all_metrics_get()
print("Scan all status:", stats)
if stats.ongoing:
return
raise Exception("Error: Scan all job is timeout.")
def create_scan_all_schedule(self, schedule_type, cron = None, expect_status_code = 201, expect_response_body = None, **kwargs):
client = self._get_client(**kwargs)
scanschedule = swagger_client.AdminJobScheduleObj()

View File

@ -82,6 +82,7 @@ class TestScanAll(unittest.TestCase):
#4. Trigger scan all event;
self.system.scan_now(**ADMIN_CLIENT)
self.system.wait_until_scans_all_finish(**ADMIN_CLIENT)
#5. Check if image in project_Alice and another image in project_Luca were both scanned.
self.artifact.check_image_scan_result(TestScanAll.project_Alice_name, image_a, tag_Alice, **USER_ALICE_CLIENT)