Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit fd1566e

Browse files
krancourpmorie
authored andcommitted
tpr storage int tests (#576)
* correct bug in keyer * fix wrong kind in broker list * add mocked out k8s core apisever client for tpr testing
1 parent 086bcb2 commit fd1566e

5 files changed

Lines changed: 370 additions & 16 deletions

File tree

pkg/registry/servicecatalog/broker/storage.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var (
4343
func NewSingular(ns, name string) runtime.Object {
4444
return &servicecatalog.Broker{
4545
TypeMeta: metav1.TypeMeta{
46-
Kind: tpr.ServiceBrokerKind.TPRName(),
46+
Kind: tpr.ServiceBrokerKind.String(),
4747
},
4848
ObjectMeta: api.ObjectMeta{
4949
Namespace: ns,
@@ -61,7 +61,7 @@ func EmptyObject() runtime.Object {
6161
func NewList() runtime.Object {
6262
return &servicecatalog.BrokerList{
6363
TypeMeta: metav1.TypeMeta{
64-
Kind: tpr.ServiceBrokerKind.TPRName(),
64+
Kind: tpr.ServiceBrokerListKind.String(),
6565
},
6666
Items: []servicecatalog.Broker{},
6767
}

pkg/storage/tpr/keyer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ func (k Keyer) NamespaceAndNameFromKey(key string) (string, string, error) {
8080
spl := strings.Split(key, k.Separator)
8181
splLen := len(spl)
8282
if splLen == 1 {
83-
// single slice entry is namespace-less, so use the default
84-
return k.DefaultNamespace, key, nil
83+
// single slice entry is name-less, so return an empty name
84+
return spl[0], "", nil
8585
} else if splLen == 2 {
8686
// two slice entries has a namespace
8787
return spl[0], spl[1], nil

test/integration/clientset_test.go

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ const (
6969

7070
var storageTypes = []server.StorageType{
7171
server.StorageTypeEtcd,
72-
// TODO: enable this storage type. https://github.com/kubernetes-incubator/service-catalog/issues/407
73-
// server.StorageTypeTPR,
72+
server.StorageTypeTPR,
7473
}
7574

7675
// Used for testing binding parameters
@@ -152,7 +151,7 @@ func TestBrokerClient(t *testing.T) {
152151
return func(t *testing.T) {
153152
client, shutdownServer := getFreshApiserverAndClient(t, sType.String())
154153
defer shutdownServer()
155-
if err := testBrokerClient(client, name); err != nil {
154+
if err := testBrokerClient(sType, client, name); err != nil {
156155
t.Fatal(err)
157156
}
158157
}
@@ -164,7 +163,7 @@ func TestBrokerClient(t *testing.T) {
164163
}
165164
}
166165

167-
func testBrokerClient(client servicecatalogclient.Interface, name string) error {
166+
func testBrokerClient(sType server.StorageType, client servicecatalogclient.Interface, name string) error {
168167
brokerClient := client.Servicecatalog().Brokers()
169168
broker := &v1alpha1.Broker{
170169
ObjectMeta: v1.ObjectMeta{Name: name},
@@ -219,6 +218,14 @@ func testBrokerClient(client servicecatalogclient.Interface, name string) error
219218
)
220219
}
221220

221+
// TODO: Here be dragons. Tests fail beyond this point due to known issues
222+
// with our TPR-based storage implementation. Bail early (until those issues)
223+
// are fixed, because some tests are better than no tests. If storage isn't
224+
// TPR-based, carry on.
225+
if sType == server.StorageTypeTPR {
226+
return nil
227+
}
228+
222229
authSecret := &v1.ObjectReference{
223230
Namespace: "test-namespace",
224231
Name: "test-name",
@@ -311,7 +318,7 @@ func TestServiceClassClient(t *testing.T) {
311318
client, shutdownServer := getFreshApiserverAndClient(t, sType.String())
312319
defer shutdownServer()
313320

314-
if err := testServiceClassClient(client, name); err != nil {
321+
if err := testServiceClassClient(sType, client, name); err != nil {
315322
t.Fatal(err)
316323
}
317324
}
@@ -323,7 +330,7 @@ func TestServiceClassClient(t *testing.T) {
323330
}
324331
}
325332

326-
func testServiceClassClient(client servicecatalogclient.Interface, name string) error {
333+
func testServiceClassClient(sType server.StorageType, client servicecatalogclient.Interface, name string) error {
327334
serviceClassClient := client.Servicecatalog().ServiceClasses()
328335

329336
serviceClass := &v1alpha1.ServiceClass{
@@ -390,6 +397,14 @@ func testServiceClassClient(client servicecatalogclient.Interface, name string)
390397
)
391398
}
392399

400+
// TODO: Here be dragons. Tests fail beyond this point due to known issues
401+
// with our TPR-based storage implementation. Bail early (until those issues)
402+
// are fixed, because some tests are better than no tests. If storage isn't
403+
// TPR-based, carry on.
404+
if sType == server.StorageTypeTPR {
405+
return nil
406+
}
407+
393408
serviceClassAtServer.Bindable = false
394409
_, err = serviceClassClient.Update(serviceClassAtServer)
395410
if err != nil {
@@ -423,7 +438,7 @@ func TestInstanceClient(t *testing.T) {
423438
const name = "test-instance"
424439
client, shutdownServer := getFreshApiserverAndClient(t, sType.String())
425440
defer shutdownServer()
426-
if err := testInstanceClient(client, name); err != nil {
441+
if err := testInstanceClient(sType, client, name); err != nil {
427442
t.Fatal(err)
428443
}
429444
}
@@ -435,7 +450,7 @@ func TestInstanceClient(t *testing.T) {
435450
}
436451
}
437452

438-
func testInstanceClient(client servicecatalogclient.Interface, name string) error {
453+
func testInstanceClient(sType server.StorageType, client servicecatalogclient.Interface, name string) error {
439454
instanceClient := client.Servicecatalog().Instances("test-namespace")
440455

441456
instance := &v1alpha1.Instance{
@@ -495,6 +510,14 @@ func testInstanceClient(client servicecatalogclient.Interface, name string) erro
495510
return fmt.Errorf("Didn't get the same instance from list and get: diff: %v", diff.ObjectReflectDiff(instanceListed, instanceServer))
496511
}
497512

513+
// TODO: Here be dragons. Tests fail beyond this point due to known issues
514+
// with our TPR-based storage implementation. Bail early (until those issues)
515+
// are fixed, because some tests are better than no tests. If storage isn't
516+
// TPR-based, carry on.
517+
if sType == server.StorageTypeTPR {
518+
return nil
519+
}
520+
498521
parameters := ipStruct{}
499522
err = json.Unmarshal(instanceServer.Spec.Parameters.Raw, &parameters)
500523
if err != nil {
@@ -568,7 +591,7 @@ func TestBindingClient(t *testing.T) {
568591
client, shutdownServer := getFreshApiserverAndClient(t, sType.String())
569592
defer shutdownServer()
570593

571-
if err := testBindingClient(client, name); err != nil {
594+
if err := testBindingClient(sType, client, name); err != nil {
572595
t.Fatal(err)
573596
}
574597
}
@@ -581,7 +604,7 @@ func TestBindingClient(t *testing.T) {
581604
}
582605
}
583606

584-
func testBindingClient(client servicecatalogclient.Interface, name string) error {
607+
func testBindingClient(sType server.StorageType, client servicecatalogclient.Interface, name string) error {
585608
bindingClient := client.Servicecatalog().Bindings("test-namespace")
586609

587610
binding := &v1alpha1.Binding{
@@ -648,6 +671,14 @@ func testBindingClient(client servicecatalogclient.Interface, name string) error
648671
)
649672
}
650673

674+
// TODO: Here be dragons. Tests fail beyond this point due to known issues
675+
// with our TPR-based storage implementation. Bail early (until those issues)
676+
// are fixed, because some tests are better than no tests. If storage isn't
677+
// TPR-based, carry on.
678+
if sType == server.StorageTypeTPR {
679+
return nil
680+
}
681+
651682
parameters := bpStruct{}
652683
err = json.Unmarshal(bindingServer.Spec.Parameters.Raw, &parameters)
653684
if err != nil {

0 commit comments

Comments
 (0)