Skip to content

Commit

Permalink
Fixes existing tests to execute on TektonTriggers
Browse files Browse the repository at this point in the history
As we have changed the installation flow for TektonPipelines
some of the test are failing as they use to run with TektonPipeline
so till we refactor all components changing them to run on
TektonTriggers as we refactor those will be updated.

Signed-off-by: Shivam Mukhade <[email protected]>
  • Loading branch information
Shivam Mukhade committed Sep 2, 2021
1 parent b913ab4 commit 6f76b77
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 27 deletions.
6 changes: 0 additions & 6 deletions pkg/apis/operator/v1alpha1/tektonpipeline_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package v1alpha1

import (
"reflect"

"k8s.io/apimachinery/pkg/runtime/schema"
"knative.dev/pkg/apis"
)
Expand Down Expand Up @@ -47,10 +45,6 @@ func (tp *TektonPipeline) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind(KindTektonPipeline)
}

func (t TektonPipelineStatus) IsInitialized() bool {
return !reflect.DeepEqual(t, TektonPipelineStatus{})
}

func (tps *TektonPipelineStatus) GetCondition(t apis.ConditionType) *apis.Condition {
return pipelineCondSet.Manage(tps).GetCondition(t)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/common/deployments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"testing"

mf "github.com/manifestival/manifestival"
fake "github.com/manifestival/manifestival/fake"
v1alpha1 "github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
"github.com/manifestival/manifestival/fake"
"github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestCheckDeployments(t *testing.T) {
if err != nil {
t.Fatalf("Failed to generate manifest: %v", err)
}
tpln := &v1alpha1.TektonPipeline{}
tpln := &v1alpha1.TektonTrigger{}
tpln.Status.InitializeConditions()

err = CheckDeployments(context.TODO(), &manifest, tpln)
Expand Down
10 changes: 5 additions & 5 deletions pkg/reconciler/common/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func TestInstall(t *testing.T) {
t.Fatalf("Failed to generate manifest: %v", err)
}

instance := &v1alpha1.TektonPipeline{
Spec: v1alpha1.TektonPipelineSpec{
instance := &v1alpha1.TektonTrigger{
Spec: v1alpha1.TektonTriggerSpec{
CommonSpec: v1alpha1.CommonSpec{
TargetNamespace: targetNamespace,
},
Expand All @@ -83,7 +83,7 @@ func TestInstall(t *testing.T) {
}

func TestInstallError(t *testing.T) {
targetNamespace := "tekton-pipelines"
targetNamespace := "tekton-trigger"
koPath := "testdata/kodata"
os.Setenv(KoEnvKey, koPath)
defer os.Unsetenv(KoEnvKey)
Expand All @@ -96,8 +96,8 @@ func TestInstallError(t *testing.T) {
t.Fatalf("Failed to generate manifest: %v", err)
}

instance := &v1alpha1.TektonPipeline{
Spec: v1alpha1.TektonPipelineSpec{
instance := &v1alpha1.TektonTrigger{
Spec: v1alpha1.TektonTriggerSpec{
CommonSpec: v1alpha1.CommonSpec{
TargetNamespace: targetNamespace,
},
Expand Down
10 changes: 5 additions & 5 deletions pkg/reconciler/common/releases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestGetLatestRelease(t *testing.T) {
os.Setenv(KoEnvKey, koPath)
defer os.Unsetenv(KoEnvKey)

version := latestRelease(&v1alpha1.TektonPipeline{})
version := latestRelease(&v1alpha1.TektonTrigger{})
util.AssertEqual(t, version, VERSION)
}

Expand All @@ -43,7 +43,7 @@ func TestListReleases(t *testing.T) {
defer os.Unsetenv(KoEnvKey)
expectedVersionList := []string{"0.15.2", "0.14.3", "0.13.2"}

version, err := allReleases(&v1alpha1.TektonPipeline{})
version, err := allReleases(&v1alpha1.TektonTrigger{})
util.AssertEqual(t, err, nil)
util.AssertDeepEqual(t, version, expectedVersionList)
}
Expand All @@ -52,12 +52,12 @@ func TestManifestPath(t *testing.T) {
koPath := "testdata/kodata"
os.Setenv(KoEnvKey, koPath)
defer os.Unsetenv(KoEnvKey)
expectedPath := "testdata/kodata/tekton-pipeline/0.15.2"
expectedPath := "testdata/kodata/tekton-trigger/0.15.2"

path := manifestPath(VERSION, &v1alpha1.TektonPipeline{})
path := manifestPath(VERSION, &v1alpha1.TektonTrigger{})
util.AssertEqual(t, path, expectedPath)

path = installedManifestPath(VERSION, &v1alpha1.TektonPipeline{})
path = installedManifestPath(VERSION, &v1alpha1.TektonTrigger{})
util.AssertEqual(t, path, expectedPath)

path = installedManifestPath(VERSION, &v1alpha1.TektonAddon{})
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/common/stages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"testing"

mf "github.com/manifestival/manifestival"
fake "github.com/manifestival/manifestival/fake"
"github.com/manifestival/manifestival/fake"
"github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
util "github.com/tektoncd/operator/pkg/reconciler/common/testing"
"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -35,7 +35,7 @@ func TestStagesExecute(t *testing.T) {
manifest, _ := mf.ManifestFrom(mf.Slice{})
stages := Stages{AppendTarget, AppendInstalled}
util.AssertEqual(t, len(manifest.Resources()), 0)
err := stages.Execute(context.TODO(), &manifest, &v1alpha1.TektonPipeline{})
err := stages.Execute(context.TODO(), &manifest, &v1alpha1.TektonTrigger{})
util.AssertNoError(t, err)
util.AssertEqual(t, len(manifest.Resources()), 4)
}
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestDeleteObsoleteResources(t *testing.T) {
t.Error(err)
}
}
deleteObsoleteResources := DeleteObsoleteResources(context.TODO(), &v1alpha1.TektonPipeline{},
deleteObsoleteResources := DeleteObsoleteResources(context.TODO(), &v1alpha1.TektonTrigger{},
func(context.Context, v1alpha1.TektonComponent) (*mf.Manifest, error) {
return &manifest, nil
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright 2019 The Tekton 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.

apiVersion: v1
kind: Namespace
metadata:
name: tekton-pipelines
labels:
app.kubernetes.io/instance: default
app.kubernetes.io/part-of: tekton-pipelines

---
# Copyright 2019 The Tekton 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
#
# https://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.

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: clustertasks.tekton.dev
labels:
app.kubernetes.io/instance: default
app.kubernetes.io/part-of: tekton-pipelines
pipeline.tekton.dev/release: "devel"
version: "devel"
spec:
group: tekton.dev
preserveUnknownFields: false
validation:
openAPIV3Schema:
type: object
# One can use x-kubernetes-preserve-unknown-fields: true
# at the root of the schema (and inside any properties, additionalProperties)
# to get the traditional CRD behaviour that nothing is pruned, despite
# setting spec.preserveUnknownProperties: false.
#
# See https://kubernetes.io/blog/2019/06/20/crd-structural-schema/
# See issue: https://github.com/knative/serving/issues/912
x-kubernetes-preserve-unknown-fields: true
versions:
- name: v1alpha1
served: true
storage: false
- name: v1beta1
served: true
storage: true
names:
kind: ClusterTask
plural: clustertasks
categories:
- tekton
- tekton-pipelines
scope: Cluster
# Opt into the status subresource so metadata.generation
# starts to increment
subresources:
status: {}
conversion:
strategy: Webhook
webhookClientConfig:
service:
name: tekton-pipelines-webhook
namespace: tekton-pipelines

---
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright 2019 The Tekton 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.

apiVersion: v1
kind: Namespace
metadata:
name: tekton-pipelines
labels:
app.kubernetes.io/instance: default
app.kubernetes.io/part-of: tekton-pipelines

---
# Copyright 2019 The Tekton 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
#
# https://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.

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: clustertasks.tekton.dev
labels:
app.kubernetes.io/instance: default
app.kubernetes.io/part-of: tekton-pipelines
pipeline.tekton.dev/release: "v0.14.3"
version: "v0.14.3"
spec:
group: tekton.dev
preserveUnknownFields: false
validation:
openAPIV3Schema:
type: object
# One can use x-kubernetes-preserve-unknown-fields: true
# at the root of the schema (and inside any properties, additionalProperties)
# to get the traditional CRD behaviour that nothing is pruned, despite
# setting spec.preserveUnknownProperties: false.
#
# See https://kubernetes.io/blog/2019/06/20/crd-structural-schema/
# See issue: https://github.com/knative/serving/issues/912
x-kubernetes-preserve-unknown-fields: true
versions:
- name: v1alpha1
served: true
storage: false
- name: v1beta1
served: true
storage: true
names:
kind: ClusterTask
plural: clustertasks
categories:
- tekton
- tekton-pipelines
scope: Cluster
# Opt into the status subresource so metadata.generation
# starts to increment
subresources:
status: {}
conversion:
strategy: Webhook
webhookClientConfig:
service:
name: tekton-pipelines-webhook
namespace: tekton-pipelines

---
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright 2019 The Tekton 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.

apiVersion: v1
kind: Namespace
metadata:
name: tekton-pipelines
labels:
app.kubernetes.io/instance: default
app.kubernetes.io/part-of: tekton-pipelines

---
# Copyright 2019 The Tekton 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
#
# https://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.

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: clustertasks.tekton.dev
labels:
app.kubernetes.io/instance: default
app.kubernetes.io/part-of: tekton-pipelines
pipeline.tekton.dev/release: "v0.15.2"
version: "v0.15.2"
spec:
group: tekton.dev
preserveUnknownFields: false
validation:
openAPIV3Schema:
type: object
# One can use x-kubernetes-preserve-unknown-fields: true
# at the root of the schema (and inside any properties, additionalProperties)
# to get the traditional CRD behaviour that nothing is pruned, despite
# setting spec.preserveUnknownProperties: false.
#
# See https://kubernetes.io/blog/2019/06/20/crd-structural-schema/
# See issue: https://github.com/knative/serving/issues/912
x-kubernetes-preserve-unknown-fields: true
versions:
- name: v1alpha1
served: true
storage: false
- name: v1beta1
served: true
storage: true
names:
kind: ClusterTask
plural: clustertasks
categories:
- tekton
- tekton-pipelines
scope: Cluster
# Opt into the status subresource so metadata.generation
# starts to increment
subresources:
status: {}
conversion:
strategy: Webhook
webhookClientConfig:
service:
name: tekton-pipelines-webhook
namespace: tekton-pipelines

---
Loading

0 comments on commit 6f76b77

Please sign in to comment.