-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add echo example apps to conduct end-to-end connectivity sanity check… #3836
Conversation
examples/echo/common.h
Outdated
constexpr chip::NodeId kClientDeviceId = 12344321; | ||
constexpr chip::NodeId kServerDeviceId = 12344322; |
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.
Can these use kTestControllerNodeId
and kTestDeviceNodeId
from src/transport/SecurePairingSession.h
?
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.
This is served as an example app, so I prefer to allow the developer to modify the test Node ID, and the example app should be programmed against the high level public stack header files much as possible.
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'm not sure I follow. The whole point of those test ids is to be used from example apps, and other example apps use them right now. If they are not exposed in a "public" header, they should move there.
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.
Acked.
examples/echo/echo_responder.cpp
Outdated
// Callback handler when a CHIP EchoRequest is received. | ||
static void HandleEchoRequestReceived(NodeId nodeId, System::PacketBuffer * payload) | ||
{ | ||
printf("Echo Request from node %lu, len=%u ... sending response.\n", nodeId, payload->DataLength()); |
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.
The README makes it sound like responses get sent....
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.
Yes, this callback allows the app to take more actions upon receiving the echo request, the echo response is sent by Echo protocol automatically. In this example, app just print out a message.
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 really thought that we'd have a standalone unit test for ExchangeMgr using echo (or another arbitrary protocol ID).
examples/ subdirectory entries should all look like customers of CHIP (separable from the tree once CHIP has a stable API). As such, they should not be "the only test we have" for CHIP library code.
Can you please investigate making this manifest under src/messaging/tests/ ?
'src/messaging/tests/' currently is used for unit testing of the messaging APIs, this standalone app is created against whole CHIP stack, so I feel it should not be put inside CHIP stack. Since the users of this app is happy/cirque automation frameworks, which are also outside of src directory, does it make more sense to put this app under "integrations" directory? |
I believe unit tests have great value for new code. Failure in integration tests are much harder to track down than focused unit tests. |
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 really thought that we'd have a standalone unit test for ExchangeMgr using echo (or another arbitrary protocol ID).
examples/ subdirectory entries should all look like customers of CHIP (separable from the tree once CHIP has a stable API). As such, they should not be "the only test we have" for CHIP library code.
Can you please investigate making this manifest under src/messaging/tests/ ?'src/messaging/tests/' currently is used for unit testing of the messaging APIs, this standalone app is created against whole CHIP stack, so I feel it should not be put inside CHIP stack.
There's no problem adding even integration tests to the main tree. It just depends on whether the main build with chip_build_tests=true
should build it, or not.
Doesn't seem true that this uses the whole CHIP stack; it doesn't depend on any components that messaging doesn't use (but it's not really a problem for a test to use a more components than the code under test, such as test_support libraries).
Since the users of this app is happy/cirque automation frameworks, which are also outside of src directory, does it make more sense to put this app under "integrations" directory?
src/messaging/tests/echo/common.h
Outdated
|
||
#pragma once | ||
|
||
#include <core/CHIPCore.h> |
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.
this header doesn't appear to need all of these include directives, they should be moved to the source files that need 'em
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.
Acked
// Count of the number of EchoResponses received. | ||
uint64_t gEchoRespCount = 0; | ||
|
||
uint64_t Now(void) |
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.
why not use the CHIP notion of "now"?
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.
Changed
int32_t len = snprintf(p, CHIP_SYSTEM_CONFIG_HEADER_RESERVE_SIZE, "Echo Message %" PRIu64 "\n", gEchoCount); | ||
|
||
// Set the datalength in the buffer appropriately. | ||
payloadBuf->SetDataLength((uint16_t) len); |
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.
we have checks for the cast-ability of these values, please use them?
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.
And C++-style cast.
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.
Acked
|
||
err = gTransportManager.Init(Transport::UdpListenParameters(&DeviceLayer::InetLayer) | ||
.SetAddressType(Inet::kIPAddressType_IPv4) | ||
.SetListenPort(ECHO_CLIENT_PORT)); |
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.
is this SetListenPort()
required? can the client be on an ephemeral port?
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.
This is to make sure the client get set to a different port other than default CHIP_PORT, we need this if we want to test echo on the same machine.
src/messaging/tests/echo/common.h
Outdated
|
||
#include <messaging/ExchangeMgr.h> | ||
|
||
using namespace chip; |
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.
Please don't use using
in headers.
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.
Acked
src/messaging/tests/echo/README.md
Outdated
|
||
``` | ||
source scripts/activate.sh | ||
cd src/messaging/tests/echo |
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.
Suggest removing this line, there is no difference building in src/messaging/tests/echo vs building at the top level so this may be confusing or waste disk space.
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.
Acked
{ | ||
CHIP_ERROR err = CHIP_NO_ERROR; | ||
|
||
printf("Init CHIP Stack\r\n"); |
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.
nit: the carriage return + line feed is in this function but not other places.
… on protocol level
Problem
Right now, we don't have an end-to-end testing for ExchangeManager/CRMP in CHIP, we are not able to detect the regression or break on the protocol level. After Echo protocol landed, we need test mock apps to:
Summary of Changes
Add echo example apps to conduct end-to-end connectivity sanity check.
Fixes #3665