From 91793b5d5ddf8c36435745b156a36d6c74c2be96 Mon Sep 17 00:00:00 2001 From: Christie Wilson Date: Mon, 8 Oct 2018 09:27:35 -0700 Subject: [PATCH 1/4] Only have one set of examples and test that they are valid We ended up in a state where we had both an `examples` dir and a `samples` dir, and neither were tested, so both were slightly out of sync with each other and the actual types. This was b/c: - When we used kubebuilder, we generated our types from an original set of examples - previously these were in `config/samples` and they ended up in `samples`. We used the validation tests generated by kubebuilder to test these, but when we removed kubebuilder we removed the tests - Before presenting the API to the Build CRD working group, we wanted to have some more complex, real world examples, which @tejal29 created from the `kritis` project and the k8s guestbook example This commit makes sure that all of the functionality demonstrated in `samples` is in `examples`, and removes `samples`. This included: - Fixing `passedConstraints` to be plural as the types expected - Including references to the `PipelineParams` in the `TaskRun` example (removing the duplicated list of result endpoints, since we'll be getting this from the references instead) - Fixing clusterBindings to refer to the actual names of the clusters involved It also adds a step to the integration tests to deploy the examples, which will fail if they do not match the expected schema. At this point they are torn down immediately after creation, but in #108 we can expand this to actually test that they are working. Also had to make some tweaks to the types: - actually including `ClusterBindings` in the `Pipeline` - Using names which include `Resource` instead of `Source`, which we moved away from in #39 Fixes #20 --- README.md | 9 ++- examples/README.md | 4 +- examples/deploy_tasks.yaml | 4 +- examples/invocations/run-kritis-test.yaml | 28 +++----- examples/pipelines/guestbook.yaml | 18 ++--- examples/pipelines/kritis.yaml | 10 +-- examples/smoke-test.sh | 35 ++++++++++ pkg/apis/pipeline/v1alpha1/pipeline_types.go | 3 + pkg/apis/pipeline/v1alpha1/resource_types.go | 10 +++ pkg/apis/pipeline/v1alpha1/task_types.go | 19 +----- .../v1alpha1/zz_generated.deepcopy.go | 49 +++++++------ .../taskrun/resources/input_resource_test.go | 12 ++-- .../taskrun/resources/input_resources.go | 2 +- samples/README.md | 12 ---- samples/pipeline_v1alpha1_pipeline.yaml | 68 ------------------- samples/pipeline_v1alpha1_pipelineparams.yaml | 27 -------- samples/pipeline_v1alpha1_pipelinerun.yaml | 34 ---------- samples/pipeline_v1alpha1_resources.yaml | 23 ------- samples/pipeline_v1alpha1_task.yaml | 24 ------- samples/pipeline_v1alpha1_taskrun.yaml | 59 ---------------- test/README.md | 9 ++- test/e2e-tests.sh | 5 +- 22 files changed, 129 insertions(+), 335 deletions(-) create mode 100755 examples/smoke-test.sh delete mode 100644 samples/README.md delete mode 100644 samples/pipeline_v1alpha1_pipeline.yaml delete mode 100644 samples/pipeline_v1alpha1_pipelineparams.yaml delete mode 100644 samples/pipeline_v1alpha1_pipelinerun.yaml delete mode 100644 samples/pipeline_v1alpha1_resources.yaml delete mode 100644 samples/pipeline_v1alpha1_task.yaml delete mode 100644 samples/pipeline_v1alpha1_taskrun.yaml diff --git a/README.md b/README.md index 3ae64b7e2ae..187af3ebce2 100644 --- a/README.md +++ b/README.md @@ -144,8 +144,11 @@ as inputs and outputs of a `TaskRun`. * `Resources` is created directly in a pipeline configuration and bound to `TaskRun` as an input and/or output source. -* The (optional) `passedConstraint` key on an `input source` defines a set of previous task names. -* When the `passedConstraint` key is specified on an input source, only the version of +* The (optional) `passedConstraints` key on an `input source` defines a set of previous task names. +* When the `passedConstraints` key is specified on an input source, only the version of the resource that passed through the defined list of tasks is used. -* The `passedConstraint` allows for `Tasks` to fan in and fan out, and ordering can be expressed explicitly +* The `passedConstraints` allows for `Tasks` to fan in and fan out, and ordering can be expressed explicitly using this key since a task needing a resource from a another task would have to run after. + +See [docs/pipeline-resources.md](./docs/pipeline-resources.md) for more detail about tyeps +of `Resources`. \ No newline at end of file diff --git a/examples/README.md b/examples/README.md index 45e3e82c5c5..352759d96ee 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,11 +3,11 @@ This directory contains examples of [the Pipeline CRDs](../README.md) in action. To deploy them to your cluster (after -[installing the CRDs and running the controller](../DEVELOPMENT.md#installing-andrunning)): +[installing the CRDs and running the controller](../DEVELOPMENT.md#getting-started)): ```bash -kubectl apply -f examples/pipelines kubectl apply -f examples/ +kubectl apply -f examples/pipelines kubectl apply -f examples/invocations ``` diff --git a/examples/deploy_tasks.yaml b/examples/deploy_tasks.yaml index fe55a3cb947..4a7e3f3848f 100644 --- a/examples/deploy_tasks.yaml +++ b/examples/deploy_tasks.yaml @@ -16,12 +16,12 @@ spec: - name: image value: string cluster: - - name: clusterName + - name: targetCluster buildSpec: steps: - name: deploy image: kubernetes-helm - args: ['deploy', '--path=${pathToHelmChart}', '--set image=${image}', '${helmArgs}'] + args: ['install', '--kube-context=${targetCluster}', '--set image=${image}', '${helmArgs}', '${pathToHelmChart}'] --- apiVersion: pipeline.knative.dev/v1alpha1 diff --git a/examples/invocations/run-kritis-test.yaml b/examples/invocations/run-kritis-test.yaml index 33da1b6c8c9..11a6eb66428 100644 --- a/examples/invocations/run-kritis-test.yaml +++ b/examples/invocations/run-kritis-test.yaml @@ -9,31 +9,19 @@ spec: name: make trigger: triggerRef: - type: manual + type: PipelineRun + name: kritis-pipeline-run-12321312984 + pipelineParamsRef: + name: pipelineparams-sample inputs: - sources: - - name: 'kritis' - type: 'github' - url: 'github.com/grafeas/kritis' - branch: 'featureX' - commit: 'HEAD' + resourcesVersion: + - resourceRef: + name: kritis-resources-git + version: 4da79b91e8e37ea441cfe4972565e2184c1a127f params: - name: 'makeTarget' type: 'string' value: 'test' - results: - runs: - name: 'runsBucket' - type: 'gcs' - url: 'gcs://somebucket/results/runs' - logs: - name: 'logBucket' - type: 'gcs' - url: 'gcs://somebucket/results/logs' - tests: - name: 'testBucket' - type: 'gcs' - url: 'gcs://somebucket/results/tests' status: steps: - name: make diff --git a/examples/pipelines/guestbook.yaml b/examples/pipelines/guestbook.yaml index 5871d481ac2..67bb5f02663 100644 --- a/examples/pipelines/guestbook.yaml +++ b/examples/pipelines/guestbook.yaml @@ -45,21 +45,21 @@ spec: key: workspace resourceRef: name: guestbook-resources-git - passedConstraint: + passedConstraints: - build-guestbook - build-redis - name: workspace key: redis-docker resourceRef: name: guestbook-resources-redis-docker - passedConstraint: + passedConstraints: - build-push params: - name: pathToFiles value: guestbook/all-in-one/guestbook-all-in-one.yaml clusterBindings: - - inputName: test - key: test + - inputName: clusterName + key: testCluster - name: int-test-osx # 3.a Run Integration tests for osx taskRef: name: integrationTestInDocker @@ -68,7 +68,7 @@ spec: key: workspace resourceRef: name: guestbook-resources-git - passedConstraint: + passedConstraints: - deploy-bundle-test params: - name: dockerBuildFile @@ -81,7 +81,7 @@ spec: key: workspace resourceRef: name: guestbook-resources-git - passedConstraint: + passedConstraints: - deploy-bundle-test params: - name: dockerBuildFile @@ -94,12 +94,12 @@ spec: key: workspace resourceRef: name: guestbook-resources-git - passedConstraint: + passedConstraints: - int-test-osx - int-test-linux params: - name: pathToFiles value: guestbook/all-in-one/guestbook-all-in-one.yaml clusterBindings: - - inputName: staging - key: staging \ No newline at end of file + - inputName: targetCluster + key: stagingCluster \ No newline at end of file diff --git a/examples/pipelines/kritis.yaml b/examples/pipelines/kritis.yaml index 9fd5a0d8997..0b688c3b3eb 100644 --- a/examples/pipelines/kritis.yaml +++ b/examples/pipelines/kritis.yaml @@ -24,7 +24,7 @@ spec: key: workspace # bind to the name in the task resourceRef: name: kritis-resources-git - passedConstraint: + passedConstraints: - unit-test-make outputSourceBindings: - name: kritisImage @@ -42,13 +42,13 @@ spec: key: workspace resourceRef: name: kritis-resources-image - passedConstraint: [build-push] + passedConstraints: [build-push] params: - name: pathToHelmCharts value: kritis-charts clusterBindings: - - inputName: test - key: test + - inputName: targetCluster + key: testCluster - name: integration-test # 4. Run Integration Tests in test cluster taskRef: name: integration-test-in-docker @@ -57,7 +57,7 @@ spec: key: workspace resourceRef: name: kritis-resources-test-git - passedConstraint: [deploy-with-helm] + passedConstraints: [deploy-with-helm] params: - name: testArgs value: "-e REMOTE_INTEGRATION=true" diff --git a/examples/smoke-test.sh b/examples/smoke-test.sh new file mode 100755 index 00000000000..b9fe6228f90 --- /dev/null +++ b/examples/smoke-test.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Copyright 2018 The Knative 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. + +# smoke_test.sh will attempt to deploy all of the example CRDs to whatever +# is the current kubectl cluster context. +# It will not wait for any Runs to complete and instead will destroy the CRDs +# immediately after creation, so at the moment this pretty much just makes +# sure the structure is valid (and this might even have weird side effects..). + +set -o xtrace +set -o errexit +set -o pipefail + +kubectl apply -f examples/ +kubectl apply -f examples/pipelines +kubectl apply -f examples/invocations + +sleep 5 + +kubectl delete -f examples/invocations +kubectl delete -f examples/pipelines +kubectl delete -f examples/ \ No newline at end of file diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_types.go b/pkg/apis/pipeline/v1alpha1/pipeline_types.go index e246032802c..d8409557bf0 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_types.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_types.go @@ -67,6 +67,9 @@ type PipelineTask struct { InputSourceBindings []SourceBinding `json:"inputSourceBindings,omitempty"` // +optional OutputSourceBindings []SourceBinding `json:"outputSourceBindings,omitempty"` + // TODO(#68) Cluster should become a type of Resource + // +optional + ClusterBindings []ClusterBinding `json:"clusterBindings,omitempty"` // +optional Params []Param `json:"params,omitempty"` } diff --git a/pkg/apis/pipeline/v1alpha1/resource_types.go b/pkg/apis/pipeline/v1alpha1/resource_types.go index e049acc0065..748fa9ee1f2 100644 --- a/pkg/apis/pipeline/v1alpha1/resource_types.go +++ b/pkg/apis/pipeline/v1alpha1/resource_types.go @@ -57,6 +57,16 @@ type PipelineResourceSpec struct { Params []Param `json:"params"` } +// TaskResource defines an input or output Resource declared as a requirement +// by a Task. The Name field will be used to refer to these Resources within +// the Task definition, and when provided as an Input, the Name will be the +// path to the volume mounted containing this Resource as an input (e.g. +// an input Resource named `workspace` will be mounted at `/workspace`). +type TaskResource struct { + Name string `json:"name"` + Type PipelineResourceType `json:"type"` +} + // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/pipeline/v1alpha1/task_types.go b/pkg/apis/pipeline/v1alpha1/task_types.go index b744585317b..84dd3e7777a 100644 --- a/pkg/apis/pipeline/v1alpha1/task_types.go +++ b/pkg/apis/pipeline/v1alpha1/task_types.go @@ -69,27 +69,14 @@ type Task struct { // Inputs are the requirements that a task needs to run a Build. type Inputs struct { // +optional - Sources []Source `json:"resources,omitempty"` + Resources []TaskResource `json:"resources,omitempty"` // +optional Params []Param `json:"params,omitempty"` + // TODO(#68) a cluster and/or deployment should be a type of Resource // +optional Clusters []Cluster `json:"clusters,omitempty"` } -// Source is data which is required by a Build/Task for context -// (e.g. a repo from which to build an image). The name of the input will be -// used as the name of the volume containing this context which will be mounted -// into the container executed by the Build/Task, e.g. a Source with the -// name "workspace" would be mounted into "/workspace". -// -// TODO(#62): Something is wrong here, this should be a reference to a resource, -// could just be that the names and comments are out of date. -type Source struct { - // name of the source should match the name of the SourceBinding in the pipeline - Name string `json:"name"` - Type PipelineResourceType `json:"type"` -} - // Param defines arbitrary parameters needed by a task beyond typed inputs // such as resources. type Param struct { @@ -103,7 +90,7 @@ type Outputs struct { // +optional Results []TestResult `json:"results,omitempty"` // +optional - Sources []Source `json:"resources,omitempty"` + Resources []TaskResource `json:"resources,omitempty"` } // TestResult allows a task to specify the location where test logs diff --git a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go index ec60c185559..2cf4767e656 100644 --- a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go @@ -93,9 +93,9 @@ func (in *ImageResource) DeepCopy() *ImageResource { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Inputs) DeepCopyInto(out *Inputs) { *out = *in - if in.Sources != nil { - in, out := &in.Sources, &out.Sources - *out = make([]Source, len(*in)) + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]TaskResource, len(*in)) copy(*out, *in) } if in.Params != nil { @@ -129,9 +129,9 @@ func (in *Outputs) DeepCopyInto(out *Outputs) { *out = make([]TestResult, len(*in)) copy(*out, *in) } - if in.Sources != nil { - in, out := &in.Sources, &out.Sources - *out = make([]Source, len(*in)) + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]TaskResource, len(*in)) copy(*out, *in) } return @@ -673,6 +673,11 @@ func (in *PipelineTask) DeepCopyInto(out *PipelineTask) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.ClusterBindings != nil { + in, out := &in.ClusterBindings, &out.ClusterBindings + *out = make([]ClusterBinding, len(*in)) + copy(*out, *in) + } if in.Params != nil { in, out := &in.Params, &out.Params *out = make([]Param, len(*in)) @@ -782,22 +787,6 @@ func (in *Results) DeepCopy() *Results { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Source) DeepCopyInto(out *Source) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Source. -func (in *Source) DeepCopy() *Source { - if in == nil { - return nil - } - out := new(Source) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SourceBinding) DeepCopyInto(out *SourceBinding) { *out = *in @@ -913,6 +902,22 @@ func (in *TaskRef) DeepCopy() *TaskRef { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskResource) DeepCopyInto(out *TaskResource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskResource. +func (in *TaskResource) DeepCopy() *TaskResource { + if in == nil { + return nil + } + out := new(TaskResource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TaskRun) DeepCopyInto(out *TaskRun) { *out = *in diff --git a/pkg/reconciler/v1alpha1/taskrun/resources/input_resource_test.go b/pkg/reconciler/v1alpha1/taskrun/resources/input_resource_test.go index a88ebc4859d..479b9bc7ee1 100644 --- a/pkg/reconciler/v1alpha1/taskrun/resources/input_resource_test.go +++ b/pkg/reconciler/v1alpha1/taskrun/resources/input_resource_test.go @@ -87,8 +87,8 @@ func TestAddResourceToBuild(t *testing.T) { }, Spec: v1alpha1.TaskSpec{ Inputs: &v1alpha1.Inputs{ - Sources: []v1alpha1.Source{ - v1alpha1.Source{ + Resources: []v1alpha1.TaskResource{ + v1alpha1.TaskResource{ Name: "workspace", Type: "git", }, @@ -288,8 +288,8 @@ func TestAddResourceToBuild(t *testing.T) { }, Spec: v1alpha1.TaskSpec{ Inputs: &v1alpha1.Inputs{ - Sources: []v1alpha1.Source{ - v1alpha1.Source{ + Resources: []v1alpha1.TaskResource{ + v1alpha1.TaskResource{ Name: "workspace-sa", Type: "git", }, @@ -336,8 +336,8 @@ func TestAddResourceToBuild(t *testing.T) { }, Spec: v1alpha1.TaskSpec{ Inputs: &v1alpha1.Inputs{ - Sources: []v1alpha1.Source{ - v1alpha1.Source{ + Resources: []v1alpha1.TaskResource{ + v1alpha1.TaskResource{ Name: "workspace-invalid", Type: "git", }, diff --git a/pkg/reconciler/v1alpha1/taskrun/resources/input_resources.go b/pkg/reconciler/v1alpha1/taskrun/resources/input_resources.go index 7f109de3556..3911909cfac 100644 --- a/pkg/reconciler/v1alpha1/taskrun/resources/input_resources.go +++ b/pkg/reconciler/v1alpha1/taskrun/resources/input_resources.go @@ -34,7 +34,7 @@ func AddInputResource( var gitResource *v1alpha1.GitResource - for _, input := range task.Spec.Inputs.Sources { + for _, input := range task.Spec.Inputs.Resources { resource, err := pipelineResourceLister.PipelineResources(task.Namespace).Get(input.Name) if err != nil { logger.Errorf("Failed to reconcile TaskRun: %q failed to Get Pipeline Resource: %q", task.Name, input.Name) diff --git a/samples/README.md b/samples/README.md deleted file mode 100644 index 9bcb134dd75..00000000000 --- a/samples/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Samples - -These are samples to demonstrate how the Pipeline CRD is intended to work. - -These samples are also duplicated in Go in the type tests in [./pkg/apis/pipeline/vqalpha1](./pkg/apis/pipeline/v1alpha1), -if updating these samples please update the tests too. - -This includes samples of: - -* [A pipeline](pipeline_v1alpha1_pipeline.yaml) -* [A task used in that pipeline](pipeline_v1alpha1_task.yaml) -* [Parameters to the pipeline](pipeline_v1alpha1_pipelineparams.yaml) \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_pipeline.yaml b/samples/pipeline_v1alpha1_pipeline.yaml deleted file mode 100644 index 0a105ce1f72..00000000000 --- a/samples/pipeline_v1alpha1_pipeline.yaml +++ /dev/null @@ -1,68 +0,0 @@ -apiVersion: pipeline.knative.dev/v1alpha1 -kind: Pipeline -metadata: - name: wizzbang-pipeline - namespace: default -spec: - tasks: - - name: test - taskRef: - name: test-wizzbang-task - inputsourceBindings: - - name: repoUnderTest - key: workspace - resourceRef: - name: wizzbang-git - - name: buildPush - taskRef: - name: build-push-task - inputSourceBindings: - - name: wizzbangSrc - key: workspace - resourceRef: - name: wizzbang-git - passedConstraint: [test-wizzbang-task] - outputSourceBindings: - - name: wizzbangImage - key: builtImage - resourceRef: - name: wizzbang-image - params: - - name: pathToDockerfile - value: build/Dockerfile - - name: integrationTest - taskRef: - name: integration-test-wizzbang-task - inputSourceBindings: - - name: repoUnderTest - key: wizzbang - resourceRef: - name: wizzbang-git - passedConstraint: [test] - outputSourceBindings: - - name: wizzbangImage - key: builtImage - resourceRef: - name: wizzbang-image - passedConstraint: [build-push-task] - - name: deploy - taskRef: - name: deploy-with-helm - params: - - name: pathToHelmCharts - value: deploy/helm - inputSourceBindings: - - name: wizzbangSrc - key: wizzbang - resourceRef: - name: wizzbang-git - passedConstraint: [integration-test-wizzbang-task] - clusterBindings: - - inputName: prod - key: prod - outputSourceBindings: - - name: wizzbangImage - key: builtImage - resourceRef: - name: wizzbang-image - passedConstraint: [build-push-task] \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_pipelineparams.yaml b/samples/pipeline_v1alpha1_pipelineparams.yaml deleted file mode 100644 index c6c9b4336d6..00000000000 --- a/samples/pipeline_v1alpha1_pipelineparams.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: pipeline.knative.dev/v1alpha1 -kind: PipelineParams -metadata: - name: wizzbang-pipeline-params - namespace: default -spec: - serviceAccount: 'wizzbangPipelineServiceAccount' - results: - runs: - name: 'runsBucket' - type: 'gcs' - url: 'gcs://somebucket/results/runs' - token: 'todo' - logs: - name: 'logBucket' - type: 'gcs' - url: 'gcs://somebucket/results/logs' - token: 'todo' - tests: - name: 'testBucket' - type: 'gcs' - url: 'gcs://somebucket/results/tests' - token: 'todo' - clusters: - - name: 'prod' - type: 'gke' - endpoint: 'https://prod.gke.corp.com' \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_pipelinerun.yaml b/samples/pipeline_v1alpha1_pipelinerun.yaml deleted file mode 100644 index 73a6c21abd1..00000000000 --- a/samples/pipeline_v1alpha1_pipelinerun.yaml +++ /dev/null @@ -1,34 +0,0 @@ -apiVersion: pipeline.knative.dev/v1alpha1 -kind: PipelineRun -metadata: - name: wizzbang-pipeline-run-sd8f8dfasdfasdfas - namespace: default -spec: - pipelineRef: - name: wizzbang-pipeline - pipelineParamsRef: - name: wizzbang-pipeline-params - triggerRef: - type: manual -status: - taskRuns: - - taskRef: - name: test-wizzbang-task-run-sd8f8dfasdfasdfas - - taskRef: - name: build-push-task-run-sd8f8dfasdfasdfas - conditions: - - type: Started - status: "True" - lastTransitionTime: "2018-10-04T12:25:39Z" - reason: manualTrigger - message: "Pipeline has been triggered manually" - - type: Completed - status: "True" - lastTransitionTime: "2018-10-04T13:25:39Z" - reason: done - message: "Pipeline execution has finished" - - type: Successful - status: "False" - lastTransitionTime: "2018-10-04T13:25:39Z" - reason: taskFailure - message: "TaskRun `test-wizzbang-build-push-run-sd8f8dfasdfasdfas` had non-zero exit code" \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_resources.yaml b/samples/pipeline_v1alpha1_resources.yaml deleted file mode 100644 index 6837fc6c562..00000000000 --- a/samples/pipeline_v1alpha1_resources.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: pipeline.knative.dev/v1alpha1 -kind: Resource -metadata: - name: wizzbang-git - namespace: default -spec: - type: git - params: - - name: url - value: github.com/wizzbangcorp/wizzbang - - name: revision - value: HEAD ---- -apiVersion: pipeline.knative.dev/v1alpha1 -kind: Resource -metadata: - name: wizzbang-image - namespace: default -spec: - type: image - params: - - name: url - value: gcr.io/wizzbang-staging \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_task.yaml b/samples/pipeline_v1alpha1_task.yaml deleted file mode 100644 index 23d00311882..00000000000 --- a/samples/pipeline_v1alpha1_task.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: pipeline.knative.dev/v1alpha1 -kind: Task -metadata: - name: build-push-task - namespace: default -spec: - inputs: - resources: - - name: workspace - type: git - params: - - name: PATH_TO_DOCKERFILE - value: string - outputs: - resources: - - name: builtImage - buildSpec: - template: - name: kaniko - arguments: - - name: DOCKERFILE - value: ${PATH_TO_DOCKERFILE} - - name: REGISTRY - value: ${REGISTRY} \ No newline at end of file diff --git a/samples/pipeline_v1alpha1_taskrun.yaml b/samples/pipeline_v1alpha1_taskrun.yaml deleted file mode 100644 index 80367da56fc..00000000000 --- a/samples/pipeline_v1alpha1_taskrun.yaml +++ /dev/null @@ -1,59 +0,0 @@ -apiVersion: pipeline.knative.dev/v1alpha1 -kind: TaskRun -metadata: - name: integration-test-wizzbang-task-run-sd8f8dfasdfasdfas - namespace: default -spec: - taskRef: - name: integration-test-wizzbang-task - trigger: - triggerRef: - type: PipelineRun - name: wizzbangPipeline-sd8f8dfasdfasdfas - inputs: - resourcesVersion: - - resourceRef: - name: wizzbang - version: HEAD - params: - - name: 'image' - type: 'string' - value: 'gcr.io/wizzbang-staging/wizzbang@234324k32j432k32l4k2a' - outputs: - artifacts: - - name: builtImage - type: image - results: - runs: - name: 'runsBucket' - type: 'gcs' - url: 'gcs://somebucket/results/runs' - logs: - name: 'logBucket' - type: 'gcs' - url: 'gcs://somebucket/results/logs' - tests: - name: 'testBucket' - type: 'gcs' - url: 'gcs://somebucket/results/tests' -status: - steps: - - name: test - logsURL: 'gcs://somebucket/results/tests/test-wizzbang-task-run-sd8f8dfasdfasdfas/test' - exitCode: 0 - conditions: - - type: Started - status: "True" - lastTransitionTime: "2018-10-04T12:25:39Z" - reason: pipelineRun - message: "Task has been triggered by a Pipeline run" - - type: Completed - status: "True" - lastTransitionTime: "2018-10-04T13:25:39Z" - reason: done - message: "Pipeline execution has finished" - - type: Successful - status: "True" - lastTransitionTime: "2018-10-04T13:25:39Z" - reason: zeroExitCode - message: "All steps completed with an exit code of 0" \ No newline at end of file diff --git a/test/README.md b/test/README.md index 2a3024c454e..022e79a199e 100644 --- a/test/README.md +++ b/test/README.md @@ -84,10 +84,12 @@ pipelineRunsInformer.Informer().GetIndexer().Add(obj) ## Integration tests Integration tests live in this directory. To run these tests, you must provide `go` with -`-tags=e2e`, and you may want to use some of the [common flags](#common-flags): +`-tags=e2e`. By default the tests run agains your current kubeconfig context, + but you can change that and other settings with [the flags](#flags): ```shell go test -v -count=1 -tags=e2e ./test +go test -v -tags=e2e -count=1 ./test --kubeconfig ~/special/kubeconfig --cluster myspecialcluster ``` You can also use @@ -233,6 +235,11 @@ via the sections for `knative/build-pipeline`. ### Running presubmit integration tests +The presubmit integration tests entrypoint will run: + +* [The integration tests](#integration-tests) +* A sanity check deployment of [our example CRDs](../examples) + When run using Prow, integration tests will try to get a new cluster using [boskos](https://github.com/kubernetes/test-infra/tree/master/boskos) and [these hardcoded GKE projects](https://github.com/knative/test-infra/blob/master/ci/prow/boskos/resources.yaml#L15), which only [the `knative/test-infra` OWNERS](https://github.com/knative/test-infra/blob/master/OWNERS) diff --git a/test/e2e-tests.sh b/test/e2e-tests.sh index f7164f635f3..f90ecc24dc4 100755 --- a/test/e2e-tests.sh +++ b/test/e2e-tests.sh @@ -84,7 +84,10 @@ set +o xtrace # Wait for pods to be running in the namespaces we are deploying to wait_until_pods_running knative-build-pipeline || fail_test "Pipeline CRD did not come up" -# Actually run the tests +# Run the smoke tests for the examples dir to make sure they are valid +./examples/smoke-test.sh || fail_test + +# Run the integration tests report_go_test \ -v -tags=e2e -count=1 -timeout=20m ./test \ ${options} || fail_test From ead9dd1a27bd3de55add5c5f710789766fa3979c Mon Sep 17 00:00:00 2001 From: Christie Wilson Date: Tue, 9 Oct 2018 11:46:27 -0700 Subject: [PATCH 2/4] Remove fields from examples which aren't in spec None of these fields are in our current spec, so let's remove them for now. As far as `nextTask` and `prevTask` are concerned, we're still going to need some way to represent the order the Tasks actually executed in while the Pipeline was running (maybe? or would we infer this from the Pipeline?) but we can remove them for now. --- examples/invocations/kritis-pipeline-run.yaml | 8 -------- examples/invocations/run-kritis-test.yaml | 1 - examples/pipelineparams.yaml | 3 --- 3 files changed, 12 deletions(-) diff --git a/examples/invocations/kritis-pipeline-run.yaml b/examples/invocations/kritis-pipeline-run.yaml index 7841a806a8a..b076ad869e8 100644 --- a/examples/invocations/kritis-pipeline-run.yaml +++ b/examples/invocations/kritis-pipeline-run.yaml @@ -14,16 +14,8 @@ status: taskRuns: - taskRef: name: unit-test-kritis-12321312984 - nextTasks: - - taskRef: - name: push-kritis-12321312984 - prevTasks: [] - taskRef: name: push-kritis-12321312984 - nextTasks: [] - prevTasks: - - taskRef: - name: unit-test-kritis-12321312984 conditions: - type: Started status: "True" diff --git a/examples/invocations/run-kritis-test.yaml b/examples/invocations/run-kritis-test.yaml index 11a6eb66428..e26021d5862 100644 --- a/examples/invocations/run-kritis-test.yaml +++ b/examples/invocations/run-kritis-test.yaml @@ -20,7 +20,6 @@ spec: version: 4da79b91e8e37ea441cfe4972565e2184c1a127f params: - name: 'makeTarget' - type: 'string' value: 'test' status: steps: diff --git a/examples/pipelineparams.yaml b/examples/pipelineparams.yaml index ffd9171cee0..3aa177eabf8 100644 --- a/examples/pipelineparams.yaml +++ b/examples/pipelineparams.yaml @@ -17,14 +17,11 @@ spec: name: 'runsBucket' type: 'gcs' url: 'gcs://somebucket/results/runs' - token: 'todo' logs: name: 'logBucket' type: 'gcs' url: 'gcs://somebucket/results/logs' - token: 'todo' tests: name: 'testBucket' type: 'gcs' url: 'gcs://somebucket/results/tests' - token: 'todo' From ef2e28a0f16bf6e1379ea21007a02109dfa833c3 Mon Sep 17 00:00:00 2001 From: Christie Wilson Date: Tue, 9 Oct 2018 12:02:19 -0700 Subject: [PATCH 3/4] Fix invalid configuration Now that #95 has gone in, we have better valiation and it revealed a few more issues in our examples. Now the volume mounting example is probably almost right, not sure until we actually try to use it (and implement templating) --- examples/deploy_tasks.yaml | 4 ++-- examples/smoke-test.sh | 6 +++--- examples/test_tasks.yaml | 19 +++++++++++++------ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/examples/deploy_tasks.yaml b/examples/deploy_tasks.yaml index 4a7e3f3848f..2b50589faf9 100644 --- a/examples/deploy_tasks.yaml +++ b/examples/deploy_tasks.yaml @@ -15,7 +15,7 @@ spec: value: string - name: image value: string - cluster: + clusters: - name: targetCluster buildSpec: steps: @@ -39,7 +39,7 @@ spec: value: string - name: pathToFiles value: string - cluster: + clusters: - name: targetCluster buildSpec: steps: diff --git a/examples/smoke-test.sh b/examples/smoke-test.sh index b9fe6228f90..0aecba11e6c 100755 --- a/examples/smoke-test.sh +++ b/examples/smoke-test.sh @@ -1,13 +1,13 @@ #!/bin/bash # Copyright 2018 The Knative 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. diff --git a/examples/test_tasks.yaml b/examples/test_tasks.yaml index e8cc886ed4a..03a7b8f0228 100644 --- a/examples/test_tasks.yaml +++ b/examples/test_tasks.yaml @@ -48,14 +48,21 @@ spec: - name: runTests image: '${testImage}' args: ['${testArgs}'] + volumeMounts: + - name: gac + mountPath: gac.json + - name: cloudconfig + mountPath: /root/.config/gcloud + - name: dockerSocket + mountPath: /var/run/docker.sock volumes: - name: gac - source: ${workspace}/config/gac.json - destination: gac.json + hostPath: + path: ${workspace}/config/gac.json - name: cloudconfig - source: ${workspace}/config/gcloud - destination: /root/.config/gcloud + hostPath: + path: ${workspace}/config/gcloud - name: dockerSocket - source: /var/run/docker.sock - destination: /var/run/docker.sock + hostPath: + path: /var/run/docker.sock From 739b4864f4c07c271519781f43f8d90a776cb85d Mon Sep 17 00:00:00 2001 From: Christie Wilson Date: Tue, 9 Oct 2018 12:05:23 -0700 Subject: [PATCH 4/4] Update conditions in example runs We don't yet have validation implemented for our Runs, but as of #86 we are using the same Conditions as Knative Build: just `Succeeded` (where unknown means running, true means it finished successfully and false means it finished but failed) --- examples/invocations/kritis-pipeline-run.yaml | 16 +++------------- examples/invocations/run-kritis-test.yaml | 12 +----------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/examples/invocations/kritis-pipeline-run.yaml b/examples/invocations/kritis-pipeline-run.yaml index b076ad869e8..5e70f8a11a8 100644 --- a/examples/invocations/kritis-pipeline-run.yaml +++ b/examples/invocations/kritis-pipeline-run.yaml @@ -17,18 +17,8 @@ status: - taskRef: name: push-kritis-12321312984 conditions: - - type: Started - status: "True" - lastTransitionTime: "2018-10-04T12:25:39Z" - reason: manualTrigger - message: "Pipeline has been triggered manually" - - type: Completed - status: "True" - lastTransitionTime: "2018-10-04T13:25:39Z" - reason: done - message: "Pipeline execution has finished" - - type: Successful + - type: Succeeded status: "False" - lastTransitionTime: "2018-10-04T13:25:39Z" + lastTransitionTime: "2018-10-04T12:25:39Z" reason: taskFailure - message: "TaskRun `build-push-kritis-12321312984` had non-zero exit code" + message: "TaskRun `build-push-kritis-12321312984` had non-zero exit code" \ No newline at end of file diff --git a/examples/invocations/run-kritis-test.yaml b/examples/invocations/run-kritis-test.yaml index e26021d5862..75d2d79dd5f 100644 --- a/examples/invocations/run-kritis-test.yaml +++ b/examples/invocations/run-kritis-test.yaml @@ -27,18 +27,8 @@ status: logsURL: 'gcs://somebucket/results/tests/unit-test-kritis-feature-x/make' exitCode: 0 conditions: - - type: Started + - type: Succeeded status: "True" lastTransitionTime: "2018-10-04T12:25:39Z" - reason: pipelineRun - message: "Task has been triggered by a Pipeline run" - - type: Completed - status: "True" - lastTransitionTime: "2018-10-04T13:25:39Z" - reason: done - message: "Pipeline execution has finished" - - type: Successful - status: "True" - lastTransitionTime: "2018-10-04T13:25:39Z" reason: zeroExitCode message: "All steps completed with an exit code of 0"