${policy_row_xpath}= Set Variable If '${repo}'=='${null}' //clr-dg-row[contains(.,'${name}')] //clr-dg-row[contains(.,'${name}') and contains(.,'${repo}')]
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_add_save_btn_id} Retry Wait Until Page Not Contains Element xpath=${p2p_preheat_add_save_btn_id}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_edit_save_btn_id} Retry Wait Until Page Not Contains Element xpath=${p2p_preheat_edit_save_btn_id}
Retry Double Keywords When Error Select P2P Preheat Policy ${name} Wait Until Element Is Visible ${p2p_execution_header}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_action_btn_id} Wait Until Element Is Visible And Enabled ${p2p_preheat_edit_btn_id}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_edit_btn_id} Wait Until Element Is Visible And Enabled ${p2p_preheat_name_input_id}
Retry Double Keywords When Error Select P2P Preheat Policy Trigger Scheduled Retry Element Click ${p2p_preheat_scheduled_edit_id}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_scheduled_type_select_id} Retry Element Click ${p2p_preheat_scheduled_type_select_id}//option[contains(.,'${type}')]
Run Keyword If '${type}' == 'Custom' Retry Text Input ${p2p_preheat_scheduled_cron_input_id} ${cron}
Retry Element Click ${p2p_preheat_scheduled_save_btn_xpath}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_edit_save_btn_id} Retry Wait Until Page Not Contains Element xpath=${p2p_preheat_edit_save_btn_id}
Verify Latest Execution Result ${project_name} ${policy_name} ${contain} ${not_contain}
Execute P2P Preheat
[Arguments] ${name} ${expected_status}=Success
Retry Double Keywords When Error Select P2P Preheat Policy ${name} Wait Until Element Is Visible ${p2p_execution_header}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_action_btn_id} Wait Until Element Is Visible And Enabled ${p2p_preheat_execute_btn_id}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_execute_btn_id} Wait Until Element Is Visible And Enabled ${p2p_preheat_confirm_execute_btn_id}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_confirm_execute_btn_id} Wait Until Element Is Visible And Enabled //clr-datagrid//div//clr-dg-row[1]//clr-dg-cell[2][contains(.,'${expected_status}')]
Retry Keyword N Times When Error 15 P2P Preheat Be Successful ${project_name} ${policy_name} ${execution_id} ${contain} ${not_contain} ${expected_status}
${rc} ${output}= Run And Return Rc And Output curl -u ${HARBOR_ADMIN}:${HARBOR_PASSWORD} -i --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/v2.0/projects/${project_name}/preheat/policies/${policy_name}/executions/${execution_id}/tasks"
Log All ${output}
Should Be Equal As Integers ${rc} 0
Should Contain Any ${output} ${expected_status} @{contain}
${out} Run Keyword And Ignore Error Get Length ${not_contain}
Run Keyword If '${out[0]}'=='PASS' Should Not Contain Any ${output} @{not_contain}