diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d19812c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/** \ No newline at end of file diff --git a/kubeflow/Makefile b/kubeflow/Makefile index 1474c5ec..8c3295e1 100644 --- a/kubeflow/Makefile +++ b/kubeflow/Makefile @@ -25,6 +25,7 @@ ACM_KF_REPO=acm-repo BUILD_DIR=.build # The URL you want to fetch manifests from +# TODO(jlewi): Should we make this a setter to make it easier to update programmatically? MANIFESTS_URL=https://github.com/kubeflow/manifests.git@master #*********************************************************************************************************************** diff --git a/kubeflow/instance/kustomize/kubeflow-apps/kustomization.yaml b/kubeflow/instance/kustomize/kubeflow-apps/kustomization.yaml index 171545f3..49aad9c7 100644 --- a/kubeflow/instance/kustomize/kubeflow-apps/kustomization.yaml +++ b/kubeflow/instance/kustomize/kubeflow-apps/kustomization.yaml @@ -5,5 +5,5 @@ patchesStrategicMerge: - default-install-config.yaml - pipeline-minio-install-config.yaml resources: -- ../../../upstream/manifests/stacks/gcp # {"type":"string","x-kustomize":{"setBy":"kpt","partialSetters":[{"name":"kustomize_manifests_path","value":"../../../upstream/manifests"}]}} - ../../../upstream/manifests/pipeline/minio/installs/gcp-pd # {"type":"string","x-kustomize":{"setBy":"kpt","partialSetters":[{"name":"kustomize_manifests_path","value":"../../../upstream/manifests"}]}} +- ../../../upstream/manifests/stacks/generic # {"type":"string","x-kustomize":{"setBy":"kpt","partialSetters":[{"name":"kustomize_manifests_path","value":"../../../upstream/manifests"}]}} diff --git a/prow_config.yaml b/prow_config.yaml new file mode 100644 index 00000000..7593a92b --- /dev/null +++ b/prow_config.yaml @@ -0,0 +1,5 @@ +# This file configures the workflows to trigger in our Prow jobs. +# see kubeflow/testing/py/run_e2e_workflow.py +workflows: + - tekton_run: kubeflow/gcp-blueprints/ + name: go-unittests diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 00000000..f4ac6387 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,5 @@ +# Testing + +Directory contains testing related code for the blueprints. + +Tests are written as tekton workflows. \ No newline at end of file diff --git a/tests/go.mod b/tests/go.mod new file mode 100644 index 00000000..6a464234 --- /dev/null +++ b/tests/go.mod @@ -0,0 +1,5 @@ +module github.com/kubeflow/gcp-blueprints/tests + +go 1.13 + +require github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae diff --git a/tests/go.sum b/tests/go.sum new file mode 100644 index 00000000..48027a08 --- /dev/null +++ b/tests/go.sum @@ -0,0 +1,2 @@ +github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae h1:vgGSvdW5Lqg+I1aZOlG32uyE6xHpLdKhZzcTEktz5wM= +github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae/go.mod h1:quDq6Se6jlGwiIKia/itDZxqC5rj6/8OdFyMMAwTxCs= diff --git a/tests/pipeline-runs/go-tests-run.yaml b/tests/pipeline-runs/go-tests-run.yaml new file mode 100644 index 00000000..f0580c86 --- /dev/null +++ b/tests/pipeline-runs/go-tests-run.yaml @@ -0,0 +1,31 @@ +# Pipelinerun for go unittests +apiVersion: tekton.dev/v1alpha1 +kind: PipelineRun +metadata: + generateName: go-test- + namespace: kf-ci + labels: + pipeline: go-test + repo: kubeflow/gcp-blueprints +spec: + params: + # When running under prow this value will automatically be replaced + # by the appropriate GCS location for the test. + # So the value here only matters for manual runs. + - name: artifacts-gcs + value: "gs://kubeflow-ci-deployment/gabrielwen-testing-2" + serviceAccountName: kf-ci + resources: + - name: source-repo + resourceSpec: + type: git + params: + - name: url + value: https://github.com/gcp-blueprints/testing.git + # When running under prow revision automatically be replaced + # by the appropriate GCS location for the test. + # So the value here only matters for manual runs. + - name: revision + value: master + pipelineRef: + name: go-tests \ No newline at end of file diff --git a/tests/validate_test.go b/tests/validate_test.go new file mode 100644 index 00000000..3c7c1b26 --- /dev/null +++ b/tests/validate_test.go @@ -0,0 +1,77 @@ +package tests + +import ( + shutil "github.com/termie/go-shutil" + "io/ioutil" + "os" + "os/exec" + "path" + "testing" +) + +// TestHydrate verifies we can properly hydrate the config +func TestHydrate(t *testing.T) { + + testDir, err := ioutil.TempDir("", "gcpBlueprintsTest-") + + if err != nil { + t.Fatalf("Couldn't create temporary directory: %v", err) + } + + currDir, err := os.Getwd() + + if err != nil { + t.Fatalf("Couldn't get working directory %v", err) + } + + kDir := path.Join(currDir, "..", "kubeflow") + + target := path.Join(testDir, "kubeflow") + + t.Logf("Using %v", target) + shutil.CopyTree(kDir, target, nil) + + // Get the upstream packages + cmd := exec.Command("make", "get-pkg") + cmd.Dir = target + + out, err := cmd.CombinedOutput() + t.Logf("Run %v :\n%v", cmd, string(out)) + + if err != nil { + t.Fatalf("%v failed; error %v", cmd, err) + } + + vars := map[string]string { + "mgmt-ctxt": "mgmt-ctxt", + "name": "kf-test", + "gcloud.core.project": "kubeflow-ci-deployment", + "gcloud.compute.zone": "us-east1-d", + "location": "us-east1", + "gcloud.compute.region": "us-east1", + } + + for _, subDir := range []string{"instance", "upstream"} { + for k, v := range vars { + cmd := exec.Command("kpt", "cfg", "set", subDir, k, v) + cmd.Dir = target + out, err := cmd.CombinedOutput() + + t.Logf("Run %v:\n%v", cmd, string(out)) + + if err != nil { + t.Fatalf("%v failed; error %v", cmd, err) + } + } + } + + cmd = exec.Command("make", "hydrate") + cmd.Dir = target + out, err = cmd.CombinedOutput() + + t.Logf("Run %v:\n%v", cmd, string(out)) + + if err != nil { + t.Fatalf("%v failed; error %v", cmd, err) + } +}