Skip to content

Commit

Permalink
RHOAIENG-2519 Service Mesh Test Case (#1336)
Browse files Browse the repository at this point in the history
* RHOAIENG-2519 - New test case for Service Mesh Integration

* RHOAIENG-2519 - Moved Reusable Keywords to commmon resouces

* RHOAIENG-2519 - Extend wait for Unmanaged

* RHOAIENG-2519 - Addressed review feedback

* RHOAIENG-2519 - changed tag to Tier1
  • Loading branch information
mattmahoneyrh authored Apr 3, 2024
1 parent 5fb70ea commit 389a773
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 38 deletions.
25 changes: 25 additions & 0 deletions ods_ci/tests/Resources/OCP.resource
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,28 @@ Wait Until CRD Exists
[Arguments] ${crd_fullname}
Wait Until Keyword Succeeds 15 times 5s
... Oc Get kind=CustomResourceDefinition name=${crd_fullname}

Is Resource Present
[Documentation] Check If Resource Is Present In Namespace
[Arguments] ${resource} ${resource_name} ${namespace} ${expected_result}
${rc}= Run And Return Rc
... oc get ${resource} ${resource_name} -n ${namespace}
Should Be Equal "${rc}" "${expected_result}" msg=${resource} does not exist in ${namespace}

Create Namespace In Openshift
[Documentation] Create a new namespace if it does not already exist
[Arguments] ${namespace}
${rc} ${output}= Run And Return Rc And Output oc get project ${namespace}
IF ${rc} != 0
${rc}= Run And Return Rc oc new-project ${namespace}
Should Be Equal "${rc}" "0" msg=${output}
END

Delete Namespace From Openshift
[Documentation] Delete namespace from opneshift if it exists
[Arguments] ${namespace}
${rc} ${output}= Run And Return Rc And Output oc get project ${namespace}
IF ${rc} == 0
${rc} ${output}= Run And Return Rc And Output oc delete project ${namespace}
Should Be Equal "${rc}" "0" msg=${output}
END
16 changes: 15 additions & 1 deletion ods_ci/tests/Resources/ODS.robot
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Set Access Groups Settings
[Documentation] Changes the rhods-groups config map to set the new access configuration
[Arguments] ${admins_group} ${users_group}
${return_code} ${output} Run And Return Rc And Output oc patch OdhDashboardConfig odh-dashboard-config -n ${APPLICATIONS_NAMESPACE} --type=merge -p '{"spec": {"groupsConfig": {"adminGroups": "${admins_group}","allowedGroups": "${users_group}"}}}' #robocop:disable
Should Be Equal As Integers ${return_code} 0 msg=Patch to group settings failed
Should Be Equal As Integers ${return_code} 0 msg=Patch to group settings failed

Set Default Access Groups Settings
[Documentation] Restores the default rhods-groups config map
Expand Down Expand Up @@ -389,3 +389,17 @@ Delete RHODS Config Map
... corresponding argument
[Arguments] ${name} ${namespace}=${APPLICATIONS_NAMESPACE}
OpenShiftLibrary.Oc Delete kind=ConfigMap name=${name} namespace=${namespace}

Wait Until Operator Ready
[Documentation] Wait for operator to be available/ready
[Arguments] ${operator_name} ${namespace} ${wait_time}=2m
${rc} ${output}= Run And Return Rc And Output
... oc wait --timeout=${wait_time} --for condition=available -n ${namespace} deploy/${operator_name}
Should Be Equal "${rc}" "0" msg=${output}

Wait For DSCI Ready State
[Documentation] Wait for DSCI to reconciled to be complete
[Arguments] ${dsci} ${namespace} ${wait_time}=2m
${rc} ${output}= Run And Return Rc And Output
... oc wait --timeout=${wait_time} --for jsonpath='{.status.conditions[].reason}'=ReconcileCompleted -n ${namespace} dsci ${dsci}
Should Be Equal "${rc}" "0" msg=${output}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*** Settings ***
Documentation Test Cases to verify Trusted CA Bundle support
Library Collections
Resource ../../../../Resources/Page/OCPDashboard/OCPDashboard.resource
Resource ../../../../Resources/OCP.resource
Resource ../../../../Resources/ODS.robot
Suite Setup Suite Setup
Suite Teardown Suite Teardown

Expand Down Expand Up @@ -87,56 +88,20 @@ Restore DSCI Trusted CA Bundle Settings
Set Custom CA Bundle Value In DSCI ${DSCI_NAME} '' ${OPERATOR_NS}
Set Trusted CA Bundle Management State ${DSCI_NAME} Managed ${OPERATOR_NS}

Wait Until Operator Ready
[Documentation] Checks if operator is available/ready
[Arguments] ${operator_name} ${namespace}
${rc} ${output}= Run And Return Rc And Output
... oc wait --timeout=2m --for condition=available -n ${namespace} deploy/${operator_name}
Should Be Equal "${rc}" "0" msg=${output}

Is Resource Present
[Documentation] Check if resource is present in namespace
[Arguments] ${resource} ${resource_name} ${namespace} ${expected_result}
${rc} ${output}= Run And Return Rc And Output
... oc get ${resource} ${resource_name} -n ${namespace}
Should Be Equal "${rc}" "${expected_result}" msg=${output}

Is CA Bundle Value Present
[Documentation] Check if the ConfigtMap contains Custom CA Bundle value
[Arguments] ${config_map} ${custom_ca_bundle_value} ${namespace} ${expected_result}
${rc} ${output}= Run And Return Rc And Output
... oc get configmap ${config_map} -n ${namespace} -o yaml | grep ${custom_ca_bundle_value}
Should Be Equal "${rc}" "${expected_result}" msg=${output}

Wait For DSCI Ready State
[Documentation] Checks that DSCI reconciled succesfully
[Arguments] ${dsci} ${namespace}
${rc} ${output}= Run And Return Rc And Output
... oc wait --timeout=3m --for jsonpath='{.status.conditions[].reason}'=ReconcileCompleted -n ${namespace} dsci ${dsci}
Should Be Equal "${rc}" "0" msg=${output}

Check ConfigMap Contains CA Bundle Key
[Documentation] Checks that ConfigMap contains CA Bundle
[Arguments] ${config_map} ${ca_bundle_name} ${namespace}
${rc} ${output}= Run And Return Rc And Output
... oc get configmap ${config_map} -n ${namespace} -o yaml | grep ${ca_bundle_name}
Should Be Equal "${rc}" "0" msg=${output}

Create Namespace In Openshift
[Documentation] Create a new namespace if it does not already exist
[Arguments] ${namespace}
${rc} ${output}= Run And Return Rc And Output oc get project ${namespace}
IF ${rc} != 0
${rc}= Run And Return Rc oc new-project ${namespace}
Should Be Equal "${rc}" "0" msg=${output}
END

Delete Namespace From Openshift
[Documentation] Delete namespace from opneshift
[Arguments] ${namespace}
${rc} ${output}= Run And Return Rc And Output oc delete project ${namespace}
Should Be Equal "${rc}" "0" msg=${output}

Set Custom CA Bundle Value In DSCI
[Documentation] Set Custom CA Bundle value in DSCI
[Arguments] ${DSCI} ${custom_ca_bundle_value} ${namespace}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
*** Settings ***
Documentation Test Cases to verify Service Mesh integration
Library Collections
Resource ../../../../Resources/OCP.resource
Resource ../../../../Resources/ODS.robot
Suite Setup Suite Setup
Suite Teardown Suite Teardown


*** Variables ***
${OPERATOR_NS} ${OPERATOR_NAMESPACE}
${RHOAI_OPERATOR_DEPLOYMENT_NAME} rhods-operator
${DSCI_NAME} default-dsci
${SERVICE_MESH_OPERATOR_NS} openshift-operators
${SERVICE_MESH_OPERATOR_DEPLOYMENT_NAME} istio-operator
${SERVICE_MESH_CR_NS} istio-system
${SERVICE_MESH_CR_NAME} data-science-smcp

${IS_PRESENT} 0
${IS_NOT_PRESENT} 1


*** Test Cases ***
Validate Service Mesh State Managed
[Documentation] The purpose of this Test Case is to validate Service Mesh integration
[Tags] Operator Tier1 ODS-2526 ServiceMesh-Managed
Is Resource Present ServiceMeshControlPlane ${SERVICE_MESH_CR_NAME} ${SERVICE_MESH_CR_NS} ${IS_PRESENT}
Check If Pod Exists istiod ${SERVICE_MESH_CR_NS}

Validate Service Mesh State Unmanaged
[Documentation] The purpose of this Test Case is to validate Service Mesh state 'Unmanaged'.
... The operator will not recreate/update the Service Mesh CR if removed or changed.
[Tags] Operator Tier1 ODS-2526 ServiceMesh-Unmanaged
Set Service Mesh Management State Unmanaged ${OPERATOR_NS}
Delete Service Mesh Control Plane ${SERVICE_MESH_CR_NS}
Wait Until Keyword Succeeds 2 min 0 sec
... Is Resource Present ServiceMeshControlPlane ${SERVICE_MESH_CR_NAME} ${SERVICE_MESH_CR_NS} ${IS_NOT_PRESENT}

[Teardown] Set Service Mesh State To Managed And Wait For CR Ready ${SERVICE_MESH_CR_NAME} ${SERVICE_MESH_CR_NS} ${OPERATOR_NS}

Validate Service Mesh State Removed
[Documentation] The purpose of this Test Case is to validate Service Mesh state 'Removed'.
... The operator will Delete the Service Mesh CR, when state is Removed.
... Test will fail until RHOAIENG-2209 is fixed
[Tags] ServiceMesh-Removed
Set Service Mesh Management State Removed ${OPERATOR_NS}
Wait Until Keyword Succeeds 2 min 0 sec
... Is Resource Present ServiceMeshControlPlane ${SERVICE_MESH_CR_NAME} ${SERVICE_MESH_CR_NS} ${IS_NOT_PRESENT}

[Teardown] Set Service Mesh State To Managed And Wait For CR Ready ${SERVICE_MESH_CONTROL_PLANE_NAME} ${SERVICE_MESH_CR_NS} ${OPERATOR_NS}


*** Keywords ***
Suite Setup
[Documentation] Suite Setup
RHOSi Setup
Wait Until Operator Ready ${SERVICE_MESH_OPERATOR_DEPLOYMENT_NAME} ${SERVICE_MESH_OPERATOR_NS}
Wait Until Operator Ready ${RHOAI_OPERATOR_DEPLOYMENT_NAME} ${OPERATOR_NS}
Wait For DSCI Ready State ${DSCI_NAME} ${OPERATOR_NS}

Suite Teardown
[Documentation] Suite Teardown
RHOSi Teardown

Delete Service Mesh Control Plane
[Documentation] Delete Service Mesh Control Plane
[Arguments] ${namespace} ${reconsile_wait_time}=15s
${rc} ${output}= Run And Return Rc And Output
... oc delete ServiceMeshControlPlane data-science-smcp -n ${namespace}
Should Be Equal "${rc}" "0" msg=${output}
# Allow operator time to reconsile
Sleep ${reconsile_wait_time}

Set Service Mesh Management State
[Documentation] Change DSCI Management State to one of Managed/Unmanaged/Removed
[Arguments] ${management_state} ${namespace}
${rc} ${output}= Run And Return Rc And Output
... oc patch DSCInitialization/default-dsci -n ${namespace} -p '{"spec":{"serviceMesh":{"managementState":"${management_state}"}}}' --type merge
Should Be Equal "${rc}" "0" msg=${output}

Set Service Mesh State To Managed And Wait For CR Ready
[Documentation] Restore Service Mesh State and Wait for Service Mesh CR to be Ready
[Arguments] ${smcp_name} ${smcp_ns} ${dsci_ns} ${timeout}=2m

Set Service Mesh Management State Managed ${dsci_ns}

Wait Until Keyword Succeeds 2 min 0 sec
... Is Resource Present ServiceMeshControlPlane ${smcp_name} ${smcp_ns} ${IS_PRESENT}

${rc} ${output}= Run And Return Rc And Output
... oc wait ServiceMeshControlPlane/${smcp_name} --for condition=Ready -n ${smcp_ns} --timeout ${timeout}
Should Be Equal "${rc}" "0" msg=${output}

0 comments on commit 389a773

Please sign in to comment.