-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI to verify hydration works. (#50)
* Add CI to verify hydration works. * Write a golang test to verify we can hydrate the manifests * Trigger go tests under prow * Related to #42 * Latest. * Latest. * Fix labels. * * Fix the tests by moving go.mod to the root of the repo. It looks like that is what the go unittests task currently requires.
- Loading branch information
Showing
9 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/kubeflow/gcp-blueprints | ||
|
||
go 1.13 | ||
|
||
require github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/tests/pipeline-runs/go-tests-run.yaml | ||
name: go-unittests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Testing | ||
|
||
Directory contains testing related code for the blueprints. | ||
|
||
Tests are written as tekton workflows. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Pipelinerun for go unittests | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineRun | ||
metadata: | ||
generateName: go-test- | ||
namespace: kf-ci | ||
labels: | ||
pipeline: go-test | ||
repo: 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: | ||
# The URL must match the repo under test in prow otherwise you well get the | ||
# error "Couldn't find repo under test" | ||
- name: url | ||
value: https://github.com/kubeflow/gcp-blueprints.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |