Skip to content

Commit

Permalink
keep del when del-set-sequence exist in consumer-state
Browse files Browse the repository at this point in the history
 Why I did it:
     when set after delete in a short time, consumer state may lost the del event.
     then what the multimap bring us for it may lost still.
 What I do:
     add the delete event even set after
     and modify the ut test for these changes.
     this can be verified by these testcase.
  • Loading branch information
inspurSDN committed Nov 16, 2023
1 parent b96c32d commit 7859651
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
9 changes: 8 additions & 1 deletion tests/redis_piped_state_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,16 @@ TEST(ConsumerStateTable, async_set_del_set)
KeyOpFieldsValuesTuple kco;
c.pop(kco);
EXPECT_EQ(kfvKey(kco), key);
EXPECT_EQ(kfvOp(kco), "SET");
EXPECT_EQ(kfvOp(kco), "DEL");

auto fvs = kfvFieldsValues(kco);
EXPECT_EQ(fvs.size(), 0U);

c.pop(kco);
EXPECT_EQ(kfvKey(kco), key);
EXPECT_EQ(kfvOp(kco), "SET");

fvs = kfvFieldsValues(kco);
EXPECT_EQ(fvs.size(), (unsigned int)maxNumOfFields);

map<string, string> mm;
Expand Down
18 changes: 16 additions & 2 deletions tests/redis_state_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,16 @@ TEST(ConsumerStateTable, set_del_set)
KeyOpFieldsValuesTuple kco;
c.pop(kco);
EXPECT_EQ(kfvKey(kco), key);
EXPECT_EQ(kfvOp(kco), "SET");
EXPECT_EQ(kfvOp(kco), "DEL");

auto fvs = kfvFieldsValues(kco);
EXPECT_EQ(fvs.size(), 0U);

c.pop(kco);
EXPECT_EQ(kfvKey(kco), key);
EXPECT_EQ(kfvOp(kco), "SET");

fvs = kfvFieldsValues(kco);
EXPECT_EQ(fvs.size(), (unsigned int)maxNumOfFields);

map<string, string> mm;
Expand Down Expand Up @@ -451,9 +458,16 @@ TEST(ConsumerStateTable, set_pop_del_set_pop_get)
KeyOpFieldsValuesTuple kco;
c.pop(kco);
EXPECT_EQ(kfvKey(kco), key);
EXPECT_EQ(kfvOp(kco), "SET");
EXPECT_EQ(kfvOp(kco), "DEL");

auto fvs = kfvFieldsValues(kco);
EXPECT_EQ(fvs.size(), 0U);

c.pop(kco);
EXPECT_EQ(kfvKey(kco), key);
EXPECT_EQ(kfvOp(kco), "SET");

fvs = kfvFieldsValues(kco);

/* size of fvs should be maxNumOfFields, no "field 1" left from first set*/
EXPECT_EQ(fvs.size(), (unsigned int)maxNumOfFields);
Expand Down

0 comments on commit 7859651

Please sign in to comment.