Skip to content

Commit

Permalink
Feat: Accelerators Profile Administration UI e2e Tests (red-hat-data-…
Browse files Browse the repository at this point in the history
…services#1209)

* feat: Accelerator Profiles administration UI e2e tests

* add tolerations and verification via CLI

* add variables

* add modify accelerator from UI test

* Add delete tolerations test case

* tests for disabling, enabling and delete

* delete todo and duplied test

* Code scanning fixes

* Code scanning fixes

* Code scanning fixes

* add sanity tags

* add seacrh in grid capability and check ap creation return code

* delete managedFields from AP files

* add jira tag. Use the search in grid capability in tests

* pr fixes

* Refactor feature: move variables and keywords to a new file

* move login keywords to a more generic file

* use correct keyword for kebab actions

* use suggested keyword for modal management when deleting an AP

* PR Fixes

* take CLI functions to CLI resources file

* modify 2 keywords to be more RF consistent

* delete descriptions

* delete spaces from common and create a consistant test setup

* modify Click enable

* Modify descriptions

* Linter fixes

* Update ods_ci/tests/Resources/Files/accelerator/qe_accelerator_profile_2.yaml

Co-authored-by: Noam Manos <[email protected]>

* Update ods_ci/tests/Resources/Files/accelerator/qe_accelerator_profile_2.yaml

Co-authored-by: Noam Manos <[email protected]>

* add information to yamls and use jinja

* Update ods_ci/tests/Resources/CLI/AcceleratorProfiles/AcceleratorProfiles.resource

Co-authored-by: Jan Stourac <[email protected]>

* Update ods_ci/tests/Tests/400__ods_dashboard/416__ods_dashboard_settings_accelerator_profiles.robot

Co-authored-by: Jan Stourac <[email protected]>

* Update ods_ci/tests/Resources/CLI/AcceleratorProfiles/AcceleratorProfiles.resource

Co-authored-by: Jan Stourac <[email protected]>

* fix indentation in resource field

* modify accelerator profiles instance names

* use APPLICATION_NAMESPACE variable

* rename some variables

* modify test tags

* modify file names

* add namespace as a dynamic variable

* delete redundat teardown

---------

Co-authored-by: Noam Manos <[email protected]>
Co-authored-by: Jan Stourac <[email protected]>
  • Loading branch information
3 people authored Mar 6, 2024
1 parent 0d18544 commit eee7385
Show file tree
Hide file tree
Showing 13 changed files with 598 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
*** Settings ***
Documentation Collection of keywords to interact with the administration of Accelerator Profiles via CLI

*** Variables ***
${ACCELERATOR_RESOURCES_DIRPATH}= ods_ci/tests/Resources/Files/accelerator


*** Keywords ***
Create An Accelerator Profile Via CLI
[Documentation] Create an instance of Accelerator Profile using OC
[Arguments] ${name} ${ns}=${APPLICATIONS_NAMESPACE}
${status}= Run Keyword And Return Status Oc Create kind=AcceleratorProfile
... src=${ACCELERATOR_RESOURCES_DIRPATH}/${name}.yaml namespace=${ns}
... template_data={test_name: '${TEST_NAME}', test_ns: '${ns}'}
Should Be Equal As Integers ${status} ${TRUE}

Get Accelerator Profile Spec Values Via CLI
[Documentation] Get Spec fields from an specific Accelerator Profile Instance
[Arguments] ${display_name} ${ns}=${APPLICATIONS_NAMESPACE}
${ap_from_oc}= Run
... oc get acceleratorprofile -n ${ns} -o json | jq '.items[] | select(.spec.displayName == "${display_name}")'
${ap_json}= Load Json String ${ap_from_oc}
${ap_spec_dict}= Get From Dictionary ${ap_json} spec
RETURN ${ap_spec_dict}

Accelerator Profile Should Not Exist
[Documentation] Get Spec fields from an specific Accelerator Profile Instance
[Arguments] ${name} ${ns}=${APPLICATIONS_NAMESPACE}
${rc} ${out}= Run And Return Rc And Output oc get acceleratorprofile ${name} -n ${ns}
Should Be Equal "${rc}" "1"
Should Contain ${out} "${name}" not found

Verify Accelerator Profile Values Via CLI
[Documentation] Verifies that an specific Accelerator Profile exists, and it's value match with the expected
[Arguments] ${name} ${identifier}=${EMPTY} ${description}=${EMPTY} ${enabled}=True
... ${tolerations}=${EMPTY} ${tol_operator}=Equal ${tol_effect}=None ${tol_key}=key
... ${tol_value}=value ${tol_seconds}=Forever ${ns}=${APPLICATIONS_NAMESPACE}
${ap_spec_dict}= Get Accelerator Profile Spec Values Via CLI ${name} ${ns}
${name_from_spec}= Get From Dictionary ${ap_spec_dict} displayName
${enabled_from_spec}= Get From Dictionary ${ap_spec_dict} enabled
${bool_enabled}= Convert To Boolean ${enabled}
Should Be Equal ${name_from_spec} ${name}
Should Be Equal ${enabled_from_spec} ${bool_enabled}
# Identifier
IF "${identifier}" != "${EMPTY}"
${identifier_from_spec}= Get From Dictionary ${ap_spec_dict} identifier
Should Be Equal ${identifier_from_spec} ${identifier}
END
# Description
IF "${description}" != "${EMPTY}"
${description_from_spec}= Get From Dictionary ${ap_spec_dict} description
Should Be Equal ${description_from_spec} ${description}
END
# Tolerations
IF "${tolerations}" != "${EMPTY}"
${tolerations_from_spec}= Get From Dictionary ${ap_spec_dict} tolerations
${tol_operator_retrieved}= Get From Dictionary ${tolerations_from_spec}[0] operator
Should Be Equal ${tol_operator_retrieved} ${tol_operator}
${tol_key_retrieved}= Get From Dictionary ${tolerations_from_spec}[0] key
Should Be Equal ${tol_key_retrieved} ${tol_key}
${tol_value_retrieved}= Get From Dictionary ${tolerations_from_spec}[0] value
Should Be Equal ${tol_value_retrieved} ${tol_value}
# Effect
${tol_effect_retrieved}= Get From Dictionary ${tolerations_from_spec}[0] effect
IF "${tol_effect}" == "None"
Should Be Equal ${tol_effect_retrieved} ""
ELSE
Should Be Equal ${tol_effect_retrieved} ${tol_effect}
END
# Toleration Seconds
IF "${tol_seconds}" != "Forever"
${tol_seconds_retrieved}= Get From Dictionary ${tolerations_from_spec}[0] tolerationSeconds
Should Be Equal "${tol_seconds_retrieved}" "${tol_seconds}"
END
END

Verify Accelerator Profile Has No Tolerations Via CLI
[Documentation] Verifies that an specific Accelerator Profile exists, and it has no tolerations
[Arguments] ${name} ${ns}=${APPLICATIONS_NAMESPACE}
${ap_spec_dict}= Get Accelerator Profile Spec Values Via CLI ${name} ${ns}
${tolerations_from_spec}= Get From Dictionary ${ap_spec_dict} tolerations
Should Be Empty ${tolerations_from_spec}

Delete All Accelerator Profiles Which Starts With
[Documentation] Delete all accelerator profiles given prefix. That prefix should match with the metadata.name
... value of the OC Accelerator Profile resource
... Uses OC
[Arguments] ${ap_prefix} ${ns}=${APPLICATIONS_NAMESPACE}
${ap_str}= Run
... oc get acceleratorprofiles -n ${ns} -o json | jq .items[].metadata.name | grep ${ap_prefix} | tr -d '"'
@{ap_list}= Split String ${ap_str} separator=\n
Log List of Accelerator Profiles to be deleted: @{ap_list} console=yes
FOR ${ap_name} IN @{ap_list}
${ap_desc}= Run oc get acceleratorprofile ${ap_name} -n ${ns} -o json
Log ${ap_desc} console=yes
${return_code}= Run And Return Rc
... oc delete acceleratorprofile ${ap_name} -n ${ns}
Should Be Equal As Integers ${return_code} 0 msg=Error deleting Accelerator profile ${ap_name}
END
7 changes: 7 additions & 0 deletions ods_ci/tests/Resources/Common.robot
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,10 @@ Configure User Workload Monitoring
${return_code} ${output} Run And Return Rc And Output oc apply -f ${UWM_CONFIG_FILEPATH}
Log To Console ${output}
Should Be Equal As Integers ${return_code} 0 msg=Error while applying the provided file

Clear Element And Input Text
[Documentation] Clear and input text element, wait .5 seconds and input new text on it
[Arguments] ${element_xpath} ${new_text}
Clear Element Text ${element_xpath}
Sleep 0.5s
Input Text ${element_xpath} ${new_text}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# File to provision an Accelerator Profile instance in test:
# "Modify An Accelerator Profile Using "Accelerator Profiles" Administration UI"
apiVersion: dashboard.opendatahub.io/v1
kind: AcceleratorProfile
metadata:
name: accelerator-profile-3349-2
namespace: {{ test_ns }}
spec:
description: {{ test_name }}
displayName: "Test: Modify Accelerator Profile 2"
enabled: true
identifier: identifier/identifier
tolerations:
- effect: NoSchedule
key: key
operator: Exists
value: value
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# File to provision an Accelerator Profile instance in test:
# "Delete Tolerations from an Accelerator Profile Using "Accelerator Profiles" Administration UI"
apiVersion: dashboard.opendatahub.io/v1
kind: AcceleratorProfile
metadata:
name: accelerator-profile-3349-3
namespace: {{ test_ns }}
spec:
displayName: "Test: Delete Tolerations from AP 3"
description: {{ test_name }}
enabled: true
identifier: nvidia.com/gpu
tolerations:
- effect: NoSchedule
key: key
operator: Exists
value: value
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# File to provision an Accelerator Profile instance in test:
# "Disable an Accelerator Profile From The Accelerator Profile Edit View"
apiVersion: dashboard.opendatahub.io/v1
kind: AcceleratorProfile
metadata:
generation: 1
name: accelerator-profile-3349-4
namespace: {{ test_ns }}
spec:
displayName: "Test: Disable AP 4 from Edit Detail View"
description: {{ test_name }}
enabled: true
identifier: nvidia.com/gpu
tolerations:
- effect: NoSchedule
key: key
operator: Exists
value: value
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# File to provision an Accelerator Profile instance in test:
# "Enable an Accelerator Profile From The Accelerator Profile Edit View"
apiVersion: dashboard.opendatahub.io/v1
kind: AcceleratorProfile
metadata:
generation: 1
name: accelerator-profile-3349-5
namespace: {{ test_ns }}
spec:
displayName: "Test: Enable AP 5 from Edit Detail View"
description: {{ test_name }}
enabled: false
identifier: nvidia.com/gpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# File to provision an Accelerator Profile instance in test:
# "Disable an Accelerator Profile From The Grid of the Accelerator Profile View"
apiVersion: dashboard.opendatahub.io/v1
kind: AcceleratorProfile
metadata:
generation: 1
name: accelerator-profile-3349-6
namespace: {{ test_ns }}
spec:
displayName: "Test: Disable AP 6 from Administration View"
description: {{ test_name }}
enabled: true
identifier: nvidia.com/gpu
tolerations:
- effect: NoSchedule
key: key
operator: Exists
value: value
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# File to provision an Accelerator Profile instance in test:
# "Enable an Accelerator Profile From The Grid of the Accelerator Profile View"
apiVersion: dashboard.opendatahub.io/v1
kind: AcceleratorProfile
metadata:
generation: 1
name: accelerator-profile-3349-7
namespace: {{ test_ns }}
spec:
displayName: "Test: Enable AP 7 from Administration View"
description: {{ test_name }}
enabled: false
identifier: nvidia.com/gpu
tolerations:
- effect: NoSchedule
key: key
operator: Exists
value: value
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# File to provision an Accelerator Profile instance in test:
# "Delete an Accelerator Profile From The Grid of the Accelerator Profile View"
apiVersion: dashboard.opendatahub.io/v1
kind: AcceleratorProfile
metadata:
generation: 1
name: accelerator-profile-3349-8
namespace: {{ test_ns }}
spec:
displayName: "Test: Delete AP 8 from grid"
enabled: false
identifier: nvidia.com/gpu
13 changes: 13 additions & 0 deletions ods_ci/tests/Resources/Page/ODH/ODHDashboard/ODHDashboard.resource
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*** Settings ***
Resource ODHDashboard.robot
Resource ../../LoginPage.robot
Library RequestsLibrary
Library SeleniumLibrary

Expand All @@ -9,3 +10,15 @@ ${SELF_BADGE_TITLE}= Self-managed
${RH_BADGE_TITLE}= Red Hat managed
${CMS_BADGE_TITLE}= Coming soon
${BETA_BADGE_TITLE}= Beta


*** Keywords ***
Open ODS Dashboard With Admin User
[Documentation] Opens a browser and logs into ODS Dashboard with a user belonging to the rhods-admins group
Launch Dashboard ${TEST_USER.USERNAME} ${TEST_USER.PASSWORD} ${TEST_USER.AUTH_TYPE}
... ${ODH_DASHBOARD_URL} browser=${BROWSER.NAME} browser_options=${BROWSER.OPTIONS}

Open ODS Dashboard With Non Admin User
[Documentation] Opens a browser and logs into ODS Dashboard with a user belonging to the rhods-users group
Launch Dashboard ${TEST_USER_3.USERNAME} ${TEST_USER_3.PASSWORD} ${TEST_USER_3.AUTH_TYPE}
... ${ODH_DASHBOARD_URL} browser=${BROWSER.NAME} browser_options=${BROWSER.OPTIONS}
Loading

0 comments on commit eee7385

Please sign in to comment.