@@ -202,6 +202,24 @@ func testTimeSeries(t *testing.T, configs util.KvrocksServerConfigs) {
202202 require .ErrorContains (t , rdb .Do (ctx , "ts.add" , key , "1000" , "13.4" ).Err (), "update is not supported when DUPLICATE_POLICY is set to BLOCK mode" )
203203 })
204204
205+ t .Run ("TS.ADD Ignore Option" , func (t * testing.T ) {
206+ ignoreKey := "test_add_ignore_key"
207+ require .NoError (t , rdb .Del (ctx , ignoreKey ).Err ())
208+ require .NoError (t , rdb .Do (ctx , "ts.create" , ignoreKey , "duplicate_policy" , "last" , "ignore" , "5" , "2" ).Err ())
209+
210+ require .Equal (t , int64 (1000 ), rdb .Do (ctx , "ts.add" , ignoreKey , "1000" , "10" ).Val ())
211+ require .Equal (t , int64 (1003 ), rdb .Do (ctx , "ts.add" , ignoreKey , "1003" , "11" ).Val ())
212+
213+ res := rdb .Do (ctx , "ts.range" , ignoreKey , "-" , "+" ).Val ().([]interface {})
214+ require .Equal (t , 1 , len (res ))
215+ assert .Equal (t , []interface {}{int64 (1000 ), float64 (10 )}, res [0 ])
216+
217+ require .Equal (t , int64 (1008 ), rdb .Do (ctx , "ts.add" , ignoreKey , "1008" , "20" ).Val ())
218+ res = rdb .Do (ctx , "ts.range" , ignoreKey , "-" , "+" ).Val ().([]interface {})
219+ require .Equal (t , 2 , len (res ))
220+ assert .Equal (t , []interface {}{int64 (1008 ), float64 (20 )}, res [1 ])
221+ })
222+
205223 t .Run ("TS.ADD With Retention" , func (t * testing.T ) {
206224 require .NoError (t , rdb .Del (ctx , key ).Err ())
207225 require .NoError (t , rdb .Do (ctx , "ts.create" , key , "retention" , "1000" ).Err ())
@@ -232,6 +250,21 @@ func testTimeSeries(t *testing.T, configs util.KvrocksServerConfigs) {
232250 assert .Contains (t , res [1 ], "update is not supported when DUPLICATE_POLICY is set to BLOCK mode" )
233251 })
234252
253+ t .Run ("TS.MADD Ignore Option" , func (t * testing.T ) {
254+ ignoreKey := "test_madd_ignore_key"
255+ require .NoError (t , rdb .Del (ctx , ignoreKey ).Err ())
256+ require .NoError (t , rdb .Do (ctx , "ts.create" , ignoreKey , "duplicate_policy" , "last" , "ignore" , "5" , "2" ).Err ())
257+ require .Equal (t , int64 (1000 ), rdb .Do (ctx , "ts.add" , ignoreKey , "1000" , "10" ).Val ())
258+
259+ res := rdb .Do (ctx , "ts.madd" , ignoreKey , "1003" , "11" , ignoreKey , "1004" , "13" , ignoreKey , "1007" , "14" ).Val ().([]interface {})
260+ assert .Equal (t , []interface {}{int64 (1003 ), int64 (1004 ), int64 (1007 )}, res )
261+
262+ samples := rdb .Do (ctx , "ts.range" , ignoreKey , "-" , "+" ).Val ().([]interface {})
263+ require .Equal (t , 2 , len (samples ))
264+ assert .Equal (t , []interface {}{int64 (1000 ), float64 (10 )}, samples [0 ])
265+ assert .Equal (t , []interface {}{int64 (1004 ), float64 (13 )}, samples [1 ])
266+ })
267+
235268 t .Run ("TS.MADD Nonexistent Key" , func (t * testing.T ) {
236269 require .NoError (t , rdb .Del (ctx , "nonexistent" ).Err ())
237270 require .NoError (t , rdb .Del (ctx , "existent" ).Err ())
0 commit comments