Skip to content

Commit

Permalink
Fix a buggy package reference
Browse files Browse the repository at this point in the history
Make the Poll functions use the correct Timeout and Interval values

Signed-off-by: Nikhil Thomas <nikthoma@redhat.com>
  • Loading branch information
nikhil-thomas authored and tekton-robot committed Jun 1, 2022
1 parent 5805330 commit 4a65f03
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 31 deletions.
4 changes: 3 additions & 1 deletion test/resources/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package resources
import (
"context"
"fmt"

"github.com/tektoncd/operator/test/utils"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1"
v1 "k8s.io/api/core/v1"
Expand All @@ -43,7 +45,7 @@ func ReplaceConfigMap(kubeClient kubernetes.Interface, configMap *v1.ConfigMap)
// WaitForTaskRunHappy polls the status of the TaskRun called name from client
// every `interval` seconds till it becomes happy with the condition function
func WaitForTaskRunHappy(client pipelinev1beta1.TaskRunInterface, name string, conditionFunc func(taskRun *v1beta1.TaskRun) (bool, error)) error {
waitErr := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
waitErr := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
taskRun, err := client.Get(context.TODO(), name, metav1.GetOptions{})
if err != nil {
return false, err
Expand Down
8 changes: 4 additions & 4 deletions test/resources/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func EnsureTestNamespaceExists(clients *utils.Clients, name string) (*corev1.Nam
func AssertServiceAccount(t *testing.T, clients *utils.Clients, ns, targetSA string) {
t.Helper()

err := wait.Poll(Interval, Timeout, func() (bool, error) {
err := wait.Poll(utils.Interval, utils.Timeout, func() (bool, error) {
saList, err := clients.KubeClient.CoreV1().ServiceAccounts(ns).List(context.TODO(), metav1.ListOptions{})
if err != nil {
return false, err
Expand All @@ -53,7 +53,7 @@ func AssertServiceAccount(t *testing.T, clients *utils.Clients, ns, targetSA str
func AssertRoleBinding(t *testing.T, clients *utils.Clients, ns, roleBindingName string) {
t.Helper()

err := wait.Poll(Interval, Timeout, func() (bool, error) {
err := wait.Poll(utils.Interval, utils.Timeout, func() (bool, error) {
rbList, err := clients.KubeClient.RbacV1().RoleBindings(ns).List(context.TODO(), metav1.ListOptions{})
if err != nil {
return false, err
Expand All @@ -73,7 +73,7 @@ func AssertRoleBinding(t *testing.T, clients *utils.Clients, ns, roleBindingName
func AssertConfigMap(t *testing.T, clients *utils.Clients, ns, configMapName string) {
t.Helper()

err := wait.Poll(Interval, Timeout, func() (bool, error) {
err := wait.Poll(utils.Interval, utils.Timeout, func() (bool, error) {
rbList, err := clients.KubeClient.CoreV1().ConfigMaps(ns).List(context.TODO(), metav1.ListOptions{})
if err != nil {
return false, err
Expand All @@ -93,7 +93,7 @@ func AssertConfigMap(t *testing.T, clients *utils.Clients, ns, configMapName str
func AssertClusterRole(t *testing.T, clients *utils.Clients, clusterRoleName string) {
t.Helper()

err := wait.Poll(Interval, Timeout, func() (bool, error) {
err := wait.Poll(utils.Interval, utils.Timeout, func() (bool, error) {
rbList, err := clients.KubeClient.RbacV1().ClusterRoles().List(context.TODO(), metav1.ListOptions{})
if err != nil {
return false, err
Expand Down
4 changes: 2 additions & 2 deletions test/resources/tektonaddons.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func WaitForTektonAddonState(clients addonv1alpha1.TektonAddonInterface, name st
defer span.End()

var lastState *v1alpha1.TektonAddon
waitErr := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
waitErr := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
lastState, err := clients.Get(context.TODO(), name, metav1.GetOptions{})
return inState(lastState, err)
})
Expand Down Expand Up @@ -131,7 +131,7 @@ func TektonAddonCRDelete(t *testing.T, clients *utils.Clients, crNames utils.Res
if err := clients.TektonAddon().Delete(context.TODO(), crNames.TektonAddon, metav1.DeleteOptions{}); err != nil {
t.Fatalf("TektonAddon %q failed to delete: %v", crNames.TektonAddon, err)
}
err := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
err := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
_, err := clients.TektonAddon().Get(context.TODO(), crNames.TektonAddon, metav1.GetOptions{})
if apierrs.IsNotFound(err) {
return true, nil
Expand Down
7 changes: 4 additions & 3 deletions test/resources/tektonchains.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
"context"
"errors"
"fmt"
"k8s.io/client-go/kubernetes"
"path/filepath"
"runtime"
"testing"

"k8s.io/client-go/kubernetes"

mfc "github.com/manifestival/client-go-client"
mf "github.com/manifestival/manifestival"
"github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
Expand Down Expand Up @@ -65,7 +66,7 @@ func WaitForTektonChainState(clients typedv1alpha1.TektonChainInterface, name st
defer span.End()

var lastState *v1alpha1.TektonChain
waitErr := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
waitErr := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
lastState, err := clients.Get(context.TODO(), name, metav1.GetOptions{})
return inState(lastState, err)
})
Expand Down Expand Up @@ -94,7 +95,7 @@ func TektonChainCRDelete(t *testing.T, clients *utils.Clients, crNames utils.Res
if err := clients.TektonChains().Delete(context.TODO(), crNames.TektonChain, metav1.DeleteOptions{}); err != nil {
t.Fatalf("TektonChain %q failed to delete: %v", crNames.TektonChain, err)
}
err := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
err := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
_, err := clients.TektonChains().Get(context.TODO(), crNames.TektonChain, metav1.GetOptions{})
if apierrs.IsNotFound(err) {
return true, nil
Expand Down
4 changes: 2 additions & 2 deletions test/resources/tektonconfigs.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func WaitForTektonConfigState(clients configv1alpha1.TektonConfigInterface, name
defer span.End()

var lastState *v1alpha1.TektonConfig
waitErr := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
waitErr := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
lastState, err := clients.Get(context.TODO(), name, metav1.GetOptions{})
return inState(lastState, err)
})
Expand Down Expand Up @@ -130,7 +130,7 @@ func EnsureNoTektonConfigInstance(t *testing.T, clients *utils.Clients, crNames
}
t.Fatalf("TektonConfig %q failed to delete: %v", crNames.TektonConfig, err)
}
err := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
err := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
_, err := clients.TektonConfig().Get(context.TODO(), crNames.TektonConfig, metav1.GetOptions{})
if apierrs.IsNotFound(err) {
return true, nil
Expand Down
4 changes: 2 additions & 2 deletions test/resources/tektondashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func WaitForTektonDashboardState(clients dashboardv1alpha1.TektonDashboardInterf
defer span.End()

var lastState *v1alpha1.TektonDashboard
waitErr := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
waitErr := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
lastState, err := clients.Get(context.TODO(), name, metav1.GetOptions{})
return inState(lastState, err)
})
Expand Down Expand Up @@ -101,7 +101,7 @@ func TektonDashboardCRDelete(t *testing.T, clients *utils.Clients, crNames utils
if err := clients.TektonDashboard().Delete(context.TODO(), crNames.TektonDashboard, metav1.DeleteOptions{}); err != nil {
t.Fatalf("TektonDashboard %q failed to delete: %v", crNames.TektonDashboard, err)
}
err := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
err := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
_, err := clients.TektonDashboard().Get(context.TODO(), crNames.TektonDashboard, metav1.GetOptions{})
if apierrs.IsNotFound(err) {
return true, nil
Expand Down
4 changes: 2 additions & 2 deletions test/resources/tektonpipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func WaitForTektonPipelineState(clients pipelinev1alpha1.TektonPipelineInterface
defer span.End()

var lastState *v1alpha1.TektonPipeline
waitErr := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
waitErr := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
lastState, err := clients.Get(context.TODO(), name, metav1.GetOptions{})
return inState(lastState, err)
})
Expand Down Expand Up @@ -99,7 +99,7 @@ func TektonPipelineCRDelete(t *testing.T, clients *utils.Clients, crNames utils.
if err := clients.TektonPipeline().Delete(context.TODO(), crNames.TektonPipeline, metav1.DeleteOptions{}); err != nil {
t.Fatalf("TektonPipeline %q failed to delete: %v", crNames.TektonPipeline, err)
}
err := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
err := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
_, err := clients.TektonPipeline().Get(context.TODO(), crNames.TektonPipeline, metav1.GetOptions{})
if apierrs.IsNotFound(err) {
return true, nil
Expand Down
10 changes: 0 additions & 10 deletions test/resources/tektonresources.go

This file was deleted.

4 changes: 2 additions & 2 deletions test/resources/tektonresults.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func WaitForTektonResultState(clients resultv1alpha1.TektonResultInterface, name
defer span.End()

var lastState *v1alpha1.TektonResult
waitErr := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
waitErr := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
lastState, err := clients.Get(context.TODO(), name, metav1.GetOptions{})
return inState(lastState, err)
})
Expand Down Expand Up @@ -99,7 +99,7 @@ func TektonResultCRDDelete(t *testing.T, clients *utils.Clients, crNames utils.R
if err := clients.TektonResult().Delete(context.TODO(), crNames.TektonResult, metav1.DeleteOptions{}); err != nil {
t.Fatalf("TektonResult %q failed to delete: %v", crNames.TektonResult, err)
}
err := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
err := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
_, err := clients.TektonResult().Get(context.TODO(), crNames.TektonResult, metav1.GetOptions{})
if apierrs.IsNotFound(err) {
return true, nil
Expand Down
4 changes: 2 additions & 2 deletions test/resources/tektontriggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func WaitForTektonTriggerState(clients triggerv1alpha1.TektonTriggerInterface, n
defer span.End()

var lastState *v1alpha1.TektonTrigger
waitErr := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
waitErr := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
lastState, err := clients.Get(context.TODO(), name, metav1.GetOptions{})
return inState(lastState, err)
})
Expand Down Expand Up @@ -96,7 +96,7 @@ func TektonTriggerCRDelete(t *testing.T, clients *utils.Clients, crNames utils.R
if err := clients.TektonTrigger().Delete(context.TODO(), crNames.TektonTrigger, metav1.DeleteOptions{}); err != nil {
t.Fatalf("TektonTrigger %q failed to delete: %v", crNames.TektonTrigger, err)
}
err := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
err := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
_, err := clients.TektonTrigger().Get(context.TODO(), crNames.TektonTrigger, metav1.GetOptions{})
if apierrs.IsNotFound(err) {
return true, nil
Expand Down
2 changes: 1 addition & 1 deletion test/resources/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func DeleteAndVerifyDeployments(t *testing.T, clients *utils.Clients, namespace,
t.Fatalf("Failed to delete deployment %s/%s: %v", deployment.Namespace, deployment.Name, err)
}

waitErr := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
waitErr := wait.PollImmediate(utils.Interval, utils.Timeout, func() (bool, error) {
dep, err := clients.KubeClient.
AppsV1().Deployments(deployment.Namespace).Get(context.TODO(), deployment.Name, metav1.GetOptions{})
if err != nil {
Expand Down

0 comments on commit 4a65f03

Please sign in to comment.