-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
66 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "RedisChannel.h" | ||
#include "sairediscommon.h" | ||
|
||
#include "swss/notificationproducer.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <memory> | ||
|
||
using namespace sairedis; | ||
|
||
static std::string g_op; | ||
static std::string g_data; | ||
|
||
static void callback( | ||
_In_ const std::string& op, | ||
_In_ const std::string& data, | ||
_In_ const std::vector<swss::FieldValueTuple>& values) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
g_op = op; | ||
g_data = data; | ||
} | ||
|
||
TEST(RedisChannel, reset) | ||
{ | ||
RedisChannel rc("ASIC_DB", callback); | ||
|
||
EXPECT_NE(nullptr, rc.getDbConnector()); | ||
} | ||
|
||
TEST(RedisChannel, notificationThreadFunction) | ||
{ | ||
RedisChannel rc("ASIC_DB", callback); | ||
|
||
rc.setResponseTimeout(10); | ||
|
||
auto db = std::make_shared<swss::DBConnector>("ASIC_DB", 0); | ||
|
||
swss::NotificationProducer p(db.get(), REDIS_TABLE_NOTIFICATIONS); | ||
|
||
std::vector<swss::FieldValueTuple> vals; | ||
p.send("foo", "bar", vals); | ||
|
||
usleep(200*1000); | ||
|
||
EXPECT_EQ(g_op, "foo"); | ||
} | ||
|
||
TEST(RedisChannel, flush) | ||
{ | ||
RedisChannel rc("ASIC_DB", callback); | ||
|
||
rc.flush(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
"zm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"zmq_endpoint": "ipc:///tmp/saiServer", | ||
"zmq_ntf_endpoint": "ipc:///tmp/saiServerNtf" | ||
} |