-
Notifications
You must be signed in to change notification settings - Fork 382
Add asynchronous provisioning test using the fake broker server #923
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package fake | ||
|
||
const ( | ||
// Namespace is a name used for test namespaces | ||
Namespace = "test-ns" | ||
// NamespaceUID is a UID used for test namespaces | ||
NamespaceUID = "test-ns-uid" | ||
|
||
// BrokerURL is the URL used for test brokers | ||
BrokerURL = "http://example.com" | ||
// BrokerName is the name used for test brokers | ||
BrokerName = "test-broker" | ||
|
||
// ServiceClassName is the name used for test service classes | ||
ServiceClassName = "test-serviceclass" | ||
// ServiceClassGUID is the GUID used for test service classes | ||
ServiceClassGUID = "SCGUID" | ||
// PlanName is the name used for test plans | ||
PlanName = "test-plan" | ||
// PlanGUID is the GUID used for test plans | ||
PlanGUID = "PGUID" | ||
//NonBindablePlanName is the name used for test plans that should not be bindable | ||
NonBindablePlanName = "test-unbindable-plan" | ||
// NonBindablePlanGUID is the GUID used for test plans that should not be bindable | ||
NonBindablePlanGUID = "UNBINDABLE-PLAN" | ||
|
||
// InstanceName is a name used for test instances | ||
InstanceName = "test-instance" | ||
// InstanceGUID is the GUID used for test instances | ||
InstanceGUID = "IGUID" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think all of these should have some indication in the name that they are the Test constants. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MHBauer I argue that they already do when used externally to this package. Recall that the package name will come first, so this specific constant will be referenced as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree that the name of the package carries the meaning. I suggest we call this package 'testfixtures', though, since the code here is not really a 'fake'. |
||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package fake | ||
|
||
func boolPtr(b bool) *bool { | ||
return &b | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do these functions exist? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. various fields need to store There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having never actually tried it, I tried it, and apparently you can't take the address of a bool. Bizzare language. Would it be better to have it once in a toplevel util package than rewriting this in a multiple places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have seen truePtr and falsePtr around somewhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, that would be nice, but out of the scope of this PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, those are hanging around. We'll probably want to move them here naturally at some point. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package fake | ||
|
||
import ( | ||
"github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1alpha1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// GetBroker is a convenience function to get a *v1alpha1.Broker for use in tests | ||
func GetBroker() *v1alpha1.Broker { | ||
return &v1alpha1.Broker{ | ||
ObjectMeta: metav1.ObjectMeta{Name: BrokerName}, | ||
Spec: v1alpha1.BrokerSpec{ | ||
URL: BrokerURL, | ||
}, | ||
} | ||
} | ||
|
||
// GetServiceClass returns a ServiceClass that can be used by tests | ||
func GetServiceClass() *v1alpha1.ServiceClass { | ||
return &v1alpha1.ServiceClass{ | ||
ObjectMeta: metav1.ObjectMeta{Name: ServiceClassName}, | ||
BrokerName: BrokerName, | ||
Description: "a test service", | ||
ExternalID: ServiceClassGUID, | ||
Bindable: true, | ||
Plans: []v1alpha1.ServicePlan{ | ||
{ | ||
Name: PlanName, | ||
Description: "a test plan", | ||
Free: true, | ||
ExternalID: PlanGUID, | ||
}, | ||
{ | ||
Name: NonBindablePlanName, | ||
Description: "a test plan", | ||
Free: true, | ||
ExternalID: NonBindablePlanGUID, | ||
Bindable: boolPtr(false), | ||
}, | ||
}, | ||
} | ||
|
||
} | ||
|
||
// GetInstance returns an Instance that can be used by tests | ||
func GetInstance() *v1alpha1.Instance { | ||
return &v1alpha1.Instance{ | ||
ObjectMeta: metav1.ObjectMeta{Name: InstanceName, Namespace: Namespace}, | ||
Spec: v1alpha1.InstanceSpec{ | ||
ServiceClassName: ServiceClassName, | ||
PlanName: PlanName, | ||
ExternalID: InstanceGUID, | ||
}, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package fake | ||
|
||
import ( | ||
osb "github.com/pmorie/go-open-service-broker-client/v2" | ||
) | ||
|
||
const ( | ||
// ServiceClassName is the static name for service classes in test data | ||
ServiceClassName = "testserviceclass" | ||
// ServiceClassGUID is the static guid for service classes in test data | ||
ServiceClassGUID = "testserviceclassGUID" | ||
// PlanName is the static name for plans in test data | ||
PlanName = "testplan" | ||
// PlanGUID is the static name for plan GUIDs in test data | ||
PlanGUID = "testPlanGUID" | ||
// NonBindablePlanName is the static name for non-bindable plans in test data | ||
NonBindablePlanName = "testNonBindablePlan" | ||
// NonBindablePlanGUID is the static GUID for non-bindable plans in test data | ||
NonBindablePlanGUID = "testNonBinablePlanGUID" | ||
) | ||
|
||
func boolPtr(b bool) *bool { | ||
return &b | ||
} | ||
|
||
// GetTestCatalog returns a static osb.CatalogResponse for use in testing | ||
func GetTestCatalog() *osb.CatalogResponse { | ||
return &osb.CatalogResponse{ | ||
Services: []osb.Service{ | ||
{ | ||
Name: ServiceClassName, | ||
ID: ServiceClassGUID, | ||
Description: "a test service", | ||
Bindable: true, | ||
Plans: []osb.Plan{ | ||
{ | ||
Name: PlanName, | ||
Free: boolPtr(true), | ||
ID: PlanGUID, | ||
Description: "a test plan", | ||
}, | ||
{ | ||
Name: NonBindablePlanName, | ||
Free: boolPtr(true), | ||
ID: NonBindablePlanGUID, | ||
Description: "a test plan", | ||
Bindable: boolPtr(false), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1000 to where you're going here, see #514