Skip to content

Commit

Permalink
WIP: release locks and try to read CONFIGURING during reconf
Browse files Browse the repository at this point in the history
  • Loading branch information
maximpertsov committed Sep 9, 2024
1 parent d5f4dc3 commit ebfa41b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions robot/impl/local_robot.go
Original file line number Diff line number Diff line change
Expand Up @@ -1422,13 +1422,13 @@ func (r *localRobot) Shutdown(ctx context.Context) error {
func (r *localRobot) MachineStatus(ctx context.Context) (robot.MachineStatus, error) {
var result robot.MachineStatus

r.manager.resourceGraphLock.Lock()
// r.manager.resourceGraphLock.Lock()
result.Resources = append(result.Resources, r.manager.resources.Status()...)
r.manager.resourceGraphLock.Unlock()
// r.manager.resourceGraphLock.Unlock()

r.configRevisionMu.RLock()
// r.configRevisionMu.RLock()
result.Config = r.configRevision
r.configRevisionMu.RUnlock()
// r.configRevisionMu.RUnlock()

return result, nil
}
Expand Down
6 changes: 3 additions & 3 deletions robot/impl/local_robot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3541,7 +3541,6 @@ func TestMachineStatus(t *testing.T) {
})

t.Run("poll during reconfiguration", func(t *testing.T) {
t.Skip()
rev4 := "rev4"
lr := setupLocalRobot(t, ctx, &config.Config{
Revision: rev4,
Expand All @@ -3556,13 +3555,14 @@ func TestMachineStatus(t *testing.T) {
defer wg.Done()
lr.Reconfigure(ctx, &config.Config{
Revision: rev5,
Components: []resource.Config{newMockConfig("m", 300, false, "1s")},
Components: []resource.Config{newMockConfig("m", 300, false, "5s")},
})
}()
time.Sleep(time.Millisecond * 100)
// while reconfiguring
mStatus, err := lr.MachineStatus(ctx)
test.That(t, err, test.ShouldBeNil)
test.That(t, mStatus.Config.Revision, test.ShouldEqual, rev4)
test.That(t, mStatus.Config.Revision, test.ShouldEqual, rev5)
expectedStatuses := rtestutils.ConcatResourceStatuses(
getExpectedDefaultStatuses(rev4),
[]resource.Status{
Expand Down

0 comments on commit ebfa41b

Please sign in to comment.