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
97368fc0
Commit
97368fc0
authored
Jun 07, 2017
by
Hemant Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up volume integration test
parent
33579467
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
27 deletions
+24
-27
attach_detach_test.go
test/integration/volume/attach_detach_test.go
+24
-27
No files found.
test/integration/volume/attach_detach_test.go
View file @
97368fc0
...
@@ -73,11 +73,13 @@ func fakePodWithVol(namespace string) *v1.Pod {
...
@@ -73,11 +73,13 @@ func fakePodWithVol(namespace string) *v1.Pod {
return
fakePod
return
fakePod
}
}
type
podCountFunc
func
(
int
)
bool
// Via integration test we can verify that if pod delete
// Via integration test we can verify that if pod delete
// event is somehow missed by AttachDetach controller - it still
// event is somehow missed by AttachDetach controller - it still
// gets cleaned up by Desired State of World populator.
// gets cleaned up by Desired State of World populator.
func
TestPodDeletionWithDswp
(
t
*
testing
.
T
)
{
func
TestPodDeletionWithDswp
(
t
*
testing
.
T
)
{
_
,
server
,
closeFn
:=
framework
.
RunAMaster
(
nil
)
_
,
server
,
closeFn
:=
framework
.
RunAMaster
(
framework
.
NewIntegrationTestMasterConfig
()
)
defer
closeFn
()
defer
closeFn
()
namespaceName
:=
"test-pod-deletion"
namespaceName
:=
"test-pod-deletion"
...
@@ -94,7 +96,6 @@ func TestPodDeletionWithDswp(t *testing.T) {
...
@@ -94,7 +96,6 @@ func TestPodDeletionWithDswp(t *testing.T) {
defer
framework
.
DeleteTestingNamespace
(
ns
,
server
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
server
,
t
)
testClient
,
ctrl
,
informers
:=
createAdClients
(
ns
,
t
,
server
,
defaultSyncPeriod
)
testClient
,
ctrl
,
informers
:=
createAdClients
(
ns
,
t
,
server
,
defaultSyncPeriod
)
pod
:=
fakePodWithVol
(
namespaceName
)
pod
:=
fakePodWithVol
(
namespaceName
)
podStopCh
:=
make
(
chan
struct
{})
podStopCh
:=
make
(
chan
struct
{})
...
@@ -130,7 +131,6 @@ func TestPodDeletionWithDswp(t *testing.T) {
...
@@ -130,7 +131,6 @@ func TestPodDeletionWithDswp(t *testing.T) {
}
}
waitForPodsInDSWP
(
t
,
ctrl
.
GetDesiredStateOfWorld
())
waitForPodsInDSWP
(
t
,
ctrl
.
GetDesiredStateOfWorld
())
// let's stop pod events from getting triggered
// let's stop pod events from getting triggered
close
(
podStopCh
)
close
(
podStopCh
)
err
=
podInformer
.
GetStore
()
.
Delete
(
podInformerObj
)
err
=
podInformer
.
GetStore
()
.
Delete
(
podInformerObj
)
...
@@ -140,17 +140,12 @@ func TestPodDeletionWithDswp(t *testing.T) {
...
@@ -140,17 +140,12 @@ func TestPodDeletionWithDswp(t *testing.T) {
waitToObservePods
(
t
,
podInformer
,
0
)
waitToObservePods
(
t
,
podInformer
,
0
)
// the populator loop turns every 1 minute
// the populator loop turns every 1 minute
time
.
Sleep
(
80
*
time
.
Second
)
waitForPodFuncInDSWP
(
t
,
ctrl
.
GetDesiredStateOfWorld
(),
80
*
time
.
Second
,
"expected 0 pods in dsw after pod delete"
,
0
)
podsToAdd
:=
ctrl
.
GetDesiredStateOfWorld
()
.
GetPodToAdd
()
if
len
(
podsToAdd
)
!=
0
{
t
.
Fatalf
(
"All pods should have been removed"
)
}
close
(
stopCh
)
close
(
stopCh
)
}
}
func
TestPodUpdateWithWithADC
(
t
*
testing
.
T
)
{
func
TestPodUpdateWithWithADC
(
t
*
testing
.
T
)
{
_
,
server
,
closeFn
:=
framework
.
RunAMaster
(
nil
)
_
,
server
,
closeFn
:=
framework
.
RunAMaster
(
framework
.
NewIntegrationTestMasterConfig
()
)
defer
closeFn
()
defer
closeFn
()
namespaceName
:=
"test-pod-update"
namespaceName
:=
"test-pod-update"
...
@@ -210,18 +205,14 @@ func TestPodUpdateWithWithADC(t *testing.T) {
...
@@ -210,18 +205,14 @@ func TestPodUpdateWithWithADC(t *testing.T) {
t
.
Errorf
(
"Failed to update pod : %v"
,
err
)
t
.
Errorf
(
"Failed to update pod : %v"
,
err
)
}
}
time
.
Sleep
(
20
*
time
.
Second
)
waitForPodFuncInDSWP
(
t
,
ctrl
.
GetDesiredStateOfWorld
(),
20
*
time
.
Second
,
"expected 0 pods in dsw after pod completion"
,
0
)
podsToAdd
:=
ctrl
.
GetDesiredStateOfWorld
()
.
GetPodToAdd
()
if
len
(
podsToAdd
)
!=
0
{
t
.
Fatalf
(
"All pods should have been removed"
)
}
close
(
podStopCh
)
close
(
podStopCh
)
close
(
stopCh
)
close
(
stopCh
)
}
}
func
TestPodUpdateWithKeepTerminatedPodVolumes
(
t
*
testing
.
T
)
{
func
TestPodUpdateWithKeepTerminatedPodVolumes
(
t
*
testing
.
T
)
{
_
,
server
,
closeFn
:=
framework
.
RunAMaster
(
nil
)
_
,
server
,
closeFn
:=
framework
.
RunAMaster
(
framework
.
NewIntegrationTestMasterConfig
()
)
defer
closeFn
()
defer
closeFn
()
namespaceName
:=
"test-pod-update"
namespaceName
:=
"test-pod-update"
...
@@ -282,11 +273,7 @@ func TestPodUpdateWithKeepTerminatedPodVolumes(t *testing.T) {
...
@@ -282,11 +273,7 @@ func TestPodUpdateWithKeepTerminatedPodVolumes(t *testing.T) {
t
.
Errorf
(
"Failed to update pod : %v"
,
err
)
t
.
Errorf
(
"Failed to update pod : %v"
,
err
)
}
}
time
.
Sleep
(
20
*
time
.
Second
)
waitForPodFuncInDSWP
(
t
,
ctrl
.
GetDesiredStateOfWorld
(),
20
*
time
.
Second
,
"expected non-zero pods in dsw if KeepTerminatedPodVolumesAnnotation is set"
,
1
)
podsToAdd
:=
ctrl
.
GetDesiredStateOfWorld
()
.
GetPodToAdd
()
if
len
(
podsToAdd
)
==
0
{
t
.
Fatalf
(
"The pod should not be removed if KeepTerminatedPodVolumesAnnotation is set"
)
}
close
(
podStopCh
)
close
(
podStopCh
)
close
(
stopCh
)
close
(
stopCh
)
...
@@ -321,6 +308,19 @@ func waitForPodsInDSWP(t *testing.T, dswp volumecache.DesiredStateOfWorld) {
...
@@ -321,6 +308,19 @@ func waitForPodsInDSWP(t *testing.T, dswp volumecache.DesiredStateOfWorld) {
}
}
}
}
// wait for pods to be observed in desired state of world
func
waitForPodFuncInDSWP
(
t
*
testing
.
T
,
dswp
volumecache
.
DesiredStateOfWorld
,
checkTimeout
time
.
Duration
,
failMessage
string
,
podCount
int
)
{
if
err
:=
wait
.
Poll
(
time
.
Millisecond
*
500
,
checkTimeout
,
func
()
(
bool
,
error
)
{
pods
:=
dswp
.
GetPodToAdd
()
if
len
(
pods
)
==
podCount
{
return
true
,
nil
}
return
false
,
nil
});
err
!=
nil
{
t
.
Fatalf
(
"%s but got error %v"
,
failMessage
,
err
)
}
}
func
createAdClients
(
ns
*
v1
.
Namespace
,
t
*
testing
.
T
,
server
*
httptest
.
Server
,
syncPeriod
time
.
Duration
)
(
*
clientset
.
Clientset
,
attachdetach
.
AttachDetachController
,
informers
.
SharedInformerFactory
)
{
func
createAdClients
(
ns
*
v1
.
Namespace
,
t
*
testing
.
T
,
server
*
httptest
.
Server
,
syncPeriod
time
.
Duration
)
(
*
clientset
.
Clientset
,
attachdetach
.
AttachDetachController
,
informers
.
SharedInformerFactory
)
{
config
:=
restclient
.
Config
{
config
:=
restclient
.
Config
{
Host
:
server
.
URL
,
Host
:
server
.
URL
,
...
@@ -368,7 +368,7 @@ func createAdClients(ns *v1.Namespace, t *testing.T, server *httptest.Server, sy
...
@@ -368,7 +368,7 @@ func createAdClients(ns *v1.Namespace, t *testing.T, server *httptest.Server, sy
// event is somehow missed by AttachDetach controller - it still
// event is somehow missed by AttachDetach controller - it still
// gets added by Desired State of World populator.
// gets added by Desired State of World populator.
func
TestPodAddedByDswp
(
t
*
testing
.
T
)
{
func
TestPodAddedByDswp
(
t
*
testing
.
T
)
{
_
,
server
,
closeFn
:=
framework
.
RunAMaster
(
nil
)
_
,
server
,
closeFn
:=
framework
.
RunAMaster
(
framework
.
NewIntegrationTestMasterConfig
()
)
defer
closeFn
()
defer
closeFn
()
namespaceName
:=
"test-pod-deletion"
namespaceName
:=
"test-pod-deletion"
...
@@ -440,12 +440,9 @@ func TestPodAddedByDswp(t *testing.T) {
...
@@ -440,12 +440,9 @@ func TestPodAddedByDswp(t *testing.T) {
}
}
waitToObservePods
(
t
,
podInformer
,
2
)
waitToObservePods
(
t
,
podInformer
,
2
)
// the findAndAddActivePods loop turns every 3 minute
// the findAndAddActivePods loop turns every 3 minute
time
.
Sleep
(
200
*
time
.
Second
)
waitForPodFuncInDSWP
(
t
,
ctrl
.
GetDesiredStateOfWorld
(),
200
*
time
.
Second
,
"expected 2 pods in dsw after pod addition"
,
2
)
podsToAdd
:=
ctrl
.
GetDesiredStateOfWorld
()
.
GetPodToAdd
()
if
len
(
podsToAdd
)
!=
2
{
t
.
Fatalf
(
"DSW should have two pods"
)
}
close
(
stopCh
)
close
(
stopCh
)
}
}
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