Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added tests for workceptor.go #922

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
139 changes: 139 additions & 0 deletions pkg/workceptor/mock_workceptor/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion pkg/workceptor/workceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"crypto/tls"
"fmt"
"io"
"io/fs"
"net"
"os"
"path"
"reflect"
Expand All @@ -34,6 +36,17 @@ type NetceptorForWorkceptor interface {
DialContext(ctx context.Context, node string, service string, tlscfg *tls.Config) (*netceptor.Conn, error) // create an interface for Conn
}

type ServerForWorkceptor interface {
AddControlFunc(name string, cType controlsvc.ControlCommandType) error
ConnectionListener(ctx context.Context, listener net.Listener)
RunControlSession(conn net.Conn)
RunControlSvc(ctx context.Context, service string, tlscfg *tls.Config, unixSocket string, unixSocketPermissions fs.FileMode, tcpListen string, tcptls *tls.Config) error
SetServerNet(n controlsvc.Neter)
SetServerTLS(t controlsvc.Tlser)
SetServerUtils(u controlsvc.Utiler)
SetupConnection(conn net.Conn)
}

// Workceptor is the main object that handles unit-of-work management.
type Workceptor struct {
ctx context.Context
Expand Down Expand Up @@ -115,7 +128,7 @@ func stdoutSize(unitdir string) int64 {
}

// RegisterWithControlService registers this workceptor instance with a control service instance.
func (w *Workceptor) RegisterWithControlService(cs *controlsvc.Server) error {
func (w *Workceptor) RegisterWithControlService(cs ServerForWorkceptor) error {
err := cs.AddControlFunc("work", &workceptorCommandType{
w: w,
})
Expand Down