Commit aa43afb6 authored by danfengliu's avatar danfengliu
Browse files

Add push-based replication test in nightly


Signed-off-by: default avatardanfengliu <danfengl@vmware.com>
parent d73265d1
......@@ -57,11 +57,14 @@ class Project(base.Base):
def check_project_name_exist(self, name=None, **kwargs):
client = self._get_client(**kwargs)
_, status_code, _ = client.projects_head_with_http_info(name)
try:
_, status_code, _ = client.projects_head_with_http_info(name)
except ApiException as e:
status_code = -1
return {
200: True,
404: False,
}.get(status_code,'error')
}.get(status_code,False)
def get_project(self, project_id, expect_status_code = 200, expect_response_body = None, **kwargs):
client = self._get_client(**kwargs)
......
......@@ -36,18 +36,21 @@ Pull image
Should Not Contain ${output} No such image:
Push image
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${sha256}=${null} ${is_robot}=${false}
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${sha256}=${null} ${is_robot}=${false} ${tag_suffix}=${false}
${image_with_sha256}= Set Variable If '${sha256}'=='${null}' ${image} ${image}@sha256:${sha256}
${image_with_tag}= Set Variable If '${sha256}'=='${null}' ${image} ${image}:${sha256}
Sleep 3
Log To Console \nRunning docker push ${image}...
Docker Pull ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image_with_sha256}
${d}= Get Current Date result_format=%m%s
${image_with_tag}= Set Variable If '${tag_suffix}'=='${true}' ${image_with_tag}_${d} ${image_with_tag}
Run Keyword If ${is_robot}==${false} Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip}
... ELSE Wait Unitl Command Success docker login -u robot\\\$${user} -p ${pwd} ${ip}
Wait Unitl Command Success docker tag ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/${image_with_sha256} ${ip}/${project}/${image_with_tag}
Wait Unitl Command Success docker push ${ip}/${project}/${image_with_tag}
Wait Unitl Command Success docker logout ${ip}
Sleep 1
[Return] ${image_with_tag}
Push Image With Tag
#tag1 is tag of image on docker hub,default latest,use a version existing if you do not want to use latest
......@@ -174,3 +177,23 @@ Docker Push Index
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/docker_push_manifest_list.sh ${ip} ${user} ${pwd} ${index} ${image1} ${image2}
Log ${output}
Should Be Equal As Integers ${rc} 0
Docker Image Can Not Be Pulled
[Arguments] ${image}
:FOR ${idx} IN RANGE 0 30
\ ${out} Run Keyword And Ignore Error Command Should be Failed docker pull ${image}
\ Exit For Loop If '${out[0]}'=='PASS'
\ Sleep 3
Log To Console Cannot Pull Image From Docker - Pull Log: ${out[1]}
Should Be Equal As Strings '${out[0]}' 'PASS'
Docker Image Can Be Pulled
[Arguments] ${image} ${period}=60 ${times}=10
:For ${n} IN RANGE 1 ${times}
\ Sleep ${period}
\ ${out} Run Keyword And Ignore Error Docker Pull ${image}
\ Log To Console Return value is ${out[0]}
\ Exit For Loop If '${out[0]}'=='PASS'
\ Sleep 5
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'
\ No newline at end of file
......@@ -73,22 +73,22 @@ Create A New Endpoint
Create A Rule With Existing Endpoint
[Arguments] ${name} ${replication_mode} ${project_name} ${resource_type} ${endpoint} ${dest_namespace}
... ${mode}=Manual ${cron}="* */59 * * * *"
... ${mode}=Manual ${cron}="* */59 * * * *" ${del_remote}=${false}
#click new
Retry Element Click ${new_name_xpath}
#input name
Retry Text Input ${rule_name} ${name}
Run Keyword If '${replication_mode}' == 'push' Run Keywords Retry Element Click ${replication_mode_radio_push}
... AND Select Dest Registry ${endpoint}
... ELSE Run Keywords Retry Element Click ${replication_mode_radio_pull}
... AND Select Source Registry ${endpoint}
Run Keyword If '${replication_mode}' == 'push' Run Keywords Retry Element Click ${replication_mode_radio_push} AND Select Dest Registry ${endpoint}
... ELSE Run Keywords Retry Element Click ${replication_mode_radio_pull} AND Select Source Registry ${endpoint}
#set filter
Retry Text Input ${source_project} ${project_name}
Run Keyword And Ignore Error Select From List By Value ${rule_resource_selector} ${resource_type}
Retry Text Input ${dest_namespace_xpath} ${dest_namespace}
#set trigger
Select Trigger ${mode}
Run Keyword If '${mode}' == 'Scheduled' Retry Text Input ${targetCron_id} ${cron}
Run Keyword If '${mode}' == 'Scheduled' Retry Text Input ${targetCron_id} ${cron}
Run Keyword If '${mode}' == 'Event Based' and '${del_remote}' == '${true}' Retry Element Click ${del_remote_checkbox}
#click save
Retry Double Keywords When Error Retry Element Click ${rule_save_button} Retry Wait Until Page Not Contains Element ${rule_save_button}
Sleep 2
......@@ -225,7 +225,7 @@ Delete Endpoint
Select Rule And Replicate
[Arguments] ${rule_name}
Retry Element Click //hbr-list-replication-rule//clr-dg-cell[contains(.,'${rule_name}')]
Retry Double Keywords When Error Retry Element Click //hbr-list-replication-rule//clr-dg-cell[contains(.,'${rule_name}')] Wait Until Element Is Visible And Enabled ${replication_exec_id}
Retry Element Click ${replication_exec_id}
Retry Double Keywords When Error Retry Element Click xpath=${dialog_replicate} Retry Wait Until Page Not Contains Element xpath=${dialog_replicate}
......@@ -256,4 +256,4 @@ Image Should Be Replicated To Project
\ Exit For Loop If '${out[0]}'=='PASS'
\ Sleep 5
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
Should Be Equal As Strings '${out[0]}' 'PASS'
\ No newline at end of file
Should Be Equal As Strings '${out[0]}' 'PASS'
......@@ -82,6 +82,7 @@ ${rule_confirm_btn} //*[@id='ruleBtnOk']
${rule_cancel_btn} //*[@id='ruleBtnCancel']
${filter_rules_btn} //*[@id='filter-rules']
${filter_rules_input} //*[@id='filter-rules']//input
${del_remote_checkbox} //label[@for='ruleDeletion']
......
......@@ -273,3 +273,28 @@ Test Case - Replication Of Pull Images from Google-GCR To Self
Image Should Be Replicated To Project project${d} httpd
Image Should Be Replicated To Project project${d} tomcat
Close Browser
Test Case - Replication Of Push Images to DockerHub
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${sha256}= Set Variable 0e67625224c1da47cb3270e7a861a83e332f708d3d89dde0cbed432c94824d9a
${image}= Set Variable redis
#login source
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project project${d}
${image_with_tag}= Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${image} sha256=${sha256} tag_suffix=${true}
Switch To Registries
Create A New Endpoint docker-hub e${d} https://hub.docker.com/ dockerhubtesterforharbor Aa12344321 Y
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} push project${d}/* image e${d} dockerhubtesterforharbor mode=Event Based del_remote=${true}
Filter Replicatin Rule rule${d}
Select Rule And Replicate rule${d}
Sleep 20
Docker Image Can Be Pulled dockerhubtesterforharbor/${image_with_tag} times=3
Go Into Project project${d}
Delete Repo project${d}
Switch To Replication Manage
Filter Replicatin Rule rule${d}
Select Rule And Replicate rule${d}
Sleep 30
Docker Image Can Not Be Pulled dockerhubtesterforharbor/${image_with_tag}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment