Skip to content

Commit

Permalink
end-to-end test for cleaning up apiservices after CSV delete
Browse files Browse the repository at this point in the history
  • Loading branch information
alecmerdler committed Mar 14, 2019
1 parent 20d4607 commit 80f9874
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 35 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/golang/mock v1.1.1
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect
github.com/grpc-ecosystem/grpc-gateway v1.7.0 // indirect
github.com/json-iterator/go v1.1.6 // indirect
github.com/maxbrunsfeld/counterfeiter v0.0.0-20181017030959-1aadac120687
github.com/openshift/api v3.9.1-0.20190129160438-bbc4289c54e0+incompatible
github.com/openshift/client-go v0.0.0-20190128154758-1540772775fa
Expand All @@ -41,5 +42,5 @@ require (
k8s.io/klog v0.2.0 // indirect
k8s.io/kube-aggregator v0.0.0-20190223015803-f706565beac0
k8s.io/kube-openapi v0.0.0-20181031203759-72693cb1fadd
k8s.io/kubernetes v1.11.9-beta.0.0.20190305054513-b2539d50ae56
k8s.io/kubernetes v1.11.9-beta.0.0.20190311041124-ede55fd57298
)
56 changes: 51 additions & 5 deletions go.sum

Large diffs are not rendered by default.

28 changes: 26 additions & 2 deletions test/e2e/csv_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"strings"
"testing"
"time"

"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
Expand All @@ -18,6 +19,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"

"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1"
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha2"
Expand Down Expand Up @@ -1216,9 +1218,31 @@ func TestCreateCSVWithOwnedAPIService(t *testing.T) {
csv.SetName(depName)

// Create the APIService CSV
cleanupCSV, err := createCSV(t, c, crc, csv, testNamespace, false, true)
cleanupCSV, err := createCSV(t, c, crc, csv, testNamespace, false, false)
require.NoError(t, err)
defer cleanupCSV()
defer func() {
watcher, err := c.ApiregistrationV1Interface().ApiregistrationV1().APIServices().Watch(metav1.ListOptions{FieldSelector: "metadata.name=" + apiServiceName})
require.NoError(t, err)

deleted := make(chan struct{})
go func() {
events := watcher.ResultChan()
for {
select {
case evt := <-events:
if evt.Type == watch.Deleted {
deleted <- struct{}{}
return
}
case <-time.After(pollDuration):
require.FailNow(t, "apiservice not cleaned up after CSV deleted")
}
}
}()

cleanupCSV()
<-deleted
}()

fetchedCSV, err := fetchCSV(t, crc, csv.Name, testNamespace, csvSucceededChecker)
require.NoError(t, err)
Expand Down
4 changes: 0 additions & 4 deletions vendor/github.com/json-iterator/go/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/json-iterator/go/any.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 6 additions & 14 deletions vendor/github.com/json-iterator/go/iter_float.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions vendor/github.com/json-iterator/go/iter_skip_strict.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/json-iterator/go/reflect_extension.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions vendor/github.com/json-iterator/go/reflect_map.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions vendor/github.com/json-iterator/go/reflect_marshaler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ github.com/hashicorp/golang-lru/simplelru
github.com/imdario/mergo
# github.com/inconshreveable/mousetrap v1.0.0
github.com/inconshreveable/mousetrap
# github.com/json-iterator/go v1.1.5
# github.com/json-iterator/go v1.1.6
github.com/json-iterator/go
# github.com/konsorten/go-windows-terminal-sequences v1.0.1
github.com/konsorten/go-windows-terminal-sequences
Expand Down Expand Up @@ -674,7 +674,7 @@ k8s.io/kube-openapi/pkg/generators/rules
k8s.io/kube-openapi/pkg/builder
k8s.io/kube-openapi/pkg/handler
k8s.io/kube-openapi/pkg/util/sets
# k8s.io/kubernetes v1.11.9-beta.0.0.20190305054513-b2539d50ae56
# k8s.io/kubernetes v1.11.9-beta.0.0.20190311041124-ede55fd57298
k8s.io/kubernetes/plugin/pkg/auth/authorizer/rbac
k8s.io/kubernetes/pkg/util/labels
k8s.io/kubernetes/pkg/apis/rbac/v1
Expand Down

0 comments on commit 80f9874

Please sign in to comment.