Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching test to kubeflow deployment #351

Merged
merged 52 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
1c7f2c9
test
IronPan Nov 21, 2018
213795b
fix
IronPan Nov 21, 2018
47d5457
fix
IronPan Nov 21, 2018
0ea4e69
fix
IronPan Nov 21, 2018
e2f5ea1
fix
IronPan Nov 21, 2018
bf05e06
fix
IronPan Nov 21, 2018
b83c4c1
update
IronPan Nov 21, 2018
21f88d0
cleanup
IronPan Nov 21, 2018
8c3f83f
fix
IronPan Nov 21, 2018
b78dc1b
coopy test
IronPan Nov 21, 2018
1323ab4
chmod
IronPan Nov 21, 2018
ab93fe8
fix
IronPan Nov 21, 2018
39d1712
fix
IronPan Nov 21, 2018
f694670
fix
IronPan Nov 21, 2018
1974bd3
fix
IronPan Nov 21, 2018
61a8ef4
fix
IronPan Nov 21, 2018
33cad5b
fix
IronPan Nov 21, 2018
97de358
fix
IronPan Nov 21, 2018
08a54ef
fix
IronPan Nov 21, 2018
6afcc66
fix
IronPan Nov 21, 2018
fa492e7
fix
IronPan Nov 21, 2018
7bd127a
fix
IronPan Nov 22, 2018
8b37fa2
fix
IronPan Nov 22, 2018
1d55b6f
fix
IronPan Nov 22, 2018
0776bf6
fix
IronPan Nov 22, 2018
fae10e9
fix
IronPan Nov 22, 2018
f198ccb
fix
IronPan Nov 22, 2018
ed04d33
fix
IronPan Nov 22, 2018
bafc268
fix
IronPan Nov 22, 2018
2ef2610
fix
IronPan Nov 22, 2018
41979ba
fix
IronPan Nov 22, 2018
f449107
fix
IronPan Nov 22, 2018
1b86ad0
fix
IronPan Nov 22, 2018
7c19bc9
fix
IronPan Nov 22, 2018
84bbc39
fix
IronPan Nov 22, 2018
1beaae7
fix
IronPan Nov 22, 2018
bb6420d
update
IronPan Nov 22, 2018
2fde6f4
fix
IronPan Nov 22, 2018
4a98037
fix
IronPan Nov 22, 2018
ab647bf
fix
IronPan Nov 22, 2018
d2e073d
fix
IronPan Nov 22, 2018
ed6b9e8
fix
IronPan Nov 22, 2018
da34b8d
fix
IronPan Nov 22, 2018
75c89c9
fix
IronPan Nov 22, 2018
63c9832
fix sample test
IronPan Nov 22, 2018
5c73e01
fix
IronPan Nov 22, 2018
25a49d9
fix
IronPan Nov 22, 2018
a5a14dc
merge
IronPan Nov 28, 2018
2701495
merge
IronPan Nov 28, 2018
94edfa8
update image builder image
IronPan Nov 28, 2018
2fdb5c7
update script
IronPan Nov 29, 2018
776034f
mount permission
IronPan Nov 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 8 additions & 36 deletions backend/test/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (

"testing"

"net/http"

"github.com/cenkalti/backoff"
experimentparams "github.com/kubeflow/pipelines/backend/api/go_http_client/experiment_client/experiment_service"
jobparams "github.com/kubeflow/pipelines/backend/api/go_http_client/job_client/job_service"
Expand All @@ -31,59 +33,29 @@ import (
"github.com/kubeflow/pipelines/backend/src/common/client/api_server"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
)

const (
// ML pipeline API server root URL
mlPipelineAPIServerBase = "/api/v1/namespaces/%s/services/ml-pipeline:8888/proxy/apis/v1beta1/%s"
)

var namespace = flag.String("namespace", "kubeflow", "The namespace ml pipeline deployed to")
var initializeTimeout = flag.Duration("initializeTimeout", 2*time.Minute, "Duration to wait for test initialization")

func getKubernetesClient() (*kubernetes.Clientset, error) {
// use the current context in kubeconfig
config, err := rest.InClusterConfig()
if err != nil {
return nil, errors.Wrapf(err, "Failed to get cluster config during K8s client initialization")
}
// create the clientset
clientSet, err := kubernetes.NewForConfig(config)
if err != nil {
return nil, errors.Wrapf(err, "Failed to create client set during K8s client initialization")
}

return clientSet, nil
}

func waitForReady(namespace string, initializeTimeout time.Duration) error {
clientSet, err := getKubernetesClient()
if err != nil {
return errors.Wrapf(err, "Failed to get K8s client set when waiting for ML pipeline to be ready")
}

var operation = func() error {
response := clientSet.RESTClient().Get().
AbsPath(fmt.Sprintf(mlPipelineAPIServerBase, namespace, "healthz")).Do()
if response.Error() == nil {
response, err := http.Get(fmt.Sprintf("http://ml-pipeline.%s.svc.cluster.local:8888/apis/v1beta1/healthz", namespace))
if err == nil {
return nil
}
var code int
response.StatusCode(&code)
// we wait only on 503 service unavailable. Stop retry otherwise.
if code != 503 {
return backoff.Permanent(errors.Wrapf(response.Error(), "Waiting for ml pipeline failed with non retriable error."))
if response.StatusCode != 503 {
return backoff.Permanent(errors.Wrapf(err, "Waiting for ml pipeline failed with non retriable error."))
}
return response.Error()
return err
}

b := backoff.NewExponentialBackOff()
b.MaxElapsedTime = initializeTimeout
err = backoff.Retry(operation, b)
err := backoff.Retry(operation, b)
return errors.Wrapf(err, "Waiting for ml pipeline failed after all attempts.")
}

Expand Down
4 changes: 4 additions & 0 deletions test/api-integration-test/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ if [ -z "$RESULTS_GCS_DIR" ]; then
exit 1
fi

if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" ]]; then
gcloud auth activate-service-account --key-file="${GOOGLE_APPLICATION_CREDENTIALS}"
fi

GITHUB_REPO=kubeflow/pipelines
BASE_DIR=/go/src/github.com/${GITHUB_REPO}
JUNIT_TEST_RESULT=junit_ApiIntegrationTestOutput.xml
Expand Down
2 changes: 1 addition & 1 deletion test/build_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ spec:
valueFrom:
path: /outputs/strict-image-name/file
container:
image: gcr.io/ml-pipeline-staging/image-builder:v20181120-0.1.3-rc.1-21-gb7c8af0-dirty-9786df
image: gcr.io/ml-pipeline-test/image-builder:v20181128-0.1.3-rc.1-109-ga5a14dc-e3b0c4
imagePullPolicy: 'Always'
args: [
"--image-build-context-gcs-uri", "{{inputs.parameters.image-build-context-gcs-uri}}",
Expand Down
52 changes: 52 additions & 0 deletions test/check-argo-status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
#
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


echo "check status of argo workflow $ARGO_WORKFLOW...."
# probing the argo workflow status until it completed. Timeout after 30 minutes
for i in $(seq 1 ${PULL_ARGO_WORKFLOW_STATUS_MAX_ATTEMPT})
do
WORKFLOW_STATUS=`kubectl get workflow $ARGO_WORKFLOW -n ${NAMESPACE} --show-labels`
echo $WORKFLOW_STATUS | grep ${WORKFLOW_COMPLETE_KEYWORD} && s=0 && break || s=$? && printf "Workflow ${ARGO_WORKFLOW} is not finished.\n${WORKFLOW_STATUS}\nSleep for 20 seconds...\n" && sleep 20
done

# Check whether the argo workflow finished or not and exit if not.
if [[ $s != 0 ]]; then
echo "Prow job Failed: Argo workflow timeout.."
argo logs -w ${ARGO_WORKFLOW} -n ${NAMESPACE}
exit $s
fi

echo "Argo workflow finished."

if [[ ! -z "$TEST_RESULT_FOLDER" ]]
then
echo "Copy test result"
mkdir -p $ARTIFACT_DIR
gsutil cp -r "${TEST_RESULTS_GCS_DIR}"/* "${ARTIFACT_DIR}" || true
fi

if [[ $WORKFLOW_STATUS = *"${WORKFLOW_FAILED_KEYWORD}"* ]]; then
echo "Test workflow failed."
echo "=========Argo Workflow Logs========="
argo logs -w ${ARGO_WORKFLOW} -n ${NAMESPACE}
echo "===================================="
argo get ${ARGO_WORKFLOW} -n ${NAMESPACE}
exit 1
else
argo get ${ARGO_WORKFLOW} -n ${NAMESPACE}
exit 0
fi
3 changes: 1 addition & 2 deletions test/e2e_test_gke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ spec:
valueFrom:
path: /outputs/strict-image-name/file
container:
image: gcr.io/ml-pipeline-staging/image-builder:v20181120-0.1.3-rc.1-21-gb7c8af0-dirty-9786df
image: gcr.io/ml-pipeline-test/image-builder:v20181128-0.1.3-rc.1-109-ga5a14dc-e3b0c4
imagePullPolicy: 'Always'
args: [
"--image-build-context-gcs-uri", "{{inputs.parameters.image-build-context-gcs-uri}}",
Expand Down Expand Up @@ -267,4 +267,3 @@ spec:
"--namespace", "{{inputs.parameters.namespace}}",
"--test-name", "{{inputs.parameters.test-name}}",
]

Loading