diff options
| author | Zheng Chao <[email protected]> | 2023-03-11 14:51:20 +0800 |
|---|---|---|
| committer | Zheng Chao <[email protected]> | 2023-03-11 14:51:20 +0800 |
| commit | cff79ab47cc7c4da9d5773aeadb833ca252b14b5 (patch) | |
| tree | 0dbb75b1fcb8c48bd06ea5bdbc30c2e400fa67ae /test | |
| parent | c0cbee9eaacb24762d307f0b4157ffaed6932a16 (diff) | |
:bug: Fix inaccuarte `TINFO` when a token bucket has a zero CIR and zero CBS.
Diffstat (limited to 'test')
| -rw-r--r-- | test/swarmkv_gtest.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/swarmkv_gtest.cpp b/test/swarmkv_gtest.cpp index 1213d98..042f1a0 100644 --- a/test/swarmkv_gtest.cpp +++ b/test/swarmkv_gtest.cpp @@ -324,7 +324,6 @@ TEST_F(SwarmkvBasicTest, TypeTokenBucket) while(now.tv_sec - start.tv_sec<3) { request_tokens=random()%(2*rate); - cmd_exec_arg_expect_integer(arg, 0); reply=swarmkv_command(db, "TCONSUME %s %lld FLEXIBLE", key, request_tokens); if(reply->type==SWARMKV_REPLY_INTEGER) { @@ -336,6 +335,23 @@ TEST_F(SwarmkvBasicTest, TypeTokenBucket) } EXPECT_LE(got_tokens, (now.tv_sec -start.tv_sec)*rate+capacity); cmd_exec_arg_free(arg); + + //Infinite tokens + reply=swarmkv_command(db, "TCFG %s 0 0", key); + EXPECT_EQ(reply->type, SWARMKV_REPLY_STATUS); + swarmkv_reply_free(reply); + long long t=0; + for(i=0; i<100; i++) + { + reply=swarmkv_command(db, "TCONSUME %s 10000", key); + t+=reply->integer; + swarmkv_reply_free(reply); + } + EXPECT_EQ(t, 10000*i); + reply=swarmkv_command(db, "TINFO %s", key); + ASSERT_EQ(reply->n_element, 10); + EXPECT_EQ(reply->elements[5]->integer, got_tokens+t); + swarmkv_reply_free(reply); } TEST_F(SwarmkvBasicTest, TypeHash) { |
