From 78a4563e4e3d9220a67c0ece2ce34f47cf77cc58 Mon Sep 17 00:00:00 2001 From: Hougang Liu Date: Fri, 26 Apr 2019 14:04:26 +0800 Subject: [PATCH] enable test for v1alpha2 (#465) * enable test for v1alpha2 * add KATIB-CORE-NAMESPACE env for controller * update example filed * share same image for two version controller * add status in subresources of crd --- examples/v1alpha2/random-example.yaml | 59 +++ manifests/v1alpha2/0-namespace.yaml | 4 + manifests/v1alpha2/katib-controller/crds.yaml | 29 ++ .../katib-controller/katib-controller.yaml | 32 ++ manifests/v1alpha2/katib-controller/rbac.yaml | 77 ++++ .../v1alpha2/katib-controller/service.yaml | 12 + .../trialTemplateConfigmap.yaml | 20 + prow_config.yaml | 30 +- scripts/v1alpha2/build.sh | 28 ++ scripts/v1alpha2/deploy.sh | 31 ++ .../v1alpha2/build-earlystopping-median.sh | 44 ++ .../v1alpha2/build-katib-controller.sh | 41 ++ test/scripts/v1alpha2/build-manager-rest.sh | 43 ++ test/scripts/v1alpha2/build-manager.sh | 43 ++ test/scripts/v1alpha2/build-suggestion-bo.sh | 44 ++ .../scripts/v1alpha2/build-suggestion-grid.sh | 44 ++ .../v1alpha2/build-suggestion-hyperband.sh | 44 ++ .../v1alpha2/build-suggestion-nasrl.sh | 43 ++ .../v1alpha2/build-suggestion-random.sh | 44 ++ test/scripts/v1alpha2/build-ui.sh | 43 ++ test/scripts/v1alpha2/create-cluster.sh | 39 ++ test/scripts/v1alpha2/delete-cluster.sh | 31 ++ test/scripts/v1alpha2/get-vendor-packages.sh | 38 ++ test/scripts/v1alpha2/python-tests.sh | 25 ++ test/scripts/v1alpha2/run-tests.sh | 94 +++++ test/scripts/v1alpha2/unit-test.sh | 84 ++++ test/workflows/components/params.libsonnet | 17 +- ...ows.jsonnet => workflows-v1alpha1.jsonnet} | 4 +- ...libsonnet => workflows-v1alpha1.libsonnet} | 0 .../components/workflows-v1alpha2.jsonnet | 14 + .../components/workflows-v1alpha2.libsonnet | 387 ++++++++++++++++++ 31 files changed, 1478 insertions(+), 10 deletions(-) create mode 100644 examples/v1alpha2/random-example.yaml create mode 100644 manifests/v1alpha2/0-namespace.yaml create mode 100644 manifests/v1alpha2/katib-controller/crds.yaml create mode 100644 manifests/v1alpha2/katib-controller/katib-controller.yaml create mode 100644 manifests/v1alpha2/katib-controller/rbac.yaml create mode 100644 manifests/v1alpha2/katib-controller/service.yaml create mode 100644 manifests/v1alpha2/katib-controller/trialTemplateConfigmap.yaml create mode 100755 scripts/v1alpha2/build.sh create mode 100755 scripts/v1alpha2/deploy.sh create mode 100755 test/scripts/v1alpha2/build-earlystopping-median.sh create mode 100755 test/scripts/v1alpha2/build-katib-controller.sh create mode 100755 test/scripts/v1alpha2/build-manager-rest.sh create mode 100755 test/scripts/v1alpha2/build-manager.sh create mode 100755 test/scripts/v1alpha2/build-suggestion-bo.sh create mode 100755 test/scripts/v1alpha2/build-suggestion-grid.sh create mode 100755 test/scripts/v1alpha2/build-suggestion-hyperband.sh create mode 100755 test/scripts/v1alpha2/build-suggestion-nasrl.sh create mode 100755 test/scripts/v1alpha2/build-suggestion-random.sh create mode 100755 test/scripts/v1alpha2/build-ui.sh create mode 100755 test/scripts/v1alpha2/create-cluster.sh create mode 100755 test/scripts/v1alpha2/delete-cluster.sh create mode 100755 test/scripts/v1alpha2/get-vendor-packages.sh create mode 100755 test/scripts/v1alpha2/python-tests.sh create mode 100755 test/scripts/v1alpha2/run-tests.sh create mode 100755 test/scripts/v1alpha2/unit-test.sh rename test/workflows/components/{workflows.jsonnet => workflows-v1alpha1.jsonnet} (75%) rename test/workflows/components/{workflows.libsonnet => workflows-v1alpha1.libsonnet} (100%) create mode 100644 test/workflows/components/workflows-v1alpha2.jsonnet create mode 100644 test/workflows/components/workflows-v1alpha2.libsonnet diff --git a/examples/v1alpha2/random-example.yaml b/examples/v1alpha2/random-example.yaml new file mode 100644 index 00000000000..537a7304833 --- /dev/null +++ b/examples/v1alpha2/random-example.yaml @@ -0,0 +1,59 @@ +apiVersion: "kubeflow.org/v1alpha2" +kind: Experiment +metadata: + namespace: kubeflow + name: random-experiment +spec: + parallelTrialCount: 3 + maxTrialCount: 12 + maxFailedTrialCount: 3 + objective: + type: maximize + goal: 0.99 + objectiveMetricName: Validation-accuracy + additionalMetricsNames: + - accuracy + algorithm: + algorithmName: random + trialTemplate: + goTemplate: + rawTemplate: |- + apiVersion: batch/v1 + kind: Job + metadata: + name: {{.Trial}} + namespace: {{.NameSpace}} + spec: + template: + spec: + containers: + - name: {{.Trial}} + image: katib/mxnet-mnist-example + command: + - "python" + - "/mxnet/example/image-classification/train_mnist.py" + - "--batch-size=64" + {{- with .HyperParameters}} + {{- range .}} + - "{{.Name}}={{.Value}}" + {{- end}} + {{- end}} + restartPolicy: Never + parameters: + - name: --lr + parameterType: double + feasibleSpace: + min: "0.01" + max: "0.03" + - name: --num-layers + parameterType: int + feasibleSpace: + min: "2" + max: "5" + - name: --optimizer + parameterType: categorical + feasibleSpace: + list: + - sgd + - adam + - ftrl diff --git a/manifests/v1alpha2/0-namespace.yaml b/manifests/v1alpha2/0-namespace.yaml new file mode 100644 index 00000000000..7a940e4673d --- /dev/null +++ b/manifests/v1alpha2/0-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: kubeflow diff --git a/manifests/v1alpha2/katib-controller/crds.yaml b/manifests/v1alpha2/katib-controller/crds.yaml new file mode 100644 index 00000000000..76ddc8aadf3 --- /dev/null +++ b/manifests/v1alpha2/katib-controller/crds.yaml @@ -0,0 +1,29 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: experiments.kubeflow.org +spec: + group: kubeflow.org + version: v1alpha2 + scope: Namespaced + subresources: + status: {} + names: + kind: Experiment + singular: experiment + plural: experiments +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: trials.kubeflow.org +spec: + group: kubeflow.org + version: v1alpha2 + scope: Namespaced + subresources: + status: {} + names: + kind: Trial + singular: trial + plural: trials diff --git a/manifests/v1alpha2/katib-controller/katib-controller.yaml b/manifests/v1alpha2/katib-controller/katib-controller.yaml new file mode 100644 index 00000000000..6deeb4586d2 --- /dev/null +++ b/manifests/v1alpha2/katib-controller/katib-controller.yaml @@ -0,0 +1,32 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: katib-controller + namespace: kubeflow + labels: + app: katib-controller +spec: + replicas: 1 + selector: + matchLabels: + app: katib-controller + template: + metadata: + labels: + app: katib-controller + spec: + serviceAccountName: katib-controller + containers: + - name: katib-controller + image: katib/katib-controller + imagePullPolicy: Always + command: ["./katib-controller.v1alpha2"] + ports: + - containerPort: 443 + name: webhook + protocol: TCP + env: + - name: KATIB_CORE_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace diff --git a/manifests/v1alpha2/katib-controller/rbac.yaml b/manifests/v1alpha2/katib-controller/rbac.yaml new file mode 100644 index 00000000000..b365fe89c7a --- /dev/null +++ b/manifests/v1alpha2/katib-controller/rbac.yaml @@ -0,0 +1,77 @@ +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: katib-controller +rules: +- apiGroups: + - "" + resources: + - configmaps + - serviceaccounts + - services + verbs: + - "*" +- apiGroups: + - "" + resources: + - pods + - pods/log + - pods/status + verbs: + - "*" +- apiGroups: + - batch + resources: + - jobs + - cronjobs + verbs: + - "*" +- apiGroups: + - apiextensions.k8s.io + resources: + - customresourcedefinitions + verbs: + - create + - get +- apiGroups: + - admissionregistration.k8s.io + resources: + - validatingwebhookconfigurations + - mutatingwebhookconfigurations + verbs: + - '*' +- apiGroups: + - kubeflow.org + resources: + - experiments + - experiments/status + - trials + - trials/status + verbs: + - "*" +- apiGroups: + - kubeflow.org + resources: + - tfjobs + - pytorchjobs + verbs: + - "*" +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: katib-controller + namespace: kubeflow +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: katib-controller +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: katib-controller +subjects: +- kind: ServiceAccount + name: katib-controller + namespace: kubeflow diff --git a/manifests/v1alpha2/katib-controller/service.yaml b/manifests/v1alpha2/katib-controller/service.yaml new file mode 100644 index 00000000000..3b70edeece4 --- /dev/null +++ b/manifests/v1alpha2/katib-controller/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: katib-controller + namespace: kubeflow +spec: + ports: + - port: 443 + protocol: TCP + targetPort: 443 + selector: + app: katib-controller diff --git a/manifests/v1alpha2/katib-controller/trialTemplateConfigmap.yaml b/manifests/v1alpha2/katib-controller/trialTemplateConfigmap.yaml new file mode 100644 index 00000000000..67ec76c00cd --- /dev/null +++ b/manifests/v1alpha2/katib-controller/trialTemplateConfigmap.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: trial-template + namespace: kubeflow +data: + defaultTrialTemplate.yaml : |- + apiVersion: batch/v1 + kind: Job + metadata: + name: {{.Trial}} + namespace: {{.NameSpace}} + spec: + template: + spec: + containers: + - name: {{.Trial}} + image: alpine + restartPolicy: Never + diff --git a/prow_config.yaml b/prow_config.yaml index 3a6bd1a7e26..afb91ebf430 100644 --- a/prow_config.yaml +++ b/prow_config.yaml @@ -2,8 +2,8 @@ # see kubeflow/testing/py/run_e2e_workflow.py workflows: - app_dir: kubeflow/katib/test/workflows - component: workflows - name: e2e + component: workflows-v1alpha1 + name: e2e-v1alpha1 job_types: - presubmit include_dirs: @@ -14,8 +14,8 @@ workflows: registry: "gcr.io/kubeflow-ci" # The postsubmit run publishes the docker images to gcr.io/kubeflow-images-public - app_dir: kubeflow/katib/test/workflows - component: workflows - name: e2e-release + component: workflows-v1alpha1 + name: e2e-v1alpha1-release job_types: - postsubmit include_dirs: @@ -24,3 +24,25 @@ workflows: - test/* params: registry: "gcr.io/kubeflow-images-public" + - app_dir: kubeflow/katib/test/workflows + component: workflows-v1alpha2 + name: e2e-v1alpha2 + job_types: + - presubmit + include_dirs: + - pkg/* + - cmd/* + - test/* + params: + registry: "gcr.io/kubeflow-ci" + - app_dir: kubeflow/katib/test/workflows + component: workflows-v1alpha2 + name: e2e-v1alpha2-release + job_types: + - postsubmit + include_dirs: + - pkg/* + - cmd/* + - test/* + params: + registry: "gcr.io/kubeflow-images-public" diff --git a/scripts/v1alpha2/build.sh b/scripts/v1alpha2/build.sh new file mode 100755 index 00000000000..f6708ac107d --- /dev/null +++ b/scripts/v1alpha2/build.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +set -o errexit +set -o nounset +set -o pipefail + +PREFIX="katib" +CMD_PREFIX="cmd" + +SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/../.. + +cd ${SCRIPT_ROOT} + +docker build -t ${PREFIX}/katib-controller -f ${CMD_PREFIX}/katib-controller/Dockerfile . diff --git a/scripts/v1alpha2/deploy.sh b/scripts/v1alpha2/deploy.sh new file mode 100755 index 00000000000..acdea097b05 --- /dev/null +++ b/scripts/v1alpha2/deploy.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +set -o errexit +set -o nounset +set -o pipefail +set -o xtrace + +SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/../.. + +cd ${SCRIPT_ROOT} +kubectl apply -f manifests/v1alpha2/0-namespace.yaml +kubectl apply -f manifests/v1alpha2/katib-controller/crds.yaml +kubectl apply -f manifests/v1alpha2/katib-controller/rbac.yaml +kubectl apply -f manifests/v1alpha2/katib-controller/service.yaml +kubectl apply -f manifests/v1alpha2/katib-controller/trialTemplateConfigmap.yaml +kubectl apply -f manifests/v1alpha2/katib-controller/katib-controller.yaml +cd - > /dev/null diff --git a/test/scripts/v1alpha2/build-earlystopping-median.sh b/test/scripts/v1alpha2/build-earlystopping-median.sh new file mode 100755 index 00000000000..11026efc75e --- /dev/null +++ b/test/scripts/v1alpha2/build-earlystopping-median.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +# This shell script is used to build an image from our argo workflow + +exit 0 + +set -o errexit +set -o nounset +set -o pipefail + +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} +REGISTRY="${GCP_REGISTRY}" +PROJECT="${GCP_PROJECT}" +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-earlystopping-median +VERSION=$(git describe --tags --always --dirty) + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} + +echo "Copy source to GOPATH" +mkdir -p ${GO_DIR} +cp -r cmd ${GO_DIR}/cmd +cp -r pkg ${GO_DIR}/pkg +cp -r vendor ${GO_DIR}/vendor + +cd ${GO_DIR} + +cp cmd/earlystopping/medianstopping/Dockerfile . +gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/earlystopping-medianstopping:${VERSION} --project=${PROJECT} +gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/earlystopping-medianstopping:${VERSION} ${REGISTRY}/${REPO_NAME}/earlystopping-medianstopping:latest --verbosity=info diff --git a/test/scripts/v1alpha2/build-katib-controller.sh b/test/scripts/v1alpha2/build-katib-controller.sh new file mode 100755 index 00000000000..1fb7b9f725f --- /dev/null +++ b/test/scripts/v1alpha2/build-katib-controller.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +# This shell script is used to build an image from our argo workflow + +set -o errexit +set -o nounset +set -o pipefail + +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} +REGISTRY="${GCP_REGISTRY}" +PROJECT="${GCP_PROJECT}" +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-katib-controller +VERSION=$(git describe --tags --always --dirty) + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} + +echo "Copy source to GOPATH" +mkdir -p ${GO_DIR} +cp -r cmd ${GO_DIR}/cmd +cp -r pkg ${GO_DIR}/pkg +cp -r vendor ${GO_DIR}/vendor + +cd ${GO_DIR} +cp cmd/katib-controller/Dockerfile . +gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/katib-controller:${VERSION} --project=${PROJECT} +gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/katib-controller:${VERSION} ${REGISTRY}/${REPO_NAME}/katib-controller:latest --verbosity=info diff --git a/test/scripts/v1alpha2/build-manager-rest.sh b/test/scripts/v1alpha2/build-manager-rest.sh new file mode 100755 index 00000000000..a283e32f2f8 --- /dev/null +++ b/test/scripts/v1alpha2/build-manager-rest.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +# This shell script is used to build an image from our argo workflow + +exit 0 + +set -o errexit +set -o nounset +set -o pipefail + +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} +REGISTRY="${GCP_REGISTRY}" +PROJECT="${GCP_PROJECT}" +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-manager-rest +VERSION=$(git describe --tags --always --dirty) + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} + +echo "Copy source to GOPATH" +mkdir -p ${GO_DIR} +cp -r cmd ${GO_DIR}/cmd +cp -r pkg ${GO_DIR}/pkg +cp -r vendor ${GO_DIR}/vendor + +cd ${GO_DIR} +cp cmd/manager-rest/Dockerfile . +gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/vizier-core-rest:${VERSION} --project=${PROJECT} +gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/vizier-core-rest:${VERSION} ${REGISTRY}/${REPO_NAME}/vizier-core-rest:latest --verbosity=info diff --git a/test/scripts/v1alpha2/build-manager.sh b/test/scripts/v1alpha2/build-manager.sh new file mode 100755 index 00000000000..9bd0e7e70c5 --- /dev/null +++ b/test/scripts/v1alpha2/build-manager.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +# This shell script is used to build an image from our argo workflow + +exit 0 + +set -o errexit +set -o nounset +set -o pipefail + +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} +REGISTRY="${GCP_REGISTRY}" +PROJECT="${GCP_PROJECT}" +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-manager +VERSION=$(git describe --tags --always --dirty) + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} + +echo "Copy source to GOPATH" +mkdir -p ${GO_DIR} +cp -r cmd ${GO_DIR}/cmd +cp -r pkg ${GO_DIR}/pkg +cp -r vendor ${GO_DIR}/vendor + +cd ${GO_DIR} +cp cmd/manager/Dockerfile . +gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/vizier-core:${VERSION} --project=${PROJECT} +gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/vizier-core:${VERSION} ${REGISTRY}/${REPO_NAME}/vizier-core:latest --verbosity=info diff --git a/test/scripts/v1alpha2/build-suggestion-bo.sh b/test/scripts/v1alpha2/build-suggestion-bo.sh new file mode 100755 index 00000000000..6ecb856d8ca --- /dev/null +++ b/test/scripts/v1alpha2/build-suggestion-bo.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +# This shell script is used to build an image from our argo workflow + +exit 0 + +set -o errexit +set -o nounset +set -o pipefail + +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} +REGISTRY="${GCP_REGISTRY}" +PROJECT="${GCP_PROJECT}" +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-suggestion-bo +VERSION=$(git describe --tags --always --dirty) + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} + +echo "Copy source to GOPATH" +mkdir -p ${GO_DIR} +cp -r cmd ${GO_DIR}/cmd +cp -r pkg ${GO_DIR}/pkg +cp -r vendor ${GO_DIR}/vendor + +cd ${GO_DIR} + +cp cmd/suggestion/bayesianoptimization/Dockerfile . +gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/suggestion-bayesianoptimization:${VERSION} --project=${PROJECT} +gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/suggestion-bayesianoptimization:${VERSION} ${REGISTRY}/${REPO_NAME}/suggestion-bayesianoptimization:latest --verbosity=info diff --git a/test/scripts/v1alpha2/build-suggestion-grid.sh b/test/scripts/v1alpha2/build-suggestion-grid.sh new file mode 100755 index 00000000000..f094ad6de33 --- /dev/null +++ b/test/scripts/v1alpha2/build-suggestion-grid.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +# This shell script is used to build an image from our argo workflow + +exit 0 + +set -o errexit +set -o nounset +set -o pipefail + +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} +REGISTRY="${GCP_REGISTRY}" +PROJECT="${GCP_PROJECT}" +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-suggestion-grid +VERSION=$(git describe --tags --always --dirty) + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} + +echo "Copy source to GOPATH" +mkdir -p ${GO_DIR} +cp -r cmd ${GO_DIR}/cmd +cp -r pkg ${GO_DIR}/pkg +cp -r vendor ${GO_DIR}/vendor + +cd ${GO_DIR} + +cp cmd/suggestion/grid/Dockerfile . +gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/suggestion-grid:${VERSION} --project=${PROJECT} +gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/suggestion-grid:${VERSION} ${REGISTRY}/${REPO_NAME}/suggestion-grid:latest --verbosity=info diff --git a/test/scripts/v1alpha2/build-suggestion-hyperband.sh b/test/scripts/v1alpha2/build-suggestion-hyperband.sh new file mode 100755 index 00000000000..376b8ae3444 --- /dev/null +++ b/test/scripts/v1alpha2/build-suggestion-hyperband.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +# This shell script is used to build an image from our argo workflow + +exit 0 + +set -o errexit +set -o nounset +set -o pipefail + +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} +REGISTRY="${GCP_REGISTRY}" +PROJECT="${GCP_PROJECT}" +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-suggestion-hyperband +VERSION=$(git describe --tags --always --dirty) + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} + +echo "Copy source to GOPATH" +mkdir -p ${GO_DIR} +cp -r cmd ${GO_DIR}/cmd +cp -r pkg ${GO_DIR}/pkg +cp -r vendor ${GO_DIR}/vendor + +cd ${GO_DIR} + +cp cmd/suggestion/hyperband/Dockerfile . +gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/suggestion-hyperband:${VERSION} --project=${PROJECT} +gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/suggestion-hyperband:${VERSION} ${REGISTRY}/${REPO_NAME}/suggestion-hyperband:latest --verbosity=info diff --git a/test/scripts/v1alpha2/build-suggestion-nasrl.sh b/test/scripts/v1alpha2/build-suggestion-nasrl.sh new file mode 100755 index 00000000000..7be1aca75ed --- /dev/null +++ b/test/scripts/v1alpha2/build-suggestion-nasrl.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +# This shell script is used to build an image from our argo workflow +exit 0 + +set -o errexit +set -o nounset +set -o pipefail + +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} +REGISTRY="${GCP_REGISTRY}" +PROJECT="${GCP_PROJECT}" +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-suggestion-nasrl +VERSION=$(git describe --tags --always --dirty) + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} + +echo "Copy source to GOPATH" +mkdir -p ${GO_DIR} +cp -r cmd ${GO_DIR}/cmd +cp -r pkg ${GO_DIR}/pkg +cp -r vendor ${GO_DIR}/vendor + +cd ${GO_DIR} + +cp cmd/suggestion/nasrl/Dockerfile . +gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/suggestion-nasrl:${VERSION} --project=${PROJECT} +gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/suggestion-nasrl:${VERSION} ${REGISTRY}/${REPO_NAME}/suggestion-nasrl:latest --verbosity=info diff --git a/test/scripts/v1alpha2/build-suggestion-random.sh b/test/scripts/v1alpha2/build-suggestion-random.sh new file mode 100755 index 00000000000..4d9035ae890 --- /dev/null +++ b/test/scripts/v1alpha2/build-suggestion-random.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +# This shell script is used to build an image from our argo workflow + +exit 0 + +set -o errexit +set -o nounset +set -o pipefail + +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} +REGISTRY="${GCP_REGISTRY}" +PROJECT="${GCP_PROJECT}" +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-suggestion-random +VERSION=$(git describe --tags --always --dirty) + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} + +echo "Copy source to GOPATH" +mkdir -p ${GO_DIR} +cp -r cmd ${GO_DIR}/cmd +cp -r pkg ${GO_DIR}/pkg +cp -r vendor ${GO_DIR}/vendor + +cd ${GO_DIR} + +cp cmd/suggestion/random/Dockerfile . +gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/suggestion-random:${VERSION} --project=${PROJECT} +gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/suggestion-random:${VERSION} ${REGISTRY}/${REPO_NAME}/suggestion-random:latest --verbosity=info diff --git a/test/scripts/v1alpha2/build-ui.sh b/test/scripts/v1alpha2/build-ui.sh new file mode 100755 index 00000000000..c5a7e2fe435 --- /dev/null +++ b/test/scripts/v1alpha2/build-ui.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +# This shell script is used to build an image from our argo workflow + +exit 0 + +set -o errexit +set -o nounset +set -o pipefail + +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} +REGISTRY="${GCP_REGISTRY}" +PROJECT="${GCP_PROJECT}" +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-modeldb +VERSION=$(git describe --tags --always --dirty) + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} + +echo "Copy source to GOPATH" +mkdir -p ${GO_DIR} +cp -r cmd ${GO_DIR}/cmd +cp -r pkg ${GO_DIR}/pkg +cp -r vendor ${GO_DIR}/vendor + +cd ${GO_DIR} +cp cmd/ui/Dockerfile . +gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/katib-ui:${VERSION} --project=${PROJECT} +gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/katib-ui:${VERSION} ${REGISTRY}/${REPO_NAME}/katib-ui:latest --verbosity=info diff --git a/test/scripts/v1alpha2/create-cluster.sh b/test/scripts/v1alpha2/create-cluster.sh new file mode 100755 index 00000000000..580878296fa --- /dev/null +++ b/test/scripts/v1alpha2/create-cluster.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Copyright 2018 The Kubernetes Authors. +# +# 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. + +# This shell script is used to build a cluster and create a namespace from our +# argo workflow + + +set -o errexit +set -o nounset +set -o pipefail + +CLUSTER_NAME="${CLUSTER_NAME}" +ZONE="${GCP_ZONE}" +PROJECT="${GCP_PROJECT}" +NAMESPACE="${DEPLOY_NAMESPACE}" + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} +echo "Creating GPU cluster" +gcloud --project ${PROJECT} beta container clusters create ${CLUSTER_NAME} \ + --zone ${ZONE} \ + --accelerator type=nvidia-tesla-k80,count=1 \ + --cluster-version 1.11 +echo "Configuring kubectl" +gcloud --project ${PROJECT} container clusters get-credentials ${CLUSTER_NAME} \ + --zone ${ZONE} diff --git a/test/scripts/v1alpha2/delete-cluster.sh b/test/scripts/v1alpha2/delete-cluster.sh new file mode 100755 index 00000000000..16e1864003c --- /dev/null +++ b/test/scripts/v1alpha2/delete-cluster.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Copyright 2018 The Kubernetes Authors. +# +# 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. + +# This shell script is used to build a cluster and create a namespace from our +# argo workflow + +set -o errexit +set -o nounset +set -o pipefail + +CLUSTER_NAME="${CLUSTER_NAME}" +ZONE="${GCP_ZONE}" +PROJECT="${GCP_PROJECT}" + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} +echo "Tearing down the cluster" +gcloud container clusters delete ${CLUSTER_NAME} --zone=${ZONE} --project=${PROJECT} diff --git a/test/scripts/v1alpha2/get-vendor-packages.sh b/test/scripts/v1alpha2/get-vendor-packages.sh new file mode 100755 index 00000000000..e232b8fffe2 --- /dev/null +++ b/test/scripts/v1alpha2/get-vendor-packages.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Copyright 2018 The Kubeflow Authors. +# +# 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. + +# This shell script is used to build an image from our argo workflow + +set -o errexit +set -o nounset +set -o pipefail + +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} +REGISTRY="${GCP_REGISTRY}" +PROJECT="${GCP_PROJECT}" +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME} +VERSION=$(git describe --tags --always --dirty) +CPATH=$PWD + +echo "Copy source to GOPATH" +echo "copy $PWD to ${GO_DIR}" +mkdir -p ${GO_DIR} +cp -r * ${GO_DIR} +go get -u github.com/golang/dep/cmd/dep +cd ${GO_DIR} +dep ensure +mv ${GO_DIR}/vendor ${CPATH}/vendor + diff --git a/test/scripts/v1alpha2/python-tests.sh b/test/scripts/v1alpha2/python-tests.sh new file mode 100755 index 00000000000..24224d69ce3 --- /dev/null +++ b/test/scripts/v1alpha2/python-tests.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright 2018 The Kubernetes Authors. +# +# 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. + +# This shell script is used to run the python tests in the argo workflow + +exit 0 + +pip install -r cmd/suggestion/bayesianoptimization/requirements.txt +pip install -r pkg/suggestion/test_requirements.txt +python setup.py develop +pylint pkg/suggestion/v1alpha1/bayesianoptimization/src --disable=fixme --exit-zero --reports=y +pytest pkg/suggestion/v1alpha1/tests --verbose --cov=pkg/suggestion/bayesianoptimization/src --cov-report term-missing diff --git a/test/scripts/v1alpha2/run-tests.sh b/test/scripts/v1alpha2/run-tests.sh new file mode 100755 index 00000000000..481ff8bcfd9 --- /dev/null +++ b/test/scripts/v1alpha2/run-tests.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +# Copyright 2018 The Kubernetes Authors. +# +# 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. + +# This shell script is used to build a cluster and create a namespace from our +# argo workflow + +set -o errexit +set -o nounset +set -o pipefail + +CLUSTER_NAME="${CLUSTER_NAME}" +ZONE="${GCP_ZONE}" +PROJECT="${GCP_PROJECT}" +NAMESPACE="${DEPLOY_NAMESPACE}" +REGISTRY="${GCP_REGISTRY}" +VERSION=$(git describe --tags --always --dirty) +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME} + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} + +echo "Configuring kubectl" + +echo "CLUSTER_NAME: ${CLUSTER_NAME}" +echo "ZONE: ${GCP_ZONE}" +echo "PROJECT: ${GCP_PROJECT}" + +gcloud --project ${PROJECT} container clusters get-credentials ${CLUSTER_NAME} \ + --zone ${ZONE} +kubectl config set-context $(kubectl config current-context) --namespace=default +USER=`gcloud config get-value account` + +kubectl apply -f - << EOF +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: cluster-admins +subjects: +- kind: User + name: $USER +roleRef: + kind: ClusterRole + name: cluster-admin + apiGroup: "" +EOF + +#This is required. But I don't know why. +VERSION=${VERSION/%?/} + +echo "Install Katib " +echo "REGISTRY ${REGISTRY}" +echo "REPO_NAME ${REPO_NAME}" +echo "VERSION ${VERSION}" + +sed -i -e "s@image: katib\/katib-controller@image: ${REGISTRY}\/${REPO_NAME}\/katib-controller:${VERSION}@" manifests/v1alpha2/katib-controller/katib-controller.yaml + +./scripts/v1alpha2/deploy.sh + +TIMEOUT=120 +PODNUM=$(kubectl get deploy -n kubeflow | grep -v NAME | wc -l) +until kubectl get pods -n kubeflow | grep Running | [[ $(wc -l) -eq $PODNUM ]]; do + echo Pod Status $(kubectl get pods -n kubeflow | grep Running | wc -l)/$PODNUM + sleep 10 + TIMEOUT=$(( TIMEOUT - 1 )) + if [[ $TIMEOUT -eq 0 ]];then + echo "NG" + kubectl get pods -n kubeflow + exit 1 + fi +done + +echo "All Katib components are running." +kubectl version +echo "Katib deployments" +kubectl -n kubeflow get deploy +echo "Katib services" +kubectl -n kubeflow get svc +echo "Katib pods" +kubectl -n kubeflow get pod + +exit 0 diff --git a/test/scripts/v1alpha2/unit-test.sh b/test/scripts/v1alpha2/unit-test.sh new file mode 100755 index 00000000000..98456626646 --- /dev/null +++ b/test/scripts/v1alpha2/unit-test.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# Copyright 2018 The Kubernetes Authors. +# +# 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. + +# This shell script is used to build a cluster and create a namespace from our +# argo workflow + +exit 0 + +set -o errexit +set -o nounset +set -o pipefail + +export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} +REGISTRY="${GCP_REGISTRY}" +CLUSTER_NAME="${CLUSTER_NAME}" +ZONE="${GCP_ZONE}" +PROJECT="${GCP_PROJECT}" +GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME} +VERSION=$(git describe --tags --always --dirty) + +echo "Activating service-account" +gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} + +echo "Configuring kubectl" + +gcloud --project ${PROJECT} container clusters get-credentials ${CLUSTER_NAME} \ + --zone ${ZONE} +kubectl config set-context $(kubectl config current-context) --namespace=default + +kubectl apply -f - < /dev/null diff --git a/test/workflows/components/params.libsonnet b/test/workflows/components/params.libsonnet index ea108ddec01..21ab8a915f3 100644 --- a/test/workflows/components/params.libsonnet +++ b/test/workflows/components/params.libsonnet @@ -6,12 +6,21 @@ components: { // Component-level parameters, defined initially from 'ks prototype use ...' // Each object below should correspond to a component in the components/ directory - workflows: { + "workflows-v1alpha1": { bucket: "kubeflow-ci_temp", - name: "some-very-very-very-very-very-long-name-jlewi-tf-k8s-presubmit-test-374-6e32", + name: "some-very-very-very-very-very-long-name-katib-v1alpha1-presubmit-test-374-6e32", namespace: "kubeflow-test-infra", - prow_env: "JOB_NAME=tf-k8s-presubmit-test,JOB_TYPE=presubmit,PULL_NUMBER=374,REPO_NAME=k8s,REPO_OWNER=tensorflow,BUILD_NUMBER=6e32", + registry: "gcr.io/kubbeflow-ci", + prow_env: "JOB_NAME=katib-v1alpha1-presubmit-test,JOB_TYPE=presubmit,PULL_NUMBER=374,REPO_NAME=k8s,REPO_OWNER=tensorflow,BUILD_NUMBER=6e32", versionTag: null, - }, + }, + "workflows-v1alpha2": { + bucket: "kubeflow-ci_temp", + name: "some-very-very-very-very-very-long-name-katib-v1alpha2-presubmit-test-374-6e32", + namespace: "kubeflow-test-infra", + registry: "gcr.io/kubbeflow-ci", + prow_env: "JOB_NAME=katib-v1alpha2-presubmit-test,JOB_TYPE=presubmit,PULL_NUMBER=374,REPO_NAME=k8s,REPO_OWNER=tensorflow,BUILD_NUMBER=6e32", + versionTag: null, + }, }, } diff --git a/test/workflows/components/workflows.jsonnet b/test/workflows/components/workflows-v1alpha1.jsonnet similarity index 75% rename from test/workflows/components/workflows.jsonnet rename to test/workflows/components/workflows-v1alpha1.jsonnet index 6c6c51abde4..9eae13a77e8 100644 --- a/test/workflows/components/workflows.jsonnet +++ b/test/workflows/components/workflows-v1alpha1.jsonnet @@ -1,7 +1,7 @@ -local params = std.extVar("__ksonnet/params").components.workflows; +local params = std.extVar("__ksonnet/params").components["workflows-v1alpha1"]; local k = import 'k.libsonnet'; -local workflows = import 'workflows.libsonnet'; +local workflows = import 'workflows-v1alpha1.libsonnet'; local namespace = params.namespace; // TODO(jlewi): Can we make name default so some random unique value? diff --git a/test/workflows/components/workflows.libsonnet b/test/workflows/components/workflows-v1alpha1.libsonnet similarity index 100% rename from test/workflows/components/workflows.libsonnet rename to test/workflows/components/workflows-v1alpha1.libsonnet diff --git a/test/workflows/components/workflows-v1alpha2.jsonnet b/test/workflows/components/workflows-v1alpha2.jsonnet new file mode 100644 index 00000000000..fee3eb85652 --- /dev/null +++ b/test/workflows/components/workflows-v1alpha2.jsonnet @@ -0,0 +1,14 @@ +local params = std.extVar("__ksonnet/params").components["workflows-v1alpha2"]; + +local k = import 'k.libsonnet'; +local workflows = import 'workflows-v1alpha2.libsonnet'; +local namespace = params.namespace; + +// TODO(jlewi): Can we make name default so some random unique value? +// I didn't see any routines in the standard library for datetime or random. +local name = params.name; + +local prowEnv = workflows.parseEnv(params.prow_env); +local bucket = params.bucket; + +std.prune(k.core.v1.list.new([workflows.parts(namespace, name, params).e2e(prowEnv, bucket)])) diff --git a/test/workflows/components/workflows-v1alpha2.libsonnet b/test/workflows/components/workflows-v1alpha2.libsonnet new file mode 100644 index 00000000000..3e37609a16f --- /dev/null +++ b/test/workflows/components/workflows-v1alpha2.libsonnet @@ -0,0 +1,387 @@ +{ + // TODO(https://github.com/ksonnet/ksonnet/issues/222): Taking namespace as an argument is a work around for the fact that ksonnet + // doesn't support automatically piping in the namespace from the environment to prototypes. + + // convert a list of two items into a map representing an environment variable + // TODO(jlewi): Should we move this into kubeflow/core/util.libsonnet + listToMap:: function(v) + { + name: v[0], + value: v[1], + }, + + // Function to turn comma separated list of prow environment variables into a dictionary. + parseEnv:: function(v) + local pieces = std.split(v, ","); + if v != "" && std.length(pieces) > 0 then + std.map( + function(i) $.listToMap(std.split(i, "=")), + std.split(v, ",") + ) + else [], + + + // default parameters. + defaultParams:: { + project:: "kubeflow-ci", + zone:: "us-east1-d", + // Default registry to use. + //registry:: "gcr.io/" + $.defaultParams.project, + + // The image tag to use. + // Defaults to a value based on the name. + versionTag:: null, + + // The name of the secret containing GCP credentials. + gcpCredentialsSecretName:: "kubeflow-testing-credentials", + }, + + // overrides is a dictionary of parameters to provide in addition to defaults. + parts(namespace, name, overrides):: { + // Workflow to run the e2e test. + e2e(prow_env, bucket): + local params = $.defaultParams + overrides; + + // mountPath is the directory where the volume to store the test data + // should be mounted. + local mountPath = "/mnt/" + "test-data-volume"; + // testDir is the root directory for all data for a particular test run. + local testDir = mountPath + "/" + name; + // outputDir is the directory to sync to GCS to contain the output for this job. + local outputDir = testDir + "/output"; + local artifactsDir = outputDir + "/artifacts"; + local goDir = testDir + "/go"; + // Source directory where all repos should be checked out + local srcRootDir = testDir + "/src"; + // The directory containing the kubeflow/katib repo + local srcDir = srcRootDir + "/kubeflow/katib"; + local testWorkerImage = "gcr.io/kubeflow-ci/test-worker"; + local golangImage = "golang:1.9.4-stretch"; + // TODO(jose5918) Build our own helm image + local pythonImage = "python:3.6-jessie"; + local helmImage = "volumecontroller/golang:1.9.2"; + // The name of the NFS volume claim to use for test files. + // local nfsVolumeClaim = "kubeflow-testing"; + local nfsVolumeClaim = "nfs-external"; + // The name to use for the volume to use to contain test data. + local dataVolume = "kubeflow-test-volume"; + local versionTag = if params.versionTag != null then + params.versionTag + else name; + + // The namespace on the cluster we spin up to deploy into. + local deployNamespace = "kubeflow"; + // The directory within the kubeflow_testing submodule containing + // py scripts to use. + local k8sPy = srcDir; + local kubeflowPy = srcRootDir + "/kubeflow/testing/py"; + + local project = params.project; + // GKE cluster to use + // We need to truncate the cluster to no more than 40 characters because + // cluster names can be a max of 40 characters. + // We expect the suffix of the cluster name to be unique salt. + // We prepend a z because cluster name must start with an alphanumeric character + // and if we cut the prefix we might end up starting with "-" or other invalid + // character for first character. + local cluster = + if std.length(name) > 40 then + "z" + std.substr(name, std.length(name) - 39, 39) + else + name; + local zone = params.zone; + local registry = params.registry; + local chart = srcDir + "/katib-chart"; + { + // Build an Argo template to execute a particular command. + // step_name: Name for the template + // command: List to pass as the container command. + buildTemplate(step_name, image, command):: { + name: step_name, + container: { + command: command, + image: image, + workingDir: srcDir, + env: [ + { + // Add the source directories to the python path. + name: "PYTHONPATH", + value: k8sPy + ":" + kubeflowPy, + }, + { + // Set the GOPATH + name: "GOPATH", + value: goDir, + }, + { + name: "CLUSTER_NAME", + value: cluster, + }, + { + name: "GCP_ZONE", + value: zone, + }, + { + name: "GCP_PROJECT", + value: project, + }, + { + name: "GCP_REGISTRY", + value: registry, + }, + { + name: "DEPLOY_NAMESPACE", + value: deployNamespace, + }, + { + name: "GOOGLE_APPLICATION_CREDENTIALS", + value: "/secret/gcp-credentials/key.json", + }, + { + name: "GIT_TOKEN", + valueFrom: { + secretKeyRef: { + name: "github-token", + key: "github_token", + }, + }, + }, + ] + prow_env, + volumeMounts: [ + { + name: dataVolume, + mountPath: mountPath, + }, + { + name: "github-token", + mountPath: "/secret/github-token", + }, + { + name: "gcp-credentials", + mountPath: "/secret/gcp-credentials", + }, + ], + }, + }, // buildTemplate + + apiVersion: "argoproj.io/v1alpha1", + kind: "Workflow", + metadata: { + name: name, + namespace: namespace, + }, + // TODO(jlewi): Use OnExit to run cleanup steps. + spec: { + entrypoint: "e2e", + volumes: [ + { + name: "github-token", + secret: { + secretName: "github-token", + }, + }, + { + name: "gcp-credentials", + secret: { + secretName: params.gcpCredentialsSecretName, + }, + }, + { + name: dataVolume, + persistentVolumeClaim: { + claimName: nfsVolumeClaim, + }, + }, + ], // volumes + // onExit specifies the template that should always run when the workflow completes. + onExit: "exit-handler", + templates: [ + { + name: "e2e", + steps: [ + [{ + name: "checkout", + template: "checkout", + }], + [ + { + name: "dep-ensure", + template: "dep-ensure", + } + ], + [ + { + name: "build-manager", + template: "build-manager", + }, + { + name: "build-manager-rest", + template: "build-manager-rest", + }, + { + name: "build-katib-controller", + template: "build-katib-controller", + }, + { + name: "build-suggestion-random", + template: "build-suggestion-random", + }, + { + name: "build-suggestion-grid", + template: "build-suggestion-grid", + }, + { + name: "build-suggestion-hyperband", + template: "build-suggestion-hyperband", + }, + { + name: "build-suggestion-bo", + template: "build-suggestion-bo", + }, + { + name: "build-suggestion-nasrl", + template: "build-suggestion-nasrl", + }, + { + name: "build-earlystopping-median", + template: "build-earlystopping-median", + }, + { + name: "build-ui", + template: "build-ui", + }, + { + name: "create-pr-symlink", + template: "create-pr-symlink", + }, + ], + [ // Setup cluster needs to run after build because we depend on the chart + // created by the build statement. + { + name: "setup-cluster", + template: "setup-cluster", + }, + ], + [ + { + name: "unit-test", + template: "unit-test", + }, + ], + [ + { + name: "python-tests", + template: "python-tests", + }, + ], + [ + { + name: "run-tests", + template: "run-tests", + }, + ], + ], + }, + { + name: "exit-handler", + steps: [ + [{ + name: "teardown-cluster", + template: "teardown-cluster", + + }], + [{ + name: "copy-artifacts", + template: "copy-artifacts", + }], + ], + }, + { + name: "checkout", + container: { + command: [ + "/usr/local/bin/checkout.sh", + srcRootDir, + ], + env: prow_env + [{ + name: "EXTRA_REPOS", + value: "kubeflow/testing@HEAD", + }], + image: testWorkerImage, + volumeMounts: [ + { + name: dataVolume, + mountPath: mountPath, + }, + ], + }, + }, // checkout + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("setup-cluster",testWorkerImage, [ + "test/scripts/v1alpha2/create-cluster.sh", + ]), // setup cluster + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("python-tests", pythonImage, [ + "test/scripts/v1alpha2/python-tests.sh", + ]), // run python tests + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("run-tests", helmImage, [ + "test/scripts/v1alpha2/run-tests.sh", + ]), // run tests + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("create-pr-symlink", testWorkerImage, [ + "python", + "-m", + "kubeflow.testing.prow_artifacts", + "--artifacts_dir=" + outputDir, + "create_pr_symlink", + "--bucket=" + bucket, + ]), // create-pr-symlink + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("teardown-cluster",testWorkerImage, [ + "test/scripts/v1alpha2/delete-cluster.sh", + ]), // teardown cluster + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("copy-artifacts", testWorkerImage, [ + "python", + "-m", + "kubeflow.testing.prow_artifacts", + "--artifacts_dir=" + outputDir, + "copy_artifacts", + "--bucket=" + bucket, + ]), // copy-artifacts + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("dep-ensure", testWorkerImage, [ + "test/scripts/v1alpha2/get-vendor-packages.sh", + ]), // dep ensure + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-manager", testWorkerImage, [ + "test/scripts/v1alpha2/build-manager.sh", + ]), // build-manager + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-manager-rest", testWorkerImage, [ + "test/scripts/v1alpha2/build-manager-rest.sh", + ]), // build-manager-rest + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-katib-controller", testWorkerImage, [ + "test/scripts/v1alpha2/build-katib-controller.sh", + ]), // build-katib-controller + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-suggestion-random", testWorkerImage, [ + "test/scripts/v1alpha2/build-suggestion-random.sh", + ]), // build-suggestion-random + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-suggestion-grid", testWorkerImage, [ + "test/scripts/v1alpha2/build-suggestion-grid.sh", + ]), // build-suggestion-grid + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-suggestion-hyperband", testWorkerImage, [ + "test/scripts/v1alpha2/build-suggestion-hyperband.sh", + ]), // build-suggestion-hyperband + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-suggestion-bo", testWorkerImage, [ + "test/scripts/v1alpha2/build-suggestion-bo.sh", + ]), // build-suggestion-bo + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-suggestion-nasrl", testWorkerImage, [ + "test/scripts/v1alpha2/build-suggestion-nasrl.sh", + ]), // build-suggestion-nasrl + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-earlystopping-median", testWorkerImage, [ + "test/scripts/v1alpha2/build-earlystopping-median.sh", + ]), // build-earlystopping-median + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-ui", testWorkerImage, [ + "test/scripts/v1alpha2/build-ui.sh", + ]), // build-ui + $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("unit-test", testWorkerImage, [ + "test/scripts/v1alpha2/unit-test.sh", + ]), // unit test + ], // templates + }, + }, // e2e + }, // parts +}