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

RSDK-702: tweak flakiness in gpio input tests #1626

Merged
merged 2 commits into from
Dec 2, 2022

Conversation

stevebriskin
Copy link
Member

@stevebriskin stevebriskin commented Nov 28, 2022

Actual changes to lower the odds of flakes.

@@ -63,7 +63,7 @@ func setup(t *testing.T) *setupResult {
"interrupt1": {
Control: input.ButtonNorth,
Invert: false,
DebounceMs: 0,
DebounceMs: 20,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed from the default 5ms

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably fine. Though the original intent was to also check that the default was applied, when the actual value was zero (e.g. when not set in json.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into adding another test to check that defaults are set in another pr

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Nov 28, 2022
err := s.b.Digitals["interrupt2"].Tick(s.ctx, true, uint64(time.Now().UnixNano()))
test.That(t, err, test.ShouldBeNil)
time.Sleep(time.Millisecond)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure what value these sleeps served. my understanding for this test was that commands should be issued as fast as possible and ensure that none get debounced.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was just "best practice" to keep things from being CPU bound. E.g. depending on load and cpu power, this might go a thousand times faster or slower on different runs/machines, and the sleep means it'll be "approximately" the same anywhere. If it works with them removed, I'm fine with them gone though.

s.axisMu.RUnlock()
}

s.b.Analogs["analog2"].Set(1023)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole test was removed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this whole test removed? Wasn't it doing something useful?

Copy link
Member Author

@stevebriskin stevebriskin Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it tested default vs. overriden poll rate. potential flakiness introduced by testing this way wasn't worth it.

@@ -526,46 +515,16 @@ func TestGPIOInput(t *testing.T) {
target = 0
s.b.Analogs["analog1"].Set(0)
}
testutils.WaitForAssertion(t, func(tb testing.TB) {
testutils.WaitForAssertionWithSleep(t, 5*time.Millisecond, 25, func(tb testing.TB) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test every 5ms instead of every 50ms.

Copy link
Member

@Otterverse Otterverse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -63,7 +63,7 @@ func setup(t *testing.T) *setupResult {
"interrupt1": {
Control: input.ButtonNorth,
Invert: false,
DebounceMs: 0,
DebounceMs: 20,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably fine. Though the original intent was to also check that the default was applied, when the actual value was zero (e.g. when not set in json.)

err := s.b.Digitals["interrupt2"].Tick(s.ctx, true, uint64(time.Now().UnixNano()))
test.That(t, err, test.ShouldBeNil)
time.Sleep(time.Millisecond)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was just "best practice" to keep things from being CPU bound. E.g. depending on load and cpu power, this might go a thousand times faster or slower on different runs/machines, and the sleep means it'll be "approximately" the same anywhere. If it works with them removed, I'm fine with them gone though.

Copy link
Member

@penguinland penguinland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I trust @Otterverse's judgment over my own (hence me leaving a comment instead of an approval), but things LGTM!

components/input/gpio/gpio_test.go Show resolved Hide resolved
components/input/gpio/gpio_test.go Show resolved Hide resolved
components/input/gpio/gpio_test.go Outdated Show resolved Hide resolved
s.axisMu.RUnlock()
}

s.b.Analogs["analog2"].Set(1023)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this whole test removed? Wasn't it doing something useful?

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Nov 29, 2022
@github-actions
Copy link
Contributor

Code Coverage

Note: merge base coverage results not available, comparing against closest eee2f24~1=(d9afabf) instead

Package Line Rate Delta Health
go.viam.com/rdk/components/arm 59% 0.00%
go.viam.com/rdk/components/arm/universalrobots 13% 0.00%
go.viam.com/rdk/components/arm/xarm 2% 0.00%
go.viam.com/rdk/components/arm/yahboom 7% 0.00%
go.viam.com/rdk/components/audioinput 55% +0.34%
go.viam.com/rdk/components/base 67% 0.00%
go.viam.com/rdk/components/base/agilex 62% 0.00%
go.viam.com/rdk/components/base/boat 41% 0.00%
go.viam.com/rdk/components/base/wheeled 76% 0.00%
go.viam.com/rdk/components/board 68% 0.00%
go.viam.com/rdk/components/board/arduino 10% 0.00%
go.viam.com/rdk/components/board/commonsysfs 47% 0.00%
go.viam.com/rdk/components/board/fake 38% 0.00%
go.viam.com/rdk/components/board/numato 19% 0.00%
go.viam.com/rdk/components/board/pi 50% 0.00%
go.viam.com/rdk/components/camera 65% +0.27%
go.viam.com/rdk/components/camera/fake 67% 0.00%
go.viam.com/rdk/components/camera/ffmpeg 77% 0.00%
go.viam.com/rdk/components/camera/transformpipeline 78% 0.00%
go.viam.com/rdk/components/camera/videosource 55% -0.68%
go.viam.com/rdk/components/encoder/fake 77% 0.00%
go.viam.com/rdk/components/gantry 68% 0.00%
go.viam.com/rdk/components/gantry/multiaxis 84% 0.00%
go.viam.com/rdk/components/gantry/oneaxis 86% 0.00%
go.viam.com/rdk/components/generic 83% 0.00%
go.viam.com/rdk/components/gripper 80% 0.00%
go.viam.com/rdk/components/input 87% 0.00%
go.viam.com/rdk/components/input/gpio 83% -0.61%
go.viam.com/rdk/components/motor 81% 0.00%
go.viam.com/rdk/components/motor/dimensionengineering 63% 0.00%
go.viam.com/rdk/components/motor/dmc4000 69% 0.00%
go.viam.com/rdk/components/motor/fake 57% 0.00%
go.viam.com/rdk/components/motor/gpio 61% -2.16%
go.viam.com/rdk/components/motor/gpiostepper 57% +0.59%
go.viam.com/rdk/components/motor/tmcstepper 62% 0.00%
go.viam.com/rdk/components/movementsensor 75% 0.00%
go.viam.com/rdk/components/movementsensor/cameramono 40% 0.00%
go.viam.com/rdk/components/movementsensor/gpsnmea 37% 0.00%
go.viam.com/rdk/components/movementsensor/gpsrtk 28% 0.00%
go.viam.com/rdk/components/posetracker 86% 0.00%
go.viam.com/rdk/components/sensor 86% 0.00%
go.viam.com/rdk/components/sensor/ultrasonic 34% 0.00%
go.viam.com/rdk/components/servo 78% 0.00%
go.viam.com/rdk/components/servo/gpio 71% 0.00%
go.viam.com/rdk/config 76% 0.00%
go.viam.com/rdk/control 57% 0.00%
go.viam.com/rdk/data 77% 0.00%
go.viam.com/rdk/grpc 25% 0.00%
go.viam.com/rdk/ml 67% 0.00%
go.viam.com/rdk/ml/inference 70% 0.00%
go.viam.com/rdk/motionplan 62% -5.24%
go.viam.com/rdk/operation 82% 0.00%
go.viam.com/rdk/pointcloud 71% 0.00%
go.viam.com/rdk/protoutils 62% 0.00%
go.viam.com/rdk/referenceframe 78% 0.00%
go.viam.com/rdk/registry 88% 0.00%
go.viam.com/rdk/resource 83% 0.00%
go.viam.com/rdk/rimage 78% 0.00%
go.viam.com/rdk/rimage/depthadapter 94% 0.00%
go.viam.com/rdk/rimage/transform 73% 0.00%
go.viam.com/rdk/rimage/transform/cmd/extrinsic_calibration 67% 0.00%
go.viam.com/rdk/robot 93% 0.00%
go.viam.com/rdk/robot/client 80% 0.00%
go.viam.com/rdk/robot/framesystem 68% 0.00%
go.viam.com/rdk/robot/impl 80% 0.00%
go.viam.com/rdk/robot/server 58% 0.00%
go.viam.com/rdk/robot/web 60% 0.00%
go.viam.com/rdk/robot/web/stream 87% 0.00%
go.viam.com/rdk/services/armremotecontrol 71% 0.00%
go.viam.com/rdk/services/armremotecontrol/builtin 25% 0.00%
go.viam.com/rdk/services/baseremotecontrol 71% 0.00%
go.viam.com/rdk/services/baseremotecontrol/builtin 66% 0.00%
go.viam.com/rdk/services/datamanager 65% 0.00%
go.viam.com/rdk/services/datamanager/builtin 80% 0.00%
go.viam.com/rdk/services/datamanager/datacapture 21% 0.00%
go.viam.com/rdk/services/datamanager/datasync 72% 0.00%
go.viam.com/rdk/services/motion 67% 0.00%
go.viam.com/rdk/services/motion/builtin 88% 0.00%
go.viam.com/rdk/services/navigation 54% 0.00%
go.viam.com/rdk/services/sensors 77% 0.00%
go.viam.com/rdk/services/sensors/builtin 97% 0.00%
go.viam.com/rdk/services/shell 14% 0.00%
go.viam.com/rdk/services/slam 84% 0.00%
go.viam.com/rdk/services/slam/builtin 72% 0.00%
go.viam.com/rdk/services/vision 80% 0.00%
go.viam.com/rdk/services/vision/builtin 74% 0.00%
go.viam.com/rdk/spatialmath 85% 0.00%
go.viam.com/rdk/subtype 96% 0.00%
go.viam.com/rdk/utils 71% 0.00%
go.viam.com/rdk/vision 26% 0.00%
go.viam.com/rdk/vision/chess 80% 0.00%
go.viam.com/rdk/vision/delaunay 87% 0.00%
go.viam.com/rdk/vision/keypoints 92% 0.00%
go.viam.com/rdk/vision/objectdetection 82% 0.00%
go.viam.com/rdk/vision/odometry 60% 0.00%
go.viam.com/rdk/vision/odometry/cmd 0% 0.00%
go.viam.com/rdk/vision/segmentation 49% 0.00%
go.viam.com/rdk/web/server 26% 0.00%
Summary 66% (19488 / 29718) -0.38%

@stevebriskin stevebriskin merged commit abdef57 into viamrobotics:main Dec 2, 2022
@stevebriskin stevebriskin deleted the RSDK-702c branch April 25, 2023 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants