mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-02 14:07:51 +01:00
068d1d46ca
After debugging for issue of missing some http message logs, we found out that swagger client configuration will be re-initiated by calling models in swagger client, so in API python tests, defination for models must be in front of swagger client defination. Signed-off-by: danfengliu <danfengl@vmware.com>
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import time
|
|
import base
|
|
import v2_swagger_client
|
|
from v2_swagger_client.rest import ApiException
|
|
|
|
class ReplicationV2(base.Base, object):
|
|
def __init__(self):
|
|
super(ReplicationV2,self).__init__(api_type = "replication")
|
|
|
|
def wait_until_jobs_finish(self, rule_id, retry=10, interval=5, **kwargs):
|
|
Succeed = False
|
|
for i in range(retry):
|
|
Succeed = False
|
|
jobs = self.get_replication_executions(rule_id, **kwargs)
|
|
for job in jobs:
|
|
if job.status == "Succeed":
|
|
return
|
|
if not Succeed:
|
|
time.sleep(interval)
|
|
if not Succeed:
|
|
raise Exception("The jobs not Succeed")
|
|
|
|
def trigger_replication_executions(self, rule_id, expect_status_code = 201, **kwargs):
|
|
_, status_code, _ = self._get_client(**kwargs).start_replication_with_http_info({"policy_id":rule_id})
|
|
base._assert_status_code(expect_status_code, status_code)
|
|
|
|
def get_replication_executions(self, rule_id, expect_status_code = 200, **kwargs):
|
|
data, status_code, _ = self._get_client(**kwargs).list_replication_executions_with_http_info(policy_id=rule_id)
|
|
base._assert_status_code(expect_status_code, status_code)
|
|
return data
|
|
|