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
9bf88ddc
Commit
9bf88ddc
authored
Sep 25, 2015
by
derekwaynecarr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix flake in gc test
parent
44b0bb1a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
14 deletions
+18
-14
gc_controller_test.go
pkg/controller/gc/gc_controller_test.go
+18
-14
No files found.
pkg/controller/gc/gc_controller_test.go
View file @
9bf88ddc
...
@@ -60,32 +60,36 @@ func (f *FakePodControl) clear() {
...
@@ -60,32 +60,36 @@ func (f *FakePodControl) clear() {
}
}
func
TestGC
(
t
*
testing
.
T
)
{
func
TestGC
(
t
*
testing
.
T
)
{
type
nameToPhase
struct
{
name
string
phase
api
.
PodPhase
}
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
pods
map
[
string
]
api
.
Pod
Phase
pods
[]
nameTo
Phase
threshold
int
threshold
int
deletedPodNames
sets
.
String
deletedPodNames
sets
.
String
}{
}{
{
{
pods
:
map
[
string
]
api
.
Pod
Phase
{
pods
:
[]
nameTo
Phase
{
"a"
:
api
.
PodFailed
,
{
name
:
"a"
,
phase
:
api
.
PodFailed
}
,
"b"
:
api
.
PodSucceeded
,
{
name
:
"b"
,
phase
:
api
.
PodSucceeded
}
,
},
},
threshold
:
0
,
threshold
:
0
,
deletedPodNames
:
sets
.
NewString
(
"a"
,
"b"
),
deletedPodNames
:
sets
.
NewString
(
"a"
,
"b"
),
},
},
{
{
pods
:
map
[
string
]
api
.
Pod
Phase
{
pods
:
[]
nameTo
Phase
{
"a"
:
api
.
PodFailed
,
{
name
:
"a"
,
phase
:
api
.
PodFailed
}
,
"b"
:
api
.
PodSucceeded
,
{
name
:
"b"
,
phase
:
api
.
PodSucceeded
}
,
},
},
threshold
:
1
,
threshold
:
1
,
deletedPodNames
:
sets
.
NewString
(
"a"
),
deletedPodNames
:
sets
.
NewString
(
"a"
),
},
},
{
{
pods
:
map
[
string
]
api
.
Pod
Phase
{
pods
:
[]
nameTo
Phase
{
"a"
:
api
.
PodFailed
,
{
name
:
"a"
,
phase
:
api
.
PodFailed
}
,
"b"
:
api
.
PodSucceeded
,
{
name
:
"b"
,
phase
:
api
.
PodSucceeded
}
,
},
},
threshold
:
5
,
threshold
:
5
,
deletedPodNames
:
sets
.
NewString
(),
deletedPodNames
:
sets
.
NewString
(),
...
@@ -99,11 +103,11 @@ func TestGC(t *testing.T) {
...
@@ -99,11 +103,11 @@ func TestGC(t *testing.T) {
gcc
.
podControl
=
fake
gcc
.
podControl
=
fake
creationTime
:=
time
.
Unix
(
0
,
0
)
creationTime
:=
time
.
Unix
(
0
,
0
)
for
name
,
phase
:=
range
test
.
pods
{
for
_
,
pod
:=
range
test
.
pods
{
creationTime
=
creationTime
.
Add
(
1
*
time
.
Hour
)
creationTime
=
creationTime
.
Add
(
1
*
time
.
Hour
)
gcc
.
podStore
.
Store
.
Add
(
&
api
.
Pod
{
gcc
.
podStore
.
Store
.
Add
(
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
,
CreationTimestamp
:
unversioned
.
Time
{
creationTime
}},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
pod
.
name
,
CreationTimestamp
:
unversioned
.
Time
{
creationTime
}},
Status
:
api
.
PodStatus
{
Phase
:
phase
},
Status
:
api
.
PodStatus
{
Phase
:
p
od
.
p
hase
},
})
})
}
}
...
@@ -119,7 +123,7 @@ func TestGC(t *testing.T) {
...
@@ -119,7 +123,7 @@ func TestGC(t *testing.T) {
pass
=
false
pass
=
false
}
}
if
!
pass
{
if
!
pass
{
t
.
Errorf
(
"[%v]pod's deleted expected and actual did not match.
\n\t
expected: %v
\n\t
actual: %v"
,
i
,
test
.
deletedPodNames
.
List
()
,
fake
.
deletePodName
)
t
.
Errorf
(
"[%v]pod's deleted expected and actual did not match.
\n\t
expected: %v
\n\t
actual: %v"
,
i
,
test
.
deletedPodNames
,
fake
.
deletePodName
)
}
}
}
}
}
}
...
...
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