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
9366ac41
Commit
9366ac41
authored
Sep 29, 2015
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass PodLW to executor in tests
parent
49a5f899
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
19 deletions
+25
-19
executor.go
contrib/mesos/pkg/executor/executor.go
+5
-1
executor_test.go
contrib/mesos/pkg/executor/executor_test.go
+8
-9
mock_test.go
contrib/mesos/pkg/executor/mock_test.go
+9
-5
suicide_test.go
contrib/mesos/pkg/executor/suicide_test.go
+3
-4
No files found.
contrib/mesos/pkg/executor/executor.go
View file @
9366ac41
...
...
@@ -139,7 +139,7 @@ type Config struct {
ExitFunc
func
(
int
)
PodStatusFunc
func
(
KubeletInterface
,
*
api
.
Pod
)
(
*
api
.
PodStatus
,
error
)
StaticPodsConfigPath
string
PodLW
cache
.
ListerWatcher
PodLW
cache
.
ListerWatcher
// mandatory, otherwise initialiation will panic
LaunchGracePeriod
time
.
Duration
}
...
...
@@ -172,6 +172,10 @@ func New(config Config) *KubernetesExecutor {
}
// watch pods from the given pod ListWatch
if
config
.
PodLW
==
nil
{
// fail early to make debugging easier
panic
(
"cannot create executor with nil PodLW"
)
}
_
,
k
.
podController
=
framework
.
NewInformer
(
config
.
PodLW
,
&
api
.
Pod
{},
podRelistPeriod
,
&
framework
.
ResourceEventHandlerFuncs
{
AddFunc
:
func
(
obj
interface
{})
{
pod
:=
obj
.
(
*
api
.
Pod
)
...
...
contrib/mesos/pkg/executor/executor_test.go
View file @
9366ac41
...
...
@@ -57,12 +57,7 @@ import (
// after Register is called.
func
TestExecutorRegister
(
t
*
testing
.
T
)
{
mockDriver
:=
&
MockExecutorDriver
{}
updates
:=
make
(
chan
interface
{},
1024
)
executor
:=
New
(
Config
{
Docker
:
dockertools
.
ConnectToDockerOrDie
(
"fake://"
),
Updates
:
updates
,
SourceName
:
"executor_test"
,
})
executor
,
updates
:=
NewTestKubernetesExecutor
()
executor
.
Init
(
mockDriver
)
executor
.
Registered
(
mockDriver
,
nil
,
nil
,
nil
)
...
...
@@ -95,7 +90,7 @@ func TestExecutorRegister(t *testing.T) {
// connected after a call to Disconnected has occurred.
func
TestExecutorDisconnect
(
t
*
testing
.
T
)
{
mockDriver
:=
&
MockExecutorDriver
{}
executor
:=
NewTestKubernetesExecutor
()
executor
,
_
:=
NewTestKubernetesExecutor
()
executor
.
Init
(
mockDriver
)
executor
.
Registered
(
mockDriver
,
nil
,
nil
,
nil
)
...
...
@@ -110,7 +105,7 @@ func TestExecutorDisconnect(t *testing.T) {
// after a connection problem happens, followed by a call to Reregistered.
func
TestExecutorReregister
(
t
*
testing
.
T
)
{
mockDriver
:=
&
MockExecutorDriver
{}
executor
:=
NewTestKubernetesExecutor
()
executor
,
_
:=
NewTestKubernetesExecutor
()
executor
.
Init
(
mockDriver
)
executor
.
Registered
(
mockDriver
,
nil
,
nil
,
nil
)
...
...
@@ -166,6 +161,7 @@ func TestExecutorLaunchAndKillTask(t *testing.T) {
Phase
:
api
.
PodRunning
,
},
nil
},
PodLW
:
&
NewMockPodsListWatch
(
api
.
PodList
{})
.
ListWatch
,
}
executor
:=
New
(
config
)
...
...
@@ -330,6 +326,7 @@ func TestExecutorStaticPods(t *testing.T) {
},
nil
},
StaticPodsConfigPath
:
staticPodsConfigPath
,
PodLW
:
&
NewMockPodsListWatch
(
api
.
PodList
{})
.
ListWatch
,
}
executor
:=
New
(
config
)
hostname
:=
"h1"
...
...
@@ -417,6 +414,7 @@ func TestExecutorFrameworkMessage(t *testing.T) {
close
(
kubeletFinished
)
},
KubeletFinished
:
kubeletFinished
,
PodLW
:
&
NewMockPodsListWatch
(
api
.
PodList
{})
.
ListWatch
,
}
executor
:=
New
(
config
)
...
...
@@ -579,6 +577,7 @@ func TestExecutorShutdown(t *testing.T) {
ExitFunc
:
func
(
_
int
)
{
atomic
.
AddInt32
(
&
exitCalled
,
1
)
},
PodLW
:
&
NewMockPodsListWatch
(
api
.
PodList
{})
.
ListWatch
,
}
executor
:=
New
(
config
)
...
...
@@ -608,7 +607,7 @@ func TestExecutorShutdown(t *testing.T) {
func
TestExecutorsendFrameworkMessage
(
t
*
testing
.
T
)
{
mockDriver
:=
&
MockExecutorDriver
{}
executor
:=
NewTestKubernetesExecutor
()
executor
,
_
:=
NewTestKubernetesExecutor
()
executor
.
Init
(
mockDriver
)
executor
.
Registered
(
mockDriver
,
nil
,
nil
,
nil
)
...
...
contrib/mesos/pkg/executor/mock_test.go
View file @
9366ac41
...
...
@@ -22,6 +22,7 @@ import (
"github.com/mesos/mesos-go/mesosproto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
)
...
...
@@ -64,16 +65,19 @@ func (m *MockExecutorDriver) SendFrameworkMessage(msg string) (mesosproto.Status
return
args
.
Get
(
0
)
.
(
mesosproto
.
Status
),
args
.
Error
(
1
)
}
func
NewTestKubernetesExecutor
()
*
KubernetesExecutor
{
func
NewTestKubernetesExecutor
()
(
*
KubernetesExecutor
,
chan
interface
{})
{
updates
:=
make
(
chan
interface
{},
1024
)
return
New
(
Config
{
Docker
:
dockertools
.
ConnectToDockerOrDie
(
"fake://"
),
Updates
:
make
(
chan
interface
{},
1024
),
})
Docker
:
dockertools
.
ConnectToDockerOrDie
(
"fake://"
),
Updates
:
updates
,
PodLW
:
&
NewMockPodsListWatch
(
api
.
PodList
{})
.
ListWatch
,
SourceName
:
"executor_test"
,
}),
updates
}
func
TestExecutorNew
(
t
*
testing
.
T
)
{
mockDriver
:=
&
MockExecutorDriver
{}
executor
:=
NewTestKubernetesExecutor
()
executor
,
_
:=
NewTestKubernetesExecutor
()
executor
.
Init
(
mockDriver
)
assert
.
Equal
(
t
,
executor
.
isDone
(),
false
,
"executor should not be in Done state on initialization"
)
...
...
contrib/mesos/pkg/executor/suicide_test.go
View file @
9366ac41
...
...
@@ -67,7 +67,7 @@ func (t *suicideTracker) makeJumper(_ jumper) jumper {
func
TestSuicide_zeroTimeout
(
t
*
testing
.
T
)
{
defer
glog
.
Flush
()
k
:=
New
(
Config
{}
)
k
,
_
:=
NewTestKubernetesExecutor
(
)
tracker
:=
&
suicideTracker
{
suicideWatcher
:
k
.
suicideWatch
}
k
.
suicideWatch
=
tracker
...
...
@@ -92,9 +92,8 @@ func TestSuicide_zeroTimeout(t *testing.T) {
func
TestSuicide_WithTasks
(
t
*
testing
.
T
)
{
defer
glog
.
Flush
()
k
:=
New
(
Config
{
SuicideTimeout
:
50
*
time
.
Millisecond
,
})
k
,
_
:=
NewTestKubernetesExecutor
()
k
.
suicideTimeout
=
50
*
time
.
Millisecond
jumps
:=
uint32
(
0
)
tracker
:=
&
suicideTracker
{
suicideWatcher
:
k
.
suicideWatch
,
jumps
:
&
jumps
}
...
...
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