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
72bbd676
Commit
72bbd676
authored
Mar 06, 2025
by
Brad Davidson
Committed by
Brad Davidson
Mar 24, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix etcd tests to use mock executor
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
a8bc4124
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
3 deletions
+86
-3
etcd_linux_test.go
pkg/etcd/etcd_linux_test.go
+2
-3
executor.go
tests/mock/executor.go
+80
-0
unit.go
tests/unit.go
+4
-0
No files found.
pkg/etcd/etcd_linux_test.go
View file @
72bbd676
...
...
@@ -399,11 +399,10 @@ func Test_UnitETCD_Start(t *testing.T) {
}
if
err
:=
tt
.
setup
(
e
,
&
tt
.
fields
.
context
);
err
!=
nil
{
t
.
Errorf
(
"Setup for ETCD.Start() failed = %v"
,
err
)
return
t
.
Fatalf
(
"Setup for ETCD.Start() failed = %v"
,
err
)
}
if
err
:=
e
.
Start
(
tt
.
fields
.
context
.
ctx
,
tt
.
args
.
clientAccessInfo
);
(
err
!=
nil
)
!=
tt
.
wantErr
{
t
.
Error
f
(
"ETCD.Start() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
t
.
Fatal
f
(
"ETCD.Start() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
}
if
!
tt
.
wantErr
{
memberAddr
=
e
.
address
...
...
tests/mock/executor.go
0 → 100644
View file @
72bbd676
package
mock
import
(
"context"
"errors"
"net/http"
"github.com/k3s-io/k3s/pkg/cli/cmds"
"github.com/k3s-io/k3s/pkg/daemons/config"
"github.com/k3s-io/k3s/pkg/daemons/executor"
"k8s.io/apiserver/pkg/authentication/authenticator"
)
// mock executor that does not actually start anything
type
Executor
struct
{}
func
(
e
*
Executor
)
Bootstrap
(
ctx
context
.
Context
,
nodeConfig
*
config
.
Node
,
cfg
cmds
.
Agent
)
error
{
return
errors
.
New
(
"not implemented"
)
}
func
(
e
*
Executor
)
Kubelet
(
ctx
context
.
Context
,
args
[]
string
)
error
{
return
errors
.
New
(
"not implemented"
)
}
func
(
e
*
Executor
)
KubeProxy
(
ctx
context
.
Context
,
args
[]
string
)
error
{
return
errors
.
New
(
"not implemented"
)
}
func
(
e
*
Executor
)
APIServerHandlers
(
ctx
context
.
Context
)
(
authenticator
.
Request
,
http
.
Handler
,
error
)
{
return
nil
,
nil
,
errors
.
New
(
"not implemented"
)
}
func
(
e
*
Executor
)
APIServer
(
ctx
context
.
Context
,
etcdReady
<-
chan
struct
{},
args
[]
string
)
error
{
return
errors
.
New
(
"not implemented"
)
}
func
(
e
*
Executor
)
Scheduler
(
ctx
context
.
Context
,
nodeReady
<-
chan
struct
{},
args
[]
string
)
error
{
return
errors
.
New
(
"not implemented"
)
}
func
(
e
*
Executor
)
ControllerManager
(
ctx
context
.
Context
,
args
[]
string
)
error
{
return
errors
.
New
(
"not implemented"
)
}
func
(
e
*
Executor
)
CurrentETCDOptions
()
(
executor
.
InitialOptions
,
error
)
{
return
executor
.
InitialOptions
{},
nil
}
func
(
e
*
Executor
)
ETCD
(
ctx
context
.
Context
,
args
executor
.
ETCDConfig
,
extraArgs
[]
string
)
error
{
embed
:=
&
executor
.
Embedded
{}
return
embed
.
ETCD
(
ctx
,
args
,
extraArgs
)
}
func
(
e
*
Executor
)
CloudControllerManager
(
ctx
context
.
Context
,
ccmRBACReady
<-
chan
struct
{},
args
[]
string
)
error
{
return
errors
.
New
(
"not implemented"
)
}
func
(
e
*
Executor
)
Containerd
(
ctx
context
.
Context
,
node
*
config
.
Node
)
error
{
return
errors
.
New
(
"not implemented"
)
}
func
(
e
*
Executor
)
Docker
(
ctx
context
.
Context
,
node
*
config
.
Node
)
error
{
return
errors
.
New
(
"not implemented"
)
}
func
(
e
*
Executor
)
CRI
(
ctx
context
.
Context
,
node
*
config
.
Node
)
error
{
return
errors
.
New
(
"not implemented"
)
}
func
(
e
*
Executor
)
APIServerReadyChan
()
<-
chan
struct
{}
{
c
:=
make
(
chan
struct
{})
close
(
c
)
return
c
}
func
(
e
*
Executor
)
CRIReadyChan
()
<-
chan
struct
{}
{
c
:=
make
(
chan
struct
{})
close
(
c
)
return
c
}
tests/unit.go
View file @
72bbd676
...
...
@@ -7,6 +7,7 @@ import (
"github.com/k3s-io/k3s/pkg/daemons/config"
"github.com/k3s-io/k3s/pkg/daemons/control/deps"
"github.com/k3s-io/k3s/pkg/daemons/executor"
)
// GenerateDataDir creates a temporary directory at "/tmp/k3s/<RANDOM_STRING>/".
...
...
@@ -43,6 +44,9 @@ func CleanupDataDir(cnf *config.Control) {
// GenerateRuntime creates a temporary data dir and configures
// config.ControlRuntime with all the appropriate certificate keys.
func
GenerateRuntime
(
cnf
*
config
.
Control
)
error
{
// use mock executor that does not actually start things
executor
.
Set
(
&
mock
.
Executor
{})
// reuse ready channel from existing runtime if set
cnf
.
Runtime
=
config
.
NewRuntime
()
if
err
:=
GenerateDataDir
(
cnf
);
err
!=
nil
{
...
...
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