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
98222b4d
Commit
98222b4d
authored
Jan 15, 2016
by
harry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace to tag
Use a testing pkg to replace testing util codes
parent
33c72db5
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
41 additions
and
37 deletions
+41
-37
listwatch_test.go
pkg/client/cache/listwatch_test.go
+3
-3
request_test.go
pkg/client/unversioned/request_test.go
+6
-5
restclient_test.go
pkg/client/unversioned/restclient_test.go
+4
-3
simple_testclient.go
...client/unversioned/testclient/simple/simple_testclient.go
+3
-3
controller_utils_test.go
pkg/controller/controller_utils_test.go
+2
-1
endpoints_controller_test.go
pkg/controller/endpoint/endpoints_controller_test.go
+3
-3
replication_controller_test.go
pkg/controller/replication/replication_controller_test.go
+5
-4
kubelet_client_test.go
pkg/kubelet/client/kubelet_client_test.go
+2
-2
http_test.go
pkg/kubelet/config/http_test.go
+4
-4
fake_handler.go
pkg/util/testing/fake_handler.go
+1
-1
fake_handler_test.go
pkg/util/testing/fake_handler_test.go
+1
-1
factory_test.go
plugin/pkg/scheduler/factory/factory_test.go
+7
-7
No files found.
pkg/client/cache/listwatch_test.go
View file @
98222b4d
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/util
"
utiltesting
"k8s.io/kubernetes/pkg/util/testing
"
)
)
func
parseSelectorOrDie
(
s
string
)
fields
.
Selector
{
func
parseSelectorOrDie
(
s
string
)
fields
.
Selector
{
...
@@ -89,7 +89,7 @@ func TestListWatchesCanList(t *testing.T) {
...
@@ -89,7 +89,7 @@ func TestListWatchesCanList(t *testing.T) {
},
},
}
}
for
_
,
item
:=
range
table
{
for
_
,
item
:=
range
table
{
handler
:=
util
.
FakeHandler
{
handler
:=
util
testing
.
FakeHandler
{
StatusCode
:
500
,
StatusCode
:
500
,
ResponseBody
:
""
,
ResponseBody
:
""
,
T
:
t
,
T
:
t
,
...
@@ -156,7 +156,7 @@ func TestListWatchesCanWatch(t *testing.T) {
...
@@ -156,7 +156,7 @@ func TestListWatchesCanWatch(t *testing.T) {
}
}
for
_
,
item
:=
range
table
{
for
_
,
item
:=
range
table
{
handler
:=
util
.
FakeHandler
{
handler
:=
util
testing
.
FakeHandler
{
StatusCode
:
500
,
StatusCode
:
500
,
ResponseBody
:
""
,
ResponseBody
:
""
,
T
:
t
,
T
:
t
,
...
...
pkg/client/unversioned/request_test.go
View file @
98222b4d
...
@@ -40,6 +40,7 @@ import (
...
@@ -40,6 +40,7 @@ import (
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/httpstream"
"k8s.io/kubernetes/pkg/util/httpstream"
"k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/pkg/util/intstr"
utiltesting
"k8s.io/kubernetes/pkg/util/testing"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
watchjson
"k8s.io/kubernetes/pkg/watch/json"
watchjson
"k8s.io/kubernetes/pkg/watch/json"
)
)
...
@@ -698,7 +699,7 @@ func TestDoRequestNewWay(t *testing.T) {
...
@@ -698,7 +699,7 @@ func TestDoRequestNewWay(t *testing.T) {
TargetPort
:
intstr
.
FromInt
(
12345
),
TargetPort
:
intstr
.
FromInt
(
12345
),
}}}}
}}}}
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
expectedObj
)
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
expectedObj
)
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
string
(
expectedBody
),
ResponseBody
:
string
(
expectedBody
),
T
:
t
,
T
:
t
,
...
@@ -867,7 +868,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
...
@@ -867,7 +868,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
TargetPort
:
intstr
.
FromInt
(
12345
),
TargetPort
:
intstr
.
FromInt
(
12345
),
}}}}
}}}}
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
expectedObj
)
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
expectedObj
)
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
string
(
expectedBody
),
ResponseBody
:
string
(
expectedBody
),
T
:
t
,
T
:
t
,
...
@@ -908,7 +909,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
...
@@ -908,7 +909,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
TargetPort
:
intstr
.
FromInt
(
12345
),
TargetPort
:
intstr
.
FromInt
(
12345
),
}}}}
}}}}
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
expectedObj
)
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
expectedObj
)
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
string
(
expectedBody
),
ResponseBody
:
string
(
expectedBody
),
T
:
t
,
T
:
t
,
...
@@ -964,7 +965,7 @@ func TestDoRequestNewWayFile(t *testing.T) {
...
@@ -964,7 +965,7 @@ func TestDoRequestNewWayFile(t *testing.T) {
TargetPort
:
intstr
.
FromInt
(
12345
),
TargetPort
:
intstr
.
FromInt
(
12345
),
}}}}
}}}}
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
expectedObj
)
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
expectedObj
)
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
string
(
expectedBody
),
ResponseBody
:
string
(
expectedBody
),
T
:
t
,
T
:
t
,
...
@@ -1010,7 +1011,7 @@ func TestWasCreated(t *testing.T) {
...
@@ -1010,7 +1011,7 @@ func TestWasCreated(t *testing.T) {
TargetPort
:
intstr
.
FromInt
(
12345
),
TargetPort
:
intstr
.
FromInt
(
12345
),
}}}}
}}}}
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
expectedObj
)
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
expectedObj
)
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
201
,
StatusCode
:
201
,
ResponseBody
:
string
(
expectedBody
),
ResponseBody
:
string
(
expectedBody
),
T
:
t
,
T
:
t
,
...
...
pkg/client/unversioned/restclient_test.go
View file @
98222b4d
...
@@ -29,12 +29,13 @@ import (
...
@@ -29,12 +29,13 @@ import (
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
utiltesting
"k8s.io/kubernetes/pkg/util/testing"
)
)
func
TestDoRequestSuccess
(
t
*
testing
.
T
)
{
func
TestDoRequestSuccess
(
t
*
testing
.
T
)
{
status
:=
&
unversioned
.
Status
{
Status
:
unversioned
.
StatusSuccess
}
status
:=
&
unversioned
.
Status
{
Status
:
unversioned
.
StatusSuccess
}
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
status
)
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
status
)
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
string
(
expectedBody
),
ResponseBody
:
string
(
expectedBody
),
T
:
t
,
T
:
t
,
...
@@ -78,7 +79,7 @@ func TestDoRequestFailed(t *testing.T) {
...
@@ -78,7 +79,7 @@ func TestDoRequestFailed(t *testing.T) {
Details
:
&
unversioned
.
StatusDetails
{},
Details
:
&
unversioned
.
StatusDetails
{},
}
}
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
status
)
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
status
)
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
404
,
StatusCode
:
404
,
ResponseBody
:
string
(
expectedBody
),
ResponseBody
:
string
(
expectedBody
),
T
:
t
,
T
:
t
,
...
@@ -111,7 +112,7 @@ func TestDoRequestFailed(t *testing.T) {
...
@@ -111,7 +112,7 @@ func TestDoRequestFailed(t *testing.T) {
func
TestDoRequestCreated
(
t
*
testing
.
T
)
{
func
TestDoRequestCreated
(
t
*
testing
.
T
)
{
status
:=
&
unversioned
.
Status
{
Status
:
unversioned
.
StatusSuccess
}
status
:=
&
unversioned
.
Status
{
Status
:
unversioned
.
StatusSuccess
}
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
status
)
expectedBody
,
_
:=
testapi
.
Default
.
Codec
()
.
Encode
(
status
)
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
201
,
StatusCode
:
201
,
ResponseBody
:
string
(
expectedBody
),
ResponseBody
:
string
(
expectedBody
),
T
:
t
,
T
:
t
,
...
...
pkg/client/unversioned/testclient/simple/simple_testclient.go
View file @
98222b4d
...
@@ -31,7 +31,7 @@ import (
...
@@ -31,7 +31,7 @@ import (
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util
"
utiltesting
"k8s.io/kubernetes/pkg/util/testing
"
)
)
const
NameRequiredError
=
"resource name may not be empty"
const
NameRequiredError
=
"resource name may not be empty"
...
@@ -58,7 +58,7 @@ type Client struct {
...
@@ -58,7 +58,7 @@ type Client struct {
Error
bool
Error
bool
Created
bool
Created
bool
server
*
httptest
.
Server
server
*
httptest
.
Server
handler
*
util
.
FakeHandler
handler
*
util
testing
.
FakeHandler
// For query args, an optional function to validate the contents
// For query args, an optional function to validate the contents
// useful when the contents can change but still be correct.
// useful when the contents can change but still be correct.
// Maps from query arg key to validator.
// Maps from query arg key to validator.
...
@@ -67,7 +67,7 @@ type Client struct {
...
@@ -67,7 +67,7 @@ type Client struct {
}
}
func
(
c
*
Client
)
Setup
(
t
*
testing
.
T
)
*
Client
{
func
(
c
*
Client
)
Setup
(
t
*
testing
.
T
)
*
Client
{
c
.
handler
=
&
util
.
FakeHandler
{
c
.
handler
=
&
util
testing
.
FakeHandler
{
StatusCode
:
c
.
Response
.
StatusCode
,
StatusCode
:
c
.
Response
.
StatusCode
,
}
}
if
responseBody
:=
body
(
t
,
c
.
Response
.
Body
,
c
.
Response
.
RawBody
);
responseBody
!=
nil
{
if
responseBody
:=
body
(
t
,
c
.
Response
.
Body
,
c
.
Response
.
RawBody
);
responseBody
!=
nil
{
...
...
pkg/controller/controller_utils_test.go
View file @
98222b4d
...
@@ -36,6 +36,7 @@ import (
...
@@ -36,6 +36,7 @@ import (
"k8s.io/kubernetes/pkg/securitycontext"
"k8s.io/kubernetes/pkg/securitycontext"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/sets"
utiltesting
"k8s.io/kubernetes/pkg/util/testing"
)
)
// NewFakeControllerExpectationsLookup creates a fake store for PodExpectations.
// NewFakeControllerExpectationsLookup creates a fake store for PodExpectations.
...
@@ -184,7 +185,7 @@ func TestControllerExpectations(t *testing.T) {
...
@@ -184,7 +185,7 @@ func TestControllerExpectations(t *testing.T) {
func
TestCreatePods
(
t
*
testing
.
T
)
{
func
TestCreatePods
(
t
*
testing
.
T
)
{
ns
:=
api
.
NamespaceDefault
ns
:=
api
.
NamespaceDefault
body
:=
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"empty_pod"
}})
body
:=
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"empty_pod"
}})
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
string
(
body
),
ResponseBody
:
string
(
body
),
}
}
...
...
pkg/controller/endpoint/endpoints_controller_test.go
View file @
98222b4d
...
@@ -31,8 +31,8 @@ import (
...
@@ -31,8 +31,8 @@ import (
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/pkg/util/intstr"
utiltesting
"k8s.io/kubernetes/pkg/util/testing"
)
)
func
addPods
(
store
cache
.
Store
,
namespace
string
,
nPods
int
,
nPorts
int
,
nNotReady
int
)
{
func
addPods
(
store
cache
.
Store
,
namespace
string
,
nPods
int
,
nPorts
int
,
nNotReady
int
)
{
...
@@ -73,8 +73,8 @@ type serverResponse struct {
...
@@ -73,8 +73,8 @@ type serverResponse struct {
obj
interface
{}
obj
interface
{}
}
}
func
makeTestServer
(
t
*
testing
.
T
,
namespace
string
,
endpointsResponse
serverResponse
)
(
*
httptest
.
Server
,
*
util
.
FakeHandler
)
{
func
makeTestServer
(
t
*
testing
.
T
,
namespace
string
,
endpointsResponse
serverResponse
)
(
*
httptest
.
Server
,
*
util
testing
.
FakeHandler
)
{
fakeEndpointsHandler
:=
util
.
FakeHandler
{
fakeEndpointsHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
endpointsResponse
.
statusCode
,
StatusCode
:
endpointsResponse
.
statusCode
,
ResponseBody
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
endpointsResponse
.
obj
.
(
runtime
.
Object
)),
ResponseBody
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
endpointsResponse
.
obj
.
(
runtime
.
Object
)),
}
}
...
...
pkg/controller/replication/replication_controller_test.go
View file @
98222b4d
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
"k8s.io/kubernetes/pkg/securitycontext"
"k8s.io/kubernetes/pkg/securitycontext"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/sets"
utiltesting
"k8s.io/kubernetes/pkg/util/testing"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
)
)
...
@@ -210,7 +211,7 @@ func TestSyncReplicationControllerCreates(t *testing.T) {
...
@@ -210,7 +211,7 @@ func TestSyncReplicationControllerCreates(t *testing.T) {
func
TestStatusUpdatesWithoutReplicasChange
(
t
*
testing
.
T
)
{
func
TestStatusUpdatesWithoutReplicasChange
(
t
*
testing
.
T
)
{
// Setup a fake server to listen for requests, and run the rc manager in steady state
// Setup a fake server to listen for requests, and run the rc manager in steady state
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
""
,
ResponseBody
:
""
,
}
}
...
@@ -252,7 +253,7 @@ func TestStatusUpdatesWithoutReplicasChange(t *testing.T) {
...
@@ -252,7 +253,7 @@ func TestStatusUpdatesWithoutReplicasChange(t *testing.T) {
func
TestControllerUpdateReplicas
(
t
*
testing
.
T
)
{
func
TestControllerUpdateReplicas
(
t
*
testing
.
T
)
{
// This is a happy server just to record the PUT request we expect for status.Replicas
// This is a happy server just to record the PUT request we expect for status.Replicas
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
""
,
ResponseBody
:
""
,
}
}
...
@@ -292,7 +293,7 @@ func TestControllerUpdateReplicas(t *testing.T) {
...
@@ -292,7 +293,7 @@ func TestControllerUpdateReplicas(t *testing.T) {
func
TestSyncReplicationControllerDormancy
(
t
*
testing
.
T
)
{
func
TestSyncReplicationControllerDormancy
(
t
*
testing
.
T
)
{
// Setup a test server so we can lie about the current state of pods
// Setup a test server so we can lie about the current state of pods
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
""
,
ResponseBody
:
""
,
}
}
...
@@ -552,7 +553,7 @@ func TestUpdatePods(t *testing.T) {
...
@@ -552,7 +553,7 @@ func TestUpdatePods(t *testing.T) {
func
TestControllerUpdateRequeue
(
t
*
testing
.
T
)
{
func
TestControllerUpdateRequeue
(
t
*
testing
.
T
)
{
// This server should force a requeue of the controller because it fails to update status.Replicas.
// This server should force a requeue of the controller because it fails to update status.Replicas.
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
500
,
StatusCode
:
500
,
ResponseBody
:
""
,
ResponseBody
:
""
,
}
}
...
...
pkg/kubelet/client/kubelet_client_test.go
View file @
98222b4d
...
@@ -24,7 +24,7 @@ import (
...
@@ -24,7 +24,7 @@ import (
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/probe"
"k8s.io/kubernetes/pkg/probe"
"k8s.io/kubernetes/pkg/util
"
utiltesting
"k8s.io/kubernetes/pkg/util/testing
"
)
)
func
TestHTTPKubeletClient
(
t
*
testing
.
T
)
{
func
TestHTTPKubeletClient
(
t
*
testing
.
T
)
{
...
@@ -34,7 +34,7 @@ func TestHTTPKubeletClient(t *testing.T) {
...
@@ -34,7 +34,7 @@ func TestHTTPKubeletClient(t *testing.T) {
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
string
(
body
),
ResponseBody
:
string
(
body
),
}
}
...
...
pkg/kubelet/config/http_test.go
View file @
98222b4d
...
@@ -29,7 +29,7 @@ import (
...
@@ -29,7 +29,7 @@ import (
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/api/validation"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util
"
utiltesting
"k8s.io/kubernetes/pkg/util/testing
"
)
)
func
TestURLErrorNotExistNoUpdate
(
t
*
testing
.
T
)
{
func
TestURLErrorNotExistNoUpdate
(
t
*
testing
.
T
)
{
...
@@ -106,7 +106,7 @@ func TestExtractInvalidPods(t *testing.T) {
...
@@ -106,7 +106,7 @@ func TestExtractInvalidPods(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"%s: Some weird json problem: %v"
,
testCase
.
desc
,
err
)
t
.
Fatalf
(
"%s: Some weird json problem: %v"
,
testCase
.
desc
,
err
)
}
}
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
string
(
data
),
ResponseBody
:
string
(
data
),
}
}
...
@@ -267,7 +267,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
...
@@ -267,7 +267,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"%s: error in encoding the pod: %v"
,
testCase
.
desc
,
err
)
t
.
Fatalf
(
"%s: error in encoding the pod: %v"
,
testCase
.
desc
,
err
)
}
}
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
string
(
data
),
ResponseBody
:
string
(
data
),
}
}
...
@@ -313,7 +313,7 @@ func TestURLWithHeader(t *testing.T) {
...
@@ -313,7 +313,7 @@ func TestURLWithHeader(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected json marshalling error: %v"
,
err
)
t
.
Fatalf
(
"Unexpected json marshalling error: %v"
,
err
)
}
}
fakeHandler
:=
util
.
FakeHandler
{
fakeHandler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
string
(
data
),
ResponseBody
:
string
(
data
),
}
}
...
...
pkg/util/fake_handler.go
→
pkg/util/
testing/
fake_handler.go
View file @
98222b4d
...
@@ -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
util
package
testing
import
(
import
(
"io/ioutil"
"io/ioutil"
...
...
pkg/util/fake_handler_test.go
→
pkg/util/
testing/
fake_handler_test.go
View file @
98222b4d
...
@@ -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
util
package
testing
import
(
import
(
"bytes"
"bytes"
...
...
plugin/pkg/scheduler/factory/factory_test.go
View file @
98222b4d
...
@@ -30,14 +30,14 @@ import (
...
@@ -30,14 +30,14 @@ import (
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util
"
utiltesting
"k8s.io/kubernetes/pkg/util/testing
"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
schedulerapi
"k8s.io/kubernetes/plugin/pkg/scheduler/api"
schedulerapi
"k8s.io/kubernetes/plugin/pkg/scheduler/api"
latestschedulerapi
"k8s.io/kubernetes/plugin/pkg/scheduler/api/latest"
latestschedulerapi
"k8s.io/kubernetes/plugin/pkg/scheduler/api/latest"
)
)
func
TestCreate
(
t
*
testing
.
T
)
{
func
TestCreate
(
t
*
testing
.
T
)
{
handler
:=
util
.
FakeHandler
{
handler
:=
util
testing
.
FakeHandler
{
StatusCode
:
500
,
StatusCode
:
500
,
ResponseBody
:
""
,
ResponseBody
:
""
,
T
:
t
,
T
:
t
,
...
@@ -56,7 +56,7 @@ func TestCreateFromConfig(t *testing.T) {
...
@@ -56,7 +56,7 @@ func TestCreateFromConfig(t *testing.T) {
var
configData
[]
byte
var
configData
[]
byte
var
policy
schedulerapi
.
Policy
var
policy
schedulerapi
.
Policy
handler
:=
util
.
FakeHandler
{
handler
:=
util
testing
.
FakeHandler
{
StatusCode
:
500
,
StatusCode
:
500
,
ResponseBody
:
""
,
ResponseBody
:
""
,
T
:
t
,
T
:
t
,
...
@@ -99,7 +99,7 @@ func TestCreateFromEmptyConfig(t *testing.T) {
...
@@ -99,7 +99,7 @@ func TestCreateFromEmptyConfig(t *testing.T) {
var
configData
[]
byte
var
configData
[]
byte
var
policy
schedulerapi
.
Policy
var
policy
schedulerapi
.
Policy
handler
:=
util
.
FakeHandler
{
handler
:=
util
testing
.
FakeHandler
{
StatusCode
:
500
,
StatusCode
:
500
,
ResponseBody
:
""
,
ResponseBody
:
""
,
T
:
t
,
T
:
t
,
...
@@ -140,7 +140,7 @@ func TestDefaultErrorFunc(t *testing.T) {
...
@@ -140,7 +140,7 @@ func TestDefaultErrorFunc(t *testing.T) {
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
"bar"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
"bar"
},
Spec
:
apitesting
.
DeepEqualSafePodSpec
(),
Spec
:
apitesting
.
DeepEqualSafePodSpec
(),
}
}
handler
:=
util
.
FakeHandler
{
handler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
testPod
),
ResponseBody
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
testPod
),
T
:
t
,
T
:
t
,
...
@@ -228,7 +228,7 @@ func TestBind(t *testing.T) {
...
@@ -228,7 +228,7 @@ func TestBind(t *testing.T) {
}
}
for
_
,
item
:=
range
table
{
for
_
,
item
:=
range
table
{
handler
:=
util
.
FakeHandler
{
handler
:=
util
testing
.
FakeHandler
{
StatusCode
:
200
,
StatusCode
:
200
,
ResponseBody
:
""
,
ResponseBody
:
""
,
T
:
t
,
T
:
t
,
...
@@ -314,7 +314,7 @@ func TestBackoff(t *testing.T) {
...
@@ -314,7 +314,7 @@ func TestBackoff(t *testing.T) {
// is of name "foo-scheduler". A pod must be picked up by at most one of the two
// is of name "foo-scheduler". A pod must be picked up by at most one of the two
// schedulers.
// schedulers.
func
TestResponsibleForPod
(
t
*
testing
.
T
)
{
func
TestResponsibleForPod
(
t
*
testing
.
T
)
{
handler
:=
util
.
FakeHandler
{
handler
:=
util
testing
.
FakeHandler
{
StatusCode
:
500
,
StatusCode
:
500
,
ResponseBody
:
""
,
ResponseBody
:
""
,
T
:
t
,
T
:
t
,
...
...
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