Skip to content

Commit

Permalink
Merge pull request #1564 from vincepri/remove-async-ginkgo
Browse files Browse the repository at this point in the history
🌱 Remove async ginkgo tests
  • Loading branch information
k8s-ci-robot committed Jun 23, 2021
2 parents b826f39 + 1f32e46 commit 7d83250
Show file tree
Hide file tree
Showing 38 changed files with 262 additions and 690 deletions.
4 changes: 1 addition & 3 deletions pkg/builder/builder_suite_test.go
Expand Up @@ -45,7 +45,7 @@ func TestBuilder(t *testing.T) {
var testenv *envtest.Environment
var cfg *rest.Config

var _ = BeforeSuite(func(done Done) {
var _ = BeforeSuite(func() {
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))

testenv = &envtest.Environment{}
Expand All @@ -63,8 +63,6 @@ var _ = BeforeSuite(func(done Done) {

webhook.DefaultPort, _, err = addr.Suggest("")
Expect(err).NotTo(HaveOccurred())

close(done)
}, 60)

var _ = AfterSuite(func() {
Expand Down
10 changes: 3 additions & 7 deletions pkg/builder/controller_test.go
Expand Up @@ -297,7 +297,7 @@ var _ = Describe("application", func() {
})

Describe("Start with ControllerManagedBy", func() {
It("should Reconcile Owns objects", func(done Done) {
It("should Reconcile Owns objects", func() {
m, err := manager.New(cfg, manager.Options{})
Expect(err).NotTo(HaveOccurred())

Expand All @@ -308,10 +308,9 @@ var _ = Describe("application", func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
doReconcileTest(ctx, "3", bldr, m, false)
close(done)
}, 10)

It("should Reconcile Watches objects", func(done Done) {
It("should Reconcile Watches objects", func() {
m, err := manager.New(cfg, manager.Options{})
Expect(err).NotTo(HaveOccurred())

Expand All @@ -324,12 +323,11 @@ var _ = Describe("application", func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
doReconcileTest(ctx, "4", bldr, m, true)
close(done)
}, 10)
})

Describe("Set custom predicates", func() {
It("should execute registered predicates only for assigned kind", func(done Done) {
It("should execute registered predicates only for assigned kind", func() {
m, err := manager.New(cfg, manager.Options{})
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -385,8 +383,6 @@ var _ = Describe("application", func() {
Expect(deployPrctExecuted).To(BeTrue(), "Deploy predicated should be called at least once")
Expect(replicaSetPrctExecuted).To(BeTrue(), "ReplicaSet predicated should be called at least once")
Expect(allPrctExecuted).To(BeNumerically(">=", 2), "Global Predicated should be called at least twice")

close(done)
})
})

Expand Down
4 changes: 1 addition & 3 deletions pkg/cache/cache_suite_test.go
Expand Up @@ -39,7 +39,7 @@ var testenv *envtest.Environment
var cfg *rest.Config
var clientset *kubernetes.Clientset

var _ = BeforeSuite(func(done Done) {
var _ = BeforeSuite(func() {
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))

testenv = &envtest.Environment{}
Expand All @@ -50,8 +50,6 @@ var _ = BeforeSuite(func(done Done) {

clientset, err = kubernetes.NewForConfig(cfg)
Expect(err).NotTo(HaveOccurred())

close(done)
}, 60)

var _ = AfterSuite(func() {
Expand Down
12 changes: 4 additions & 8 deletions pkg/cache/cache_test.go
Expand Up @@ -885,7 +885,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
})
Describe("as an Informer", func() {
Context("with structured objects", func() {
It("should be able to get informer for the object", func(done Done) {
It("should be able to get informer for the object", func() {
By("getting a shared index informer for a pod")
pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -921,9 +921,8 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca

By("verifying the object is received on the channel")
Eventually(out).Should(Receive(Equal(pod)))
close(done)
})
It("should be able to get an informer by group/version/kind", func(done Done) {
It("should be able to get an informer by group/version/kind", func() {
By("getting an shared index informer for gvk = core/v1/pod")
gvk := schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Pod"}
sii, err := informerCache.GetInformerForKind(context.TODO(), gvk)
Expand Down Expand Up @@ -960,7 +959,6 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca

By("verifying the object is received on the channel")
Eventually(out).Should(Receive(Equal(pod)))
close(done)
})
It("should be able to index an object field then retrieve objects by that field", func() {
By("creating the cache")
Expand Down Expand Up @@ -1030,7 +1028,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
})
})
Context("with unstructured objects", func() {
It("should be able to get informer for the object", func(done Done) {
It("should be able to get informer for the object", func() {
By("getting a shared index informer for a pod")

pod := &unstructured.Unstructured{
Expand Down Expand Up @@ -1072,7 +1070,6 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca

By("verifying the object is received on the channel")
Eventually(out).Should(Receive(Equal(pod)))
close(done)
}, 3)

It("should be able to index an object field then retrieve objects by that field", func() {
Expand Down Expand Up @@ -1145,7 +1142,7 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
})
})
Context("with metadata-only objects", func() {
It("should be able to get informer for the object", func(done Done) {
It("should be able to get informer for the object", func() {
By("getting a shared index informer for a pod")

pod := &corev1.Pod{
Expand Down Expand Up @@ -1193,7 +1190,6 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca

By("verifying the object's metadata is received on the channel")
Eventually(out).Should(Receive(Equal(podMeta)))
close(done)
}, 3)

It("should be able to index an object field then retrieve objects by that field", func() {
Expand Down
7 changes: 2 additions & 5 deletions pkg/certwatcher/certwatcher_suite_test.go
Expand Up @@ -38,15 +38,12 @@ func TestSource(t *testing.T) {
RunSpecsWithDefaultAndCustomReporters(t, suiteName, []Reporter{printer.NewlineReporter{}, printer.NewProwReporter(suiteName)})
}

var _ = BeforeSuite(func(done Done) {
var _ = BeforeSuite(func() {
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))

close(done)
}, 60)

var _ = AfterSuite(func(done Done) {
var _ = AfterSuite(func() {
for _, file := range []string{certPath, keyPath} {
_ = os.Remove(file)
}
close(done)
}, 60)
4 changes: 1 addition & 3 deletions pkg/client/apiutil/apiutil_suite_test.go
Expand Up @@ -36,11 +36,9 @@ func TestSource(t *testing.T) {

var cfg *rest.Config

var _ = BeforeSuite(func(done Done) {
var _ = BeforeSuite(func() {
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))

// for things that technically need a rest.Config for defaulting, but don't actually use them
cfg = &rest.Config{}

close(done)
}, 60)
4 changes: 1 addition & 3 deletions pkg/client/client_suite_test.go
Expand Up @@ -40,7 +40,7 @@ var testenv *envtest.Environment
var cfg *rest.Config
var clientset *kubernetes.Clientset

var _ = BeforeSuite(func(done Done) {
var _ = BeforeSuite(func() {
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))

testenv = &envtest.Environment{}
Expand All @@ -51,8 +51,6 @@ var _ = BeforeSuite(func(done Done) {

clientset, err = kubernetes.NewForConfig(cfg)
Expect(err).NotTo(HaveOccurred())

close(done)
}, 60)

var _ = AfterSuite(func() {
Expand Down

0 comments on commit 7d83250

Please sign in to comment.