Add Job Service Dashboard Job Queues testcase (#18347)

Fix #17949

Signed-off-by: Yang Jiao <jiaoya@vmware.com>
This commit is contained in:
Yang Jiao 2023-03-14 17:09:19 +08:00 committed by GitHub
parent 1acba0c3bb
commit 26ce10221e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 247 additions and 23 deletions

View File

@ -23,10 +23,13 @@ Switch To Garbage Collection
Retry Double Keywords When Error Retry Element Click xpath=${gc_page_xpath} Retry Wait Until Page Contains Element ${gc_now_button}
GC Now
[Arguments] ${untag}=${false}
[Arguments] ${untag}=${false} ${dry_run}=${false}
Switch To Garbage Collection
Run Keyword If '${untag}' == '${true}' Retry Element Click xpath=${checkbox_delete_untagged_artifacts}
Retry Double Keywords When Error Retry Element Click ${gc_now_button} Retry Wait Until Page Contains Running
${button}= Run Keyword If ${dry_run}==${false} Set Variable ${gc_now_button} ELSE Set Variable ${dry_run_button}
Retry Double Keywords When Error Retry Element Click ${button} Retry Wait Until Page Contains Running
${execution_id}= Get Text ${gc_latest_execution_id}
[Return] ${execution_id}
Retry GC Should Be Successful
[Arguments] ${history_id} ${expected_msg}
@ -55,4 +58,3 @@ Set GC Schedule
Run Keyword If '${type}'=='custom' Run Keywords Retry Element Click ${vulnerability_dropdown_list_item_custom} AND Retry Text Input ${targetCron_id} ${value}
... ELSE Retry Element Click ${vulnerability_dropdown_list_item_none}
Retry Double Keywords When Error Retry Element Click ${GC_schedule_save_btn} Retry Wait Until Page Not Contains Element ${gc_schedule_save_btn}
Capture Page Screenshot

View File

@ -18,8 +18,10 @@ Documentation This resource provides any keywords related to the Harbor private
*** Variables ***
${gc_page_xpath} //clr-main-container//clr-vertical-nav-group//span[contains(.,'Clean Up')]
${gc_now_button} //*[@id='gc-now']
${dry_run_button} //*[@id='gc-dry-run']
${checkbox_delete_untagged_artifacts} //gc-config//clr-toggle-wrapper/label[contains(@for,'delete_untagged')]
${latest_job_id_xpath} //clr-datagrid//div//clr-dg-row[1]//clr-dg-cell[1]
${gc_schedule_edit_btn} //*[@id='editSchedule']
${gc_schedule_select} //*[@id='selectPolicy']
${gc_schedule_save_btn} //*[@id='config-save']
${gc_schedule_save_btn} //*[@id='config-save']
${gc_latest_execution_id} //clr-dg-row[1]//clr-dg-cell[1]

View File

@ -0,0 +1,120 @@
# Copyright Project Harbor Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
*** Keywords ***
Switch To Job Queues
Retry Element Click //clr-main-container//clr-vertical-nav-group//span[contains(.,'Job Service Dashboard')]
Retry Wait Until Page Contains Element //h2//span[contains(.,'Job Service Dashboard')]
Select Jobs
[Arguments] @{job_types}
FOR ${job_type} IN @{job_types}
Retry Element Click //clr-datagrid//clr-dg-row[contains(.,'${job_type}')]//label
END
Stop Pending Jobs
[Arguments] @{job_types}
Select Jobs @{job_types}
Retry Double Keywords When Error Retry Button Click ${job_service_stop_btn} Retry Button Click ${confirm_btn}
Retry Wait Until Page Contains Stopped jobs successfully
Stop All Pending Jobs
Retry Double Keywords When Error Retry Button Click ${job_service_stop_all_btn} Retry Button Click ${confirm_btn}
Retry Wait Until Page Contains Stopped all the job queues successfully
Pause Jobs
[Arguments] @{job_types}
Select Jobs @{job_types}
Retry Double Keywords When Error Retry Button Click ${job_service_pause_btn} Retry Button Click ${confirm_btn}
Retry Wait Until Page Contains Paused jobs successfully
Check Jobs Paused Yes @{job_types}
Resume Jobs
[Arguments] @{job_types}
Select Jobs @{job_types}
Retry Double Keywords When Error Retry Button Click ${job_service_resume_btn} Retry Button Click ${confirm_btn}
Retry Wait Until Page Contains Resumed jobs successfully
Check Jobs Paused No @{job_types}
Check Jobs Paused
[Arguments] ${paused}=No @{job_types}
FOR ${job_type} IN @{job_types}
Retry Double Keywords When Error Retry Element Click ${job_service_refresh_btn} Retry Wait Element Visible //clr-datagrid//clr-dg-row[contains(.,'${job_type}')]//clr-dg-cell[4][contains(.,'${paused}')]
Select Jobs ${job_type}
Run Keyword If '${paused}' == 'No' Run Keywords
... Retry Wait Element Should Be Disabled ${job_service_resume_btn}
... AND Retry Wait Element ${job_service_pause_btn}
... ELSE Run Keywords
... Retry Wait Element Should Be Disabled ${job_service_pause_btn}
... AND Retry Wait Element ${job_service_resume_btn}
END
Check Jobs Pending Count
[Arguments] &{jobs_type_pending_count}
FOR ${job_type} IN @{jobs_type_pending_count.keys()}
Retry Wait Element Visible //clr-datagrid//clr-dg-row[contains(.,'${job_type}')]//clr-dg-cell[2][contains(.,'${jobs_type_pending_count['${job_type}']}')]
END
Check Pending Job Card
[Arguments] &{jobs_type_pending_count}
${total}= Set Variable ${jobs_type_pending_count['Total']}
Remove From Dictionary ${jobs_type_pending_count} Total
${total_pending_count}= Set Variable 0
${index}= Set Variable 1
FOR ${job_type} IN @{jobs_type_pending_count.keys()}
Run Keyword If '${total}' != '0' Retry Wait Until Page Contains Element //app-pending-job-card//div[contains(@class,'clr-row ng-star-inserted')][${index}]//div[1][contains(.,'${job_type}')]
Retry Wait Until Page Contains Element //app-pending-job-card//div[contains(@class,'clr-row ng-star-inserted')][${index}]//div[2][contains(.,'${jobs_type_pending_count['${job_type}']}')]
${index}= Evaluate ${index} + 1
${total_pending_count}= Evaluate ${total_pending_count} + ${jobs_type_pending_count['${job_type}']}
END
Retry Wait Element Visible //app-pending-job-card//div[contains(text(),'Total: ${total_pending_count}')]
Check Jobs Latency
[Arguments] &{jobs_type_is_zore}
FOR ${job_type} IN @{jobs_type_is_zore.keys()}
${latency_xpath}= Set Variable //clr-datagrid//clr-dg-row[contains(.,'${job_type}')]//clr-dg-cell[3][text()='0']
Run Keyword If ${jobs_type_is_zore['${job_type}']}==${true} Retry Wait Until Page Contains Element ${latency_xpath}
... ELSE Retry Wait Until Page Not Contains Element ${latency_xpath}
END
Check Button Status
# Pause is Yes
Select Jobs GARBAGE_COLLECTION
Retry Wait Element ${job_service_resume_btn}
Retry Wait Element Should Be Disabled ${job_service_pause_btn}
# Pause is Yes
Select Jobs PURGE_AUDIT_LOG
Retry Wait Element ${job_service_resume_btn}
Retry Wait Element Should Be Disabled ${job_service_pause_btn}
# Pause is No
Select Jobs SCAN_DATA_EXPORT
Retry Wait Element Should Be Disabled ${job_service_resume_btn}
Retry Wait Element Should Be Disabled ${job_service_pause_btn}
# Refresh
Retry Element Click ${job_service_refresh_btn}
# Pause is No
Select Jobs REPLICATION
Retry Wait Element ${job_service_pause_btn}
Retry Wait Element Should Be Disabled ${job_service_resume_btn}
# Pause is No
Select Jobs P2P_PREHEAT
Retry Wait Element ${job_service_pause_btn}
Retry Wait Element Should Be Disabled ${job_service_resume_btn}
# Pause is Yes
Select Jobs IMAGE_SCAN
Retry Wait Element Should Be Disabled ${job_service_resume_btn}
Retry Wait Element Should Be Disabled ${job_service_pause_btn}

View File

@ -0,0 +1,23 @@
# Copyright Project Harbor Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${job_service_stop_btn} //button[.//span[text()=' STOP ']]
${job_service_stop_all_btn} //button[contains(.,'STOP ALL')]
${job_service_pause_btn} //button[contains(text(),'PAUSE')]
${job_service_resume_btn} //button[contains(text(),'RESUME')]
${job_service_refresh_btn} //clr-datagrid//span[contains(@class,'refresh-btn')]

View File

@ -26,8 +26,8 @@ Purge Now
Retry Double Keywords When Error Retry Element Click ${keep_records_unit_select} Retry Element Click ${keep_records_unit_select}//option[contains(.,'${keep_records_unit}')]
${len}= Get Length ${exclude_operations}
Run Keyword If ${len} > 0 Click Exclude Operation @{exclude_operations}
Retry Double Keywords When Error Retry Button Click ${purge_now_btn} Retry Wait Until Page Contains Element ${latest_purge_job_status_xpath}\[contains(.,'SUCCESS')]
Retry Action Keyword Verify Last completed Time
Retry Double Keywords When Error Retry Button Click ${purge_now_btn} Retry Wait Until Page Contains Element ${latest_purge_job_status_xpath}\[contains(.,'${expected_status}')]
Run Keyword If '${expected_status}' == 'SUCCESS' Retry Action Keyword Verify Last completed Time
Click Exclude Operation
[Arguments] @{exclude_operations}
@ -44,7 +44,7 @@ Set Log Rotation Schedule
[Arguments] ${keep_records} ${keep_records_unit} ${type} ${cron}=${null} ${exclude_operations}=@{EMPTY}
Retry Text Input ${keep_records_input} ${keep_records}
Retry Double Keywords When Error Retry Element Click ${keep_records_unit_select} Retry Element Click ${keep_records_unit_select}//option[contains(.,'${keep_records_unit}')]
Retry Button Click ${log_rotation_schedule_edit_btn}
Retry Button Click ${log_rotation_schedule_edit_btn}
Retry Double Keywords When Error Retry Element Click ${log_rotation_schedule_select} Retry Element Click ${log_rotation_schedule_select}//option[contains(.,'${type}')]
Run Keyword If '${type}' == 'Custom' Retry Text Input ${log_rotation_schedule_cron_input} ${cron}
${len}= Get Length ${exclude_operations}
@ -55,4 +55,4 @@ Get Purge Job Results
${cmd}= Set Variable curl -u ${HARBOR_ADMIN}:${HARBOR_PASSWORD} -s --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/v2.0/system/purgeaudit?sort=-creation_time&page=1&page_size=100"
${rc} ${output}= Run And Return Rc And Output ${cmd}
Log ${output}
[Return] ${output}
[Return] ${output}

View File

@ -88,7 +88,7 @@ Set Daily Schedule
Execute Result Should Be
[Arguments] ${image} ${result}
FOR ${idx} IN RANGE 0 20
${out} Run Keyword And Ignore Error Retry Wait Until Page Contains Element xpath=//div[contains(@role, 'grid')]//div[contains(@class, 'datagrid-row-master') and contains(@role, 'row')]//clr-datagrid//div[contains(@role, 'grid')]//div[contains(@class, 'datagrid-row-master') and contains(@role, 'row')]//div[contains(@class, 'datagrid-row-scrollable') and contains(., '${result}') and contains(., '${image}')]
${out} Run Keyword And Ignore Error Retry Wait Until Page Contains Element //app-tag-retention-tasks//clr-datagrid//clr-dg-row[contains(., '${image}') and contains(., '${result}')]
Exit For Loop If '${out[0]}'=='PASS'
Sleep 1
Retry Element Click ${project_tag_retention_refresh_xpath}
@ -101,19 +101,20 @@ Execute Result Should Be
Execute Dry Run
[Arguments] ${image} ${result}
Retry Element Click xpath=${project_tag_retention_dry_run_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_record_yes_xpath}
Sleep 5
Retry Element Click xpath=${project_tag_retention_record_yes_xpath}
# memcached:123 should be deleted and hello-world:latest should be retained
Retry Button Click //clr-expandable-animation//button[1]
Execute Result Should Be ${image} ${result}
${execution_id}= Get Text ${project_tag_retention_latest_execution_id_xpath}
[Return] ${execution_id}
Execute Run
[Arguments] ${image} ${result}=${null}
Retry Element Click xpath=${project_tag_retention_run_now_xpath}
Retry Element Click xpath=${project_tag_retention_execute_run_xpath}
Retry Wait Until Page Contains Element xpath=${project_tag_retention_record_no_xpath}
Sleep 5
Retry Element Click xpath=${project_tag_retention_record_no_xpath}
# memcached:123 should be deleted and hello-world:latest should be retained
Retry Button Click //clr-expandable-animation//button
Run Keyword If '${result}' != '${null}' Execute Result Should Be ${image} ${result}
${execution_id}= Get Text ${project_tag_retention_latest_execution_id_xpath}
[Return] ${execution_id}
Check Retention Execution
[Arguments] ${execution_id} ${status} ${dry_run}
Retry Wait Until Page Contains Element //clr-datagrid//clr-dg-row//div[contains(., '${execution_id}') and contains(., '${status}') and contains(., '${dry_run}')]

View File

@ -41,6 +41,7 @@ ${project_tag_retention_action_button_xpath} //button[contains(.,'ACTION')]
${project_tag_retention_delete_button_xpath} //div[contains(@class,'dropdown-menu')]//button[contains(.,'Delete')]
${project_tag_retention_edit_button_xpath} //div[contains(@class,'dropdown-menu')]//button[contains(.,'Edit')]
${project_tag_retention_modal_title_edit_xpath} //h3[contains(.,'Edit Tag Retention Rule')]
${project_tag_retention_latest_execution_id_xpath} //clr-dg-row[1]//clr-dg-cell[1]
${project_tag_immutability_scope_input_xpath} //*[@id='scope-input']
${project_tag_immutability_tag_input_xpath} //*[@id='tag-input']

View File

@ -296,4 +296,4 @@ Executions Result Count Should Be
Check Latest Replication Job Status
[Arguments] ${expected_status}
Retry Wait Element //hbr-replication//div[contains(@class,'datagrid')]//clr-dg-row[1][contains(.,'${expected_status}')]
Retry Wait Element //hbr-replication//div[contains(@class,'datagrid')]//clr-dg-row[1][contains(.,'${expected_status}')]

View File

@ -27,7 +27,6 @@ Switch To Vulnerability Page
Retry Element Click xpath=//app-interrogation-services//a[contains(.,'Vulnerability')]
Retry Wait Element ${scan_now_button}
Set Vulnerabilty Serverity
#0 is critical, 1 is high, 2 is medium, 3 is low, 4 is negligible.
[Arguments] ${level}
@ -111,4 +110,4 @@ Stop Scan All Artifact
Check Scan All Artifact Job Status Is Stopped
Wait Until Element Is Visible ${stopped_icon}
${stopped_total}= Get Text ${stopped_icon}
Should Be True ${stopped_total} > 0
Should Be True ${stopped_total} > 0

View File

@ -69,6 +69,8 @@ Resource Harbor-Pages/Logs.robot
Resource Harbor-Pages/Logs_Elements.robot
Resource Harbor-Pages/Log_Rotation.robot
Resource Harbor-Pages/Log_Rotation_Elements.robot
Resource Harbor-Pages/Job_Service_Dashboard.robot
Resource Harbor-Pages/Job_Service_Dashboard_Elements.robot
Resource Harbor-Pages/Verify.robot
Resource Docker-Util.robot
Resource CNAB_Util.robot
@ -316,4 +318,4 @@ Click Link New Tab And Switch
[Arguments] ${element_xpath}
Retry Link Click ${element_xpath}
${handles}= Get Window Handles
Retry Action Keyword Switch Window ${handles}[-1]
Retry Action Keyword Switch Window ${handles}[-1]

View File

@ -1015,3 +1015,78 @@ Test Case - Helm3.7 CLI Push And Pull In Harbor
${pwd}= Set Variable Test1@34
Sign In Harbor ${HARBOR_URL} ${user} ${pwd}
Retry Keyword N Times When Error 4 Helm3.7 CLI Work Flow ${user} ${pwd}
Close Browser
Test Case - Job Service Dashboard Job Queues
[Tags] job_service_job_queues
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
# Pause GARBAGE_COLLECTION PURGE_AUDIT_LOG IMAGE_SCAN RETENTION jobs
Switch To Job Queues
Pause Jobs GARBAGE_COLLECTION PURGE_AUDIT_LOG IMAGE_SCAN RETENTION
Check Button Status
Create An New Project And Go Into Project project${d}
Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} photon 2.0_scan 2.0_scan
Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} photon 3.0_scan 3.0_scan
Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} photon 4.0_scan 4.0_scan
Switch To Tag Retention
Add A Tag Retention Rule
# Triggers two RETENTION jobs
${retention_execution1}= Execute Dry Run photon 0/0
${retention_execution2}= Execute Run photon 0/0
# Triggers three IMAGE_SCAN jobs
Switch To Project Repo
Go Into Repo photon
Retry Element Click //clr-datagrid//label[contains(.,'Select All')]
Retry Button Click ${scan_artifact_btn}
# Triggers a GARBAGE_COLLECTION job
${gc_execution1}= GC Now dry_run=${true}
# Triggers a PURGE_AUDIT_LOG job
Switch to Log Rotation
Purge Now 2 Days Running
# Check job queues
Switch To Job Queues
Check Pending Job Card IMAGE_SCAN=3 RETENTION=2 Others=2 Total=7
Check Jobs Pending Count IMAGE_SCAN=3 RETENTION=2 GARBAGE_COLLECTION=1 PURGE_AUDIT_LOG=1
Check Jobs Latency GARBAGE_COLLECTION=${false} PURGE_AUDIT_LOG=${false} IMAGE_SCAN=${false} RETENTION=${false}
# Resume GARBAGE_COLLECTION RETENTION jobs
Resume Jobs GARBAGE_COLLECTION RETENTION
# Check job queues
Check Pending Job Card IMAGE_SCAN=3 PURGE_AUDIT_LOG=1 Others=0 Total=4
Check Jobs Pending Count IMAGE_SCAN=3 RETENTION=0 GARBAGE_COLLECTION=0 PURGE_AUDIT_LOG=1
Check Jobs Latency GARBAGE_COLLECTION=${true} PURGE_AUDIT_LOG=${false} IMAGE_SCAN=${false} RETENTION=${true}
# Check retention and GC status
Go Into Project project${d}
Switch To Tag Retention
Check Retention Execution ${retention_execution1} Success Yes
Check Retention Execution ${retention_execution2} Success No
Retry GC Should Be Successful ${gc_execution1} success to run gc in job
# Stop PURGE_AUDIT_LOG IMAGE_SCAN jobs
Switch To Job Queues
Stop Pending Jobs PURGE_AUDIT_LOG IMAGE_SCAN
# Check job queues
Check Pending Job Card first_job=0 second_job=0 the_third_job=0 Total=0
Check Jobs Pending Count IMAGE_SCAN=0 PURGE_AUDIT_LOG=0
Check Jobs Latency GARBAGE_COLLECTION=${true} PURGE_AUDIT_LOG=${true} IMAGE_SCAN=${true} RETENTION=${true}
# Triggers a PURGE_AUDIT_LOG job
Switch to Log Rotation
Purge Now 1 Days Running
# Triggers three IMAGE_SCAN jobs
Go Into Project project${d}
Go Into Repo photon
Retry Element Click //clr-datagrid//label[contains(.,'Select All')]
Retry Button Click ${scan_artifact_btn}
# Check job queues
Switch To Job Queues
Check Pending Job Card IMAGE_SCAN=3 PURGE_AUDIT_LOG=1 Others=0 Total=4
Check Jobs Pending Count IMAGE_SCAN=3 PURGE_AUDIT_LOG=1
Check Jobs Latency IMAGE_SCAN=${false} PURGE_AUDIT_LOG=${false}
# Stop all job
Stop All Pending Jobs
# Check job queues
Check Pending Job Card first_job=0 second_job=0 the_third_job=0 Total=0
Check Jobs Pending Count IMAGE_SCAN=0 PURGE_AUDIT_LOG=0
Check Jobs Latency IMAGE_SCAN=${true} PURGE_AUDIT_LOG=${true}
Resume Jobs IMAGE_SCAN PURGE_AUDIT_LOG
Close Browser

View File

@ -126,7 +126,6 @@ Test Case - Replication Rule Edit
Close Browser
Test Case - Replication Rule Delete
[Tags] test
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
${endpoint1}= Set Variable e1${d}

View File

@ -255,4 +255,4 @@ Test Case - Log Rotation Schedule Job
Should Not Contain Any ${log["job_parameters"]["include_operations"]} @{exclude_operations} ignore_case=True
END
Should Be True ${len} > 3 and ${len} < 6
Close Browser
Close Browser