Skip to content

Commit

Permalink
Refactored netceptor startup
Browse files Browse the repository at this point in the history
  • Loading branch information
thom-at-redhat authored and AaronH88 committed Feb 27, 2024
1 parent a363718 commit 608ff52
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions pkg/workceptor/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import (
"k8s.io/client-go/tools/remotecommand"
)

func TestShouldUseReconnect(t *testing.T) {
const envVariable string = "RECEPTOR_KUBE_SUPPORT_RECONNECT"

func startNetceptorNodeWithWorkceptor() (*workceptor.KubeUnit, error) {
kw := &workceptor.KubeUnit{
BaseWorkUnitForWorkUnit: &workceptor.BaseWorkUnit{},
}
Expand All @@ -35,21 +33,32 @@ func TestShouldUseReconnect(t *testing.T) {
n1 := netceptor.New(context.Background(), "node1")
b1, err := netceptor.NewExternalBackend()
if err != nil {
t.Fatal(err)
return kw, err
}

err = n1.AddBackend(b1)
if err != nil {
t.Fatal(err)
return kw, err
}

w, err := workceptor.New(context.Background(), n1, "")
if err != nil {
t.Fatal(err)
return kw, err
}

kw.SetWorkceptor(w)

return kw, nil
}

func TestShouldUseReconnect(t *testing.T) {
const envVariable string = "RECEPTOR_KUBE_SUPPORT_RECONNECT"

kw, err := startNetceptorNodeWithWorkceptor()
if err != nil {
t.Fatal(err)
}

tests := []struct {
name string
envValue string
Expand Down Expand Up @@ -246,28 +255,11 @@ func Test_IsCompatibleK8S(t *testing.T) {
versionStr string
}

kw := &workceptor.KubeUnit{
BaseWorkUnitForWorkUnit: &workceptor.BaseWorkUnit{},
}

// Create Netceptor node using external backends
n1 := netceptor.New(context.Background(), "node1")
b1, err := netceptor.NewExternalBackend()
if err != nil {
t.Fatal(err)
}
err = n1.AddBackend(b1)
if err != nil {
t.Fatal(err)
}

w, err := workceptor.New(context.Background(), n1, "")
kw, err := startNetceptorNodeWithWorkceptor()
if err != nil {
t.Fatal(err)
}

kw.SetWorkceptor(w)

tests := []struct {
name string
args args
Expand Down

0 comments on commit 608ff52

Please sign in to comment.