Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
eddb06e
[pyext] Add more OUTPUT type
qiluo-msft Aug 29, 2020
639599d
Refactor: add new class RedisConnector
qiluo-msft Aug 29, 2020
27dc476
dbconnector: remove emtpy line
qiluo-msft Aug 29, 2020
9341111
Refine script functions parameter
qiluo-msft Aug 29, 2020
ee3a609
Add copy constructor to RedisConnector
qiluo-msft Sep 2, 2020
c358b24
Optimize DBConnector ctor
qiluo-msft Sep 2, 2020
eab9a9b
Revert back m_namespace
qiluo-msft Sep 2, 2020
89bd455
Refactor: change name
qiluo-msft Sep 2, 2020
f11bca4
Add new ctor for DBConnector from RedisContext and dbId
qiluo-msft Sep 11, 2020
5f4e3da
(ongoing) Add DBInterface class
qiluo-msft Sep 11, 2020
f731fcf
(temp, not build)
qiluo-msft Sep 12, 2020
c7b7023
Fix build
qiluo-msft Sep 22, 2020
9b4d414
Extract psubscribe and subscribe function into DBConnector class
qiluo-msft Sep 23, 2020
d901fe5
Implement _subscribe_keyspace_notification, _unsubscribe_keyspace_not…
qiluo-msft Sep 24, 2020
03b99c5
Implement blockable
qiluo-msft Sep 24, 2020
1aa56b4
Implement connect with retry
qiluo-msft Sep 24, 2020
a8457a9
Implement DBConnector::publish(),
qiluo-msft Sep 25, 2020
87bcf7f
Use c++11 syntax instead of c++14
qiluo-msft Sep 26, 2020
b0fbe03
Implement blocking for get and del
qiluo-msft Sep 26, 2020
bf779bd
Add to pyext
qiluo-msft Sep 26, 2020
c193a6a
Add set_redis_kwargs(), fix _onetime_connect()
qiluo-msft Sep 28, 2020
9f0eb3e
Fix LGTM: delete implicitly-declared copy assignment operator
qiluo-msft Sep 29, 2020
e126eb1
update DBInterface redis_client index from db_id to db_name
qiluo-msft Oct 1, 2020
c754f15
Add DBInterface::delete_all_by_pattern()
qiluo-msft Oct 1, 2020
d282fbc
Add SonicV2Connector class
qiluo-msft Oct 2, 2020
c530fea
Add unit test for SonicV2Connector
qiluo-msft Oct 3, 2020
fdc256f
Make const strings public because they are used as public method default
qiluo-msft Oct 5, 2020
d4e442c
SWIG supports keyword arguments in generated python module
qiluo-msft Oct 5, 2020
1d628ec
Add python namespace property to DBConnector class, solve the paramter
qiluo-msft Oct 5, 2020
8c93402
Move SonicV2Connector to standalone .h/.cpp files
qiluo-msft Oct 5, 2020
f84f07b
Add missing include statements into SWIG inteface file
qiluo-msft Oct 7, 2020
3a761e6
Add pytest unit test for DBInterface and SonicV2Connector
qiluo-msft Oct 7, 2020
04545d7
Fix swig customization on SonicV2Connector ctor
qiluo-msft Oct 7, 2020
2c8b889
Add attrib SonicV2Connector.namespace
qiluo-msft Oct 7, 2020
11658b9
Remove debug code
qiluo-msft Oct 8, 2020
832ace7
Use EXPECT_NE to simplify test
qiluo-msft Oct 8, 2020
b789a21
Remove unused code
qiluo-msft Oct 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyext/swsscommon.i
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
%include <std_string.i>
%include <std_vector.i>
%include <std_pair.i>
%include <std_map.i>
%include <typemaps.i>
%include <stdint.i>

%template(FieldValuePair) std::pair<std::string, std::string>;
%template(FieldValuePairs) std::vector<std::pair<std::string, std::string>>;
%template(FieldValueMap) std::map<std::string, std::string>;
%template(VectorString) std::vector<std::string>;

%apply int *OUTPUT {int *fd};
Expand Down
23 changes: 23 additions & 0 deletions tests/test_redis_ut.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import time
import pytest
from threading import Thread
from pympler.tracker import SummaryTracker
from swsscommon import swsscommon
from swsscommon.swsscommon import DBInterface, SonicV2Connector, SonicDBConfig

existing_file = "./tests/redis_multi_db_ut_config/database_config.json"
nonexisting_file = "./tests/redis_multi_db_ut_config/database_config_nonexisting.json"
global_existing_file = "./tests/redis_multi_db_ut_config/database_global.json"

@pytest.fixture(scope="session", autouse=True)
def prepare(request):
SonicDBConfig.initialize(existing_file)

def test_ProducerTable():
db = swsscommon.DBConnector("APPL_DB", 0, True)
Expand Down Expand Up @@ -122,3 +132,16 @@ def generator_SelectMemoryLeak():
cases.append("%s - %d objects for %d repeats" % (name, count, N))
thr.join()
assert not cases


def test_DBInterface():
dbintf = DBInterface()
dbintf.set_redis_kwargs("", "127.0.0.1", 6379)
dbintf.connect(15, "TEST_DB")

db = SonicV2Connector()
db.connect("TEST_DB")
db.set("TEST_DB", "key0", "field1", "value2")
fvs = db.get_all("TEST_DB", "key0")
assert "field1" in fvs
assert fvs["field1"] == "value2"