Commit 7bc833e6 authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Fix etcd tests to use mock executor

Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com> (cherry picked from commit 72bbd676) Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com>
parent 8b8b7d37
......@@ -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.Errorf("ETCD.Start() error = %v, wantErr %v", err, tt.wantErr)
t.Fatalf("ETCD.Start() error = %v, wantErr %v", err, tt.wantErr)
}
if !tt.wantErr {
memberAddr = e.address
......
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
}
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment