diff --git a/tests/apitests/python/library/oras.py b/tests/apitests/python/library/oras.py index ce082984c..66ed8c0fc 100644 --- a/tests/apitests/python/library/oras.py +++ b/tests/apitests/python/library/oras.py @@ -22,11 +22,26 @@ def oras_push(harbor_server, user, password, project, repo, tag): fo = open(file_config, "w") fo.write( "{\"doc\":\"readme.md\"}" ) fo.close() - ret = base.run_command( [oras_cmd, "push", harbor_server + "/" + project + "/" + repo+":"+ tag, + + exception = None + for _ in range(5): + exception = oras_push_cmd(harbor_server, project, repo, tag) + if exception == None: + break + if exception != None: + raise exception + return md5_artifact.split(' ')[0], md5_readme.split(' ')[0] + +def oras_push_cmd(harbor_server, project, repo, tag): + try: + ret = base.run_command( [oras_cmd, "push", harbor_server + "/" + project + "/" + repo+":"+ tag, "--manifest-config", "config.json:application/vnd.acme.rocket.config.v1+json", \ file_artifact+":application/vnd.acme.rocket.layer.v1+txt", \ file_readme +":application/vnd.acme.rocket.docs.layer.v1+json"] ) - return md5_artifact.split(' ')[0], md5_readme.split(' ')[0] + return None + except Exception as e: + print("Run command error:", str(e)) + return e def oras_login(harbor_server, user, password): ret = base.run_command([oras_cmd, "login", "-u", user, "-p", password, harbor_server]) diff --git a/tests/resources/CNAB_Util.robot b/tests/resources/CNAB_Util.robot index 8c4160e04..2726ff718 100644 --- a/tests/resources/CNAB_Util.robot +++ b/tests/resources/CNAB_Util.robot @@ -20,10 +20,7 @@ Library Process *** Keywords *** CNAB Push Bundle [Arguments] ${ip} ${user} ${pwd} ${target} ${bundle_file} ${registry} ${namespace} ${index1} ${index2} - ${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/cnab_push_bundle.sh ${ip} ${user} ${pwd} ${target} ${bundle_file} ${registry} ${namespace} ${index1} ${index2} - Log To Console ${output} - Log ${output} - Should Be Equal As Integers ${rc} 0 + Wait Unitl Command Success ./tests/robot-cases/Group0-Util/cnab_push_bundle.sh ${ip} ${user} ${pwd} ${target} ${bundle_file} ${registry} ${namespace} ${index1} ${index2} Prepare Cnab Push Test Data [Arguments] ${ip} ${user} ${pwd} ${project} ${index1_image1} ${index1_image2} ${index2_image1} ${index2_image2} ${image_tag}=latest diff --git a/tests/resources/Helm-Util.robot b/tests/resources/Helm-Util.robot index 8986d78b9..bff2ff4ee 100644 --- a/tests/resources/Helm-Util.robot +++ b/tests/resources/Helm-Util.robot @@ -38,9 +38,7 @@ Helm Repo Push Helm Chart Push [Arguments] ${ip} ${user} ${pwd} ${chart_file} ${archive} ${project} ${repo_name} ${verion} - ${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/helm_push_chart.sh ${ip} ${user} ${pwd} ${chart_file} ${archive} ${project} ${repo_name} ${verion} - Log ${output} - Should Be Equal As Integers ${rc} 0 + Wait Unitl Command Success ./tests/robot-cases/Group0-Util/helm_push_chart.sh ${ip} ${user} ${pwd} ${chart_file} ${archive} ${project} ${repo_name} ${verion} Helm3.7 Registry Login [Arguments] ${ip} ${user} ${password} diff --git a/tests/resources/TestCaseBody.robot b/tests/resources/TestCaseBody.robot index f829938b5..541717fff 100644 --- a/tests/resources/TestCaseBody.robot +++ b/tests/resources/TestCaseBody.robot @@ -174,10 +174,7 @@ Body Of Admin Push Signed Image ${src_tag}= Set Variable latest ${src_image}= Set Variable ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image}:${src_tag} Docker Pull ${src_image} - ${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/notary-push-image.sh ${ip} ${project} ${image} ${tag} ${notaryServerEndpoint} ${src_image} ${user} ${pwd} - - Log ${output} - Should Be Equal As Integers ${rc} 0 + Wait Unitl Command Success ./tests/robot-cases/Group0-Util/notary-push-image.sh ${ip} ${project} ${image} ${tag} ${notaryServerEndpoint} ${src_image} ${user} ${pwd} ${rc} ${output}= Run And Return Rc And Output curl -u admin:Harbor12345 -s --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/v2.0/projects/${project}/repositories/${image}/artifacts/${tag}?with_signature=true" diff --git a/tests/robot-cases/Group1-Nightly/Common.robot b/tests/robot-cases/Group1-Nightly/Common.robot index a809cf6e9..3ea90461a 100644 --- a/tests/robot-cases/Group1-Nightly/Common.robot +++ b/tests/robot-cases/Group1-Nightly/Common.robot @@ -747,7 +747,7 @@ Test Case - Push Helm Chart and Display Sign In Harbor ${HARBOR_URL} user010 Test1@34 Create An New Project And Go Into Project test${d} - Helm Chart Push ${ip} user010 Test1@34 ${chart_file} ${archive} test${d} ${repo_name} ${verion} + Retry Action Keyword Helm Chart Push ${ip} user010 Test1@34 ${chart_file} ${archive} test${d} ${repo_name} ${verion} Go Into Project test${d} Wait Until Page Contains test${d}/${repo_name}