diff --git a/test/deploy-cluster.sh b/test/deploy-cluster.sh index a9daf87c436..07d427c31a4 100755 --- a/test/deploy-cluster.sh +++ b/test/deploy-cluster.sh @@ -41,6 +41,7 @@ function clean_up { ALL_PODS=($(kubectl get pods -o=custom-columns=:metadata.name -n $NAMESPACE)) for POD_NAME in "${ALL_PODS[@]}"; do pod_info_file="$POD_INFO_DIR/$POD_NAME.txt" + echo "Saving log of $POD_NAME to $pod_info_file" echo "Pod name: $POD_NAME" >> "$pod_info_file" echo "Detailed logs:" >> "$pod_info_file" echo "https://console.cloud.google.com/logs/viewer?project=$PROJECT&advancedFilter=resource.type%3D%22k8s_container%22%0Aresource.labels.project_id%3D%22$PROJECT%22%0Aresource.labels.location%3D%22us-east1-b%22%0Aresource.labels.cluster_name%3D%22${TEST_CLUSTER}%22%0Aresource.labels.namespace_name%3D%22$NAMESPACE%22%0Aresource.labels.pod_name%3D%22$POD_NAME%22" \ @@ -50,6 +51,11 @@ function clean_up { echo "--------" >> "$pod_info_file" kubectl get pod $POD_NAME -n $NAMESPACE -o yaml >> "$pod_info_file" done + + echo "Archiving ${ARTIFACTS} into ./${COMMIT_SHA}_logs.tar.gz" + tar -czf ./${COMMIT_SHA}_logs.tar.gz ${ARTIFACTS} + echo "Uploading ./${COMMIT_SHA}_logs.tar.gz to ${TEST_RESULTS_GCS_DIR}/logs" + gsutil cp ${COMMIT_SHA}_logs.tar.gz "${TEST_RESULTS_GCS_DIR}/logs" echo "Clean up cluster..." if [ $SHOULD_CLEANUP_CLUSTER == true ]; then diff --git a/test/frontend-integration-test/README.md b/test/frontend-integration-test/README.md new file mode 100644 index 00000000000..b2090b051b2 --- /dev/null +++ b/test/frontend-integration-test/README.md @@ -0,0 +1,24 @@ +# Frontend integration test + +This test gets triggered by the end-to-end testing workflows. + +## Local run + +1. Deploy KFP on a k8s cluster and enable port forwarding. Replace the default namespace `kubeflow` below if needed. + + ```bash + POD=`kubectl get pods -n kubeflow -l app=ml-pipeline-ui -o jsonpath='{.items[0].metadata.name}'` + kubectl port-forward -n kubeflow ${POD} 3000:3000 & + ``` + +1. Build the container with the tests: + + ```bash + docker build . -t kfp-frontend-integration-test:local + ``` + +1. Run the test with enabled networking (**this exposes your local networking stack to the testing container**): + + ```bash + docker run --net=host kfp-frontend-integration-test:local --remote-run true + ``` diff --git a/test/frontend-integration-test/run_test.sh b/test/frontend-integration-test/run_test.sh index eaa4965afeb..362ef51af4c 100755 --- a/test/frontend-integration-test/run_test.sh +++ b/test/frontend-integration-test/run_test.sh @@ -18,16 +18,29 @@ set -xe # K8s Namespace that all resources deployed to NAMESPACE=kubeflow +REMOTE_RUN=false usage() { echo "usage: run_test.sh --results-gcs-dir GCS directory for the test results. Usually gs:////e2e_test [--namespace k8s namespace where ml-pipelines is deployed. The tests run against the instance in this namespace] + [--remote-run host address of a remote KFP UI. Used for local tests only.] [-h help]" } -while [ "$1" != "" ]; do +function parse_bool { + local str="${1:-false}" + local pat='^(true|1|yes)$' + if [[ "$str" =~ $pat ]] + then + echo 'true' + else + echo 'false' + fi +} + +while [[ "$1" != "" ]]; do case $1 in --results-gcs-dir )shift RESULTS_GCS_DIR=$1 @@ -35,6 +48,9 @@ while [ "$1" != "" ]; do --namespace ) shift NAMESPACE=$1 ;; + --remote-run ) shift + REMOTE_RUN=$(parse_bool "${1:-}") + ;; -h | --help ) usage exit ;; @@ -44,29 +60,32 @@ while [ "$1" != "" ]; do shift done -if [ -z "$RESULTS_GCS_DIR" ]; then - usage - exit 1 -fi - -if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" ]]; then - gcloud auth activate-service-account --key-file="${GOOGLE_APPLICATION_CREDENTIALS}" +if [[ "$REMOTE_RUN" != "true" ]]; then + if [[ -z "$RESULTS_GCS_DIR" ]]; then + usage + exit 1 + fi + if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" ]]; then + gcloud auth activate-service-account --key-file="${GOOGLE_APPLICATION_CREDENTIALS}" + fi fi npm install -function clean_up() { - set +e +if [[ "$REMOTE_RUN" != "true" ]]; then + function clean_up() { + set +e - echo "Stopping background jobs..." - kill -15 %1 - kill -15 %2 -} -trap clean_up EXIT SIGINT SIGTERM + echo "Stopping background jobs..." + kill -15 %1 + kill -15 %2 + } + trap clean_up EXIT SIGINT SIGTERM -# Port forward the UI so tests can work against localhost -POD=`kubectl get pods -n ${NAMESPACE} -l app=ml-pipeline-ui -o jsonpath='{.items[0].metadata.name}'` -kubectl port-forward -n ${NAMESPACE} ${POD} 3000:3000 & + # Port forward the UI so tests can work against localhost + POD=`kubectl get pods -n ${NAMESPACE} -l app=ml-pipeline-ui -o jsonpath='{.items[0].metadata.name}'` + kubectl port-forward -n ${NAMESPACE} ${POD} 3000:3000 & +fi # Run Selenium server /opt/bin/entry_point.sh & @@ -82,7 +101,9 @@ set -e JUNIT_TEST_RESULT=junit_FrontendIntegrationTestOutput.xml -echo "Copy test result to GCS ${RESULTS_GCS_DIR}/${JUNIT_TEST_RESULT}" -gsutil cp ${JUNIT_TEST_RESULT} ${RESULTS_GCS_DIR}/${JUNIT_TEST_RESULT} +if [[ "$REMOTE_RUN" != "true" ]]; then + echo "Copy test result to GCS ${RESULTS_GCS_DIR}/${JUNIT_TEST_RESULT}" + gsutil cp ${JUNIT_TEST_RESULT} ${RESULTS_GCS_DIR}/${JUNIT_TEST_RESULT} +fi exit $TEST_EXIT_CODE