Skip to content

Commit

Permalink
RSDK-5992: Have module logging test poll for expected output. (viamro…
Browse files Browse the repository at this point in the history
  • Loading branch information
dgottlieb authored Dec 8, 2023
1 parent 4fd25f7 commit 07b5eb7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions robot/impl/resource_manager_modular_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/jhump/protoreflect/desc"
"github.com/pkg/errors"
"go.viam.com/test"
"go.viam.com/utils/testutils"

"go.viam.com/rdk/components/generic"
"go.viam.com/rdk/components/motor"
Expand Down Expand Up @@ -475,7 +476,6 @@ func (m *dummyModMan) Close(ctx context.Context) error {
}

func TestDynamicModuleLogging(t *testing.T) {
t.Skip("RSDK-5992")
modPath, err := rtestutils.BuildTempModule(t, "module/testmodule")
test.That(t, err, test.ShouldBeNil)

Expand Down Expand Up @@ -518,7 +518,10 @@ func TestDynamicModuleLogging(t *testing.T) {
test.That(t, err, test.ShouldBeNil)

// Our log observer should find one occurrence of the log line.
test.That(t, observer.FilterMessageSnippet(logLine).Len(), test.ShouldEqual, 1)
testutils.WaitForAssertion(t, func(tb testing.TB) {
tb.Helper()
test.That(tb, observer.FilterMessageSnippet(logLine).Len(), test.ShouldEqual, 1)
})

// The module is currently configured to log at info. If the module tries to log at debug,
// nothing new should be observed.
Expand All @@ -539,6 +542,9 @@ func TestDynamicModuleLogging(t *testing.T) {
_, err = client.DoCommand(ctx, testCmd)
test.That(t, err, test.ShouldBeNil)

test.That(t, observer.FilterMessageSnippet(logLine).Len(), test.ShouldEqual, 2)
test.That(t, observer.FilterMessageSnippet(logLine).FilterMessageSnippet("DEBUG").Len(), test.ShouldEqual, 1)
testutils.WaitForAssertion(t, func(tb testing.TB) {
tb.Helper()
test.That(tb, observer.FilterMessageSnippet(logLine).Len(), test.ShouldEqual, 2)
test.That(tb, observer.FilterMessageSnippet(logLine).FilterMessageSnippet("DEBUG").Len(), test.ShouldEqual, 1)
})
}

0 comments on commit 07b5eb7

Please sign in to comment.