Skip to content

Commit

Permalink
Adapt changes for NullLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
acumino committed Jul 19, 2022
1 parent 5503261 commit c81c514
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 108 deletions.
4 changes: 2 additions & 2 deletions pkg/testmachinery/collector/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"os"
"path/filepath"

"github.com/go-logr/logr"
"github.com/golang/mock/gomock"
"k8s.io/apimachinery/pkg/util/json"
"sigs.k8s.io/controller-runtime/pkg/log"

"github.com/gardener/test-infra/pkg/apis/config"
"github.com/gardener/test-infra/pkg/testmachinery"
Expand Down Expand Up @@ -61,7 +61,7 @@ var _ = Describe("collector summary", func() {
esClient = mock_elasticsearch.NewMockClient(esCtrl)
s3Client = mock_collector.NewMockClient(s3Ctrl)
c = &collector{
log: log.NullLogger{},
log: logr.Discard(),
esClient: esClient,
s3Client: s3Client,
s3Config: &config.S3{BucketName: "testbucket"},
Expand Down
4 changes: 2 additions & 2 deletions pkg/testmachinery/collector/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"os"
"path/filepath"

"github.com/go-logr/logr"
"github.com/golang/mock/gomock"
"k8s.io/apimachinery/pkg/util/json"
"sigs.k8s.io/controller-runtime/pkg/log"

"github.com/gardener/test-infra/pkg/apis/config"
"github.com/gardener/test-infra/pkg/testmachinery"
Expand Down Expand Up @@ -56,7 +56,7 @@ var _ = Describe("collector summary", func() {
esClient = mock_elasticsearch.NewMockClient(esCtrl)
s3Client = mock_collector.NewMockClient(s3Ctrl)
c = &collector{
log: log.NullLogger{},
log: logr.Discard(),
esClient: esClient,
s3Client: s3Client,
s3Config: &config.S3{BucketName: "testbucket"},
Expand Down
4 changes: 2 additions & 2 deletions pkg/testmachinery/collector/summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package collector

import (
"github.com/go-logr/logr"
"github.com/onsi/ginkgo"
"sigs.k8s.io/controller-runtime/pkg/log"

"github.com/gardener/test-infra/pkg/apis/testmachinery/v1beta1"
"github.com/gardener/test-infra/pkg/testmachinery/metadata"
Expand All @@ -33,7 +33,7 @@ var _ = Describe("output generation tests", func() {

ginkgo.BeforeEach(func() {
c = &collector{
log: log.NullLogger{},
log: logr.Discard(),
}
})

Expand Down
4 changes: 2 additions & 2 deletions pkg/testmachinery/controller/reconciler/resume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"time"

argov1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/go-logr/logr"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/log"

tmv1beta1 "github.com/gardener/test-infra/pkg/apis/testmachinery/v1beta1"
"github.com/gardener/test-infra/pkg/testmachinery"
Expand All @@ -31,7 +31,7 @@ var _ = Describe("Testmachinery controller resume", func() {

BeforeEach(func() {
reconciler = &TestmachineryReconciler{
Logger: log.NullLogger{},
Logger: logr.Discard(),
timers: make(map[string]*time.Timer),
}
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/testmachinery/controller/reconciler/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"time"

argov1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/go-logr/logr"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"sigs.k8s.io/controller-runtime/pkg/log"

tmv1beta1 "github.com/gardener/test-infra/pkg/apis/testmachinery/v1beta1"
)
Expand Down Expand Up @@ -74,7 +74,7 @@ var _ = Describe("Testmachinery controller update", func() {

BeforeEach(func() {
reconciler = &TestmachineryReconciler{
Logger: log.NullLogger{},
Logger: logr.Discard(),
timers: make(map[string]*time.Timer),
}
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/testmachinery/controller/watch/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"sync"
"time"

"github.com/go-logr/logr"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/log"

tmv1beta1 "github.com/gardener/test-infra/pkg/apis/testmachinery/v1beta1"
"github.com/gardener/test-infra/pkg/testmachinery/controller/watch"
Expand Down Expand Up @@ -58,7 +58,7 @@ var _ = Describe("Watch Cache Informer", func() {
Expect(err).ToNot(HaveOccurred())

wg = sync.WaitGroup{}
w, err = watch.New(log.NullLogger{}, restConfig, opts)
w, err = watch.New(logr.Discard(), restConfig, opts)
Expect(err).ToNot(HaveOccurred())
wg.Add(1)
go func() {
Expand Down
10 changes: 5 additions & 5 deletions pkg/testmachinery/controller/watch/polling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"strconv"
"time"

"github.com/go-logr/logr"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/log"

tmv1beta1 "github.com/gardener/test-infra/pkg/apis/testmachinery/v1beta1"
"github.com/gardener/test-infra/pkg/testmachinery/controller/watch"
Expand Down Expand Up @@ -63,7 +63,7 @@ var _ = Describe("Watch Polling Informer", func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

w, err := watch.New(log.NullLogger{}, restConfig, options)
w, err := watch.New(logr.Discard(), restConfig, options)
Expect(err).ToNot(HaveOccurred())
go func() {
err := w.Start(ctx)
Expand All @@ -82,7 +82,7 @@ var _ = Describe("Watch Polling Informer", func() {
It("watch should reconcile once", func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
w, err := watch.New(log.NullLogger{}, restConfig, options)
w, err := watch.New(logr.Discard(), restConfig, options)
Expect(err).ToNot(HaveOccurred())

go func() {
Expand Down Expand Up @@ -116,7 +116,7 @@ var _ = Describe("Watch Polling Informer", func() {
It("watch should reconcile until the latest update was received", func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
w, err := watch.New(log.NullLogger{}, restConfig, options)
w, err := watch.New(logr.Discard(), restConfig, options)
Expect(err).ToNot(HaveOccurred())
go func() {
err := w.Start(ctx)
Expand Down Expand Up @@ -153,7 +153,7 @@ var _ = Describe("Watch Polling Informer", func() {
It("watch should return an error if the watch function returns an error", func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
w, err := watch.New(log.NullLogger{}, restConfig, options)
w, err := watch.New(logr.Discard(), restConfig, options)
Expect(err).ToNot(HaveOccurred())
go func() {
err := w.Start(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (

mock_ociclient "github.com/gardener/component-cli/ociclient/mock"
"github.com/gardener/component-cli/pkg/commands/constants"
"github.com/go-logr/logr"
"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"sigs.k8s.io/controller-runtime/pkg/log"
)

func TestConfig(t *testing.T) {
Expand Down Expand Up @@ -58,7 +58,7 @@ var _ = Describe("componentdescriptor test", func() {
Expect(os.Setenv(constants.ComponentRepositoryCacheDirEnvVar, "./testdata")).To(Succeed())
defer os.Unsetenv(constants.ComponentRepositoryCacheDirEnvVar)

dependencies, err := GetComponents(ctx, log.NullLogger{}, mockOCIClient, input)
dependencies, err := GetComponents(ctx, logr.Discard(), mockOCIClient, input)
Expect(err).ToNot(HaveOccurred())

Expect(len(dependencies)).To(Equal(2))
Expand All @@ -73,7 +73,7 @@ var _ = Describe("componentdescriptor test", func() {
Expect(os.Remove("./testdata/registry.example/github.com/gardener/gardener-0.18.0")).To(Succeed())
}()

dependencies, err := GetComponents(ctx, log.NullLogger{}, mockOCIClient, input)
dependencies, err := GetComponents(ctx, logr.Discard(), mockOCIClient, input)
Expect(err).ToNot(HaveOccurred())

Expect(len(dependencies)).To(Equal(2))
Expand All @@ -98,7 +98,7 @@ var _ = Describe("componentdescriptor test", func() {
},
}

dependencies, err := GetComponents(ctx, log.NullLogger{}, mockOCIClient, input)
dependencies, err := GetComponents(ctx, logr.Discard(), mockOCIClient, input)
Expect(err).ToNot(HaveOccurred())

Expect(len(dependencies)).To(Equal(3), "There should be 3 dependencies")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
meta:
schemaVersion: 'v2'

component:
name: 'example.com/repo1'
version: '0.17.0'

repositoryContexts:
- type: 'ociRegistry'
baseUrl: 'registry.example'
provider: 'internal'
sources: []
resources: []
componentReferences:
- name: 'repo2'
componentName: 'example.com/repo2'
version: '1.27.0'
- name: 'repo3'
componentName: 'example.com/repo3'
version: '1.30.0'
{"meta":{"schemaVersion":"v2"},"component":{"name":"example.com/repo1","version":"0.17.0","repositoryContexts":[{"baseUrl":"registry.example","type":"ociRegistry"}],"provider":"internal","sources":[],"componentReferences":[{"name":"repo2","componentName":"example.com/repo2","version":"1.27.0"},{"name":"repo3","componentName":"example.com/repo3","version":"1.30.0"}],"resources":[]}}
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
meta:
schemaVersion: 'v2'

component:
name: 'github.com/gardener/gardener'
version: '0.17.0'

repositoryContexts:
- type: 'ociRegistry'
baseUrl: 'registry.example'
provider: 'internal'
sources: []
resources: []
componentReferences:
- name: 'dashboard'
componentName: 'github.com/gardener/dashboard'
version: '1.27.0'
{"meta":{"schemaVersion":"v2"},"component":{"name":"github.com/gardener/gardener","version":"0.17.0","repositoryContexts":[{"baseUrl":"registry.example","type":"ociRegistry"}],"provider":"internal","sources":[],"componentReferences":[{"name":"dashboard","componentName":"github.com/gardener/dashboard","version":"1.27.0"}],"resources":[]}}
24 changes: 12 additions & 12 deletions pkg/testrunner/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"math"
"time"

"github.com/go-logr/logr"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"sigs.k8s.io/controller-runtime/pkg/log"

"github.com/gardener/test-infra/pkg/testrunner"
)
Expand All @@ -30,7 +30,7 @@ var _ = Describe("Executor tests", func() {
Context("basic", func() {
It("should run a set of functions in serial without backoff", func() {
executions := [3]*execution{}
executor, err := testrunner.NewExecutor(log.NullLogger{}, testrunner.ExecutorConfig{
executor, err := testrunner.NewExecutor(logr.Discard(), testrunner.ExecutorConfig{
Serial: true,
})
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -59,7 +59,7 @@ var _ = Describe("Executor tests", func() {

It("should run all functions in parallel", func() {
executions := [3]*execution{}
executor, err := testrunner.NewExecutor(log.NullLogger{}, testrunner.ExecutorConfig{})
executor, err := testrunner.NewExecutor(logr.Discard(), testrunner.ExecutorConfig{})
Expect(err).ToNot(HaveOccurred())

for i := 0; i < 3; i++ {
Expand All @@ -85,7 +85,7 @@ var _ = Describe("Executor tests", func() {

It("should run 3 functions in serial with a backoff", func() {
executions := [3]*execution{}
executor, err := testrunner.NewExecutor(log.NullLogger{}, testrunner.ExecutorConfig{
executor, err := testrunner.NewExecutor(logr.Discard(), testrunner.ExecutorConfig{
Serial: true,
BackoffBucket: 1,
BackoffPeriod: 2 * time.Second,
Expand Down Expand Up @@ -113,7 +113,7 @@ var _ = Describe("Executor tests", func() {
}, 10)

It("should run 1 function in serial", func() {
executor, err := testrunner.NewExecutor(log.NullLogger{}, testrunner.ExecutorConfig{
executor, err := testrunner.NewExecutor(logr.Discard(), testrunner.ExecutorConfig{
Serial: true,
})
Expect(err).ToNot(HaveOccurred())
Expand All @@ -131,7 +131,7 @@ var _ = Describe("Executor tests", func() {

It("should run 3 functions in serial", func() {
executions := [3]*execution{}
executor, err := testrunner.NewExecutor(log.NullLogger{}, testrunner.ExecutorConfig{
executor, err := testrunner.NewExecutor(logr.Discard(), testrunner.ExecutorConfig{
Serial: true,
})
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -159,7 +159,7 @@ var _ = Describe("Executor tests", func() {

It("should run 6 functions in parallel with a backoff in a bucket of 2", func() {
executions := [6]*execution{}
executor, err := testrunner.NewExecutor(log.NullLogger{}, testrunner.ExecutorConfig{
executor, err := testrunner.NewExecutor(logr.Discard(), testrunner.ExecutorConfig{
Serial: false,
BackoffBucket: 2,
BackoffPeriod: 2 * time.Second,
Expand Down Expand Up @@ -188,7 +188,7 @@ var _ = Describe("Executor tests", func() {

It("should run 6 functions in serial with a backoff in a bucket of 2", func() {
executions := [6]*execution{}
executor, err := testrunner.NewExecutor(log.NullLogger{}, testrunner.ExecutorConfig{
executor, err := testrunner.NewExecutor(logr.Discard(), testrunner.ExecutorConfig{
Serial: true,
BackoffBucket: 2,
BackoffPeriod: 2 * time.Second,
Expand Down Expand Up @@ -218,7 +218,7 @@ var _ = Describe("Executor tests", func() {

It("should add another test during execution", func() {
executions := [3]*execution{}
executor, err := testrunner.NewExecutor(log.NullLogger{}, testrunner.ExecutorConfig{
executor, err := testrunner.NewExecutor(logr.Discard(), testrunner.ExecutorConfig{
Serial: true,
})
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -249,7 +249,7 @@ var _ = Describe("Executor tests", func() {

It("should add another test during execution in parallel steps", func() {
executions := [3]*execution{}
executor, err := testrunner.NewExecutor(log.NullLogger{}, testrunner.ExecutorConfig{})
executor, err := testrunner.NewExecutor(logr.Discard(), testrunner.ExecutorConfig{})
Expect(err).ToNot(HaveOccurred())

addExecution := newExecution(4)
Expand Down Expand Up @@ -277,7 +277,7 @@ var _ = Describe("Executor tests", func() {

It("should add another test during execution in parallel steps that start immediately", func() {
executions := [3]*execution{}
executor, err := testrunner.NewExecutor(log.NullLogger{}, testrunner.ExecutorConfig{})
executor, err := testrunner.NewExecutor(logr.Discard(), testrunner.ExecutorConfig{})
Expect(err).ToNot(HaveOccurred())

addExecution := newExecution(4)
Expand Down Expand Up @@ -308,7 +308,7 @@ var _ = Describe("Executor tests", func() {

It("should add same test during execution in parallel steps", func() {
executions := [3]*execution{}
executor, err := testrunner.NewExecutor(log.NullLogger{}, testrunner.ExecutorConfig{})
executor, err := testrunner.NewExecutor(logr.Discard(), testrunner.ExecutorConfig{})
Expect(err).ToNot(HaveOccurred())

for i := 0; i < 3; i++ {
Expand Down
Loading

0 comments on commit c81c514

Please sign in to comment.