This repository has been archived by the owner on May 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add asynchronous provisioning test using the fake broker server
- Loading branch information
Showing
17 changed files
with
1,045 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.