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

APP-7497: Add Switch client, server, and fake models #4741

Merged
merged 5 commits into from
Jan 29, 2025

Conversation

ethanlookpotts
Copy link
Contributor

This adds the switch client and server, and registers switch 2-way, 3-way, and 10-way fake models.

Here are switch components properly configured in app:
image

  1. APP-7497: Add Button and Switch APIs api#619
  2. APP-7497: Add Button client, server, and fake model #4740
  3. APP-7497: Add Switch client, server, and fake models #4741

Change log

I used Cursor quite a bit here:

  • Add Switch SDK helpers
  • Add client and tests
  • Add server and tests
  • Add inject testutil
  • Add fake switch implementations and register them

Review requests

  • Code review
  • Try a config with the switch fakes - does they work as expected?

@@ -0,0 +1,88 @@
// Package switch_component contains a gRPC based switch client.
package switch_component
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: switch is a keyword, so the package is called switch_component

Copy link
Member

Choose a reason for hiding this comment

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

le sigh

Copy link
Member

Choose a reason for hiding this comment

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

toggleswitch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't matter to me, happy to update to toggleswitch

Copy link
Member

Choose a reason for hiding this comment

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

lets do it

@ethanlookpotts ethanlookpotts changed the title APP-7497: Add Switch client, server, and fake model APP-7497: Add Switch client, server, and fake models Jan 24, 2025
@ethanlookpotts ethanlookpotts force-pushed the APP-7497/ethanlookpotts/switch branch from 904d410 to 9038c5c Compare January 27, 2025 17:42
@ethanlookpotts ethanlookpotts force-pushed the APP-7497/ethanlookpotts/button branch from d1ec868 to d62aae2 Compare January 27, 2025 17:45
@ethanlookpotts ethanlookpotts force-pushed the APP-7497/ethanlookpotts/switch branch from 9038c5c to fc28a0f Compare January 27, 2025 17:45
components/switch/client.go Outdated Show resolved Hide resolved
@@ -0,0 +1,88 @@
// Package switch_component contains a gRPC based switch client.
package switch_component
Copy link
Member

Choose a reason for hiding this comment

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

le sigh

testutils/inject/switch.go Outdated Show resolved Hide resolved
components/switch/switch.go Show resolved Hide resolved
components/switch/fake/switch.go Outdated Show resolved Hide resolved
components/switch/fake/switch.go Show resolved Hide resolved
components/switch/fake/switch.go Outdated Show resolved Hide resolved
components/switch/fake/switch.go Outdated Show resolved Hide resolved
components/switch/fake/switch.go Outdated Show resolved Hide resolved
@randhid
Copy link
Member

randhid commented Jan 27, 2025

Done with first pass - will look at tests in the second.

@ethanlookpotts ethanlookpotts force-pushed the APP-7497/ethanlookpotts/switch branch 5 times, most recently from 4996b8f to f31815d Compare January 28, 2025 17:21
Comment on lines +94 to +103
resp, err := client1.DoCommand(context.Background(), testutils.TestCommand)
test.That(t, err, test.ShouldBeNil)
test.That(t, resp["command"], test.ShouldEqual, testutils.TestCommand["command"])
test.That(t, resp["data"], test.ShouldEqual, testutils.TestCommand["data"])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@randhid any thoughts on why this DoCommand client test would be failing? I've spent a good amount of time debugging and I can't figure it out. For whatever reason, the inject button implementation of DoCommand is not being called.

Copy link
Member

@randhid randhid Jan 29, 2025

Choose a reason for hiding this comment

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

There is no server DoCommand implemented for switch https://github.com/viamrobotics/rdk/pull/4741/files#r1933063119

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, thank you for catching this!!

5e27be1

@@ -0,0 +1,37 @@
package toggleswitch_test
Copy link
Member

Choose a reason for hiding this comment

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

move this to fake switch's folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ethanlookpotts ethanlookpotts force-pushed the APP-7497/ethanlookpotts/button branch from d52ab1b to 1ff98bc Compare January 29, 2025 15:12
@ethanlookpotts ethanlookpotts force-pushed the APP-7497/ethanlookpotts/switch branch from f31815d to 5e27be1 Compare January 29, 2025 15:12
@ethanlookpotts ethanlookpotts force-pushed the APP-7497/ethanlookpotts/switch branch from 5e27be1 to 60f8380 Compare January 29, 2025 16:35
Base automatically changed from APP-7497/ethanlookpotts/button to main January 29, 2025 16:36
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jan 29, 2025
@ethanlookpotts ethanlookpotts merged commit 85e76a9 into main Jan 29, 2025
16 checks passed
@ethanlookpotts ethanlookpotts deleted the APP-7497/ethanlookpotts/switch branch January 29, 2025 17:23
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