-
Notifications
You must be signed in to change notification settings - Fork 111
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
RSDK-9440 Report machine state
through GetMachineStatus
#4616
base: main
Are you sure you want to change the base?
Changes from all commits
42db31c
c1e816c
2175276
bebeadf
5485043
8e4e8a3
aa5808f
9e80ade
19bce88
441ed47
96a1043
0de679d
2e0011d
881bde0
041f191
39db863
a0810a6
a2d8bd2
9e68fd6
f7e60f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,8 +107,11 @@ func TestClientSessionOptions(t *testing.T) { | |
return &dummyEcho{Named: arbName.AsNamed()}, nil | ||
}, | ||
ResourceRPCAPIsFunc: func() []resource.RPCAPI { return nil }, | ||
LoggerFunc: func() logging.Logger { return logger }, | ||
SessMgr: sessMgr, | ||
MachineStatusFunc: func(_ context.Context) (robot.MachineStatus, error) { | ||
return robot.MachineStatus{State: robot.StateRunning}, nil | ||
}, | ||
LoggerFunc: func() logging.Logger { return logger }, | ||
SessMgr: sessMgr, | ||
} | ||
|
||
svc := web.New(injectRobot, logger) | ||
|
@@ -129,13 +132,11 @@ func TestClientSessionOptions(t *testing.T) { | |
Disable: true, | ||
}))) | ||
} | ||
roboClient, err := client.New(ctx, addr, logger, opts...) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In three of the client session tests, I had to move the instantiation of the robot client to be below the injection of the session manager. I'd like to meet offline at some point to walk through |
||
test.That(t, err, test.ShouldBeNil) | ||
|
||
injectRobot.Mu.Lock() | ||
injectRobot.MachineStatusFunc = func(ctx context.Context) (robot.MachineStatus, error) { | ||
session.SafetyMonitorResourceName(ctx, someTargetName1) | ||
return robot.MachineStatus{}, nil | ||
return robot.MachineStatus{State: robot.StateRunning}, nil | ||
} | ||
injectRobot.Mu.Unlock() | ||
|
||
|
@@ -179,6 +180,8 @@ func TestClientSessionOptions(t *testing.T) { | |
} | ||
sessMgr.mu.Unlock() | ||
|
||
roboClient, err := client.New(ctx, addr, logger, opts...) | ||
test.That(t, err, test.ShouldBeNil) | ||
resp, err := roboClient.MachineStatus(nextCtx) | ||
test.That(t, err, test.ShouldBeNil) | ||
test.That(t, resp, test.ShouldNotBeNil) | ||
|
@@ -289,6 +292,9 @@ func TestClientSessionExpiration(t *testing.T) { | |
ResourceByNameFunc: func(name resource.Name) (resource.Resource, error) { | ||
return &dummyEcho1, nil | ||
}, | ||
MachineStatusFunc: func(_ context.Context) (robot.MachineStatus, error) { | ||
return robot.MachineStatus{State: robot.StateRunning}, nil | ||
}, | ||
ResourceRPCAPIsFunc: func() []resource.RPCAPI { return nil }, | ||
LoggerFunc: func() logging.Logger { return logger }, | ||
SessMgr: sessMgr, | ||
|
@@ -306,8 +312,6 @@ func TestClientSessionExpiration(t *testing.T) { | |
Disable: true, | ||
}))) | ||
} | ||
roboClient, err := client.New(ctx, addr, logger, opts...) | ||
test.That(t, err, test.ShouldBeNil) | ||
|
||
injectRobot.Mu.Lock() | ||
var capSessID uuid.UUID | ||
|
@@ -317,7 +321,7 @@ func TestClientSessionExpiration(t *testing.T) { | |
panic("expected session") | ||
} | ||
capSessID = sess.ID() | ||
return robot.MachineStatus{}, nil | ||
return robot.MachineStatus{State: robot.StateRunning}, nil | ||
} | ||
injectRobot.Mu.Unlock() | ||
|
||
|
@@ -372,6 +376,8 @@ func TestClientSessionExpiration(t *testing.T) { | |
} | ||
sessMgr.mu.Unlock() | ||
|
||
roboClient, err := client.New(ctx, addr, logger, opts...) | ||
test.That(t, err, test.ShouldBeNil) | ||
resp, err := roboClient.MachineStatus(nextCtx) | ||
test.That(t, err, test.ShouldBeNil) | ||
test.That(t, resp, test.ShouldNotBeNil) | ||
|
@@ -480,8 +486,11 @@ func TestClientSessionResume(t *testing.T) { | |
injectRobot := &inject.Robot{ | ||
ResourceNamesFunc: func() []resource.Name { return []resource.Name{} }, | ||
ResourceRPCAPIsFunc: func() []resource.RPCAPI { return nil }, | ||
LoggerFunc: func() logging.Logger { return logger }, | ||
SessMgr: sessMgr, | ||
MachineStatusFunc: func(_ context.Context) (robot.MachineStatus, error) { | ||
return robot.MachineStatus{State: robot.StateRunning}, nil | ||
}, | ||
LoggerFunc: func() logging.Logger { return logger }, | ||
SessMgr: sessMgr, | ||
} | ||
|
||
svc := web.New(injectRobot, logger) | ||
|
@@ -496,8 +505,6 @@ func TestClientSessionResume(t *testing.T) { | |
Disable: true, | ||
}))) | ||
} | ||
roboClient, err := client.New(ctx, addr, logger, opts...) | ||
test.That(t, err, test.ShouldBeNil) | ||
|
||
var capMu sync.Mutex | ||
var startCalled int | ||
|
@@ -536,10 +543,12 @@ func TestClientSessionResume(t *testing.T) { | |
panic("expected session") | ||
} | ||
capSessID = sess.ID() | ||
return robot.MachineStatus{}, nil | ||
return robot.MachineStatus{State: robot.StateRunning}, nil | ||
} | ||
injectRobot.Mu.Unlock() | ||
|
||
roboClient, err := client.New(ctx, addr, logger, opts...) | ||
test.That(t, err, test.ShouldBeNil) | ||
resp, err := roboClient.MachineStatus(nextCtx) | ||
test.That(t, err, test.ShouldBeNil) | ||
test.That(t, resp, test.ShouldNotBeNil) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I inject an almost identical
MachineStatusFunc
all over the place inclient_session_test.go
andclient_test.go
.client.New
now callsMachineStatus
when in a testing environment to make sure the robot is in arobot.StateRunning
and therefore capable of receiving resource API calls.I thought about placing this functionality in
inject/robot.go
, but opted to just put it in every robot inject, since we currently do that forResourceNamesFunc
andResourceByNameFunc
.