Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
842b9d8d
Commit
842b9d8d
authored
Apr 07, 2015
by
Nikhil Jindal
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6493 from smarterclayton/make_client_pluggable
Make the client.Fake more powerful by standardizing how the fake loads data
parents
cb0850d7
51db3bd6
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
828 additions
and
544 deletions
+828
-544
fake.go
pkg/client/fake.go
+0
-93
fake_endpoints.go
pkg/client/testclient/fake_endpoints.go
+9
-9
fake_events.go
pkg/client/testclient/fake_events.go
+13
-13
fake_limit_ranges.go
pkg/client/testclient/fake_limit_ranges.go
+11
-11
fake_namespaces.go
pkg/client/testclient/fake_namespaces.go
+13
-14
fake_nodes.go
pkg/client/testclient/fake_nodes.go
+13
-19
fake_persistent_volume_claims.go
pkg/client/testclient/fake_persistent_volume_claims.go
+15
-14
fake_persistent_volumes.go
pkg/client/testclient/fake_persistent_volumes.go
+16
-15
fake_pods.go
pkg/client/testclient/fake_pods.go
+13
-13
fake_replication_controllers.go
pkg/client/testclient/fake_replication_controllers.go
+13
-13
fake_resource_quotas.go
pkg/client/testclient/fake_resource_quotas.go
+13
-14
fake_secrets.go
pkg/client/testclient/fake_secrets.go
+12
-12
fake_services.go
pkg/client/testclient/fake_services.go
+12
-12
fake_test.go
pkg/client/testclient/fake_test.go
+6
-4
fixture.go
pkg/client/testclient/fixture.go
+218
-0
testclient.go
pkg/client/testclient/testclient.go
+127
-0
testclient_test.go
pkg/client/testclient/testclient_test.go
+74
-0
nodecontroller_test.go
pkg/cloudprovider/controller/nodecontroller_test.go
+29
-54
replication_controller_test.go
pkg/controller/replication_controller_test.go
+3
-2
describe_test.go
pkg/kubectl/describe_test.go
+40
-31
resize_test.go
pkg/kubectl/resize_test.go
+16
-17
rolling_updater_test.go
pkg/kubectl/rolling_updater_test.go
+8
-7
stop_test.go
pkg/kubectl/stop_test.go
+16
-17
kubelet_test.go
pkg/kubelet/kubelet_test.go
+18
-19
status_manager_test.go
pkg/kubelet/status_manager_test.go
+3
-2
namespace_controller_test.go
pkg/namespace/namespace_controller_test.go
+6
-6
api_test.go
pkg/proxy/config/api_test.go
+27
-27
registry.go
pkg/registry/controller/registry.go
+1
-0
resource_quota_controller_test.go
pkg/resourcequota/resource_quota_controller_test.go
+4
-6
secret_test.go
pkg/volume/secret/secret_test.go
+2
-3
admission_test.go
...n/pkg/admission/namespace/autoprovision/admission_test.go
+5
-5
admission_test.go
plugin/pkg/admission/namespace/lifecycle/admission_test.go
+2
-2
admission_test.go
plugin/pkg/admission/resourcequota/admission_test.go
+70
-90
No files found.
pkg/client/fake.go
View file @
842b9d8d
...
@@ -20,103 +20,10 @@ import (
...
@@ -20,103 +20,10 @@ import (
"net/http"
"net/http"
"net/url"
"net/url"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
)
)
type
FakeAction
struct
{
Action
string
Value
interface
{}
}
// Fake implements Interface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the method you want to test easier.
type
Fake
struct
{
Actions
[]
FakeAction
PodsList
api
.
PodList
CtrlList
api
.
ReplicationControllerList
Ctrl
api
.
ReplicationController
ServiceList
api
.
ServiceList
EndpointsList
api
.
EndpointsList
MinionsList
api
.
NodeList
EventsList
api
.
EventList
LimitRangesList
api
.
LimitRangeList
ResourceQuotaStatus
api
.
ResourceQuota
ResourceQuotasList
api
.
ResourceQuotaList
NamespacesList
api
.
NamespaceList
Namespace
api
.
Namespace
SecretList
api
.
SecretList
Secret
api
.
Secret
Err
error
Watch
watch
.
Interface
PersistentVolume
api
.
PersistentVolume
PersistentVolumesList
api
.
PersistentVolumeList
PersistentVolumeClaim
api
.
PersistentVolumeClaim
PersistentVolumeClaimList
api
.
PersistentVolumeClaimList
}
func
(
c
*
Fake
)
LimitRanges
(
namespace
string
)
LimitRangeInterface
{
return
&
FakeLimitRanges
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
ResourceQuotas
(
namespace
string
)
ResourceQuotaInterface
{
return
&
FakeResourceQuotas
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
ReplicationControllers
(
namespace
string
)
ReplicationControllerInterface
{
return
&
FakeReplicationControllers
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
Nodes
()
NodeInterface
{
return
&
FakeNodes
{
Fake
:
c
}
}
func
(
c
*
Fake
)
Events
(
namespace
string
)
EventInterface
{
return
&
FakeEvents
{
Fake
:
c
}
}
func
(
c
*
Fake
)
Endpoints
(
namespace
string
)
EndpointsInterface
{
return
&
FakeEndpoints
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
Pods
(
namespace
string
)
PodInterface
{
return
&
FakePods
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
PersistentVolumes
()
PersistentVolumeInterface
{
return
&
FakePersistentVolumes
{
Fake
:
c
}
}
func
(
c
*
Fake
)
PersistentVolumeClaims
(
namespace
string
)
PersistentVolumeClaimInterface
{
return
&
FakePersistentVolumeClaims
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
Services
(
namespace
string
)
ServiceInterface
{
return
&
FakeServices
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
Secrets
(
namespace
string
)
SecretsInterface
{
return
&
FakeSecrets
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
Namespaces
()
NamespaceInterface
{
return
&
FakeNamespaces
{
Fake
:
c
}
}
func
(
c
*
Fake
)
ServerVersion
()
(
*
version
.
Info
,
error
)
{
c
.
Actions
=
append
(
c
.
Actions
,
FakeAction
{
Action
:
"get-version"
,
Value
:
nil
})
versionInfo
:=
version
.
Get
()
return
&
versionInfo
,
nil
}
func
(
c
*
Fake
)
ServerAPIVersions
()
(
*
api
.
APIVersions
,
error
)
{
c
.
Actions
=
append
(
c
.
Actions
,
FakeAction
{
Action
:
"get-apiversions"
,
Value
:
nil
})
return
&
api
.
APIVersions
{
Versions
:
[]
string
{
"v1beta1"
,
"v1beta2"
}},
nil
}
type
HTTPClientFunc
func
(
*
http
.
Request
)
(
*
http
.
Response
,
error
)
type
HTTPClientFunc
func
(
*
http
.
Request
)
(
*
http
.
Response
,
error
)
func
(
f
HTTPClientFunc
)
Do
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
func
(
f
HTTPClientFunc
)
Do
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
...
...
pkg/client/fake_endpoints.go
→
pkg/client/
testclient/
fake_endpoints.go
View file @
842b9d8d
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -31,18 +31,18 @@ type FakeEndpoints struct {
...
@@ -31,18 +31,18 @@ type FakeEndpoints struct {
}
}
func
(
c
*
FakeEndpoints
)
Create
(
endpoints
*
api
.
Endpoints
)
(
*
api
.
Endpoints
,
error
)
{
func
(
c
*
FakeEndpoints
)
Create
(
endpoints
*
api
.
Endpoints
)
(
*
api
.
Endpoints
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"create-endpoints"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-endpoints"
},
&
api
.
Endpoints
{
})
return
&
api
.
Endpoints
{},
nil
return
obj
.
(
*
api
.
Endpoints
),
err
}
}
func
(
c
*
FakeEndpoints
)
List
(
selector
labels
.
Selector
)
(
*
api
.
EndpointsList
,
error
)
{
func
(
c
*
FakeEndpoints
)
List
(
selector
labels
.
Selector
)
(
*
api
.
EndpointsList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-endpoints"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-endpoints"
},
&
api
.
EndpointsList
{
})
return
api
.
Scheme
.
CopyOrDie
(
&
c
.
Fake
.
EndpointsList
)
.
(
*
api
.
EndpointsList
),
c
.
Fake
.
E
rr
return
obj
.
(
*
api
.
EndpointsList
),
e
rr
}
}
func
(
c
*
FakeEndpoints
)
Get
(
name
string
)
(
*
api
.
Endpoints
,
error
)
{
func
(
c
*
FakeEndpoints
)
Get
(
name
string
)
(
*
api
.
Endpoints
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-endpoints"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-endpoints"
,
Value
:
name
},
&
api
.
Endpoints
{
})
return
&
api
.
Endpoints
{},
nil
return
obj
.
(
*
api
.
Endpoints
),
err
}
}
func
(
c
*
FakeEndpoints
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeEndpoints
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
...
@@ -51,6 +51,6 @@ func (c *FakeEndpoints) Watch(label labels.Selector, field fields.Selector, reso
...
@@ -51,6 +51,6 @@ func (c *FakeEndpoints) Watch(label labels.Selector, field fields.Selector, reso
}
}
func
(
c
*
FakeEndpoints
)
Update
(
endpoints
*
api
.
Endpoints
)
(
*
api
.
Endpoints
,
error
)
{
func
(
c
*
FakeEndpoints
)
Update
(
endpoints
*
api
.
Endpoints
)
(
*
api
.
Endpoints
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-endpoints"
,
Value
:
endpoints
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-endpoints"
,
Value
:
endpoints
.
Name
},
&
api
.
Endpoints
{
})
return
&
api
.
Endpoints
{},
nil
return
obj
.
(
*
api
.
Endpoints
),
err
}
}
pkg/client/fake_events.go
→
pkg/client/
testclient/
fake_events.go
View file @
842b9d8d
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -32,26 +32,26 @@ type FakeEvents struct {
...
@@ -32,26 +32,26 @@ type FakeEvents struct {
// Create makes a new event. Returns the copy of the event the server returns, or an error.
// Create makes a new event. Returns the copy of the event the server returns, or an error.
func
(
c
*
FakeEvents
)
Create
(
event
*
api
.
Event
)
(
*
api
.
Event
,
error
)
{
func
(
c
*
FakeEvents
)
Create
(
event
*
api
.
Event
)
(
*
api
.
Event
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-event"
,
Value
:
event
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-event"
,
Value
:
event
.
Name
},
&
api
.
Event
{
})
return
&
api
.
Event
{},
nil
return
obj
.
(
*
api
.
Event
),
err
}
}
// Update replaces an existing event. Returns the copy of the event the server returns, or an error.
// Update replaces an existing event. Returns the copy of the event the server returns, or an error.
func
(
c
*
FakeEvents
)
Update
(
event
*
api
.
Event
)
(
*
api
.
Event
,
error
)
{
func
(
c
*
FakeEvents
)
Update
(
event
*
api
.
Event
)
(
*
api
.
Event
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-event"
,
Value
:
event
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-event"
,
Value
:
event
.
Name
},
&
api
.
Event
{
})
return
&
api
.
Event
{},
nil
return
obj
.
(
*
api
.
Event
),
err
}
}
// List returns a list of events matching the selectors.
// List returns a list of events matching the selectors.
func
(
c
*
FakeEvents
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
EventList
,
error
)
{
func
(
c
*
FakeEvents
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
EventList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-events"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-events"
},
&
api
.
EventList
{
})
return
&
c
.
Fake
.
EventsList
,
nil
return
obj
.
(
*
api
.
EventList
),
err
}
}
// Get returns the given event, or an error.
// Get returns the given event, or an error.
func
(
c
*
FakeEvents
)
Get
(
id
string
)
(
*
api
.
Event
,
error
)
{
func
(
c
*
FakeEvents
)
Get
(
id
string
)
(
*
api
.
Event
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-event"
,
Value
:
id
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-endpoints"
,
Value
:
id
},
&
api
.
Event
{
})
return
&
api
.
Event
{},
nil
return
obj
.
(
*
api
.
Event
),
err
}
}
// Watch starts watching for events matching the given selectors.
// Watch starts watching for events matching the given selectors.
...
@@ -62,13 +62,13 @@ func (c *FakeEvents) Watch(label labels.Selector, field fields.Selector, resourc
...
@@ -62,13 +62,13 @@ func (c *FakeEvents) Watch(label labels.Selector, field fields.Selector, resourc
// Search returns a list of events matching the specified object.
// Search returns a list of events matching the specified object.
func
(
c
*
FakeEvents
)
Search
(
objOrRef
runtime
.
Object
)
(
*
api
.
EventList
,
error
)
{
func
(
c
*
FakeEvents
)
Search
(
objOrRef
runtime
.
Object
)
(
*
api
.
EventList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"search-events"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"search-events"
},
&
api
.
EventList
{
})
return
&
c
.
Fake
.
EventsList
,
nil
return
obj
.
(
*
api
.
EventList
),
err
}
}
func
(
c
*
FakeEvents
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeEvents
)
Delete
(
name
string
)
error
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"delete-event"
,
Value
:
name
})
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-event"
,
Value
:
name
},
&
api
.
Event
{
})
return
nil
return
err
}
}
func
(
c
*
FakeEvents
)
GetFieldSelector
(
involvedObjectName
,
involvedObjectNamespace
,
involvedObjectKind
,
involvedObjectUID
*
string
)
fields
.
Selector
{
func
(
c
*
FakeEvents
)
GetFieldSelector
(
involvedObjectName
,
involvedObjectNamespace
,
involvedObjectKind
,
involvedObjectUID
*
string
)
fields
.
Selector
{
...
...
pkg/client/fake_limit_ranges.go
→
pkg/client/
testclient/
fake_limit_ranges.go
View file @
842b9d8d
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -31,28 +31,28 @@ type FakeLimitRanges struct {
...
@@ -31,28 +31,28 @@ type FakeLimitRanges struct {
}
}
func
(
c
*
FakeLimitRanges
)
List
(
selector
labels
.
Selector
)
(
*
api
.
LimitRangeList
,
error
)
{
func
(
c
*
FakeLimitRanges
)
List
(
selector
labels
.
Selector
)
(
*
api
.
LimitRangeList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-limitRanges"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-limitRanges"
},
&
api
.
LimitRangeList
{
})
return
api
.
Scheme
.
CopyOrDie
(
&
c
.
Fake
.
LimitRangesList
)
.
(
*
api
.
LimitRangeList
),
nil
return
obj
.
(
*
api
.
LimitRangeList
),
err
}
}
func
(
c
*
FakeLimitRanges
)
Get
(
name
string
)
(
*
api
.
LimitRange
,
error
)
{
func
(
c
*
FakeLimitRanges
)
Get
(
name
string
)
(
*
api
.
LimitRange
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-limitRange"
,
Value
:
name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-limitRange"
,
Value
:
name
},
&
api
.
LimitRange
{
})
return
&
api
.
LimitRange
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
,
Namespace
:
c
.
Namespace
}},
nil
return
obj
.
(
*
api
.
LimitRange
),
err
}
}
func
(
c
*
FakeLimitRanges
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeLimitRanges
)
Delete
(
name
string
)
error
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"delete-limitRange"
,
Value
:
name
})
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-limitRange"
,
Value
:
name
},
&
api
.
LimitRange
{
})
return
nil
return
err
}
}
func
(
c
*
FakeLimitRanges
)
Create
(
limitRange
*
api
.
LimitRange
)
(
*
api
.
LimitRange
,
error
)
{
func
(
c
*
FakeLimitRanges
)
Create
(
limitRange
*
api
.
LimitRange
)
(
*
api
.
LimitRange
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"create-limitRange"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-limitRange"
},
&
api
.
LimitRange
{
})
return
&
api
.
LimitRange
{},
nil
return
obj
.
(
*
api
.
LimitRange
),
err
}
}
func
(
c
*
FakeLimitRanges
)
Update
(
limitRange
*
api
.
LimitRange
)
(
*
api
.
LimitRange
,
error
)
{
func
(
c
*
FakeLimitRanges
)
Update
(
limitRange
*
api
.
LimitRange
)
(
*
api
.
LimitRange
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-limitRange"
,
Value
:
limitRange
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-limitRange"
,
Value
:
limitRange
.
Name
},
&
api
.
LimitRange
{
})
return
&
api
.
LimitRange
{},
nil
return
obj
.
(
*
api
.
LimitRange
),
err
}
}
func
(
c
*
FakeLimitRanges
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeLimitRanges
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
...
...
pkg/client/fake_namespaces.go
→
pkg/client/
testclient/
fake_namespaces.go
View file @
842b9d8d
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -30,18 +30,18 @@ type FakeNamespaces struct {
...
@@ -30,18 +30,18 @@ type FakeNamespaces struct {
}
}
func
(
c
*
FakeNamespaces
)
List
(
labels
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
NamespaceList
,
error
)
{
func
(
c
*
FakeNamespaces
)
List
(
labels
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
NamespaceList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-namespaces"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-namespaces"
},
&
api
.
NamespaceList
{
})
return
api
.
Scheme
.
CopyOrDie
(
&
c
.
Fake
.
NamespacesList
)
.
(
*
api
.
NamespaceList
),
nil
return
obj
.
(
*
api
.
NamespaceList
),
err
}
}
func
(
c
*
FakeNamespaces
)
Get
(
name
string
)
(
*
api
.
Namespace
,
error
)
{
func
(
c
*
FakeNamespaces
)
Get
(
name
string
)
(
*
api
.
Namespace
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-namespace"
,
Value
:
name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-namespace"
,
Value
:
name
},
&
api
.
Namespace
{
})
return
&
api
.
Namespace
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
}},
nil
return
obj
.
(
*
api
.
Namespace
),
err
}
}
func
(
c
*
FakeNamespaces
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeNamespaces
)
Delete
(
name
string
)
error
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"delete-namespace"
,
Value
:
name
})
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-namespace"
,
Value
:
name
},
&
api
.
Namespace
{
})
return
nil
return
err
}
}
func
(
c
*
FakeNamespaces
)
Create
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
func
(
c
*
FakeNamespaces
)
Create
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
...
@@ -50,8 +50,8 @@ func (c *FakeNamespaces) Create(namespace *api.Namespace) (*api.Namespace, error
...
@@ -50,8 +50,8 @@ func (c *FakeNamespaces) Create(namespace *api.Namespace) (*api.Namespace, error
}
}
func
(
c
*
FakeNamespaces
)
Update
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
func
(
c
*
FakeNamespaces
)
Update
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-namespace"
,
Value
:
namespace
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-namespace"
,
Value
:
namespace
},
&
api
.
Namespace
{
})
return
&
api
.
Namespace
{},
nil
return
obj
.
(
*
api
.
Namespace
),
err
}
}
func
(
c
*
FakeNamespaces
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeNamespaces
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
...
@@ -60,12 +60,11 @@ func (c *FakeNamespaces) Watch(label labels.Selector, field fields.Selector, res
...
@@ -60,12 +60,11 @@ func (c *FakeNamespaces) Watch(label labels.Selector, field fields.Selector, res
}
}
func
(
c
*
FakeNamespaces
)
Finalize
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
func
(
c
*
FakeNamespaces
)
Finalize
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"finalize-namespace"
,
Value
:
namespace
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"finalize-namespace"
,
Value
:
namespace
},
&
api
.
Namespace
{})
c
.
Fake
.
Namespace
=
*
namespace
return
obj
.
(
*
api
.
Namespace
),
err
return
namespace
,
nil
}
}
func
(
c
*
FakeNamespaces
)
Status
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
func
(
c
*
FakeNamespaces
)
Status
(
namespace
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"status-namespace"
,
Value
:
namespace
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"status-namespace"
,
Value
:
namespace
},
&
api
.
Namespace
{
})
return
&
api
.
Namespace
{},
nil
return
obj
.
(
*
api
.
Namespace
),
err
}
}
pkg/client/
fake_minion
s.go
→
pkg/client/
testclient/fake_node
s.go
View file @
842b9d8d
...
@@ -14,11 +14,10 @@ See the License for the specific language governing permissions and
...
@@ -14,11 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
...
@@ -31,36 +30,31 @@ type FakeNodes struct {
...
@@ -31,36 +30,31 @@ type FakeNodes struct {
}
}
func
(
c
*
FakeNodes
)
Get
(
name
string
)
(
*
api
.
Node
,
error
)
{
func
(
c
*
FakeNodes
)
Get
(
name
string
)
(
*
api
.
Node
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-minion"
,
Value
:
name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-node"
,
Value
:
name
},
&
api
.
Node
{})
for
i
:=
range
c
.
Fake
.
MinionsList
.
Items
{
return
obj
.
(
*
api
.
Node
),
err
if
c
.
Fake
.
MinionsList
.
Items
[
i
]
.
Name
==
name
{
return
&
c
.
Fake
.
MinionsList
.
Items
[
i
],
nil
}
}
return
nil
,
errors
.
NewNotFound
(
"Minions"
,
name
)
}
}
func
(
c
*
FakeNodes
)
List
()
(
*
api
.
NodeList
,
error
)
{
func
(
c
*
FakeNodes
)
List
()
(
*
api
.
NodeList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-minions"
,
Value
:
nil
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-nodes"
},
&
api
.
NodeList
{
})
return
&
c
.
Fake
.
MinionsList
,
nil
return
obj
.
(
*
api
.
NodeList
),
err
}
}
func
(
c
*
FakeNodes
)
Create
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
func
(
c
*
FakeNodes
)
Create
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"create-minion"
,
Value
:
minion
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-node"
,
Value
:
minion
},
&
api
.
Node
{
})
return
&
api
.
Node
{},
nil
return
obj
.
(
*
api
.
Node
),
err
}
}
func
(
c
*
FakeNodes
)
Delete
(
id
string
)
error
{
func
(
c
*
FakeNodes
)
Delete
(
name
string
)
error
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"delete-minion"
,
Value
:
id
})
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-node"
,
Value
:
name
},
&
api
.
Node
{
})
return
nil
return
err
}
}
func
(
c
*
FakeNodes
)
Update
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
func
(
c
*
FakeNodes
)
Update
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-minion"
,
Value
:
minion
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-node"
,
Value
:
minion
},
&
api
.
Node
{
})
return
&
api
.
Node
{},
nil
return
obj
.
(
*
api
.
Node
),
err
}
}
func
(
c
*
FakeNodes
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeNodes
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"watch-
minion
s"
,
Value
:
resourceVersion
})
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"watch-
node
s"
,
Value
:
resourceVersion
})
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
}
}
pkg/client/fake_persistent_volume_claims.go
→
pkg/client/
testclient/
fake_persistent_volume_claims.go
View file @
842b9d8d
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -28,31 +28,32 @@ type FakePersistentVolumeClaims struct {
...
@@ -28,31 +28,32 @@ type FakePersistentVolumeClaims struct {
Namespace
string
Namespace
string
}
}
func
(
c
*
FakePersistentVolumeClaims
)
List
(
label
s
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PersistentVolumeClaimList
,
error
)
{
func
(
c
*
FakePersistentVolumeClaims
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PersistentVolumeClaimList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-persistentVolumeClaims"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-persistentVolumeClaims"
},
&
api
.
PersistentVolumeClaimList
{
})
return
api
.
Scheme
.
CopyOrDie
(
&
c
.
Fake
.
PersistentVolumeClaimList
)
.
(
*
api
.
PersistentVolumeClaimList
),
c
.
Fake
.
E
rr
return
obj
.
(
*
api
.
PersistentVolumeClaimList
),
e
rr
}
}
func
(
c
*
FakePersistentVolumeClaims
)
Get
(
name
string
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
func
(
c
*
FakePersistentVolumeClaims
)
Get
(
name
string
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-persistentVolumeClaim"
,
Value
:
name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-persistentVolumeClaims"
,
Value
:
name
},
&
api
.
PersistentVolumeClaim
{
})
return
api
.
Scheme
.
CopyOrDie
(
&
c
.
Fake
.
PersistentVolumeClaim
)
.
(
*
api
.
PersistentVolumeClaim
),
nil
return
obj
.
(
*
api
.
PersistentVolumeClaim
),
err
}
}
func
(
c
*
FakePersistentVolumeClaims
)
Delete
(
name
string
)
error
{
func
(
c
*
FakePersistentVolumeClaims
)
Delete
(
name
string
)
error
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"delete-persistentVolumeClaim"
,
Value
:
name
})
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-persistentVolumeClaims"
,
Value
:
name
},
&
api
.
PersistentVolumeClaim
{
})
return
nil
return
err
}
}
func
(
c
*
FakePersistentVolumeClaims
)
Create
(
persistent
volumeclaim
*
api
.
PersistentVolumeClaim
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
func
(
c
*
FakePersistentVolumeClaims
)
Create
(
persistent
VolumeClaims
*
api
.
PersistentVolumeClaim
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"create-persistentVolumeClaim"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-persistentVolumeClaims"
},
&
api
.
PersistentVolumeClaim
{
})
return
&
api
.
PersistentVolumeClaim
{},
nil
return
obj
.
(
*
api
.
PersistentVolumeClaim
),
err
}
}
func
(
c
*
FakePersistentVolumeClaims
)
Update
(
persistent
volumeclaim
*
api
.
PersistentVolumeClaim
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
func
(
c
*
FakePersistentVolumeClaims
)
Update
(
persistent
VolumeClaims
*
api
.
PersistentVolumeClaim
)
(
*
api
.
PersistentVolumeClaim
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-persistentVolumeClaim"
,
Value
:
persistentvolumeclaim
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-persistentVolumeClaims"
,
Value
:
persistentVolumeClaims
.
Name
},
&
api
.
PersistentVolumeClaim
{
})
return
&
api
.
PersistentVolumeClaim
{},
nil
return
obj
.
(
*
api
.
PersistentVolumeClaim
),
err
}
}
func
(
c
*
FakePersistentVolumeClaims
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakePersistentVolumeClaims
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"watch-persistentVolumeClaims"
,
Value
:
resourceVersion
})
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
return
c
.
Fake
.
Watch
,
c
.
Fake
.
Err
}
}
pkg/client/fake_persistent_volumes.go
→
pkg/client/
testclient/
fake_persistent_volumes.go
View file @
842b9d8d
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -24,32 +24,33 @@ import (
...
@@ -24,32 +24,33 @@ import (
)
)
type
FakePersistentVolumes
struct
{
type
FakePersistentVolumes
struct
{
Fake
*
Fake
Fake
*
Fake
Namespace
string
}
}
func
(
c
*
FakePersistentVolumes
)
List
(
label
s
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PersistentVolumeList
,
error
)
{
func
(
c
*
FakePersistentVolumes
)
List
(
label
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
PersistentVolumeList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-persistentVolumes"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-persistentVolumes"
},
&
api
.
PersistentVolumeList
{
})
return
api
.
Scheme
.
CopyOrDie
(
&
c
.
Fake
.
PersistentVolumesList
)
.
(
*
api
.
PersistentVolumeList
),
nil
return
obj
.
(
*
api
.
PersistentVolumeList
),
err
}
}
func
(
c
*
FakePersistentVolumes
)
Get
(
name
string
)
(
*
api
.
PersistentVolume
,
error
)
{
func
(
c
*
FakePersistentVolumes
)
Get
(
name
string
)
(
*
api
.
PersistentVolume
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-persistentVolume"
,
Value
:
name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-persistentVolumes"
,
Value
:
name
},
&
api
.
PersistentVolume
{
})
return
api
.
Scheme
.
CopyOrDie
(
&
c
.
Fake
.
PersistentVolume
)
.
(
*
api
.
PersistentVolume
),
nil
return
obj
.
(
*
api
.
PersistentVolume
),
err
}
}
func
(
c
*
FakePersistentVolumes
)
Delete
(
name
string
)
error
{
func
(
c
*
FakePersistentVolumes
)
Delete
(
name
string
)
error
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"delete-persistentVolume"
,
Value
:
name
})
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-persistentVolumes"
,
Value
:
name
},
&
api
.
PersistentVolume
{
})
return
nil
return
err
}
}
func
(
c
*
FakePersistentVolumes
)
Create
(
persistent
volume
*
api
.
PersistentVolume
)
(
*
api
.
PersistentVolume
,
error
)
{
func
(
c
*
FakePersistentVolumes
)
Create
(
persistent
Volumes
*
api
.
PersistentVolume
)
(
*
api
.
PersistentVolume
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"create-persistentVolume"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-persistentVolumes"
},
&
api
.
PersistentVolume
{
})
return
&
api
.
PersistentVolume
{},
nil
return
obj
.
(
*
api
.
PersistentVolume
),
err
}
}
func
(
c
*
FakePersistentVolumes
)
Update
(
persistent
volume
*
api
.
PersistentVolume
)
(
*
api
.
PersistentVolume
,
error
)
{
func
(
c
*
FakePersistentVolumes
)
Update
(
persistent
Volumes
*
api
.
PersistentVolume
)
(
*
api
.
PersistentVolume
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-persistentVolume"
,
Value
:
persistentvolume
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-persistentVolumes"
,
Value
:
persistentVolumes
.
Name
},
&
api
.
PersistentVolume
{
})
return
&
api
.
PersistentVolume
{},
nil
return
obj
.
(
*
api
.
PersistentVolume
),
err
}
}
func
(
c
*
FakePersistentVolumes
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakePersistentVolumes
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
...
...
pkg/client/fake_pods.go
→
pkg/client/
testclient/
fake_pods.go
View file @
842b9d8d
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -31,28 +31,28 @@ type FakePods struct {
...
@@ -31,28 +31,28 @@ type FakePods struct {
}
}
func
(
c
*
FakePods
)
List
(
selector
labels
.
Selector
)
(
*
api
.
PodList
,
error
)
{
func
(
c
*
FakePods
)
List
(
selector
labels
.
Selector
)
(
*
api
.
PodList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-pods"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-pods"
},
&
api
.
PodList
{
})
return
api
.
Scheme
.
CopyOrDie
(
&
c
.
Fake
.
PodsList
)
.
(
*
api
.
PodList
),
nil
return
obj
.
(
*
api
.
PodList
),
err
}
}
func
(
c
*
FakePods
)
Get
(
name
string
)
(
*
api
.
Pod
,
error
)
{
func
(
c
*
FakePods
)
Get
(
name
string
)
(
*
api
.
Pod
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-pod"
,
Value
:
name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-pod"
,
Value
:
name
},
&
api
.
Pod
{
})
return
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
,
Namespace
:
c
.
Namespace
}},
nil
return
obj
.
(
*
api
.
Pod
),
err
}
}
func
(
c
*
FakePods
)
Delete
(
name
string
)
error
{
func
(
c
*
FakePods
)
Delete
(
name
string
)
error
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"delete-pod"
,
Value
:
name
})
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-pod"
,
Value
:
name
},
&
api
.
Pod
{
})
return
nil
return
err
}
}
func
(
c
*
FakePods
)
Create
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
{
func
(
c
*
FakePods
)
Create
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"create-pod"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-pod"
},
&
api
.
Pod
{
})
return
&
api
.
Pod
{},
nil
return
obj
.
(
*
api
.
Pod
),
err
}
}
func
(
c
*
FakePods
)
Update
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
{
func
(
c
*
FakePods
)
Update
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-pod"
,
Value
:
pod
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-pod"
,
Value
:
pod
.
Name
},
&
api
.
Pod
{
})
return
&
api
.
Pod
{},
nil
return
obj
.
(
*
api
.
Pod
),
err
}
}
func
(
c
*
FakePods
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakePods
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
...
@@ -66,6 +66,6 @@ func (c *FakePods) Bind(bind *api.Binding) error {
...
@@ -66,6 +66,6 @@ func (c *FakePods) Bind(bind *api.Binding) error {
}
}
func
(
c
*
FakePods
)
UpdateStatus
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
{
func
(
c
*
FakePods
)
UpdateStatus
(
pod
*
api
.
Pod
)
(
*
api
.
Pod
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-status-pod"
,
Value
:
pod
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-status-pod"
,
Value
:
pod
.
Name
},
&
api
.
Pod
{
})
return
&
api
.
Pod
{},
nil
return
obj
.
(
*
api
.
Pod
),
err
}
}
pkg/client/fake_replication_controllers.go
→
pkg/client/
testclient/
fake_replication_controllers.go
View file @
842b9d8d
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -31,31 +31,31 @@ type FakeReplicationControllers struct {
...
@@ -31,31 +31,31 @@ type FakeReplicationControllers struct {
}
}
func
(
c
*
FakeReplicationControllers
)
List
(
selector
labels
.
Selector
)
(
*
api
.
ReplicationControllerList
,
error
)
{
func
(
c
*
FakeReplicationControllers
)
List
(
selector
labels
.
Selector
)
(
*
api
.
ReplicationControllerList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-controllers"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-replicationControllers"
},
&
api
.
ReplicationControllerList
{
})
return
api
.
Scheme
.
CopyOrDie
(
&
c
.
Fake
.
CtrlList
)
.
(
*
api
.
ReplicationControllerList
),
nil
return
obj
.
(
*
api
.
ReplicationControllerList
),
err
}
}
func
(
c
*
FakeReplicationControllers
)
Get
(
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
FakeReplicationControllers
)
Get
(
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-controller"
,
Value
:
name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-replicationController"
,
Value
:
name
},
&
api
.
ReplicationController
{
})
return
api
.
Scheme
.
CopyOrDie
(
&
c
.
Fake
.
Ctrl
)
.
(
*
api
.
ReplicationController
),
nil
return
obj
.
(
*
api
.
ReplicationController
),
err
}
}
func
(
c
*
FakeReplicationControllers
)
Create
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
FakeReplicationControllers
)
Create
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"create-controller"
,
Value
:
controller
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-replicationController"
,
Value
:
controller
},
&
api
.
ReplicationController
{
})
return
&
api
.
ReplicationController
{},
nil
return
obj
.
(
*
api
.
ReplicationController
),
err
}
}
func
(
c
*
FakeReplicationControllers
)
Update
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
FakeReplicationControllers
)
Update
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-controller"
,
Value
:
controller
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-replicationController"
,
Value
:
controller
},
&
api
.
ReplicationController
{
})
return
&
api
.
ReplicationController
{},
nil
return
obj
.
(
*
api
.
ReplicationController
),
err
}
}
func
(
c
*
FakeReplicationControllers
)
Delete
(
controller
string
)
error
{
func
(
c
*
FakeReplicationControllers
)
Delete
(
name
string
)
error
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"delete-controller"
,
Value
:
controller
})
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-replicationController"
,
Value
:
name
},
&
api
.
ReplicationController
{
})
return
nil
return
err
}
}
func
(
c
*
FakeReplicationControllers
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeReplicationControllers
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"watch-
controllers
"
,
Value
:
resourceVersion
})
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"watch-
replicationController
"
,
Value
:
resourceVersion
})
return
c
.
Fake
.
Watch
,
nil
return
c
.
Fake
.
Watch
,
nil
}
}
pkg/client/fake_resource_quotas.go
→
pkg/client/
testclient/
fake_resource_quotas.go
View file @
842b9d8d
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -31,34 +31,33 @@ type FakeResourceQuotas struct {
...
@@ -31,34 +31,33 @@ type FakeResourceQuotas struct {
}
}
func
(
c
*
FakeResourceQuotas
)
List
(
selector
labels
.
Selector
)
(
*
api
.
ResourceQuotaList
,
error
)
{
func
(
c
*
FakeResourceQuotas
)
List
(
selector
labels
.
Selector
)
(
*
api
.
ResourceQuotaList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-resourceQuotas"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-resourceQuotas"
},
&
api
.
ResourceQuotaList
{
})
return
api
.
Scheme
.
CopyOrDie
(
&
c
.
Fake
.
ResourceQuotasList
)
.
(
*
api
.
ResourceQuotaList
),
nil
return
obj
.
(
*
api
.
ResourceQuotaList
),
err
}
}
func
(
c
*
FakeResourceQuotas
)
Get
(
name
string
)
(
*
api
.
ResourceQuota
,
error
)
{
func
(
c
*
FakeResourceQuotas
)
Get
(
name
string
)
(
*
api
.
ResourceQuota
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-resourceQuota"
,
Value
:
name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-resourceQuota"
,
Value
:
name
},
&
api
.
ResourceQuota
{
})
return
&
api
.
ResourceQuota
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
,
Namespace
:
c
.
Namespace
}},
nil
return
obj
.
(
*
api
.
ResourceQuota
),
err
}
}
func
(
c
*
FakeResourceQuotas
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeResourceQuotas
)
Delete
(
name
string
)
error
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"delete-resourceQuota"
,
Value
:
name
})
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-resourceQuota"
,
Value
:
name
},
&
api
.
ResourceQuota
{
})
return
nil
return
err
}
}
func
(
c
*
FakeResourceQuotas
)
Create
(
resourceQuota
*
api
.
ResourceQuota
)
(
*
api
.
ResourceQuota
,
error
)
{
func
(
c
*
FakeResourceQuotas
)
Create
(
resourceQuota
*
api
.
ResourceQuota
)
(
*
api
.
ResourceQuota
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"create-resourceQuota"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-resourceQuota"
,
Value
:
resourceQuota
},
&
api
.
ResourceQuota
{
})
return
&
api
.
ResourceQuota
{},
nil
return
obj
.
(
*
api
.
ResourceQuota
),
err
}
}
func
(
c
*
FakeResourceQuotas
)
Update
(
resourceQuota
*
api
.
ResourceQuota
)
(
*
api
.
ResourceQuota
,
error
)
{
func
(
c
*
FakeResourceQuotas
)
Update
(
resourceQuota
*
api
.
ResourceQuota
)
(
*
api
.
ResourceQuota
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-resourceQuota"
,
Value
:
resourceQuota
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-resourceQuota"
,
Value
:
resourceQuota
},
&
api
.
ResourceQuota
{
})
return
&
api
.
ResourceQuota
{},
nil
return
obj
.
(
*
api
.
ResourceQuota
),
err
}
}
func
(
c
*
FakeResourceQuotas
)
UpdateStatus
(
resourceQuota
*
api
.
ResourceQuota
)
(
*
api
.
ResourceQuota
,
error
)
{
func
(
c
*
FakeResourceQuotas
)
UpdateStatus
(
resourceQuota
*
api
.
ResourceQuota
)
(
*
api
.
ResourceQuota
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-status-resourceQuota"
,
Value
:
resourceQuota
.
Name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-status-resourceQuota"
,
Value
:
resourceQuota
},
&
api
.
ResourceQuota
{})
c
.
Fake
.
ResourceQuotaStatus
=
*
resourceQuota
return
obj
.
(
*
api
.
ResourceQuota
),
err
return
&
api
.
ResourceQuota
{},
nil
}
}
func
(
c
*
FakeResourceQuotas
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeResourceQuotas
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
...
...
pkg/client/fake_secrets.go
→
pkg/client/
testclient/
fake_secrets.go
View file @
842b9d8d
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -31,28 +31,28 @@ type FakeSecrets struct {
...
@@ -31,28 +31,28 @@ type FakeSecrets struct {
}
}
func
(
c
*
FakeSecrets
)
List
(
labels
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
SecretList
,
error
)
{
func
(
c
*
FakeSecrets
)
List
(
labels
labels
.
Selector
,
field
fields
.
Selector
)
(
*
api
.
SecretList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-secrets"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-secrets"
},
&
api
.
SecretList
{
})
return
&
c
.
Fake
.
SecretList
,
c
.
Fake
.
E
rr
return
obj
.
(
*
api
.
SecretList
),
e
rr
}
}
func
(
c
*
FakeSecrets
)
Get
(
name
string
)
(
*
api
.
Secret
,
error
)
{
func
(
c
*
FakeSecrets
)
Get
(
name
string
)
(
*
api
.
Secret
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-secret"
,
Value
:
name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-secret"
,
Value
:
name
},
&
api
.
Secret
{
})
return
api
.
Scheme
.
CopyOrDie
(
&
c
.
Fake
.
Secret
)
.
(
*
api
.
Secret
),
nil
return
obj
.
(
*
api
.
Secret
),
err
}
}
func
(
c
*
FakeSecrets
)
Create
(
secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
{
func
(
c
*
FakeSecrets
)
Create
(
secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"create-secret"
,
Value
:
secret
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-secret"
,
Value
:
secret
},
&
api
.
Secret
{
})
return
&
api
.
Secret
{},
nil
return
obj
.
(
*
api
.
Secret
),
err
}
}
func
(
c
*
FakeSecrets
)
Update
(
secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
{
func
(
c
*
FakeSecrets
)
Update
(
secret
*
api
.
Secret
)
(
*
api
.
Secret
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-secret"
,
Value
:
secret
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-secret"
,
Value
:
secret
},
&
api
.
Secret
{
})
return
&
api
.
Secret
{},
nil
return
obj
.
(
*
api
.
Secret
),
err
}
}
func
(
c
*
FakeSecrets
)
Delete
(
secret
string
)
error
{
func
(
c
*
FakeSecrets
)
Delete
(
name
string
)
error
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"delete-secret"
,
Value
:
secret
})
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-secret"
,
Value
:
name
},
&
api
.
Secret
{
})
return
nil
return
err
}
}
func
(
c
*
FakeSecrets
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeSecrets
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
...
...
pkg/client/fake_services.go
→
pkg/client/
testclient/
fake_services.go
View file @
842b9d8d
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -31,28 +31,28 @@ type FakeServices struct {
...
@@ -31,28 +31,28 @@ type FakeServices struct {
}
}
func
(
c
*
FakeServices
)
List
(
selector
labels
.
Selector
)
(
*
api
.
ServiceList
,
error
)
{
func
(
c
*
FakeServices
)
List
(
selector
labels
.
Selector
)
(
*
api
.
ServiceList
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"list-services"
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"list-services"
},
&
api
.
ServiceList
{
})
return
&
c
.
Fake
.
ServiceList
,
c
.
Fake
.
E
rr
return
obj
.
(
*
api
.
ServiceList
),
e
rr
}
}
func
(
c
*
FakeServices
)
Get
(
name
string
)
(
*
api
.
Service
,
error
)
{
func
(
c
*
FakeServices
)
Get
(
name
string
)
(
*
api
.
Service
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"get-service"
,
Value
:
name
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"get-service"
,
Value
:
name
},
&
api
.
Service
{
})
return
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
,
Namespace
:
c
.
Namespace
}},
nil
return
obj
.
(
*
api
.
Service
),
err
}
}
func
(
c
*
FakeServices
)
Create
(
service
*
api
.
Service
)
(
*
api
.
Service
,
error
)
{
func
(
c
*
FakeServices
)
Create
(
service
*
api
.
Service
)
(
*
api
.
Service
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"create-service"
,
Value
:
service
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"create-service"
,
Value
:
service
},
&
api
.
Service
{
})
return
&
api
.
Service
{},
nil
return
obj
.
(
*
api
.
Service
),
err
}
}
func
(
c
*
FakeServices
)
Update
(
service
*
api
.
Service
)
(
*
api
.
Service
,
error
)
{
func
(
c
*
FakeServices
)
Update
(
service
*
api
.
Service
)
(
*
api
.
Service
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-service"
,
Value
:
service
})
obj
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"update-service"
,
Value
:
service
},
&
api
.
Service
{
})
return
&
api
.
Service
{},
nil
return
obj
.
(
*
api
.
Service
),
err
}
}
func
(
c
*
FakeServices
)
Delete
(
servic
e
string
)
error
{
func
(
c
*
FakeServices
)
Delete
(
nam
e
string
)
error
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"delete-service"
,
Value
:
service
})
_
,
err
:=
c
.
Fake
.
Invokes
(
FakeAction
{
Action
:
"delete-service"
,
Value
:
name
},
&
api
.
Service
{
})
return
nil
return
err
}
}
func
(
c
*
FakeServices
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeServices
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
...
...
pkg/client/fake_test.go
→
pkg/client/
testclient/
fake_test.go
View file @
842b9d8d
...
@@ -14,17 +14,19 @@ See the License for the specific language governing permissions and
...
@@ -14,17 +14,19 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
client
package
test
client
import
(
import
(
"testing"
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
)
)
// This test file just ensures that Fake and structs it is embedded in
// This test file just ensures that Fake and structs it is embedded in
// implement Interface.
// implement Interface.
func
TestFakeImplementsInterface
(
t
*
testing
.
T
)
{
func
TestFakeImplementsInterface
(
t
*
testing
.
T
)
{
_
=
Interface
(
&
Fake
{})
_
=
client
.
Interface
(
&
Fake
{})
}
}
type
MyFake
struct
{
type
MyFake
struct
{
...
@@ -32,6 +34,6 @@ type MyFake struct {
...
@@ -32,6 +34,6 @@ type MyFake struct {
}
}
func
TestEmbeddedFakeImplementsInterface
(
t
*
testing
.
T
)
{
func
TestEmbeddedFakeImplementsInterface
(
t
*
testing
.
T
)
{
_
=
Interface
(
MyFake
{
&
Fake
{}})
_
=
client
.
Interface
(
MyFake
{
&
Fake
{}})
_
=
Interface
(
&
MyFake
{
&
Fake
{}})
_
=
client
.
Interface
(
&
MyFake
{
&
Fake
{}})
}
}
pkg/client/testclient/fixture.go
0 → 100644
View file @
842b9d8d
/*
Copyright 2015 Google Inc. All rights reserved.
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
testclient
import
(
"fmt"
"io/ioutil"
"reflect"
"strings"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/yaml"
)
// ObjectRetriever abstracts the implementation for retrieving or setting generic
// objects. It is intended to be used to fake calls to a server by returning
// objects based on their kind and name.
type
ObjectRetriever
interface
{
// Kind should return a resource or a list of resources (depending on the provided kind and
// name). It should return an error if the caller should communicate an error to the server.
Kind
(
kind
,
name
string
)
(
runtime
.
Object
,
error
)
// Add adds a runtime object for test purposes into this object.
Add
(
runtime
.
Object
)
error
}
// ObjectReaction returns a ReactionFunc that takes a generic action string of the form
// <verb>-<resource> or <verb>-<subresource>-<resource> and attempts to return a runtime
// Object or error that matches the requested action. For instance, list-replicationControllers
// should attempt to return a list of replication controllers. This method delegates to the
// ObjectRetriever interface to satisfy retrieval of lists or retrieval of single items.
// TODO: add support for sub resources
func
ObjectReaction
(
o
ObjectRetriever
,
mapper
meta
.
RESTMapper
)
ReactionFunc
{
return
func
(
action
FakeAction
)
(
runtime
.
Object
,
error
)
{
segments
:=
strings
.
Split
(
action
.
Action
,
"-"
)
var
verb
,
resource
string
switch
len
(
segments
)
{
case
3
:
verb
,
_
,
resource
=
segments
[
0
],
segments
[
1
],
segments
[
2
]
case
2
:
verb
,
resource
=
segments
[
0
],
segments
[
1
]
default
:
return
nil
,
fmt
.
Errorf
(
"unrecognized action, need two or three segments <verb>-<resource> or <verb>-<subresource>-<resource>: %s"
,
action
.
Action
)
}
_
,
kind
,
err
:=
mapper
.
VersionAndKindForResource
(
resource
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"unrecognized action %s: %v"
,
resource
,
err
)
}
// TODO: have mapper return a Kind for a subresource?
switch
verb
{
case
"list"
,
"search"
:
return
o
.
Kind
(
kind
+
"List"
,
""
)
case
"get"
,
"create"
,
"update"
,
"delete"
:
// TODO: handle sub resources
if
s
,
ok
:=
action
.
Value
.
(
string
);
ok
&&
action
.
Value
!=
nil
{
return
o
.
Kind
(
kind
,
s
)
}
return
o
.
Kind
(
kind
,
"unknown"
)
default
:
return
nil
,
fmt
.
Errorf
(
"no reaction implemented for %s"
,
action
.
Action
)
}
return
nil
,
nil
}
}
// AddObjectsFromPath loads the JSON or YAML file containing Kubernetes API resources
// and adds them to the provided ObjectRetriever.
func
AddObjectsFromPath
(
path
string
,
o
ObjectRetriever
)
error
{
data
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
return
err
}
data
,
err
=
yaml
.
ToJSON
(
data
)
if
err
!=
nil
{
return
err
}
obj
,
err
:=
api
.
Codec
.
Decode
(
data
)
if
err
!=
nil
{
return
err
}
if
err
:=
o
.
Add
(
obj
);
err
!=
nil
{
return
err
}
return
nil
}
type
objects
struct
{
types
map
[
string
][]
runtime
.
Object
last
map
[
string
]
int
typer
runtime
.
ObjectTyper
creater
runtime
.
ObjectCreater
copier
copier
}
var
_
ObjectRetriever
=
&
objects
{}
type
copier
interface
{
Copy
(
obj
runtime
.
Object
)
(
runtime
.
Object
,
error
)
}
// NewObjects implements the ObjectRetriever interface by introspecting the
// objects provided to Add() and returning them when the Kind method is invoked.
// If an api.List object is provided to Add(), each child item is added. If an
// object is added that is itself a list (PodList, ServiceList) then that is added
// to the "PodList" kind. If no PodList is added, the retriever will take any loaded
// Pods and return them in a list. If an api.Status is added, and the Details.Kind field
// is set, that status will be returned instead (as an error if Status != Success, or
// as a runtime.Object if Status == Success). If multiple PodLists are provided, they
// will be returned in order by the Kind call, and the last PodList will be reused for
// subsequent calls.
func
NewObjects
(
scheme
*
runtime
.
Scheme
)
ObjectRetriever
{
return
objects
{
types
:
make
(
map
[
string
][]
runtime
.
Object
),
last
:
make
(
map
[
string
]
int
),
typer
:
scheme
,
creater
:
scheme
,
copier
:
scheme
,
}
}
func
(
o
objects
)
Kind
(
kind
,
name
string
)
(
runtime
.
Object
,
error
)
{
empty
,
_
:=
o
.
creater
.
New
(
""
,
kind
)
nilValue
:=
reflect
.
Zero
(
reflect
.
TypeOf
(
empty
))
.
Interface
()
.
(
runtime
.
Object
)
arr
,
ok
:=
o
.
types
[
kind
]
if
!
ok
{
if
strings
.
HasSuffix
(
kind
,
"List"
)
{
itemKind
:=
kind
[
:
len
(
kind
)
-
4
]
arr
,
ok
:=
o
.
types
[
itemKind
]
if
!
ok
{
return
empty
,
nil
}
out
,
err
:=
o
.
creater
.
New
(
""
,
kind
)
if
err
!=
nil
{
return
nilValue
,
err
}
if
err
:=
runtime
.
SetList
(
out
,
arr
);
err
!=
nil
{
return
nilValue
,
err
}
if
out
,
err
=
o
.
copier
.
Copy
(
out
);
err
!=
nil
{
return
nilValue
,
err
}
return
out
,
nil
}
return
nilValue
,
errors
.
NewNotFound
(
kind
,
name
)
}
index
:=
o
.
last
[
kind
]
if
index
>=
len
(
arr
)
{
index
=
len
(
arr
)
-
1
}
if
index
<
0
{
return
nilValue
,
errors
.
NewNotFound
(
kind
,
name
)
}
out
,
err
:=
o
.
copier
.
Copy
(
arr
[
index
])
if
err
!=
nil
{
return
nilValue
,
err
}
o
.
last
[
kind
]
=
index
+
1
if
status
,
ok
:=
out
.
(
*
api
.
Status
);
ok
{
if
status
.
Details
!=
nil
{
status
.
Details
.
Kind
=
kind
}
if
status
.
Status
!=
api
.
StatusSuccess
{
return
nilValue
,
&
errors
.
StatusError
{
*
status
}
}
}
return
out
,
nil
}
func
(
o
objects
)
Add
(
obj
runtime
.
Object
)
error
{
_
,
kind
,
err
:=
o
.
typer
.
ObjectVersionAndKind
(
obj
)
if
err
!=
nil
{
return
err
}
switch
{
case
runtime
.
IsListType
(
obj
)
:
if
kind
!=
"List"
{
o
.
types
[
kind
]
=
append
(
o
.
types
[
kind
],
obj
)
}
list
,
err
:=
runtime
.
ExtractList
(
obj
)
if
err
!=
nil
{
return
err
}
for
_
,
obj
:=
range
list
{
if
err
:=
o
.
Add
(
obj
);
err
!=
nil
{
return
err
}
}
default
:
if
status
,
ok
:=
obj
.
(
*
api
.
Status
);
ok
&&
status
.
Details
!=
nil
{
kind
=
status
.
Details
.
Kind
}
o
.
types
[
kind
]
=
append
(
o
.
types
[
kind
],
obj
)
}
return
nil
}
pkg/client/testclient/testclient.go
0 → 100644
View file @
842b9d8d
/*
Copyright 2015 Google Inc. All rights reserved.
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
testclient
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
)
// NewSimpleFake returns a client that will respond with the provided objects
func
NewSimpleFake
(
objects
...
runtime
.
Object
)
*
Fake
{
o
:=
NewObjects
(
api
.
Scheme
)
for
_
,
obj
:=
range
objects
{
if
err
:=
o
.
Add
(
obj
);
err
!=
nil
{
panic
(
err
)
}
}
return
&
Fake
{
ReactFn
:
ObjectReaction
(
o
,
latest
.
RESTMapper
)}
}
type
FakeAction
struct
{
Action
string
Value
interface
{}
}
// ReactionFunc is a function that returns an object or error for a given Action
type
ReactionFunc
func
(
FakeAction
)
(
runtime
.
Object
,
error
)
// Fake implements client.Interface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the method you want to test easier.
type
Fake
struct
{
Actions
[]
FakeAction
Watch
watch
.
Interface
Err
error
// ReactFn is an optional function that will be invoked with the provided action
// and return a response. It can implement scenario specific behavior. The type
// of object returned must match the expected type from the caller (even if nil).
ReactFn
ReactionFunc
}
// Invokes records the provided FakeAction and then invokes the ReactFn (if provided).
// obj is expected to be of the same type a normal call would return.
func
(
c
*
Fake
)
Invokes
(
action
FakeAction
,
obj
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
c
.
Actions
=
append
(
c
.
Actions
,
action
)
if
c
.
ReactFn
!=
nil
{
return
c
.
ReactFn
(
action
)
}
return
obj
,
c
.
Err
}
func
(
c
*
Fake
)
LimitRanges
(
namespace
string
)
client
.
LimitRangeInterface
{
return
&
FakeLimitRanges
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
ResourceQuotas
(
namespace
string
)
client
.
ResourceQuotaInterface
{
return
&
FakeResourceQuotas
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
ReplicationControllers
(
namespace
string
)
client
.
ReplicationControllerInterface
{
return
&
FakeReplicationControllers
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
Nodes
()
client
.
NodeInterface
{
return
&
FakeNodes
{
Fake
:
c
}
}
func
(
c
*
Fake
)
Events
(
namespace
string
)
client
.
EventInterface
{
return
&
FakeEvents
{
Fake
:
c
}
}
func
(
c
*
Fake
)
Endpoints
(
namespace
string
)
client
.
EndpointsInterface
{
return
&
FakeEndpoints
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
PersistentVolumes
()
client
.
PersistentVolumeInterface
{
return
&
FakePersistentVolumes
{
Fake
:
c
}
}
func
(
c
*
Fake
)
PersistentVolumeClaims
(
namespace
string
)
client
.
PersistentVolumeClaimInterface
{
return
&
FakePersistentVolumeClaims
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
Pods
(
namespace
string
)
client
.
PodInterface
{
return
&
FakePods
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
Services
(
namespace
string
)
client
.
ServiceInterface
{
return
&
FakeServices
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
Secrets
(
namespace
string
)
client
.
SecretsInterface
{
return
&
FakeSecrets
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
Namespaces
()
client
.
NamespaceInterface
{
return
&
FakeNamespaces
{
Fake
:
c
}
}
func
(
c
*
Fake
)
ServerVersion
()
(
*
version
.
Info
,
error
)
{
c
.
Actions
=
append
(
c
.
Actions
,
FakeAction
{
Action
:
"get-version"
,
Value
:
nil
})
versionInfo
:=
version
.
Get
()
return
&
versionInfo
,
nil
}
func
(
c
*
Fake
)
ServerAPIVersions
()
(
*
api
.
APIVersions
,
error
)
{
c
.
Actions
=
append
(
c
.
Actions
,
FakeAction
{
Action
:
"get-apiversions"
,
Value
:
nil
})
return
&
api
.
APIVersions
{
Versions
:
[]
string
{
"v1beta1"
,
"v1beta2"
}},
nil
}
pkg/client/testclient/testclient_test.go
0 → 100644
View file @
842b9d8d
/*
Copyright 2015 Google Inc. All rights reserved.
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
testclient
import
(
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
func
TestNewClient
(
t
*
testing
.
T
)
{
o
:=
NewObjects
(
api
.
Scheme
)
if
err
:=
AddObjectsFromPath
(
"../../../examples/guestbook/frontend-service.json"
,
o
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
client
:=
&
Fake
{
ReactFn
:
ObjectReaction
(
o
,
latest
.
RESTMapper
)}
list
,
err
:=
client
.
Services
(
"test"
)
.
List
(
labels
.
Everything
())
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
list
.
Items
)
!=
1
{
t
.
Fatalf
(
"unexpected list %#v"
,
list
)
}
// When list is invoked a second time, the same results are returned.
list
,
err
=
client
.
Services
(
"test"
)
.
List
(
labels
.
Everything
())
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
list
.
Items
)
!=
1
{
t
.
Fatalf
(
"unexpected list %#v"
,
list
)
}
t
.
Logf
(
"list: %#v"
,
list
)
}
func
TestErrors
(
t
*
testing
.
T
)
{
o
:=
NewObjects
(
api
.
Scheme
)
o
.
Add
(
&
api
.
List
{
Items
:
[]
runtime
.
Object
{
// This first call to List will return this error
&
(
errors
.
NewNotFound
(
"ServiceList"
,
""
)
.
(
*
errors
.
StatusError
)
.
ErrStatus
),
// The second call to List will return this error
&
(
errors
.
NewForbidden
(
"ServiceList"
,
""
,
nil
)
.
(
*
errors
.
StatusError
)
.
ErrStatus
),
},
})
client
:=
&
Fake
{
ReactFn
:
ObjectReaction
(
o
,
latest
.
RESTMapper
)}
_
,
err
:=
client
.
Services
(
"test"
)
.
List
(
labels
.
Everything
())
if
!
errors
.
IsNotFound
(
err
)
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
t
.
Logf
(
"error: %#v"
,
err
.
(
*
errors
.
StatusError
)
.
Status
())
_
,
err
=
client
.
Services
(
"test"
)
.
List
(
labels
.
Everything
())
if
!
errors
.
IsForbidden
(
err
)
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
pkg/cloudprovider/controller/nodecontroller_test.go
View file @
842b9d8d
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
apierrors
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
apierrors
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
fake_cloud
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
fake_cloud
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
...
@@ -49,7 +50,7 @@ const (
...
@@ -49,7 +50,7 @@ const (
// PodsInterface and PodInterface to test list & delet pods, which is implemented in
// PodsInterface and PodInterface to test list & delet pods, which is implemented in
// the embeded client.Fake field.
// the embeded client.Fake field.
type
FakeNodeHandler
struct
{
type
FakeNodeHandler
struct
{
client
.
Fake
*
test
client
.
Fake
// Input: Hooks determine if request is valid or not
// Input: Hooks determine if request is valid or not
CreateHook
func
(
*
FakeNodeHandler
,
*
api
.
Node
)
bool
CreateHook
func
(
*
FakeNodeHandler
,
*
api
.
Node
)
bool
...
@@ -508,6 +509,9 @@ func TestSyncCloudNodes(t *testing.T) {
...
@@ -508,6 +509,9 @@ func TestSyncCloudNodes(t *testing.T) {
}
}
for
_
,
item
:=
range
table
{
for
_
,
item
:=
range
table
{
if
item
.
fakeNodeHandler
.
Fake
==
nil
{
item
.
fakeNodeHandler
.
Fake
=
testclient
.
NewSimpleFake
()
}
nodeController
:=
NewNodeController
(
item
.
fakeCloud
,
item
.
matchRE
,
nil
,
&
api
.
NodeResources
{},
item
.
fakeNodeHandler
,
nil
,
10
,
time
.
Minute
,
nodeController
:=
NewNodeController
(
item
.
fakeCloud
,
item
.
matchRE
,
nil
,
&
api
.
NodeResources
{},
item
.
fakeNodeHandler
,
nil
,
10
,
time
.
Minute
,
util
.
NewFakeRateLimiter
(),
testNodeMonitorGracePeriod
,
testNodeStartupGracePeriod
,
testNodeMonitorPeriod
)
util
.
NewFakeRateLimiter
(),
testNodeMonitorGracePeriod
,
testNodeStartupGracePeriod
,
testNodeMonitorPeriod
)
if
err
:=
nodeController
.
SyncCloudNodes
();
err
!=
nil
{
if
err
:=
nodeController
.
SyncCloudNodes
();
err
!=
nil
{
...
@@ -542,15 +546,13 @@ func TestSyncCloudNodesEvictPods(t *testing.T) {
...
@@ -542,15 +546,13 @@ func TestSyncCloudNodesEvictPods(t *testing.T) {
matchRE
string
matchRE
string
expectedRequestCount
int
expectedRequestCount
int
expectedDeleted
[]
string
expectedDeleted
[]
string
expectedActions
[]
client
.
FakeAction
expectedActions
[]
test
client
.
FakeAction
}{
}{
{
{
// No node to delete: do nothing.
// No node to delete: do nothing.
fakeNodeHandler
:
&
FakeNodeHandler
{
fakeNodeHandler
:
&
FakeNodeHandler
{
Existing
:
[]
*
api
.
Node
{
newNode
(
"node0"
),
newNode
(
"node1"
)},
Existing
:
[]
*
api
.
Node
{
newNode
(
"node0"
),
newNode
(
"node1"
)},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
),
*
newPod
(
"pod1"
,
"node1"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
),
*
newPod
(
"pod1"
,
"node1"
)}},
},
},
},
fakeCloud
:
&
fake_cloud
.
FakeCloud
{
fakeCloud
:
&
fake_cloud
.
FakeCloud
{
Machines
:
[]
string
{
"node0"
,
"node1"
},
Machines
:
[]
string
{
"node0"
,
"node1"
},
...
@@ -564,9 +566,7 @@ func TestSyncCloudNodesEvictPods(t *testing.T) {
...
@@ -564,9 +566,7 @@ func TestSyncCloudNodesEvictPods(t *testing.T) {
// Delete node1, and pod0 is running on it.
// Delete node1, and pod0 is running on it.
fakeNodeHandler
:
&
FakeNodeHandler
{
fakeNodeHandler
:
&
FakeNodeHandler
{
Existing
:
[]
*
api
.
Node
{
newNode
(
"node0"
),
newNode
(
"node1"
)},
Existing
:
[]
*
api
.
Node
{
newNode
(
"node0"
),
newNode
(
"node1"
)},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node1"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node1"
)}},
},
},
},
fakeCloud
:
&
fake_cloud
.
FakeCloud
{
fakeCloud
:
&
fake_cloud
.
FakeCloud
{
Machines
:
[]
string
{
"node0"
},
Machines
:
[]
string
{
"node0"
},
...
@@ -574,15 +574,13 @@ func TestSyncCloudNodesEvictPods(t *testing.T) {
...
@@ -574,15 +574,13 @@ func TestSyncCloudNodesEvictPods(t *testing.T) {
matchRE
:
".*"
,
matchRE
:
".*"
,
expectedRequestCount
:
2
,
// List + Delete
expectedRequestCount
:
2
,
// List + Delete
expectedDeleted
:
[]
string
{
"node1"
},
expectedDeleted
:
[]
string
{
"node1"
},
expectedActions
:
[]
client
.
FakeAction
{{
Action
:
"list-pods"
},
{
Action
:
"delete-pod"
,
Value
:
"pod0"
}},
expectedActions
:
[]
test
client
.
FakeAction
{{
Action
:
"list-pods"
},
{
Action
:
"delete-pod"
,
Value
:
"pod0"
}},
},
},
{
{
// Delete node1, but pod0 is running on node0.
// Delete node1, but pod0 is running on node0.
fakeNodeHandler
:
&
FakeNodeHandler
{
fakeNodeHandler
:
&
FakeNodeHandler
{
Existing
:
[]
*
api
.
Node
{
newNode
(
"node0"
),
newNode
(
"node1"
)},
Existing
:
[]
*
api
.
Node
{
newNode
(
"node0"
),
newNode
(
"node1"
)},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
fakeCloud
:
&
fake_cloud
.
FakeCloud
{
fakeCloud
:
&
fake_cloud
.
FakeCloud
{
Machines
:
[]
string
{
"node0"
},
Machines
:
[]
string
{
"node0"
},
...
@@ -590,11 +588,14 @@ func TestSyncCloudNodesEvictPods(t *testing.T) {
...
@@ -590,11 +588,14 @@ func TestSyncCloudNodesEvictPods(t *testing.T) {
matchRE
:
".*"
,
matchRE
:
".*"
,
expectedRequestCount
:
2
,
// List + Delete
expectedRequestCount
:
2
,
// List + Delete
expectedDeleted
:
[]
string
{
"node1"
},
expectedDeleted
:
[]
string
{
"node1"
},
expectedActions
:
[]
client
.
FakeAction
{{
Action
:
"list-pods"
}},
expectedActions
:
[]
test
client
.
FakeAction
{{
Action
:
"list-pods"
}},
},
},
}
}
for
_
,
item
:=
range
table
{
for
_
,
item
:=
range
table
{
if
item
.
fakeNodeHandler
.
Fake
==
nil
{
item
.
fakeNodeHandler
.
Fake
=
testclient
.
NewSimpleFake
()
}
nodeController
:=
NewNodeController
(
item
.
fakeCloud
,
item
.
matchRE
,
nil
,
&
api
.
NodeResources
{},
item
.
fakeNodeHandler
,
nil
,
10
,
time
.
Minute
,
nodeController
:=
NewNodeController
(
item
.
fakeCloud
,
item
.
matchRE
,
nil
,
&
api
.
NodeResources
{},
item
.
fakeNodeHandler
,
nil
,
10
,
time
.
Minute
,
util
.
NewFakeRateLimiter
(),
testNodeMonitorGracePeriod
,
testNodeStartupGracePeriod
,
testNodeMonitorPeriod
)
util
.
NewFakeRateLimiter
(),
testNodeMonitorGracePeriod
,
testNodeStartupGracePeriod
,
testNodeMonitorPeriod
)
if
err
:=
nodeController
.
SyncCloudNodes
();
err
!=
nil
{
if
err
:=
nodeController
.
SyncCloudNodes
();
err
!=
nil
{
...
@@ -915,7 +916,7 @@ func TestSyncProbedNodeStatusEvictPods(t *testing.T) {
...
@@ -915,7 +916,7 @@ func TestSyncProbedNodeStatusEvictPods(t *testing.T) {
fakeNodeHandler
*
FakeNodeHandler
fakeNodeHandler
*
FakeNodeHandler
fakeKubeletClient
*
FakeKubeletClient
fakeKubeletClient
*
FakeKubeletClient
expectedRequestCount
int
expectedRequestCount
int
expectedActions
[]
client
.
FakeAction
expectedActions
[]
test
client
.
FakeAction
}{
}{
{
{
// Existing node is healthy, current probe is healthy too.
// Existing node is healthy, current probe is healthy too.
...
@@ -935,9 +936,7 @@ func TestSyncProbedNodeStatusEvictPods(t *testing.T) {
...
@@ -935,9 +936,7 @@ func TestSyncProbedNodeStatusEvictPods(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node1"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node1"
)}},
},
},
},
fakeKubeletClient
:
&
FakeKubeletClient
{
fakeKubeletClient
:
&
FakeKubeletClient
{
Status
:
probe
.
Success
,
Status
:
probe
.
Success
,
...
@@ -965,9 +964,7 @@ func TestSyncProbedNodeStatusEvictPods(t *testing.T) {
...
@@ -965,9 +964,7 @@ func TestSyncProbedNodeStatusEvictPods(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
fakeKubeletClient
:
&
FakeKubeletClient
{
fakeKubeletClient
:
&
FakeKubeletClient
{
Status
:
probe
.
Failure
,
Status
:
probe
.
Failure
,
...
@@ -997,9 +994,7 @@ func TestSyncProbedNodeStatusEvictPods(t *testing.T) {
...
@@ -997,9 +994,7 @@ func TestSyncProbedNodeStatusEvictPods(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
fakeKubeletClient
:
&
FakeKubeletClient
{
fakeKubeletClient
:
&
FakeKubeletClient
{
Status
:
probe
.
Failure
,
Status
:
probe
.
Failure
,
...
@@ -1030,16 +1025,14 @@ func TestSyncProbedNodeStatusEvictPods(t *testing.T) {
...
@@ -1030,16 +1025,14 @@ func TestSyncProbedNodeStatusEvictPods(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
fakeKubeletClient
:
&
FakeKubeletClient
{
fakeKubeletClient
:
&
FakeKubeletClient
{
Status
:
probe
.
Failure
,
Status
:
probe
.
Failure
,
Err
:
nil
,
Err
:
nil
,
},
},
expectedRequestCount
:
2
,
// List+Update
expectedRequestCount
:
2
,
// List+Update
expectedActions
:
[]
client
.
FakeAction
{{
Action
:
"list-pods"
},
{
Action
:
"delete-pod"
,
Value
:
"pod0"
}},
expectedActions
:
[]
test
client
.
FakeAction
{{
Action
:
"list-pods"
},
{
Action
:
"delete-pod"
,
Value
:
"pod0"
}},
},
},
}
}
...
@@ -1081,9 +1074,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
...
@@ -1081,9 +1074,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
timeToPass
:
0
,
timeToPass
:
0
,
newNodeStatus
:
api
.
NodeStatus
{},
newNodeStatus
:
api
.
NodeStatus
{},
...
@@ -1111,9 +1102,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
...
@@ -1111,9 +1102,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
timeToPass
:
evictionTimeout
,
timeToPass
:
evictionTimeout
,
newNodeStatus
:
api
.
NodeStatus
{
newNodeStatus
:
api
.
NodeStatus
{
...
@@ -1151,9 +1140,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
...
@@ -1151,9 +1140,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
timeToPass
:
time
.
Hour
,
timeToPass
:
time
.
Hour
,
newNodeStatus
:
api
.
NodeStatus
{
newNodeStatus
:
api
.
NodeStatus
{
...
@@ -1191,9 +1178,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
...
@@ -1191,9 +1178,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
timeToPass
:
evictionTimeout
-
testNodeMonitorGracePeriod
,
timeToPass
:
evictionTimeout
-
testNodeMonitorGracePeriod
,
newNodeStatus
:
api
.
NodeStatus
{
newNodeStatus
:
api
.
NodeStatus
{
...
@@ -1231,9 +1216,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
...
@@ -1231,9 +1216,7 @@ func TestMonitorNodeStatusEvictPods(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
timeToPass
:
60
*
time
.
Minute
,
timeToPass
:
60
*
time
.
Minute
,
newNodeStatus
:
api
.
NodeStatus
{
newNodeStatus
:
api
.
NodeStatus
{
...
@@ -1302,9 +1285,7 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
...
@@ -1302,9 +1285,7 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
expectedRequestCount
:
2
,
// List+Update
expectedRequestCount
:
2
,
// List+Update
expectedNodes
:
[]
*
api
.
Node
{
expectedNodes
:
[]
*
api
.
Node
{
...
@@ -1339,9 +1320,7 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
...
@@ -1339,9 +1320,7 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
expectedRequestCount
:
1
,
// List
expectedRequestCount
:
1
,
// List
expectedNodes
:
nil
,
expectedNodes
:
nil
,
...
@@ -1376,9 +1355,7 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
...
@@ -1376,9 +1355,7 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
expectedRequestCount
:
3
,
// (List+)List+Update
expectedRequestCount
:
3
,
// (List+)List+Update
timeToPass
:
time
.
Hour
,
timeToPass
:
time
.
Hour
,
...
@@ -1454,9 +1431,7 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
...
@@ -1454,9 +1431,7 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
},
},
},
},
},
},
Fake
:
client
.
Fake
{
Fake
:
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}}),
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
*
newPod
(
"pod0"
,
"node0"
)}},
},
},
},
expectedRequestCount
:
1
,
// List
expectedRequestCount
:
1
,
// List
expectedNodes
:
nil
,
expectedNodes
:
nil
,
...
...
pkg/controller/replication_controller_test.go
View file @
842b9d8d
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
...
@@ -339,12 +340,12 @@ func TestControllerUpdateReplicas(t *testing.T) {
...
@@ -339,12 +340,12 @@ func TestControllerUpdateReplicas(t *testing.T) {
type
FakeWatcher
struct
{
type
FakeWatcher
struct
{
w
*
watch
.
FakeWatcher
w
*
watch
.
FakeWatcher
*
client
.
Fake
*
test
client
.
Fake
}
}
func
TestWatchControllers
(
t
*
testing
.
T
)
{
func
TestWatchControllers
(
t
*
testing
.
T
)
{
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
:=
watch
.
NewFake
()
client
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
client
:=
&
test
client
.
Fake
{
Watch
:
fakeWatch
}
manager
:=
NewReplicationManager
(
client
)
manager
:=
NewReplicationManager
(
client
)
var
testControllerSpec
api
.
ReplicationController
var
testControllerSpec
api
.
ReplicationController
received
:=
make
(
chan
struct
{})
received
:=
make
(
chan
struct
{})
...
...
pkg/kubectl/describe_test.go
View file @
842b9d8d
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
)
...
@@ -33,7 +34,7 @@ type describeClient struct {
...
@@ -33,7 +34,7 @@ type describeClient struct {
T
*
testing
.
T
T
*
testing
.
T
Namespace
string
Namespace
string
Err
error
Err
error
*
client
.
Fak
e
client
.
Interfac
e
}
}
func
init
()
{
func
init
()
{
...
@@ -41,8 +42,13 @@ func init() {
...
@@ -41,8 +42,13 @@ func init() {
}
}
func
TestDescribePod
(
t
*
testing
.
T
)
{
func
TestDescribePod
(
t
*
testing
.
T
)
{
fake
:=
&
client
.
Fake
{}
fake
:=
testclient
.
NewSimpleFake
(
&
api
.
Pod
{
c
:=
&
describeClient
{
T
:
t
,
Namespace
:
"foo"
,
Fake
:
fake
}
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
,
Namespace
:
"foo"
,
},
})
c
:=
&
describeClient
{
T
:
t
,
Namespace
:
"foo"
,
Interface
:
fake
}
d
:=
PodDescriber
{
c
}
d
:=
PodDescriber
{
c
}
out
,
err
:=
d
.
Describe
(
"foo"
,
"bar"
)
out
,
err
:=
d
.
Describe
(
"foo"
,
"bar"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -54,8 +60,13 @@ func TestDescribePod(t *testing.T) {
...
@@ -54,8 +60,13 @@ func TestDescribePod(t *testing.T) {
}
}
func
TestDescribeService
(
t
*
testing
.
T
)
{
func
TestDescribeService
(
t
*
testing
.
T
)
{
fake
:=
&
client
.
Fake
{}
fake
:=
testclient
.
NewSimpleFake
(
&
api
.
Service
{
c
:=
&
describeClient
{
T
:
t
,
Namespace
:
"foo"
,
Fake
:
fake
}
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
,
Namespace
:
"foo"
,
},
})
c
:=
&
describeClient
{
T
:
t
,
Namespace
:
"foo"
,
Interface
:
fake
}
d
:=
ServiceDescriber
{
c
}
d
:=
ServiceDescriber
{
c
}
out
,
err
:=
d
.
Describe
(
"foo"
,
"bar"
)
out
,
err
:=
d
.
Describe
(
"foo"
,
"bar"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -68,34 +79,32 @@ func TestDescribeService(t *testing.T) {
...
@@ -68,34 +79,32 @@ func TestDescribeService(t *testing.T) {
func
TestPodDescribeResultsSorted
(
t
*
testing
.
T
)
{
func
TestPodDescribeResultsSorted
(
t
*
testing
.
T
)
{
// Arrange
// Arrange
fake
:=
&
client
.
Fake
{
fake
:=
testclient
.
NewSimpleFake
(
&
api
.
EventList
{
EventsList
:
api
.
EventList
{
Items
:
[]
api
.
Event
{
Items
:
[]
api
.
Event
{
{
{
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 1"
,
Message
:
"Item 1"
,
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Count
:
1
,
Count
:
1
,
},
},
{
{
Source
:
api
.
EventSource
{
Component
:
"scheduler"
},
Source
:
api
.
EventSource
{
Component
:
"scheduler"
},
Message
:
"Item 2"
,
Message
:
"Item 2"
,
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Count
:
1
,
Count
:
1
,
},
},
{
{
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 3"
,
Message
:
"Item 3"
,
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Count
:
1
,
Count
:
1
,
},
},
},
},
},
}
}
)
c
:=
&
describeClient
{
T
:
t
,
Namespace
:
"foo"
,
Fak
e
:
fake
}
c
:=
&
describeClient
{
T
:
t
,
Namespace
:
"foo"
,
Interfac
e
:
fake
}
d
:=
PodDescriber
{
c
}
d
:=
PodDescriber
{
c
}
// Act
// Act
...
...
pkg/kubectl/resize_test.go
View file @
842b9d8d
...
@@ -22,10 +22,11 @@ import (
...
@@ -22,10 +22,11 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
)
)
type
ErrorReplicationControllers
struct
{
type
ErrorReplicationControllers
struct
{
client
.
FakeReplicationControllers
test
client
.
FakeReplicationControllers
}
}
func
(
c
*
ErrorReplicationControllers
)
Update
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
ErrorReplicationControllers
)
Update
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
...
@@ -33,15 +34,15 @@ func (c *ErrorReplicationControllers) Update(controller *api.ReplicationControll
...
@@ -33,15 +34,15 @@ func (c *ErrorReplicationControllers) Update(controller *api.ReplicationControll
}
}
type
ErrorReplicationControllerClient
struct
{
type
ErrorReplicationControllerClient
struct
{
client
.
Fake
test
client
.
Fake
}
}
func
(
c
*
ErrorReplicationControllerClient
)
ReplicationControllers
(
namespace
string
)
client
.
ReplicationControllerInterface
{
func
(
c
*
ErrorReplicationControllerClient
)
ReplicationControllers
(
namespace
string
)
client
.
ReplicationControllerInterface
{
return
&
ErrorReplicationControllers
{
client
.
FakeReplicationControllers
{
Fake
:
&
c
.
Fake
,
Namespace
:
namespace
}}
return
&
ErrorReplicationControllers
{
test
client
.
FakeReplicationControllers
{
Fake
:
&
c
.
Fake
,
Namespace
:
namespace
}}
}
}
func
TestReplicationControllerResizeRetry
(
t
*
testing
.
T
)
{
func
TestReplicationControllerResizeRetry
(
t
*
testing
.
T
)
{
fake
:=
&
ErrorReplicationControllerClient
{
Fake
:
client
.
Fake
{}}
fake
:=
&
ErrorReplicationControllerClient
{
Fake
:
test
client
.
Fake
{}}
resizer
:=
ReplicationControllerResizer
{
fake
}
resizer
:=
ReplicationControllerResizer
{
fake
}
preconditions
:=
ResizePrecondition
{
-
1
,
""
}
preconditions
:=
ResizePrecondition
{
-
1
,
""
}
count
:=
uint
(
3
)
count
:=
uint
(
3
)
...
@@ -65,7 +66,7 @@ func TestReplicationControllerResizeRetry(t *testing.T) {
...
@@ -65,7 +66,7 @@ func TestReplicationControllerResizeRetry(t *testing.T) {
}
}
func
TestReplicationControllerResize
(
t
*
testing
.
T
)
{
func
TestReplicationControllerResize
(
t
*
testing
.
T
)
{
fake
:=
&
client
.
Fake
{}
fake
:=
&
test
client
.
Fake
{}
resizer
:=
ReplicationControllerResizer
{
fake
}
resizer
:=
ReplicationControllerResizer
{
fake
}
preconditions
:=
ResizePrecondition
{
-
1
,
""
}
preconditions
:=
ResizePrecondition
{
-
1
,
""
}
count
:=
uint
(
3
)
count
:=
uint
(
3
)
...
@@ -75,22 +76,20 @@ func TestReplicationControllerResize(t *testing.T) {
...
@@ -75,22 +76,20 @@ func TestReplicationControllerResize(t *testing.T) {
if
len
(
fake
.
Actions
)
!=
2
{
if
len
(
fake
.
Actions
)
!=
2
{
t
.
Errorf
(
"unexpected actions: %v, expected 2 actions (get, update)"
,
fake
.
Actions
)
t
.
Errorf
(
"unexpected actions: %v, expected 2 actions (get, update)"
,
fake
.
Actions
)
}
}
if
fake
.
Actions
[
0
]
.
Action
!=
"get-
c
ontroller"
||
fake
.
Actions
[
0
]
.
Value
!=
name
{
if
fake
.
Actions
[
0
]
.
Action
!=
"get-
replicationC
ontroller"
||
fake
.
Actions
[
0
]
.
Value
!=
name
{
t
.
Errorf
(
"unexpected action: %v, expected get-
c
ontroller %s"
,
fake
.
Actions
[
0
],
name
)
t
.
Errorf
(
"unexpected action: %v, expected get-
replicationC
ontroller %s"
,
fake
.
Actions
[
0
],
name
)
}
}
if
fake
.
Actions
[
1
]
.
Action
!=
"update-
c
ontroller"
||
fake
.
Actions
[
1
]
.
Value
.
(
*
api
.
ReplicationController
)
.
Spec
.
Replicas
!=
int
(
count
)
{
if
fake
.
Actions
[
1
]
.
Action
!=
"update-
replicationC
ontroller"
||
fake
.
Actions
[
1
]
.
Value
.
(
*
api
.
ReplicationController
)
.
Spec
.
Replicas
!=
int
(
count
)
{
t
.
Errorf
(
"unexpected action %v, expected update-
c
ontroller with replicas = %d"
,
fake
.
Actions
[
1
],
count
)
t
.
Errorf
(
"unexpected action %v, expected update-
replicationC
ontroller with replicas = %d"
,
fake
.
Actions
[
1
],
count
)
}
}
}
}
func
TestReplicationControllerResizeFailsPreconditions
(
t
*
testing
.
T
)
{
func
TestReplicationControllerResizeFailsPreconditions
(
t
*
testing
.
T
)
{
fake
:=
&
client
.
Fake
{
fake
:=
testclient
.
NewSimpleFake
(
&
api
.
ReplicationController
{
Ctrl
:
api
.
ReplicationController
{
Spec
:
api
.
ReplicationControllerSpec
{
Spec
:
api
.
ReplicationControllerSpec
{
Replicas
:
10
,
Replicas
:
10
,
},
},
},
}
}
)
resizer
:=
ReplicationControllerResizer
{
fake
}
resizer
:=
ReplicationControllerResizer
{
fake
}
preconditions
:=
ResizePrecondition
{
2
,
""
}
preconditions
:=
ResizePrecondition
{
2
,
""
}
count
:=
uint
(
3
)
count
:=
uint
(
3
)
...
@@ -100,8 +99,8 @@ func TestReplicationControllerResizeFailsPreconditions(t *testing.T) {
...
@@ -100,8 +99,8 @@ func TestReplicationControllerResizeFailsPreconditions(t *testing.T) {
if
len
(
fake
.
Actions
)
!=
1
{
if
len
(
fake
.
Actions
)
!=
1
{
t
.
Errorf
(
"unexpected actions: %v, expected 2 actions (get, update)"
,
fake
.
Actions
)
t
.
Errorf
(
"unexpected actions: %v, expected 2 actions (get, update)"
,
fake
.
Actions
)
}
}
if
fake
.
Actions
[
0
]
.
Action
!=
"get-
c
ontroller"
||
fake
.
Actions
[
0
]
.
Value
!=
name
{
if
fake
.
Actions
[
0
]
.
Action
!=
"get-
replicationC
ontroller"
||
fake
.
Actions
[
0
]
.
Value
!=
name
{
t
.
Errorf
(
"unexpected action: %v, expected get-
c
ontroller %s"
,
fake
.
Actions
[
0
],
name
)
t
.
Errorf
(
"unexpected action: %v, expected get-
replicationC
ontroller %s"
,
fake
.
Actions
[
0
],
name
)
}
}
}
}
...
...
pkg/kubectl/rolling_updater_test.go
View file @
842b9d8d
...
@@ -24,10 +24,11 @@ import (
...
@@ -24,10 +24,11 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
)
)
type
updaterFake
struct
{
type
updaterFake
struct
{
*
client
.
Fake
*
test
client
.
Fake
ctrl
client
.
ReplicationControllerInterface
ctrl
client
.
ReplicationControllerInterface
}
}
...
@@ -36,11 +37,11 @@ func (c *updaterFake) ReplicationControllers(namespace string) client.Replicatio
...
@@ -36,11 +37,11 @@ func (c *updaterFake) ReplicationControllers(namespace string) client.Replicatio
}
}
func
fakeClientFor
(
namespace
string
,
responses
[]
fakeResponse
)
client
.
Interface
{
func
fakeClientFor
(
namespace
string
,
responses
[]
fakeResponse
)
client
.
Interface
{
fake
:=
client
.
Fake
{}
fake
:=
test
client
.
Fake
{}
return
&
updaterFake
{
return
&
updaterFake
{
&
fake
,
&
fake
,
&
fakeRc
{
&
fakeRc
{
&
client
.
FakeReplicationControllers
{
&
test
client
.
FakeReplicationControllers
{
Fake
:
&
fake
,
Fake
:
&
fake
,
Namespace
:
namespace
,
Namespace
:
namespace
,
},
},
...
@@ -55,12 +56,12 @@ type fakeResponse struct {
...
@@ -55,12 +56,12 @@ type fakeResponse struct {
}
}
type
fakeRc
struct
{
type
fakeRc
struct
{
*
client
.
FakeReplicationControllers
*
test
client
.
FakeReplicationControllers
responses
[]
fakeResponse
responses
[]
fakeResponse
}
}
func
(
c
*
fakeRc
)
Get
(
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
fakeRc
)
Get
(
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
action
:=
client
.
FakeAction
{
Action
:
"get-controller"
,
Value
:
name
}
action
:=
test
client
.
FakeAction
{
Action
:
"get-controller"
,
Value
:
name
}
if
len
(
c
.
responses
)
==
0
{
if
len
(
c
.
responses
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"Unexpected Action: %s"
,
action
)
return
nil
,
fmt
.
Errorf
(
"Unexpected Action: %s"
,
action
)
}
}
...
@@ -71,12 +72,12 @@ func (c *fakeRc) Get(name string) (*api.ReplicationController, error) {
...
@@ -71,12 +72,12 @@ func (c *fakeRc) Get(name string) (*api.ReplicationController, error) {
}
}
func
(
c
*
fakeRc
)
Create
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
fakeRc
)
Create
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
client
.
FakeAction
{
Action
:
"create-controller"
,
Value
:
controller
.
ObjectMeta
.
Name
})
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
test
client
.
FakeAction
{
Action
:
"create-controller"
,
Value
:
controller
.
ObjectMeta
.
Name
})
return
controller
,
nil
return
controller
,
nil
}
}
func
(
c
*
fakeRc
)
Update
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
c
*
fakeRc
)
Update
(
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
client
.
FakeAction
{
Action
:
"update-controller"
,
Value
:
controller
.
ObjectMeta
.
Name
})
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
test
client
.
FakeAction
{
Action
:
"update-controller"
,
Value
:
controller
.
ObjectMeta
.
Name
})
return
controller
,
nil
return
controller
,
nil
}
}
...
...
pkg/kubectl/stop_test.go
View file @
842b9d8d
...
@@ -23,16 +23,15 @@ import (
...
@@ -23,16 +23,15 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
)
)
func
TestReplicationControllerStop
(
t
*
testing
.
T
)
{
func
TestReplicationControllerStop
(
t
*
testing
.
T
)
{
fake
:=
&
client
.
Fake
{
fake
:=
testclient
.
NewSimpleFake
(
&
api
.
ReplicationController
{
Ctrl
:
api
.
ReplicationController
{
Spec
:
api
.
ReplicationControllerSpec
{
Spec
:
api
.
ReplicationControllerSpec
{
Replicas
:
0
,
Replicas
:
0
,
},
},
},
}
}
)
reaper
:=
ReplicationControllerReaper
{
fake
,
time
.
Millisecond
,
time
.
Millisecond
}
reaper
:=
ReplicationControllerReaper
{
fake
,
time
.
Millisecond
,
time
.
Millisecond
}
name
:=
"foo"
name
:=
"foo"
s
,
err
:=
reaper
.
Stop
(
"default"
,
name
)
s
,
err
:=
reaper
.
Stop
(
"default"
,
name
)
...
@@ -47,14 +46,14 @@ func TestReplicationControllerStop(t *testing.T) {
...
@@ -47,14 +46,14 @@ func TestReplicationControllerStop(t *testing.T) {
t
.
Errorf
(
"unexpected actions: %v, expected 4 actions (get, update, get, delete)"
,
fake
.
Actions
)
t
.
Errorf
(
"unexpected actions: %v, expected 4 actions (get, update, get, delete)"
,
fake
.
Actions
)
}
}
for
i
,
action
:=
range
[]
string
{
"get"
,
"update"
,
"get"
,
"delete"
}
{
for
i
,
action
:=
range
[]
string
{
"get"
,
"update"
,
"get"
,
"delete"
}
{
if
fake
.
Actions
[
i
]
.
Action
!=
action
+
"-
c
ontroller"
{
if
fake
.
Actions
[
i
]
.
Action
!=
action
+
"-
replicationC
ontroller"
{
t
.
Errorf
(
"unexpected action: %v, expected %s-
c
ontroller"
,
fake
.
Actions
[
i
],
action
)
t
.
Errorf
(
"unexpected action: %v, expected %s-
replicationC
ontroller"
,
fake
.
Actions
[
i
],
action
)
}
}
}
}
}
}
type
noSuchPod
struct
{
type
noSuchPod
struct
{
*
client
.
FakePods
*
test
client
.
FakePods
}
}
func
(
c
*
noSuchPod
)
Get
(
name
string
)
(
*
api
.
Pod
,
error
)
{
func
(
c
*
noSuchPod
)
Get
(
name
string
)
(
*
api
.
Pod
,
error
)
{
...
@@ -62,7 +61,7 @@ func (c *noSuchPod) Get(name string) (*api.Pod, error) {
...
@@ -62,7 +61,7 @@ func (c *noSuchPod) Get(name string) (*api.Pod, error) {
}
}
type
noDeleteService
struct
{
type
noDeleteService
struct
{
*
client
.
FakeServices
*
test
client
.
FakeServices
}
}
func
(
c
*
noDeleteService
)
Delete
(
service
string
)
error
{
func
(
c
*
noDeleteService
)
Delete
(
service
string
)
error
{
...
@@ -70,12 +69,12 @@ func (c *noDeleteService) Delete(service string) error {
...
@@ -70,12 +69,12 @@ func (c *noDeleteService) Delete(service string) error {
}
}
type
reaperFake
struct
{
type
reaperFake
struct
{
*
client
.
Fake
*
test
client
.
Fake
noSuchPod
,
noDeleteService
bool
noSuchPod
,
noDeleteService
bool
}
}
func
(
c
*
reaperFake
)
Pods
(
namespace
string
)
client
.
PodInterface
{
func
(
c
*
reaperFake
)
Pods
(
namespace
string
)
client
.
PodInterface
{
pods
:=
&
client
.
FakePods
{
c
.
Fake
,
namespace
}
pods
:=
&
test
client
.
FakePods
{
c
.
Fake
,
namespace
}
if
c
.
noSuchPod
{
if
c
.
noSuchPod
{
return
&
noSuchPod
{
pods
}
return
&
noSuchPod
{
pods
}
}
}
...
@@ -83,7 +82,7 @@ func (c *reaperFake) Pods(namespace string) client.PodInterface {
...
@@ -83,7 +82,7 @@ func (c *reaperFake) Pods(namespace string) client.PodInterface {
}
}
func
(
c
*
reaperFake
)
Services
(
namespace
string
)
client
.
ServiceInterface
{
func
(
c
*
reaperFake
)
Services
(
namespace
string
)
client
.
ServiceInterface
{
services
:=
&
client
.
FakeServices
{
c
.
Fake
,
namespace
}
services
:=
&
test
client
.
FakeServices
{
c
.
Fake
,
namespace
}
if
c
.
noDeleteService
{
if
c
.
noDeleteService
{
return
&
noDeleteService
{
services
}
return
&
noDeleteService
{
services
}
}
}
...
@@ -100,7 +99,7 @@ func TestSimpleStop(t *testing.T) {
...
@@ -100,7 +99,7 @@ func TestSimpleStop(t *testing.T) {
}{
}{
{
{
fake
:
&
reaperFake
{
fake
:
&
reaperFake
{
Fake
:
&
client
.
Fake
{},
Fake
:
&
test
client
.
Fake
{},
},
},
kind
:
"Pod"
,
kind
:
"Pod"
,
actions
:
[]
string
{
"get-pod"
,
"delete-pod"
},
actions
:
[]
string
{
"get-pod"
,
"delete-pod"
},
...
@@ -109,7 +108,7 @@ func TestSimpleStop(t *testing.T) {
...
@@ -109,7 +108,7 @@ func TestSimpleStop(t *testing.T) {
},
},
{
{
fake
:
&
reaperFake
{
fake
:
&
reaperFake
{
Fake
:
&
client
.
Fake
{},
Fake
:
&
test
client
.
Fake
{},
},
},
kind
:
"Service"
,
kind
:
"Service"
,
actions
:
[]
string
{
"get-service"
,
"delete-service"
},
actions
:
[]
string
{
"get-service"
,
"delete-service"
},
...
@@ -118,7 +117,7 @@ func TestSimpleStop(t *testing.T) {
...
@@ -118,7 +117,7 @@ func TestSimpleStop(t *testing.T) {
},
},
{
{
fake
:
&
reaperFake
{
fake
:
&
reaperFake
{
Fake
:
&
client
.
Fake
{},
Fake
:
&
test
client
.
Fake
{},
noSuchPod
:
true
,
noSuchPod
:
true
,
},
},
kind
:
"Pod"
,
kind
:
"Pod"
,
...
@@ -128,7 +127,7 @@ func TestSimpleStop(t *testing.T) {
...
@@ -128,7 +127,7 @@ func TestSimpleStop(t *testing.T) {
},
},
{
{
fake
:
&
reaperFake
{
fake
:
&
reaperFake
{
Fake
:
&
client
.
Fake
{},
Fake
:
&
test
client
.
Fake
{},
noDeleteService
:
true
,
noDeleteService
:
true
,
},
},
kind
:
"Service"
,
kind
:
"Service"
,
...
...
pkg/kubelet/kubelet_test.go
View file @
842b9d8d
...
@@ -37,8 +37,8 @@ import (
...
@@ -37,8 +37,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities"
"github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/cadvisor"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/cadvisor"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
...
@@ -63,7 +63,7 @@ type TestKubelet struct {
...
@@ -63,7 +63,7 @@ type TestKubelet struct {
kubelet
*
Kubelet
kubelet
*
Kubelet
fakeDocker
*
dockertools
.
FakeDockerClient
fakeDocker
*
dockertools
.
FakeDockerClient
fakeCadvisor
*
cadvisor
.
Mock
fakeCadvisor
*
cadvisor
.
Mock
fakeKubeClient
*
client
.
Fake
fakeKubeClient
*
test
client
.
Fake
waitGroup
*
sync
.
WaitGroup
waitGroup
*
sync
.
WaitGroup
fakeMirrorClient
*
fakeMirrorClient
fakeMirrorClient
*
fakeMirrorClient
}
}
...
@@ -72,7 +72,7 @@ func newTestKubelet(t *testing.T) *TestKubelet {
...
@@ -72,7 +72,7 @@ func newTestKubelet(t *testing.T) *TestKubelet {
fakeDocker
:=
&
dockertools
.
FakeDockerClient
{
RemovedImages
:
util
.
StringSet
{}}
fakeDocker
:=
&
dockertools
.
FakeDockerClient
{
RemovedImages
:
util
.
StringSet
{}}
fakeDockerCache
:=
dockertools
.
NewFakeDockerCache
(
fakeDocker
)
fakeDockerCache
:=
dockertools
.
NewFakeDockerCache
(
fakeDocker
)
fakeRecorder
:=
&
record
.
FakeRecorder
{}
fakeRecorder
:=
&
record
.
FakeRecorder
{}
fakeKubeClient
:=
&
client
.
Fake
{}
fakeKubeClient
:=
&
test
client
.
Fake
{}
kubelet
:=
&
Kubelet
{}
kubelet
:=
&
Kubelet
{}
kubelet
.
dockerClient
=
fakeDocker
kubelet
.
dockerClient
=
fakeDocker
...
@@ -3053,10 +3053,9 @@ func TestUpdateNewNodeStatus(t *testing.T) {
...
@@ -3053,10 +3053,9 @@ func TestUpdateNewNodeStatus(t *testing.T) {
testKubelet
:=
newTestKubelet
(
t
)
testKubelet
:=
newTestKubelet
(
t
)
kubelet
:=
testKubelet
.
kubelet
kubelet
:=
testKubelet
.
kubelet
kubeClient
:=
testKubelet
.
fakeKubeClient
kubeClient
:=
testKubelet
.
fakeKubeClient
mockCadvisor
:=
testKubelet
.
fakeCadvisor
kubeClient
.
ReactFn
=
testclient
.
NewSimpleFake
(
&
api
.
NodeList
{
Items
:
[]
api
.
Node
{
kubeClient
.
MinionsList
=
api
.
NodeList
{
Items
:
[]
api
.
Node
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"testnode"
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"testnode"
}},
}}
}}
)
.
ReactFn
machineInfo
:=
&
cadvisorApi
.
MachineInfo
{
machineInfo
:=
&
cadvisorApi
.
MachineInfo
{
MachineID
:
"123"
,
MachineID
:
"123"
,
SystemUUID
:
"abc"
,
SystemUUID
:
"abc"
,
...
@@ -3064,6 +3063,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
...
@@ -3064,6 +3063,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
NumCores
:
2
,
NumCores
:
2
,
MemoryCapacity
:
1024
,
MemoryCapacity
:
1024
,
}
}
mockCadvisor
:=
testKubelet
.
fakeCadvisor
mockCadvisor
.
On
(
"MachineInfo"
)
.
Return
(
machineInfo
,
nil
)
mockCadvisor
.
On
(
"MachineInfo"
)
.
Return
(
machineInfo
,
nil
)
versionInfo
:=
&
cadvisorApi
.
VersionInfo
{
versionInfo
:=
&
cadvisorApi
.
VersionInfo
{
KernelVersion
:
"3.16.0-0.bpo.4-amd64"
,
KernelVersion
:
"3.16.0-0.bpo.4-amd64"
,
...
@@ -3104,8 +3104,8 @@ func TestUpdateNewNodeStatus(t *testing.T) {
...
@@ -3104,8 +3104,8 @@ func TestUpdateNewNodeStatus(t *testing.T) {
if
err
:=
kubelet
.
updateNodeStatus
();
err
!=
nil
{
if
err
:=
kubelet
.
updateNodeStatus
();
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
if
len
(
kubeClient
.
Actions
)
!=
2
{
if
len
(
kubeClient
.
Actions
)
!=
2
||
kubeClient
.
Actions
[
1
]
.
Action
!=
"update-node"
{
t
.
Error
f
(
"unexpected actions: %v"
,
kubeClient
.
Actions
)
t
.
Fatal
f
(
"unexpected actions: %v"
,
kubeClient
.
Actions
)
}
}
updatedNode
,
ok
:=
kubeClient
.
Actions
[
1
]
.
Value
.
(
*
api
.
Node
)
updatedNode
,
ok
:=
kubeClient
.
Actions
[
1
]
.
Value
.
(
*
api
.
Node
)
if
!
ok
{
if
!
ok
{
...
@@ -3120,7 +3120,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
...
@@ -3120,7 +3120,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
updatedNode
.
Status
.
Conditions
[
0
]
.
LastProbeTime
=
util
.
Time
{}
updatedNode
.
Status
.
Conditions
[
0
]
.
LastProbeTime
=
util
.
Time
{}
updatedNode
.
Status
.
Conditions
[
0
]
.
LastTransitionTime
=
util
.
Time
{}
updatedNode
.
Status
.
Conditions
[
0
]
.
LastTransitionTime
=
util
.
Time
{}
if
!
reflect
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
if
!
reflect
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
t
.
Errorf
(
"
expected
\n
%v
\n
, got
\n
%v"
,
expectedNode
,
updatedNode
)
t
.
Errorf
(
"
unexpected objects: %s"
,
util
.
ObjectDiff
(
expectedNode
,
updatedNode
)
)
}
}
}
}
...
@@ -3128,8 +3128,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
...
@@ -3128,8 +3128,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
testKubelet
:=
newTestKubelet
(
t
)
testKubelet
:=
newTestKubelet
(
t
)
kubelet
:=
testKubelet
.
kubelet
kubelet
:=
testKubelet
.
kubelet
kubeClient
:=
testKubelet
.
fakeKubeClient
kubeClient
:=
testKubelet
.
fakeKubeClient
mockCadvisor
:=
testKubelet
.
fakeCadvisor
kubeClient
.
ReactFn
=
testclient
.
NewSimpleFake
(
&
api
.
NodeList
{
Items
:
[]
api
.
Node
{
kubeClient
.
MinionsList
=
api
.
NodeList
{
Items
:
[]
api
.
Node
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"testnode"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"testnode"
},
Spec
:
api
.
NodeSpec
{},
Spec
:
api
.
NodeSpec
{},
...
@@ -3149,7 +3148,8 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
...
@@ -3149,7 +3148,8 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
},
},
},
},
},
},
}}
}})
.
ReactFn
mockCadvisor
:=
testKubelet
.
fakeCadvisor
machineInfo
:=
&
cadvisorApi
.
MachineInfo
{
machineInfo
:=
&
cadvisorApi
.
MachineInfo
{
MachineID
:
"123"
,
MachineID
:
"123"
,
SystemUUID
:
"abc"
,
SystemUUID
:
"abc"
,
...
@@ -3205,11 +3205,11 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
...
@@ -3205,11 +3205,11 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
t
.
Errorf
(
"unexpected object type"
)
t
.
Errorf
(
"unexpected object type"
)
}
}
// Expect LastProbeTime to be updated to Now, while LastTransitionTime to be the same.
// Expect LastProbeTime to be updated to Now, while LastTransitionTime to be the same.
if
reflect
.
DeepEqual
(
updatedNode
.
Status
.
Conditions
[
0
]
.
LastProbeTime
,
util
.
Date
(
2012
,
1
,
1
,
0
,
0
,
0
,
0
,
time
.
UTC
)
)
{
if
reflect
.
DeepEqual
(
updatedNode
.
Status
.
Conditions
[
0
]
.
LastProbeTime
.
Rfc3339Copy
()
.
UTC
(),
util
.
Date
(
2012
,
1
,
1
,
0
,
0
,
0
,
0
,
time
.
UTC
)
.
Time
)
{
t
.
Errorf
(
"expected
\n
%v
\n
, got
\n
%v"
,
util
.
Now
(),
util
.
Date
(
2012
,
1
,
1
,
0
,
0
,
0
,
0
,
time
.
UTC
))
t
.
Errorf
(
"expected
\n
%v
\n
, got
\n
%v"
,
util
.
Now
(),
util
.
Date
(
2012
,
1
,
1
,
0
,
0
,
0
,
0
,
time
.
UTC
))
}
}
if
!
reflect
.
DeepEqual
(
updatedNode
.
Status
.
Conditions
[
0
]
.
LastTransitionTime
,
util
.
Date
(
2012
,
1
,
1
,
0
,
0
,
0
,
0
,
time
.
UTC
)
)
{
if
!
reflect
.
DeepEqual
(
updatedNode
.
Status
.
Conditions
[
0
]
.
LastTransitionTime
.
Rfc3339Copy
()
.
UTC
(),
util
.
Date
(
2012
,
1
,
1
,
0
,
0
,
0
,
0
,
time
.
UTC
)
.
Time
)
{
t
.
Errorf
(
"expected
\n
%
v
\n
, got
\n
%v"
,
updatedNode
.
Status
.
Conditions
[
0
]
.
LastTransitionTime
,
t
.
Errorf
(
"expected
\n
%
#v
\n
, got
\n
%#v"
,
updatedNode
.
Status
.
Conditions
[
0
]
.
LastTransitionTime
.
Rfc3339Copy
()
,
util
.
Date
(
2012
,
1
,
1
,
0
,
0
,
0
,
0
,
time
.
UTC
))
util
.
Date
(
2012
,
1
,
1
,
0
,
0
,
0
,
0
,
time
.
UTC
))
}
}
updatedNode
.
Status
.
Conditions
[
0
]
.
LastProbeTime
=
util
.
Time
{}
updatedNode
.
Status
.
Conditions
[
0
]
.
LastProbeTime
=
util
.
Time
{}
...
@@ -3222,15 +3222,14 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
...
@@ -3222,15 +3222,14 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
func
TestUpdateNodeStatusError
(
t
*
testing
.
T
)
{
func
TestUpdateNodeStatusError
(
t
*
testing
.
T
)
{
testKubelet
:=
newTestKubelet
(
t
)
testKubelet
:=
newTestKubelet
(
t
)
kubelet
:=
testKubelet
.
kubelet
kubelet
:=
testKubelet
.
kubelet
kubeClient
:=
testKubelet
.
fakeKubeClient
// No matching node for the kubelet
// No matching node for the kubelet
kubeClient
.
MinionsList
=
api
.
NodeList
{
Items
:
[]
api
.
Node
{}}
testKubelet
.
fakeKubeClient
.
ReactFn
=
testclient
.
NewSimpleFake
(
&
api
.
NodeList
{
Items
:
[]
api
.
Node
{}})
.
ReactFn
if
err
:=
kubelet
.
updateNodeStatus
();
err
==
nil
{
if
err
:=
kubelet
.
updateNodeStatus
();
err
==
nil
{
t
.
Errorf
(
"unexpected non error: %v"
,
err
)
t
.
Errorf
(
"unexpected non error: %v"
,
err
)
}
}
if
len
(
k
ubeClient
.
Actions
)
!=
nodeStatusUpdateRetry
{
if
len
(
testKubelet
.
fakeK
ubeClient
.
Actions
)
!=
nodeStatusUpdateRetry
{
t
.
Errorf
(
"unexpected actions: %v"
,
k
ubeClient
.
Actions
)
t
.
Errorf
(
"unexpected actions: %v"
,
testKubelet
.
fakeK
ubeClient
.
Actions
)
}
}
}
}
...
...
pkg/kubelet/status_manager_test.go
View file @
842b9d8d
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
)
)
var
testPod
*
api
.
Pod
=
&
api
.
Pod
{
var
testPod
*
api
.
Pod
=
&
api
.
Pod
{
...
@@ -34,7 +35,7 @@ var testPod *api.Pod = &api.Pod{
...
@@ -34,7 +35,7 @@ var testPod *api.Pod = &api.Pod{
}
}
func
newTestStatusManager
()
*
statusManager
{
func
newTestStatusManager
()
*
statusManager
{
return
newStatusManager
(
&
client
.
Fake
{})
return
newStatusManager
(
&
test
client
.
Fake
{})
}
}
func
generateRandomMessage
()
string
{
func
generateRandomMessage
()
string
{
...
@@ -48,7 +49,7 @@ func getRandomPodStatus() api.PodStatus {
...
@@ -48,7 +49,7 @@ func getRandomPodStatus() api.PodStatus {
}
}
func
verifyActions
(
t
*
testing
.
T
,
kubeClient
client
.
Interface
,
expectedActions
[]
string
)
{
func
verifyActions
(
t
*
testing
.
T
,
kubeClient
client
.
Interface
,
expectedActions
[]
string
)
{
actions
:=
kubeClient
.
(
*
client
.
Fake
)
.
Actions
actions
:=
kubeClient
.
(
*
test
client
.
Fake
)
.
Actions
if
len
(
actions
)
!=
len
(
expectedActions
)
{
if
len
(
actions
)
!=
len
(
expectedActions
)
{
t
.
Errorf
(
"unexpected actions, got: %s expected: %s"
,
actions
,
expectedActions
)
t
.
Errorf
(
"unexpected actions, got: %s expected: %s"
,
actions
,
expectedActions
)
return
return
...
...
pkg/namespace/namespace_controller_test.go
View file @
842b9d8d
...
@@ -20,8 +20,8 @@ import (
...
@@ -20,8 +20,8 @@ import (
"testing"
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
)
...
@@ -41,7 +41,7 @@ func TestFinalized(t *testing.T) {
...
@@ -41,7 +41,7 @@ func TestFinalized(t *testing.T) {
}
}
func
TestFinalize
(
t
*
testing
.
T
)
{
func
TestFinalize
(
t
*
testing
.
T
)
{
mockClient
:=
&
client
.
Fake
{}
mockClient
:=
&
test
client
.
Fake
{}
testNamespace
:=
api
.
Namespace
{
testNamespace
:=
api
.
Namespace
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"test"
,
Name
:
"test"
,
...
@@ -58,7 +58,7 @@ func TestFinalize(t *testing.T) {
...
@@ -58,7 +58,7 @@ func TestFinalize(t *testing.T) {
if
mockClient
.
Actions
[
0
]
.
Action
!=
"finalize-namespace"
{
if
mockClient
.
Actions
[
0
]
.
Action
!=
"finalize-namespace"
{
t
.
Errorf
(
"Expected finalize-namespace action %v"
,
mockClient
.
Actions
[
0
]
.
Action
)
t
.
Errorf
(
"Expected finalize-namespace action %v"
,
mockClient
.
Actions
[
0
]
.
Action
)
}
}
finalizers
:=
mockClient
.
Namespace
.
Spec
.
Finalizers
finalizers
:=
mockClient
.
Actions
[
0
]
.
Value
.
(
*
api
.
Namespace
)
.
Spec
.
Finalizers
if
len
(
finalizers
)
!=
1
{
if
len
(
finalizers
)
!=
1
{
t
.
Errorf
(
"There should be a single finalizer remaining"
)
t
.
Errorf
(
"There should be a single finalizer remaining"
)
}
}
...
@@ -68,7 +68,7 @@ func TestFinalize(t *testing.T) {
...
@@ -68,7 +68,7 @@ func TestFinalize(t *testing.T) {
}
}
func
TestSyncNamespaceThatIsTerminating
(
t
*
testing
.
T
)
{
func
TestSyncNamespaceThatIsTerminating
(
t
*
testing
.
T
)
{
mockClient
:=
&
client
.
Fake
{}
mockClient
:=
&
test
client
.
Fake
{}
nm
:=
NamespaceManager
{
kubeClient
:
mockClient
,
store
:
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)}
nm
:=
NamespaceManager
{
kubeClient
:
mockClient
,
store
:
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)}
now
:=
util
.
Now
()
now
:=
util
.
Now
()
testNamespace
:=
api
.
Namespace
{
testNamespace
:=
api
.
Namespace
{
...
@@ -92,7 +92,7 @@ func TestSyncNamespaceThatIsTerminating(t *testing.T) {
...
@@ -92,7 +92,7 @@ func TestSyncNamespaceThatIsTerminating(t *testing.T) {
"list-services"
,
"list-services"
,
"list-pods"
,
"list-pods"
,
"list-resourceQuotas"
,
"list-resourceQuotas"
,
"list-
c
ontrollers"
,
"list-
replicationC
ontrollers"
,
"list-secrets"
,
"list-secrets"
,
"list-limitRanges"
,
"list-limitRanges"
,
"list-events"
,
"list-events"
,
...
@@ -108,7 +108,7 @@ func TestSyncNamespaceThatIsTerminating(t *testing.T) {
...
@@ -108,7 +108,7 @@ func TestSyncNamespaceThatIsTerminating(t *testing.T) {
}
}
func
TestSyncNamespaceThatIsActive
(
t
*
testing
.
T
)
{
func
TestSyncNamespaceThatIsActive
(
t
*
testing
.
T
)
{
mockClient
:=
&
client
.
Fake
{}
mockClient
:=
&
test
client
.
Fake
{}
nm
:=
NamespaceManager
{
kubeClient
:
mockClient
,
store
:
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)}
nm
:=
NamespaceManager
{
kubeClient
:
mockClient
,
store
:
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)}
testNamespace
:=
api
.
Namespace
{
testNamespace
:=
api
.
Namespace
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
...
...
pkg/proxy/config/api_test.go
View file @
842b9d8d
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"testing"
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client
/testclient
"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
)
)
...
@@ -30,7 +30,7 @@ func TestServices(t *testing.T) {
...
@@ -30,7 +30,7 @@ func TestServices(t *testing.T) {
service
:=
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
}}
service
:=
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
,
ResourceVersion
:
"2"
}}
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
:=
watch
.
NewFake
()
fakeClient
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
fakeClient
:=
&
test
client
.
Fake
{
Watch
:
fakeWatch
}
services
:=
make
(
chan
ServiceUpdate
)
services
:=
make
(
chan
ServiceUpdate
)
source
:=
SourceAPI
{
source
:=
SourceAPI
{
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
),
services
:
services
},
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
),
services
:
services
},
...
@@ -44,7 +44,7 @@ func TestServices(t *testing.T) {
...
@@ -44,7 +44,7 @@ func TestServices(t *testing.T) {
// test adding a service to the watch
// test adding a service to the watch
fakeWatch
.
Add
(
&
service
)
fakeWatch
.
Add
(
&
service
)
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
client
.
FakeAction
{{
"watch-services"
,
"1"
}})
{
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
test
client
.
FakeAction
{{
"watch-services"
,
"1"
}})
{
t
.
Errorf
(
"expected call to watch-services, got %#v"
,
fakeClient
)
t
.
Errorf
(
"expected call to watch-services, got %#v"
,
fakeClient
)
}
}
...
@@ -68,7 +68,7 @@ func TestServices(t *testing.T) {
...
@@ -68,7 +68,7 @@ func TestServices(t *testing.T) {
fakeWatch
.
Stop
()
fakeWatch
.
Stop
()
newFakeWatch
.
Add
(
&
service
)
newFakeWatch
.
Add
(
&
service
)
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
client
.
FakeAction
{{
"watch-services"
,
"1"
},
{
"watch-services"
,
"2"
}})
{
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
test
client
.
FakeAction
{{
"watch-services"
,
"1"
},
{
"watch-services"
,
"2"
}})
{
t
.
Errorf
(
"expected call to watch-endpoints, got %#v"
,
fakeClient
)
t
.
Errorf
(
"expected call to watch-endpoints, got %#v"
,
fakeClient
)
}
}
}
}
...
@@ -78,13 +78,13 @@ func TestServicesFromZero(t *testing.T) {
...
@@ -78,13 +78,13 @@ func TestServicesFromZero(t *testing.T) {
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
.
Stop
()
fakeWatch
.
Stop
()
fakeClient
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
fakeClient
:=
testclient
.
NewSimpleFake
(
&
api
.
ServiceList
{
fakeClient
.
ServiceList
=
api
.
ServiceList
{
ListMeta
:
api
.
ListMeta
{
ResourceVersion
:
"2"
},
ListMeta
:
api
.
ListMeta
{
ResourceVersion
:
"2"
},
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
service
,
service
,
},
},
}
})
fakeClient
.
Watch
=
fakeWatch
services
:=
make
(
chan
ServiceUpdate
)
services
:=
make
(
chan
ServiceUpdate
)
source
:=
SourceAPI
{
source
:=
SourceAPI
{
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
),
services
:
services
},
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
),
services
:
services
},
...
@@ -108,13 +108,13 @@ func TestServicesFromZero(t *testing.T) {
...
@@ -108,13 +108,13 @@ func TestServicesFromZero(t *testing.T) {
if
resourceVersion
!=
"2"
{
if
resourceVersion
!=
"2"
{
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
}
}
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
client
.
FakeAction
{{
"list-services"
,
nil
},
{
"watch-services"
,
"2"
}})
{
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
test
client
.
FakeAction
{{
"list-services"
,
nil
},
{
"watch-services"
,
"2"
}})
{
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
}
}
}
}
func
TestServicesError
(
t
*
testing
.
T
)
{
func
TestServicesError
(
t
*
testing
.
T
)
{
fakeClient
:=
&
client
.
Fake
{
Err
:
errors
.
New
(
"test"
)}
fakeClient
:=
&
test
client
.
Fake
{
Err
:
errors
.
New
(
"test"
)}
services
:=
make
(
chan
ServiceUpdate
)
services
:=
make
(
chan
ServiceUpdate
)
source
:=
SourceAPI
{
source
:=
SourceAPI
{
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
),
services
:
services
},
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
),
services
:
services
},
...
@@ -131,13 +131,13 @@ func TestServicesError(t *testing.T) {
...
@@ -131,13 +131,13 @@ func TestServicesError(t *testing.T) {
if
resourceVersion
!=
""
{
if
resourceVersion
!=
""
{
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
}
}
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
client
.
FakeAction
{{
"watch-services"
,
"1"
}})
{
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
test
client
.
FakeAction
{{
"watch-services"
,
"1"
}})
{
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
}
}
}
}
func
TestServicesErrorTimeout
(
t
*
testing
.
T
)
{
func
TestServicesErrorTimeout
(
t
*
testing
.
T
)
{
fakeClient
:=
&
client
.
Fake
{
Err
:
errors
.
New
(
"use of closed network connection"
)}
fakeClient
:=
&
test
client
.
Fake
{
Err
:
errors
.
New
(
"use of closed network connection"
)}
services
:=
make
(
chan
ServiceUpdate
)
services
:=
make
(
chan
ServiceUpdate
)
source
:=
SourceAPI
{
source
:=
SourceAPI
{
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
),
services
:
services
},
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
),
services
:
services
},
...
@@ -154,13 +154,13 @@ func TestServicesErrorTimeout(t *testing.T) {
...
@@ -154,13 +154,13 @@ func TestServicesErrorTimeout(t *testing.T) {
if
resourceVersion
!=
"1"
{
if
resourceVersion
!=
"1"
{
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
}
}
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
client
.
FakeAction
{{
"watch-services"
,
"1"
}})
{
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
test
client
.
FakeAction
{{
"watch-services"
,
"1"
}})
{
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
}
}
}
}
func
TestServicesFromZeroError
(
t
*
testing
.
T
)
{
func
TestServicesFromZeroError
(
t
*
testing
.
T
)
{
fakeClient
:=
&
client
.
Fake
{
Err
:
errors
.
New
(
"test"
)}
fakeClient
:=
&
test
client
.
Fake
{
Err
:
errors
.
New
(
"test"
)}
services
:=
make
(
chan
ServiceUpdate
)
services
:=
make
(
chan
ServiceUpdate
)
source
:=
SourceAPI
{
source
:=
SourceAPI
{
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
),
services
:
services
},
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
),
services
:
services
},
...
@@ -177,7 +177,7 @@ func TestServicesFromZeroError(t *testing.T) {
...
@@ -177,7 +177,7 @@ func TestServicesFromZeroError(t *testing.T) {
if
resourceVersion
!=
""
{
if
resourceVersion
!=
""
{
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
}
}
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
client
.
FakeAction
{{
"list-services"
,
nil
}})
{
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
test
client
.
FakeAction
{{
"list-services"
,
nil
}})
{
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
}
}
}
}
...
@@ -192,7 +192,7 @@ func TestEndpoints(t *testing.T) {
...
@@ -192,7 +192,7 @@ func TestEndpoints(t *testing.T) {
}
}
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
:=
watch
.
NewFake
()
fakeClient
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
fakeClient
:=
&
test
client
.
Fake
{
Watch
:
fakeWatch
}
endpoints
:=
make
(
chan
EndpointsUpdate
)
endpoints
:=
make
(
chan
EndpointsUpdate
)
source
:=
SourceAPI
{
source
:=
SourceAPI
{
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
)},
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
)},
...
@@ -206,7 +206,7 @@ func TestEndpoints(t *testing.T) {
...
@@ -206,7 +206,7 @@ func TestEndpoints(t *testing.T) {
// test adding an endpoint to the watch
// test adding an endpoint to the watch
fakeWatch
.
Add
(
&
endpoint
)
fakeWatch
.
Add
(
&
endpoint
)
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
client
.
FakeAction
{{
"watch-endpoints"
,
"1"
}})
{
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
test
client
.
FakeAction
{{
"watch-endpoints"
,
"1"
}})
{
t
.
Errorf
(
"expected call to watch-endpoints, got %#v"
,
fakeClient
)
t
.
Errorf
(
"expected call to watch-endpoints, got %#v"
,
fakeClient
)
}
}
...
@@ -230,7 +230,7 @@ func TestEndpoints(t *testing.T) {
...
@@ -230,7 +230,7 @@ func TestEndpoints(t *testing.T) {
fakeWatch
.
Stop
()
fakeWatch
.
Stop
()
newFakeWatch
.
Add
(
&
endpoint
)
newFakeWatch
.
Add
(
&
endpoint
)
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
client
.
FakeAction
{{
"watch-endpoints"
,
"1"
},
{
"watch-endpoints"
,
"2"
}})
{
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
test
client
.
FakeAction
{{
"watch-endpoints"
,
"1"
},
{
"watch-endpoints"
,
"2"
}})
{
t
.
Errorf
(
"expected call to watch-endpoints, got %#v"
,
fakeClient
)
t
.
Errorf
(
"expected call to watch-endpoints, got %#v"
,
fakeClient
)
}
}
}
}
...
@@ -246,13 +246,13 @@ func TestEndpointsFromZero(t *testing.T) {
...
@@ -246,13 +246,13 @@ func TestEndpointsFromZero(t *testing.T) {
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
.
Stop
()
fakeWatch
.
Stop
()
fakeClient
:=
&
client
.
Fake
{
Watch
:
fakeWatch
}
fakeClient
:=
testclient
.
NewSimpleFake
(
&
api
.
EndpointsList
{
fakeClient
.
EndpointsList
=
api
.
EndpointsList
{
ListMeta
:
api
.
ListMeta
{
ResourceVersion
:
"2"
},
ListMeta
:
api
.
ListMeta
{
ResourceVersion
:
"2"
},
Items
:
[]
api
.
Endpoints
{
Items
:
[]
api
.
Endpoints
{
endpoint
,
endpoint
,
},
},
}
})
fakeClient
.
Watch
=
fakeWatch
endpoints
:=
make
(
chan
EndpointsUpdate
)
endpoints
:=
make
(
chan
EndpointsUpdate
)
source
:=
SourceAPI
{
source
:=
SourceAPI
{
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
)},
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
)},
...
@@ -276,13 +276,13 @@ func TestEndpointsFromZero(t *testing.T) {
...
@@ -276,13 +276,13 @@ func TestEndpointsFromZero(t *testing.T) {
if
resourceVersion
!=
"2"
{
if
resourceVersion
!=
"2"
{
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
}
}
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
client
.
FakeAction
{{
"list-endpoints"
,
nil
},
{
"watch-endpoints"
,
"2"
}})
{
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
test
client
.
FakeAction
{{
"list-endpoints"
,
nil
},
{
"watch-endpoints"
,
"2"
}})
{
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
}
}
}
}
func
TestEndpointsError
(
t
*
testing
.
T
)
{
func
TestEndpointsError
(
t
*
testing
.
T
)
{
fakeClient
:=
&
client
.
Fake
{
Err
:
errors
.
New
(
"test"
)}
fakeClient
:=
&
test
client
.
Fake
{
Err
:
errors
.
New
(
"test"
)}
endpoints
:=
make
(
chan
EndpointsUpdate
)
endpoints
:=
make
(
chan
EndpointsUpdate
)
source
:=
SourceAPI
{
source
:=
SourceAPI
{
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
)},
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
)},
...
@@ -299,13 +299,13 @@ func TestEndpointsError(t *testing.T) {
...
@@ -299,13 +299,13 @@ func TestEndpointsError(t *testing.T) {
if
resourceVersion
!=
""
{
if
resourceVersion
!=
""
{
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
}
}
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
client
.
FakeAction
{{
"watch-endpoints"
,
"1"
}})
{
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
test
client
.
FakeAction
{{
"watch-endpoints"
,
"1"
}})
{
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
}
}
}
}
func
TestEndpointsErrorTimeout
(
t
*
testing
.
T
)
{
func
TestEndpointsErrorTimeout
(
t
*
testing
.
T
)
{
fakeClient
:=
&
client
.
Fake
{
Err
:
errors
.
New
(
"use of closed network connection"
)}
fakeClient
:=
&
test
client
.
Fake
{
Err
:
errors
.
New
(
"use of closed network connection"
)}
endpoints
:=
make
(
chan
EndpointsUpdate
)
endpoints
:=
make
(
chan
EndpointsUpdate
)
source
:=
SourceAPI
{
source
:=
SourceAPI
{
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
)},
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
)},
...
@@ -322,13 +322,13 @@ func TestEndpointsErrorTimeout(t *testing.T) {
...
@@ -322,13 +322,13 @@ func TestEndpointsErrorTimeout(t *testing.T) {
if
resourceVersion
!=
"1"
{
if
resourceVersion
!=
"1"
{
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
}
}
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
client
.
FakeAction
{{
"watch-endpoints"
,
"1"
}})
{
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
test
client
.
FakeAction
{{
"watch-endpoints"
,
"1"
}})
{
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
}
}
}
}
func
TestEndpointsFromZeroError
(
t
*
testing
.
T
)
{
func
TestEndpointsFromZeroError
(
t
*
testing
.
T
)
{
fakeClient
:=
&
client
.
Fake
{
Err
:
errors
.
New
(
"test"
)}
fakeClient
:=
&
test
client
.
Fake
{
Err
:
errors
.
New
(
"test"
)}
endpoints
:=
make
(
chan
EndpointsUpdate
)
endpoints
:=
make
(
chan
EndpointsUpdate
)
source
:=
SourceAPI
{
source
:=
SourceAPI
{
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
)},
s
:
servicesReflector
{
watcher
:
fakeClient
.
Services
(
api
.
NamespaceAll
)},
...
@@ -345,7 +345,7 @@ func TestEndpointsFromZeroError(t *testing.T) {
...
@@ -345,7 +345,7 @@ func TestEndpointsFromZeroError(t *testing.T) {
if
resourceVersion
!=
""
{
if
resourceVersion
!=
""
{
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
t
.
Errorf
(
"unexpected resource version, got %#v"
,
resourceVersion
)
}
}
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
client
.
FakeAction
{{
"list-endpoints"
,
nil
}})
{
if
!
reflect
.
DeepEqual
(
fakeClient
.
Actions
,
[]
test
client
.
FakeAction
{{
"list-endpoints"
,
nil
}})
{
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
t
.
Errorf
(
"unexpected actions, got %#v"
,
fakeClient
)
}
}
}
}
pkg/registry/controller/registry.go
View file @
842b9d8d
...
@@ -18,6 +18,7 @@ package controller
...
@@ -18,6 +18,7 @@ package controller
import
(
import
(
"fmt"
"fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/rest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/rest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
...
...
pkg/resourcequota/resource_quota_controller_test.go
View file @
842b9d8d
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client
/testclient
"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
)
...
@@ -150,17 +150,15 @@ func TestSyncResourceQuota(t *testing.T) {
...
@@ -150,17 +150,15 @@ func TestSyncResourceQuota(t *testing.T) {
},
},
}
}
kubeClient
:=
&
client
.
Fake
{
kubeClient
:=
testclient
.
NewSimpleFake
(
&
podList
,
&
quota
)
PodsList
:
podList
,
}
resourceQuotaManager
:=
NewResourceQuotaManager
(
kubeClient
)
resourceQuotaManager
:=
NewResourceQuotaManager
(
kubeClient
)
err
:=
resourceQuotaManager
.
syncResourceQuota
(
quota
)
err
:=
resourceQuotaManager
.
syncResourceQuota
(
quota
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
f
(
"Unexpected error %v"
,
err
)
t
.
Fatal
f
(
"Unexpected error %v"
,
err
)
}
}
usage
:=
kubeClient
.
ResourceQuotaStatus
usage
:=
kubeClient
.
Actions
[
1
]
.
Value
.
(
*
api
.
ResourceQuota
)
// ensure hard and used limits are what we expected
// ensure hard and used limits are what we expected
for
k
,
v
:=
range
expectedUsage
.
Status
.
Hard
{
for
k
,
v
:=
range
expectedUsage
.
Status
.
Hard
{
...
...
pkg/volume/secret/secret_test.go
View file @
842b9d8d
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/mount"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/mount"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
...
@@ -86,9 +87,7 @@ func TestPlugin(t *testing.T) {
...
@@ -86,9 +87,7 @@ func TestPlugin(t *testing.T) {
},
},
}
}
client
:=
&
client
.
Fake
{
client
:=
testclient
.
NewSimpleFake
(
&
secret
)
Secret
:
secret
,
}
pluginMgr
:=
volume
.
VolumePluginMgr
{}
pluginMgr
:=
volume
.
VolumePluginMgr
{}
pluginMgr
.
InitPlugins
(
ProbeVolumePlugins
(),
newTestHost
(
t
,
client
))
pluginMgr
.
InitPlugins
(
ProbeVolumePlugins
(),
newTestHost
(
t
,
client
))
...
...
plugin/pkg/admission/namespace/autoprovision/admission_test.go
View file @
842b9d8d
...
@@ -22,14 +22,14 @@ import (
...
@@ -22,14 +22,14 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/admission"
"github.com/GoogleCloudPlatform/kubernetes/pkg/admission"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
)
)
// TestAdmission verifies a namespace is created on create requests for namespace managed resources
// TestAdmission verifies a namespace is created on create requests for namespace managed resources
func
TestAdmission
(
t
*
testing
.
T
)
{
func
TestAdmission
(
t
*
testing
.
T
)
{
namespace
:=
"test"
namespace
:=
"test"
mockClient
:=
&
client
.
Fake
{}
mockClient
:=
&
test
client
.
Fake
{}
handler
:=
&
provision
{
handler
:=
&
provision
{
client
:
mockClient
,
client
:
mockClient
,
store
:
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
),
store
:
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
),
...
@@ -56,7 +56,7 @@ func TestAdmission(t *testing.T) {
...
@@ -56,7 +56,7 @@ func TestAdmission(t *testing.T) {
// TestAdmissionNamespaceExists verifies that no client call is made when a namespace already exists
// TestAdmissionNamespaceExists verifies that no client call is made when a namespace already exists
func
TestAdmissionNamespaceExists
(
t
*
testing
.
T
)
{
func
TestAdmissionNamespaceExists
(
t
*
testing
.
T
)
{
namespace
:=
"test"
namespace
:=
"test"
mockClient
:=
&
client
.
Fake
{}
mockClient
:=
&
test
client
.
Fake
{}
store
:=
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)
store
:=
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)
store
.
Add
(
&
api
.
Namespace
{
store
.
Add
(
&
api
.
Namespace
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
namespace
},
...
@@ -84,7 +84,7 @@ func TestAdmissionNamespaceExists(t *testing.T) {
...
@@ -84,7 +84,7 @@ func TestAdmissionNamespaceExists(t *testing.T) {
// TestIgnoreAdmission validates that a request is ignored if its not a create
// TestIgnoreAdmission validates that a request is ignored if its not a create
func
TestIgnoreAdmission
(
t
*
testing
.
T
)
{
func
TestIgnoreAdmission
(
t
*
testing
.
T
)
{
namespace
:=
"test"
namespace
:=
"test"
mockClient
:=
&
client
.
Fake
{}
mockClient
:=
&
test
client
.
Fake
{}
handler
:=
&
provision
{
handler
:=
&
provision
{
client
:
mockClient
,
client
:
mockClient
,
store
:
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
),
store
:
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
),
...
@@ -108,7 +108,7 @@ func TestIgnoreAdmission(t *testing.T) {
...
@@ -108,7 +108,7 @@ func TestIgnoreAdmission(t *testing.T) {
// TestAdmissionNamespaceExistsUnknownToHandler
// TestAdmissionNamespaceExistsUnknownToHandler
func
TestAdmissionNamespaceExistsUnknownToHandler
(
t
*
testing
.
T
)
{
func
TestAdmissionNamespaceExistsUnknownToHandler
(
t
*
testing
.
T
)
{
namespace
:=
"test"
namespace
:=
"test"
mockClient
:=
&
client
.
Fake
{
mockClient
:=
&
test
client
.
Fake
{
Err
:
errors
.
NewAlreadyExists
(
"namespaces"
,
namespace
),
Err
:
errors
.
NewAlreadyExists
(
"namespaces"
,
namespace
),
}
}
store
:=
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)
store
:=
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)
...
...
plugin/pkg/admission/namespace/lifecycle/admission_test.go
View file @
842b9d8d
...
@@ -21,8 +21,8 @@ import (
...
@@ -21,8 +21,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/admission"
"github.com/GoogleCloudPlatform/kubernetes/pkg/admission"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
)
)
// TestAdmission
// TestAdmission
...
@@ -38,7 +38,7 @@ func TestAdmission(t *testing.T) {
...
@@ -38,7 +38,7 @@ func TestAdmission(t *testing.T) {
}
}
store
:=
cache
.
NewStore
(
cache
.
MetaNamespaceIndexFunc
)
store
:=
cache
.
NewStore
(
cache
.
MetaNamespaceIndexFunc
)
store
.
Add
(
namespaceObj
)
store
.
Add
(
namespaceObj
)
mockClient
:=
&
client
.
Fake
{}
mockClient
:=
&
test
client
.
Fake
{}
handler
:=
&
lifecycle
{
handler
:=
&
lifecycle
{
client
:
mockClient
,
client
:
mockClient
,
store
:
store
,
store
:
store
,
...
...
plugin/pkg/admission/resourcequota/admission_test.go
View file @
842b9d8d
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/admission"
"github.com/GoogleCloudPlatform/kubernetes/pkg/admission"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client
/testclient
"
)
)
func
getResourceRequirements
(
cpu
,
memory
string
)
api
.
ResourceRequirements
{
func
getResourceRequirements
(
cpu
,
memory
string
)
api
.
ResourceRequirements
{
...
@@ -40,7 +40,7 @@ func getResourceRequirements(cpu, memory string) api.ResourceRequirements {
...
@@ -40,7 +40,7 @@ func getResourceRequirements(cpu, memory string) api.ResourceRequirements {
func
TestAdmissionIgnoresDelete
(
t
*
testing
.
T
)
{
func
TestAdmissionIgnoresDelete
(
t
*
testing
.
T
)
{
namespace
:=
"default"
namespace
:=
"default"
handler
:=
NewResourceQuota
(
&
client
.
Fake
{})
handler
:=
NewResourceQuota
(
&
test
client
.
Fake
{})
err
:=
handler
.
Admit
(
admission
.
NewAttributesRecord
(
nil
,
namespace
,
"pods"
,
"DELETE"
))
err
:=
handler
.
Admit
(
admission
.
NewAttributesRecord
(
nil
,
namespace
,
"pods"
,
"DELETE"
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"ResourceQuota should admit all deletes"
,
err
)
t
.
Errorf
(
"ResourceQuota should admit all deletes"
,
err
)
...
@@ -49,19 +49,17 @@ func TestAdmissionIgnoresDelete(t *testing.T) {
...
@@ -49,19 +49,17 @@ func TestAdmissionIgnoresDelete(t *testing.T) {
func
TestIncrementUsagePods
(
t
*
testing
.
T
)
{
func
TestIncrementUsagePods
(
t
*
testing
.
T
)
{
namespace
:=
"default"
namespace
:=
"default"
client
:=
&
client
.
Fake
{
client
:=
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
Resources
:
getResourceRequirements
(
"100m"
,
"1Gi"
)}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
Resources
:
getResourceRequirements
(
"100m"
,
"1Gi"
)}},
},
},
},
},
},
},
},
}
}
)
status
:=
&
api
.
ResourceQuotaStatus
{
status
:=
&
api
.
ResourceQuotaStatus
{
Hard
:
api
.
ResourceList
{},
Hard
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
...
@@ -84,19 +82,17 @@ func TestIncrementUsagePods(t *testing.T) {
...
@@ -84,19 +82,17 @@ func TestIncrementUsagePods(t *testing.T) {
func
TestIncrementUsageMemory
(
t
*
testing
.
T
)
{
func
TestIncrementUsageMemory
(
t
*
testing
.
T
)
{
namespace
:=
"default"
namespace
:=
"default"
client
:=
&
client
.
Fake
{
client
:=
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
Resources
:
getResourceRequirements
(
"100m"
,
"1Gi"
)}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
Resources
:
getResourceRequirements
(
"100m"
,
"1Gi"
)}},
},
},
},
},
},
},
},
}
}
)
status
:=
&
api
.
ResourceQuotaStatus
{
status
:=
&
api
.
ResourceQuotaStatus
{
Hard
:
api
.
ResourceList
{},
Hard
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
...
@@ -127,19 +123,17 @@ func TestIncrementUsageMemory(t *testing.T) {
...
@@ -127,19 +123,17 @@ func TestIncrementUsageMemory(t *testing.T) {
func
TestExceedUsageMemory
(
t
*
testing
.
T
)
{
func
TestExceedUsageMemory
(
t
*
testing
.
T
)
{
namespace
:=
"default"
namespace
:=
"default"
client
:=
&
client
.
Fake
{
client
:=
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
Resources
:
getResourceRequirements
(
"100m"
,
"1Gi"
)}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
Resources
:
getResourceRequirements
(
"100m"
,
"1Gi"
)}},
},
},
},
},
},
},
},
}
}
)
status
:=
&
api
.
ResourceQuotaStatus
{
status
:=
&
api
.
ResourceQuotaStatus
{
Hard
:
api
.
ResourceList
{},
Hard
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
...
@@ -162,19 +156,17 @@ func TestExceedUsageMemory(t *testing.T) {
...
@@ -162,19 +156,17 @@ func TestExceedUsageMemory(t *testing.T) {
func
TestIncrementUsageCPU
(
t
*
testing
.
T
)
{
func
TestIncrementUsageCPU
(
t
*
testing
.
T
)
{
namespace
:=
"default"
namespace
:=
"default"
client
:=
&
client
.
Fake
{
client
:=
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
Resources
:
getResourceRequirements
(
"100m"
,
"1Gi"
)}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
Resources
:
getResourceRequirements
(
"100m"
,
"1Gi"
)}},
},
},
},
},
},
},
},
}
}
)
status
:=
&
api
.
ResourceQuotaStatus
{
status
:=
&
api
.
ResourceQuotaStatus
{
Hard
:
api
.
ResourceList
{},
Hard
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
...
@@ -205,19 +197,17 @@ func TestIncrementUsageCPU(t *testing.T) {
...
@@ -205,19 +197,17 @@ func TestIncrementUsageCPU(t *testing.T) {
func
TestExceedUsageCPU
(
t
*
testing
.
T
)
{
func
TestExceedUsageCPU
(
t
*
testing
.
T
)
{
namespace
:=
"default"
namespace
:=
"default"
client
:=
&
client
.
Fake
{
client
:=
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
Resources
:
getResourceRequirements
(
"100m"
,
"1Gi"
)}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
Resources
:
getResourceRequirements
(
"100m"
,
"1Gi"
)}},
},
},
},
},
},
},
},
}
}
)
status
:=
&
api
.
ResourceQuotaStatus
{
status
:=
&
api
.
ResourceQuotaStatus
{
Hard
:
api
.
ResourceList
{},
Hard
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
...
@@ -240,19 +230,17 @@ func TestExceedUsageCPU(t *testing.T) {
...
@@ -240,19 +230,17 @@ func TestExceedUsageCPU(t *testing.T) {
func
TestExceedUsagePods
(
t
*
testing
.
T
)
{
func
TestExceedUsagePods
(
t
*
testing
.
T
)
{
namespace
:=
"default"
namespace
:=
"default"
client
:=
&
client
.
Fake
{
client
:=
testclient
.
NewSimpleFake
(
&
api
.
PodList
{
PodsList
:
api
.
PodList
{
Items
:
[]
api
.
Pod
{
Items
:
[]
api
.
Pod
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
Resources
:
getResourceRequirements
(
"100m"
,
"1Gi"
)}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
Resources
:
getResourceRequirements
(
"100m"
,
"1Gi"
)}},
},
},
},
},
},
},
},
}
}
)
status
:=
&
api
.
ResourceQuotaStatus
{
status
:=
&
api
.
ResourceQuotaStatus
{
Hard
:
api
.
ResourceList
{},
Hard
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
...
@@ -268,15 +256,13 @@ func TestExceedUsagePods(t *testing.T) {
...
@@ -268,15 +256,13 @@ func TestExceedUsagePods(t *testing.T) {
func
TestIncrementUsageServices
(
t
*
testing
.
T
)
{
func
TestIncrementUsageServices
(
t
*
testing
.
T
)
{
namespace
:=
"default"
namespace
:=
"default"
client
:=
&
client
.
Fake
{
client
:=
testclient
.
NewSimpleFake
(
&
api
.
ServiceList
{
ServiceList
:
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
},
},
},
},
},
}
}
)
status
:=
&
api
.
ResourceQuotaStatus
{
status
:=
&
api
.
ResourceQuotaStatus
{
Hard
:
api
.
ResourceList
{},
Hard
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
...
@@ -299,15 +285,13 @@ func TestIncrementUsageServices(t *testing.T) {
...
@@ -299,15 +285,13 @@ func TestIncrementUsageServices(t *testing.T) {
func
TestExceedUsageServices
(
t
*
testing
.
T
)
{
func
TestExceedUsageServices
(
t
*
testing
.
T
)
{
namespace
:=
"default"
namespace
:=
"default"
client
:=
&
client
.
Fake
{
client
:=
testclient
.
NewSimpleFake
(
&
api
.
ServiceList
{
ServiceList
:
api
.
ServiceList
{
Items
:
[]
api
.
Service
{
Items
:
[]
api
.
Service
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
},
},
},
},
},
}
}
)
status
:=
&
api
.
ResourceQuotaStatus
{
status
:=
&
api
.
ResourceQuotaStatus
{
Hard
:
api
.
ResourceList
{},
Hard
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
...
@@ -323,15 +307,13 @@ func TestExceedUsageServices(t *testing.T) {
...
@@ -323,15 +307,13 @@ func TestExceedUsageServices(t *testing.T) {
func
TestIncrementUsageReplicationControllers
(
t
*
testing
.
T
)
{
func
TestIncrementUsageReplicationControllers
(
t
*
testing
.
T
)
{
namespace
:=
"default"
namespace
:=
"default"
client
:=
&
client
.
Fake
{
client
:=
testclient
.
NewSimpleFake
(
&
api
.
ReplicationControllerList
{
CtrlList
:
api
.
ReplicationControllerList
{
Items
:
[]
api
.
ReplicationController
{
Items
:
[]
api
.
ReplicationController
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
},
},
},
},
},
}
}
)
status
:=
&
api
.
ResourceQuotaStatus
{
status
:=
&
api
.
ResourceQuotaStatus
{
Hard
:
api
.
ResourceList
{},
Hard
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
...
@@ -354,15 +336,13 @@ func TestIncrementUsageReplicationControllers(t *testing.T) {
...
@@ -354,15 +336,13 @@ func TestIncrementUsageReplicationControllers(t *testing.T) {
func
TestExceedUsageReplicationControllers
(
t
*
testing
.
T
)
{
func
TestExceedUsageReplicationControllers
(
t
*
testing
.
T
)
{
namespace
:=
"default"
namespace
:=
"default"
client
:=
&
client
.
Fake
{
client
:=
testclient
.
NewSimpleFake
(
&
api
.
ReplicationControllerList
{
CtrlList
:
api
.
ReplicationControllerList
{
Items
:
[]
api
.
ReplicationController
{
Items
:
[]
api
.
ReplicationController
{
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
},
},
},
},
},
}
}
)
status
:=
&
api
.
ResourceQuotaStatus
{
status
:=
&
api
.
ResourceQuotaStatus
{
Hard
:
api
.
ResourceList
{},
Hard
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
Used
:
api
.
ResourceList
{},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment