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
ac270b66
Commit
ac270b66
authored
Jun 23, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move first few integration tests to use dedicated namespaces
parent
08f17fef
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
175 deletions
+106
-175
client_test.go
test/integration/client_test.go
+49
-49
configmap_test.go
test/integration/configmap_test.go
+11
-23
extender_test.go
test/integration/extender_test.go
+1
-11
master_utils.go
test/integration/framework/master_utils.go
+16
-0
pods_test.go
test/integration/pods_test.go
+11
-34
scheduler_test.go
test/integration/scheduler_test.go
+4
-33
secret_test.go
test/integration/secret_test.go
+14
-25
No files found.
test/integration/client_test.go
View file @
ac270b66
...
...
@@ -44,15 +44,14 @@ import (
)
func
TestClient
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
ns
:=
api
.
NamespaceDefault
client
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
ns
:=
framework
.
CreateTestingNamespace
(
"client"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
info
,
err
:=
client
.
Discovery
()
.
ServerVersion
()
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
...
...
@@ -61,7 +60,7 @@ func TestClient(t *testing.T) {
t
.
Errorf
(
"expected %#v, got %#v"
,
e
,
a
)
}
pods
,
err
:=
client
.
Pods
(
ns
)
.
List
(
api
.
ListOptions
{})
pods
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
List
(
api
.
ListOptions
{})
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
...
...
@@ -73,6 +72,7 @@ func TestClient(t *testing.T) {
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
GenerateName
:
"test"
,
Namespace
:
ns
.
Name
,
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
...
...
@@ -83,14 +83,14 @@ func TestClient(t *testing.T) {
},
}
got
,
err
:=
client
.
Pods
(
ns
)
.
Create
(
pod
)
got
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
Create
(
pod
)
if
err
==
nil
{
t
.
Fatalf
(
"unexpected non-error: %v"
,
got
)
}
// get a created pod
pod
.
Spec
.
Containers
[
0
]
.
Image
=
"an-image"
got
,
err
=
client
.
Pods
(
ns
)
.
Create
(
pod
)
got
,
err
=
client
.
Pods
(
ns
.
Name
)
.
Create
(
pod
)
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
...
...
@@ -99,7 +99,7 @@ func TestClient(t *testing.T) {
}
// pod is shown, but not scheduled
pods
,
err
=
client
.
Pods
(
ns
)
.
List
(
api
.
ListOptions
{})
pods
,
err
=
client
.
Pods
(
ns
.
Name
)
.
List
(
api
.
ListOptions
{})
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
...
...
@@ -116,20 +116,21 @@ func TestClient(t *testing.T) {
}
func
TestAtomicPut
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
c
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
ns
:=
framework
.
CreateTestingNamespace
(
"atomic-put"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
rcBody
:=
api
.
ReplicationController
{
TypeMeta
:
unversioned
.
TypeMeta
{
APIVersion
:
c
.
APIVersion
()
.
String
(),
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"atomicrc"
,
Name
:
"atomicrc"
,
Namespace
:
ns
.
Name
,
Labels
:
map
[
string
]
string
{
"name"
:
"atomicrc"
,
},
...
...
@@ -153,7 +154,7 @@ func TestAtomicPut(t *testing.T) {
},
},
}
rcs
:=
c
.
ReplicationControllers
(
api
.
NamespaceDefault
)
rcs
:=
c
.
ReplicationControllers
(
ns
.
Name
)
rc
,
err
:=
rcs
.
Create
(
&
rcBody
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed creating atomicRC: %v"
,
err
)
...
...
@@ -207,14 +208,14 @@ func TestAtomicPut(t *testing.T) {
}
func
TestPatch
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
c
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
ns
:=
framework
.
CreateTestingNamespace
(
"patch"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
name
:=
"patchpod"
resource
:=
"pods"
podBody
:=
api
.
Pod
{
...
...
@@ -222,8 +223,9 @@ func TestPatch(t *testing.T) {
APIVersion
:
c
.
APIVersion
()
.
String
(),
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
,
Labels
:
map
[
string
]
string
{},
Name
:
name
,
Namespace
:
ns
.
Name
,
Labels
:
map
[
string
]
string
{},
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
...
...
@@ -231,7 +233,7 @@ func TestPatch(t *testing.T) {
},
},
}
pods
:=
c
.
Pods
(
api
.
NamespaceDefault
)
pods
:=
c
.
Pods
(
ns
.
Name
)
pod
,
err
:=
pods
.
Create
(
&
podBody
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed creating patchpods: %v"
,
err
)
...
...
@@ -266,7 +268,7 @@ func TestPatch(t *testing.T) {
execPatch
:=
func
(
pt
api
.
PatchType
,
body
[]
byte
)
error
{
return
c
.
Patch
(
pt
)
.
Resource
(
resource
)
.
Namespace
(
api
.
NamespaceDefault
)
.
Namespace
(
ns
.
Name
)
.
Name
(
name
)
.
Body
(
body
)
.
Do
()
.
...
...
@@ -315,16 +317,19 @@ func TestPatch(t *testing.T) {
}
func
TestPatchWithCreateOnUpdate
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
c
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
ns
:=
framework
.
CreateTestingNamespace
(
"patch-with-create"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
endpointTemplate
:=
&
api
.
Endpoints
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"patchendpoint"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"patchendpoint"
,
Namespace
:
ns
.
Name
,
},
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{{
IP
:
"1.2.3.4"
}},
...
...
@@ -334,7 +339,7 @@ func TestPatchWithCreateOnUpdate(t *testing.T) {
}
patchEndpoint
:=
func
(
json
[]
byte
)
(
runtime
.
Object
,
error
)
{
return
c
.
Patch
(
api
.
MergePatchType
)
.
Resource
(
"endpoints"
)
.
Namespace
(
api
.
NamespaceDefault
)
.
Name
(
"patchendpoint"
)
.
Body
(
json
)
.
Do
()
.
Get
()
return
c
.
Patch
(
api
.
MergePatchType
)
.
Resource
(
"endpoints"
)
.
Namespace
(
ns
.
Name
)
.
Name
(
"patchendpoint"
)
.
Body
(
json
)
.
Do
()
.
Get
()
}
// Make sure patch doesn't get to CreateOnUpdate
...
...
@@ -349,7 +354,7 @@ func TestPatchWithCreateOnUpdate(t *testing.T) {
}
// Create the endpoint (endpoints set AllowCreateOnUpdate=true) to get a UID and resource version
createdEndpoint
,
err
:=
c
.
Endpoints
(
api
.
NamespaceDefault
)
.
Update
(
endpointTemplate
)
createdEndpoint
,
err
:=
c
.
Endpoints
(
ns
.
Name
)
.
Update
(
endpointTemplate
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed creating endpoint: %v"
,
err
)
}
...
...
@@ -423,9 +428,6 @@ func TestPatchWithCreateOnUpdate(t *testing.T) {
}
func
TestAPIVersions
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
...
...
@@ -448,24 +450,23 @@ func TestAPIVersions(t *testing.T) {
}
func
TestSingleWatch
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
ns
:=
"blargh"
ns
:=
framework
.
CreateTestingNamespace
(
"single-watch"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
client
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
mkEvent
:=
func
(
i
int
)
*
api
.
Event
{
name
:=
fmt
.
Sprintf
(
"event-%v"
,
i
)
return
&
api
.
Event
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
ns
,
Namespace
:
ns
.
Name
,
Name
:
name
,
},
InvolvedObject
:
api
.
ObjectReference
{
Namespace
:
ns
,
Namespace
:
ns
.
Name
,
Name
:
name
,
},
Reason
:
fmt
.
Sprintf
(
"event %v"
,
i
),
...
...
@@ -475,7 +476,7 @@ func TestSingleWatch(t *testing.T) {
rv1
:=
""
for
i
:=
0
;
i
<
10
;
i
++
{
event
:=
mkEvent
(
i
)
got
,
err
:=
client
.
Events
(
ns
)
.
Create
(
event
)
got
,
err
:=
client
.
Events
(
ns
.
Name
)
.
Create
(
event
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed creating event %#q: %v"
,
event
,
err
)
}
...
...
@@ -490,7 +491,7 @@ func TestSingleWatch(t *testing.T) {
w
,
err
:=
client
.
Get
()
.
Prefix
(
"watch"
)
.
Namespace
IfScoped
(
ns
,
len
(
ns
)
>
0
)
.
Namespace
(
ns
.
Name
)
.
Resource
(
"events"
)
.
Name
(
"event-9"
)
.
Param
(
"resourceVersion"
,
rv1
)
.
...
...
@@ -531,16 +532,15 @@ func TestMultiWatch(t *testing.T) {
// TODO: Reenable this test when we get #6059 resolved.
return
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
const
watcherCount
=
50
rt
.
GOMAXPROCS
(
watcherCount
)
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
ns
:=
api
.
NamespaceDefault
ns
:=
framework
.
CreateTestingNamespace
(
"multi-watch"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
client
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
dummyEvent
:=
func
(
i
int
)
*
api
.
Event
{
...
...
@@ -548,11 +548,11 @@ func TestMultiWatch(t *testing.T) {
return
&
api
.
Event
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
fmt
.
Sprintf
(
"%v.%x"
,
name
,
time
.
Now
()
.
UnixNano
()),
Namespace
:
ns
,
Namespace
:
ns
.
Name
,
},
InvolvedObject
:
api
.
ObjectReference
{
Name
:
name
,
Namespace
:
ns
,
Namespace
:
ns
.
Name
,
},
Reason
:
fmt
.
Sprintf
(
"unrelated change %v"
,
i
),
}
...
...
@@ -570,7 +570,7 @@ func TestMultiWatch(t *testing.T) {
for
i
:=
0
;
i
<
watcherCount
;
i
++
{
watchesStarted
.
Add
(
1
)
name
:=
fmt
.
Sprintf
(
"multi-watch-%v"
,
i
)
got
,
err
:=
client
.
Pods
(
ns
)
.
Create
(
&
api
.
Pod
{
got
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
Create
(
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
,
Labels
:
labels
.
Set
{
"watchlabel"
:
name
},
...
...
@@ -591,7 +591,7 @@ func TestMultiWatch(t *testing.T) {
LabelSelector
:
labels
.
Set
{
"watchlabel"
:
name
}
.
AsSelector
(),
ResourceVersion
:
rv
,
}
w
,
err
:=
client
.
Pods
(
ns
)
.
Watch
(
options
)
w
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
Watch
(
options
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"watch error for %v: %v"
,
name
,
err
))
}
...
...
@@ -640,7 +640,7 @@ func TestMultiWatch(t *testing.T) {
if
!
ok
{
return
}
if
_
,
err
:=
client
.
Events
(
ns
)
.
Create
(
dummyEvent
(
i
));
err
!=
nil
{
if
_
,
err
:=
client
.
Events
(
ns
.
Name
)
.
Create
(
dummyEvent
(
i
));
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"couldn't make an event: %v"
,
err
))
}
changeMade
<-
i
...
...
@@ -677,7 +677,7 @@ func TestMultiWatch(t *testing.T) {
return
}
name
:=
fmt
.
Sprintf
(
"unrelated-%v"
,
i
)
_
,
err
:=
client
.
Pods
(
ns
)
.
Create
(
&
api
.
Pod
{
_
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
Create
(
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
,
},
...
...
@@ -711,13 +711,13 @@ func TestMultiWatch(t *testing.T) {
for
i
:=
0
;
i
<
watcherCount
;
i
++
{
go
func
(
i
int
)
{
name
:=
fmt
.
Sprintf
(
"multi-watch-%v"
,
i
)
pod
,
err
:=
client
.
Pods
(
ns
)
.
Get
(
name
)
pod
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
Get
(
name
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"Couldn't get %v: %v"
,
name
,
err
))
}
pod
.
Spec
.
Containers
[
0
]
.
Image
=
e2e
.
GetPauseImageName
(
client
)
sentTimes
<-
timePair
{
time
.
Now
(),
name
}
if
_
,
err
:=
client
.
Pods
(
ns
)
.
Update
(
pod
);
err
!=
nil
{
if
_
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
Update
(
pod
);
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"Couldn't make %v: %v"
,
name
,
err
))
}
}(
i
)
...
...
test/integration/configmap_test.go
View file @
ac270b66
...
...
@@ -21,46 +21,33 @@ package integration
// This file tests use of the configMap API resource.
import
(
"net/http"
"net/http/httptest"
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/client/restclient"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/test/integration/framework"
)
// TestConfigMap tests apiserver-side behavior of creation of ConfigMaps and pods that consume them.
func
TestConfigMap
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
var
m
*
master
.
Master
s
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
m
.
Handler
.
ServeHTTP
(
w
,
req
)
}))
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
m
,
err
:=
master
.
New
(
masterConfig
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
client
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
DoTestConfigMap
(
t
,
client
)
ns
:=
framework
.
CreateTestingNamespace
(
"config-map"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
DoTestConfigMap
(
t
,
client
,
ns
)
}
func
DoTestConfigMap
(
t
*
testing
.
T
,
client
*
client
.
Client
)
{
ns
:=
"ns"
func
DoTestConfigMap
(
t
*
testing
.
T
,
client
*
client
.
Client
,
ns
*
api
.
Namespace
)
{
cfg
:=
api
.
ConfigMap
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"configmap"
,
Namespace
:
ns
,
Namespace
:
ns
.
Name
,
},
Data
:
map
[
string
]
string
{
"data-1"
:
"value-1"
,
...
...
@@ -76,7 +63,8 @@ func DoTestConfigMap(t *testing.T, client *client.Client) {
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"XXX"
,
Name
:
"XXX"
,
Namespace
:
ns
.
Name
,
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
...
...
@@ -123,10 +111,10 @@ func DoTestConfigMap(t *testing.T, client *client.Client) {
}
pod
.
ObjectMeta
.
Name
=
"uses-configmap"
if
_
,
err
:=
client
.
Pods
(
ns
)
.
Create
(
pod
);
err
!=
nil
{
if
_
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
Create
(
pod
);
err
!=
nil
{
t
.
Errorf
(
"Failed to create pod: %v"
,
err
)
}
defer
deletePodOrErrorf
(
t
,
client
,
ns
,
pod
.
Name
)
defer
deletePodOrErrorf
(
t
,
client
,
ns
.
Name
,
pod
.
Name
)
}
func
deleteConfigMapOrErrorf
(
t
*
testing
.
T
,
c
*
client
.
Client
,
ns
,
name
string
)
{
...
...
test/integration/extender_test.go
View file @
ac270b66
...
...
@@ -36,7 +36,6 @@ import (
"k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/restclient"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/plugin/pkg/scheduler"
_
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider"
...
...
@@ -189,18 +188,9 @@ func TestSchedulerExtender(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
var
m
*
master
.
Master
s
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
m
.
Handler
.
ServeHTTP
(
w
,
req
)
}))
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
m
,
err
:=
master
.
New
(
masterConfig
)
if
err
!=
nil
{
t
.
Fatalf
(
"error in bringing up the master: %v"
,
err
)
}
restClient
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
extender1
:=
&
Extender
{
...
...
test/integration/framework/master_utils.go
View file @
ac270b66
...
...
@@ -239,6 +239,22 @@ func (m *MasterComponents) Stop(apiServer, rcManager bool) {
}
}
func
CreateTestingNamespace
(
baseName
string
,
apiserver
*
httptest
.
Server
,
t
*
testing
.
T
)
*
api
.
Namespace
{
// TODO: Create a namespace with a given basename.
// Currently we neither create the namespace nor delete all its contents at the end.
// But as long as tests are not using the same namespaces, this should work fine.
return
&
api
.
Namespace
{
ObjectMeta
:
api
.
ObjectMeta
{
// TODO: Once we start creating namespaces, switch to GenerateName.
Name
:
baseName
,
},
}
}
func
DeleteTestingNamespace
(
ns
*
api
.
Namespace
,
apiserver
*
httptest
.
Server
,
t
*
testing
.
T
)
{
// TODO: Remove all resources from a given namespace once we implement CreateTestingNamespace.
}
// RCFromManifest reads a .json file and returns the rc in it.
func
RCFromManifest
(
fileName
string
)
*
api
.
ReplicationController
{
data
,
err
:=
ioutil
.
ReadFile
(
fileName
)
...
...
test/integration/pods_test.go
View file @
ac270b66
...
...
@@ -20,34 +20,21 @@ package integration
import
(
"fmt"
"net/http"
"net/http/httptest"
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/client/restclient"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/test/integration/framework"
)
func
TestPodUpdateActiveDeadlineSeconds
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
var
m
*
master
.
Master
s
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
m
.
Handler
.
ServeHTTP
(
w
,
req
)
}))
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
ns
:=
"pod-activedeadline-update"
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
m
,
err
:=
master
.
New
(
masterConfig
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
ns
:=
framework
.
CreateTestingNamespace
(
"pod-activedeadline-update"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
client
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
...
...
@@ -142,40 +129,30 @@ func TestPodUpdateActiveDeadlineSeconds(t *testing.T) {
pod
.
Spec
.
ActiveDeadlineSeconds
=
tc
.
original
pod
.
ObjectMeta
.
Name
=
fmt
.
Sprintf
(
"activedeadlineseconds-test-%v"
,
i
)
if
_
,
err
:=
client
.
Pods
(
ns
)
.
Create
(
pod
);
err
!=
nil
{
if
_
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
Create
(
pod
);
err
!=
nil
{
t
.
Errorf
(
"Failed to create pod: %v"
,
err
)
}
pod
.
Spec
.
ActiveDeadlineSeconds
=
tc
.
update
_
,
err
:=
client
.
Pods
(
ns
)
.
Update
(
pod
)
_
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
Update
(
pod
)
if
tc
.
valid
&&
err
!=
nil
{
t
.
Errorf
(
"%v: failed to update pod: %v"
,
tc
.
name
,
err
)
}
else
if
!
tc
.
valid
&&
err
==
nil
{
t
.
Errorf
(
"%v: unexpected allowed update to pod"
,
tc
.
name
)
}
deletePodOrErrorf
(
t
,
client
,
ns
,
pod
.
Name
)
deletePodOrErrorf
(
t
,
client
,
ns
.
Name
,
pod
.
Name
)
}
}
func
TestPodReadOnlyFilesystem
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
var
m
*
master
.
Master
s
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
m
.
Handler
.
ServeHTTP
(
w
,
req
)
}))
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
isReadOnly
:=
true
ns
:=
"pod-readonly-root"
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
m
,
err
:=
master
.
New
(
masterConfig
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
ns
:=
framework
.
CreateTestingNamespace
(
"pod-readonly-root"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
client
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
...
...
@@ -196,9 +173,9 @@ func TestPodReadOnlyFilesystem(t *testing.T) {
},
}
if
_
,
err
:=
client
.
Pods
(
ns
)
.
Create
(
pod
);
err
!=
nil
{
if
_
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
Create
(
pod
);
err
!=
nil
{
t
.
Errorf
(
"Failed to create pod: %v"
,
err
)
}
deletePodOrErrorf
(
t
,
client
,
ns
,
pod
.
Name
)
deletePodOrErrorf
(
t
,
client
,
ns
.
Name
,
pod
.
Name
)
}
test/integration/scheduler_test.go
View file @
ac270b66
...
...
@@ -22,8 +22,6 @@ package integration
import
(
"fmt"
"net/http"
"net/http/httptest"
"testing"
"time"
...
...
@@ -36,7 +34,6 @@ import (
"k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/restclient"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/plugin/pkg/scheduler"
_
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider"
...
...
@@ -56,18 +53,9 @@ func TestUnschedulableNodes(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
var
m
*
master
.
Master
s
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
m
.
Handler
.
ServeHTTP
(
w
,
req
)
}))
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
m
,
err
:=
master
.
New
(
masterConfig
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
restClient
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
schedulerConfigFactory
:=
factory
.
NewConfigFactory
(
restClient
,
api
.
DefaultSchedulerName
,
api
.
DefaultHardPodAffinitySymmetricWeight
,
api
.
DefaultFailureDomains
)
...
...
@@ -304,19 +292,11 @@ func TestMultiScheduler(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
var
m
*
master
.
Master
s
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
m
.
Handler
.
ServeHTTP
(
w
,
req
)
}))
_
,
s
:=
framework
.
RunAMaster
(
t
)
// TODO: Uncomment when fix #19254
// This seems to be a different issue - it still doesn't work.
// defer s.Close()
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
m
,
err
:=
master
.
New
(
masterConfig
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
/*
This integration tests the multi-scheduler feature in the following way:
1. create a default scheduler
...
...
@@ -493,18 +473,9 @@ func createPod(client *client.Client, name string, annotation map[string]string)
func
TestAllocatable
(
t
*
testing
.
T
)
{
framework
.
DeleteAllEtcdKeys
()
var
m
*
master
.
Master
s
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
m
.
Handler
.
ServeHTTP
(
w
,
req
)
}))
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
m
,
err
:=
master
.
New
(
masterConfig
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
// 1. create and start default-scheduler
restClient
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
...
...
test/integration/secret_test.go
View file @
ac270b66
...
...
@@ -21,15 +21,12 @@ package integration
// This file tests use of the secrets API resource.
import
(
"net/http"
"net/http/httptest"
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/client/restclient"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/test/integration/framework"
)
...
...
@@ -41,33 +38,24 @@ func deleteSecretOrErrorf(t *testing.T, c *client.Client, ns, name string) {
// TestSecrets tests apiserver-side behavior of creation of secret objects and their use by pods.
func
TestSecrets
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
var
m
*
master
.
Master
s
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
m
.
Handler
.
ServeHTTP
(
w
,
req
)
}))
_
,
s
:=
framework
.
RunAMaster
(
t
)
defer
s
.
Close
()
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
m
,
err
:=
master
.
New
(
masterConfig
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in bringing up the master: %v"
,
err
)
}
client
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
DoTestSecrets
(
t
,
client
)
ns
:=
framework
.
CreateTestingNamespace
(
"secret"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
DoTestSecrets
(
t
,
client
,
ns
)
}
// DoTestSecrets test secrets for one api version.
func
DoTestSecrets
(
t
*
testing
.
T
,
client
*
client
.
Client
)
{
func
DoTestSecrets
(
t
*
testing
.
T
,
client
*
client
.
Client
,
ns
*
api
.
Namespace
)
{
// Make a secret object.
ns
:=
"ns"
s
:=
api
.
Secret
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"secret"
,
Namespace
:
ns
,
Namespace
:
ns
.
Name
,
},
Data
:
map
[
string
][]
byte
{
"data"
:
[]
byte
(
"value1
\n
"
),
...
...
@@ -82,7 +70,8 @@ func DoTestSecrets(t *testing.T, client *client.Client) {
// Template for pods that use a secret.
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"XXX"
,
Name
:
"XXX"
,
Namespace
:
ns
.
Name
,
},
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{
...
...
@@ -113,17 +102,17 @@ func DoTestSecrets(t *testing.T, client *client.Client) {
// Create a pod to consume secret.
pod
.
ObjectMeta
.
Name
=
"uses-secret"
if
_
,
err
:=
client
.
Pods
(
ns
)
.
Create
(
pod
);
err
!=
nil
{
if
_
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
Create
(
pod
);
err
!=
nil
{
t
.
Errorf
(
"Failed to create pod: %v"
,
err
)
}
defer
deletePodOrErrorf
(
t
,
client
,
ns
,
pod
.
Name
)
defer
deletePodOrErrorf
(
t
,
client
,
ns
.
Name
,
pod
.
Name
)
// Create a pod that consumes non-existent secret.
pod
.
ObjectMeta
.
Name
=
"uses-non-existent-secret"
if
_
,
err
:=
client
.
Pods
(
ns
)
.
Create
(
pod
);
err
!=
nil
{
if
_
,
err
:=
client
.
Pods
(
ns
.
Name
)
.
Create
(
pod
);
err
!=
nil
{
t
.
Errorf
(
"Failed to create pod: %v"
,
err
)
}
defer
deletePodOrErrorf
(
t
,
client
,
ns
,
pod
.
Name
)
defer
deletePodOrErrorf
(
t
,
client
,
ns
.
Name
,
pod
.
Name
)
// This pod may fail to run, but we don't currently prevent this, and this
// test can't check whether the kubelet actually pulls the secret.
...
...
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