|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +source $TEST_DIR/common |
| 4 | + |
| 5 | +MY_DIR=$(readlink -f `dirname "${BASH_SOURCE[0]}"`) |
| 6 | + |
| 7 | +source ${MY_DIR}/../util |
| 8 | + |
| 9 | +os::test::junit::declare_suite_start "$MY_SCRIPT" |
| 10 | + |
| 11 | +OPERATOR_IMAGE="quay.io/opendatahub/ai-library-operator:v0.6" |
| 12 | +AI_LIBRARY_CR="${MY_DIR}/../resources/ai_library_cr.yaml" |
| 13 | + |
| 14 | +function test_ai_library() { |
| 15 | + header "Testing AI Library installation" |
| 16 | + os::cmd::expect_success "oc project ${ODHPROJECT}" |
| 17 | + os::cmd::try_until_text "oc get deployment ailibrary-operator" "ailibrary-operator" $odhdefaulttimeout $odhdefaultinterval |
| 18 | + os::cmd::try_until_text "oc get deployment ailibrary-operator -o jsonpath='{$.spec.template.spec.containers[0].image}'" ${OPERATOR_IMAGE} $odhdefaulttimeout $odhdefaultinterval |
| 19 | + os::cmd::try_until_text "oc get pods -l name=ailibrary-operator --field-selector='status.phase=Running' -o jsonpath='{$.items[*].metadata.name}'" "ailibrary-operator" $odhdefaulttimeout $odhdefaultinterval |
| 20 | + runningpods=($(oc get pods -l name=ailibrary-operator --field-selector="status.phase=Running" -o jsonpath="{$.items[*].metadata.name}")) |
| 21 | + os::cmd::expect_success_and_text "echo ${#runningpods[@]}" "1" |
| 22 | +} |
| 23 | + |
| 24 | +function create_ai_lib_cr() { |
| 25 | + os::cmd::expect_success "oc create -f ${AI_LIBRARY_CR}" |
| 26 | + header "The AI Library Opeator should create seldondeployments and a dc for the UI, wait for them to show up" |
| 27 | + os::cmd::try_until_not_text "oc get seldondeployment flakes-predict" "not found" $odhdefaulttimeout $odhdefaultinterval |
| 28 | + os::cmd::try_until_not_text "oc get seldondeployment regression-predict" "not found" $odhdefaulttimeout $odhdefaultinterval |
| 29 | + os::cmd::try_until_not_text "oc get deploymentconfig ai-library-ui" "not found" $odhdefaulttimeout $odhdefaultinterval |
| 30 | +} |
| 31 | + |
| 32 | +function delete_ai_lib_cr() { |
| 33 | + os::cmd::expect_success "oc delete -f ${AI_LIBRARY_CR}" |
| 34 | + header "The AI Library Opeator should delete seldondeployments and a dc for the UI, wait for them to disappear" |
| 35 | + os::cmd::try_until_text "oc get seldondeployment flakes-predict" "not found" $odhdefaulttimeout $odhdefaultinterval |
| 36 | + os::cmd::try_until_text "oc get seldondeployment regression-predict" "not found" $odhdefaulttimeout $odhdefaultinterval |
| 37 | + os::cmd::try_until_text "oc get deploymentconfig ai-library-ui" "not found" $odhdefaulttimeout $odhdefaultinterval |
| 38 | +} |
| 39 | + |
| 40 | +function verify_functionality() { |
| 41 | + header "Verifying that the SeldonDeployments are up and running" |
| 42 | + os::cmd::try_until_text 'oc get seldondeployment flakes-predict -o jsonpath="{$.status.state}"' "Available" $odhdefaulttimeout $odhdefaultinterval |
| 43 | + os::cmd::try_until_text 'oc get seldondeployment regression-predict -o jsonpath="{$.status.state}"' "Available" $odhdefaulttimeout $odhdefaultinterval |
| 44 | + |
| 45 | + # Check that the UI is indeed up by curling the route |
| 46 | + uiroute=$(oc get route ui -o jsonpath="{$.status.ingress[0].host}") |
| 47 | + os::cmd::try_until_text "curl -k https://$uiroute" "AI Library" |
| 48 | +} |
| 49 | + |
| 50 | +function test_ai_library_functionality() { |
| 51 | + header "Testing AI Library functionality" |
| 52 | + os::cmd::expect_success "oc project ${ODHPROJECT}" |
| 53 | + create_ai_lib_cr |
| 54 | + verify_functionality |
| 55 | + delete_ai_lib_cr |
| 56 | +} |
| 57 | + |
| 58 | +test_ai_library |
| 59 | +test_ai_library_functionality |
| 60 | + |
| 61 | +os::test::junit::declare_suite_end |
0 commit comments