Commit Graph

846 Commits

Author SHA1 Message Date
Salvatore Sanfilippo
d2c5f80e2e
Merge pull request #6926 from oranagra/fork-test-fix
fix race in module api test for fork
2020-02-27 09:58:04 +01:00
Oran Agra
2f1a1c3835 fix github actions failing latency test for active defrag - part 2
it seems that running two clients at a time is ok too, resuces action
time from 20 minutes to 10. we'll use this for now, and if one day it
won't be enough we'll have to run just the sensitive tests one by one
separately from the others.

this commit also fixes an issue with the defrag test that appears to be
very rare.
2020-02-27 08:34:53 +02:00
Oran Agra
537893420b fix github actions failing latency test for active defrag
seems that github actions are slow, using just one client to reduce
false positives.

also adding verbose, testing only on latest ubuntu, and building on
older one.

when doing that, i can reduce the test threshold back to something saner
2020-02-25 17:53:23 +02:00
Oran Agra
0a643efa0c fix race in module api test for fork
in some cases we were trying to kill the fork before it got created
2020-02-23 16:48:37 +02:00
Oran Agra
62adabd0e0 Fix latency sensitivity of new defrag test
I saw that the new defag test for list was failing in CI recently, so i
reduce it's threshold from 12 to 60.

besides that, i add / improve the latency test for that other two defrag
tests (add a sensitive latency and digest / save checks)

and fix bad usage of debug populate (can't overrides existing keys).
this was the original intention, which creates higher fragmentation.
2020-02-23 13:05:52 +02:00
Salvatore Sanfilippo
e741b0c257
Merge pull request #6903 from oranagra/defrag_lists
Defrag big lists in portions to avoid latency and freeze
2020-02-20 13:00:39 +01:00
Guy Benoish
770cb0ba97 XGROUP DESTROY should unblock XREADGROUP with -NOGROUP 2020-02-19 08:25:31 +05:30
Oran Agra
485425cec7 Defrag big lists in portions to avoid latency and freeze
When active defrag kicks in and finds a big list, it will create a bookmark to
a node so that it is able to resume iteration from that node later.

The quicklist manages that bookmark, and updates it in case that node is deleted.

This will increase memory usage only on lists of over 1000 (see
active-defrag-max-scan-fields) quicklist nodes (1000 ziplists, not 1000 items)
by 16 bytes.

In 32 bit build, this change reduces the maximum effective config of
list-compress-depth and list-max-ziplist-size (from 32767 to 8191)
2020-02-18 17:22:32 +02:00
antirez
8ea7a3ee68 Tracking: first set of tests for the feature. 2020-02-14 14:29:00 +01:00
antirez
d5c6a833c8 Merge branch 'acl-log' into unstable 2020-02-06 11:24:16 +01:00
antirez
90fae58b49 ACL LOG: make max log entries configurable. 2020-02-04 13:19:40 +01:00
antirez
64a73e9293 ACL LOG: test for AUTH reason. 2020-02-04 12:58:48 +01:00
WuYunlong
01eaf53bb3 Add tcl regression test in scripting.tcl to reproduce memory leak. 2020-02-04 16:34:11 +08:00
Guy Benoish
2deb55512f ld2string should fail if string contains \0 in the middle
This bug affected RM_StringToLongDouble and HINCRBYFLOAT.
I added tests for both cases.

Main changes:
1. Fixed string2ld to fail if string contains \0 in the middle
2. Use string2ld in getLongDoubleFromObject - No point of
   having duplicated code here

The two changes above broke RM_SaveLongDouble/RM_LoadLongDouble
because the long double string was saved with length+1 (An innocent
mistake, but it's actually a bug - The length passed to
RM_SaveLongDouble should not include the last \0).
2020-01-30 18:15:17 +05:30
antirez
b189a21974 ACL LOG: implement a few basic tests. 2020-01-30 11:14:13 +01:00
Salvatore Sanfilippo
bf53f9280a
Merge pull request #6699 from guybe7/module_blocked_on_key_timeout_memleak
Modules: Fix blocked-client-related memory leak
2020-01-29 12:06:14 +01:00
Salvatore Sanfilippo
bb93686754
Merge pull request #6703 from guybe7/blocking_xread_empty_reply
Blocking XREAD[GROUP] should always reply with valid data (or timeout)
2020-01-09 17:32:14 +01:00
Guy Benoish
d7d13721d3 Modules: Fix blocked-client-related memory leak
If a blocked module client times-out (or disconnects, unblocked
by CLIENT command, etc.) we need to call moduleUnblockClient
in order to free memory allocated by the module sub-system
and blocked-client private data

Other changes:
Made blockedonkeys.tcl tests a bit more aggressive in order
to smoke-out potential memory leaks
2019-12-30 10:10:59 +05:30
Guy Benoish
a351e74fe9 Blocking XREAD[GROUP] should always reply with valid data (or timeout)
This commit solves the following bug:
127.0.0.1:6379> XGROUP CREATE x grp $ MKSTREAM
OK
127.0.0.1:6379> XADD x 666 f v
"666-0"
127.0.0.1:6379> XREADGROUP GROUP grp Alice BLOCK 0 STREAMS x >
1) 1) "x"
   2) 1) 1) "666-0"
         2) 1) "f"
            2) "v"
127.0.0.1:6379> XADD x 667 f v
"667-0"
127.0.0.1:6379> XDEL x 667
(integer) 1
127.0.0.1:6379> XREADGROUP GROUP grp Alice BLOCK 0 STREAMS x >
1) 1) "x"
   2) (empty array)

The root cause is that we use s->last_id in streamCompareID
while we should use the last *valid* ID
2019-12-30 10:06:01 +05:30
Salvatore Sanfilippo
3ff95d9074
Merge pull request #6706 from guybe7/stream_id_edge_cases
Stream: Handle streamID-related edge cases
2019-12-29 14:53:06 +01:00
Oran Agra
0c3fe52ef7 config.c adjust config limits and mutable
- make lua-replicate-commands mutable (it never was, but i don't see why)
- make tcp-backlog immutable (fix a recent refactory mistake)
- increase the max limit of a few configs to match what they were before
the recent refactory
2019-12-26 15:16:15 +02:00
Guy Benoish
1f75ce30df Stream: Handle streamID-related edge cases
This commit solves several edge cases that are related to
exhausting the streamID limits: We should correctly calculate
the succeeding streamID instead of blindly incrementing 'seq'
This affects both XREAD and XADD.

Other (unrelated) changes:
Reply with a better error message when trying to add an entry
to a stream that has exhausted last_id
2019-12-26 15:31:37 +05:30
antirez
e6e58e455c Revert "Geo: output 10 chars of geohash, not 11."
This reverts commit 009862ab7e.
2019-12-18 12:54:46 +01:00
zhaozhao.zz
24044f3356 add a new SET option KEEPTTL that doesn't remove expire time 2019-12-18 15:20:36 +08:00
Madelyn Olson
034dcf185c Add module APIs for custom authentication 2019-12-17 06:59:59 +00:00
Yossi Gottlieb
0283db5883 Improve RM_ModuleTypeReplaceValue() API.
With the previous API, a NULL return value was ambiguous and could
represent either an old value of NULL or an error condition. The new API
returns a status code and allows the old value to be returned
by-reference.

This commit also includes test coverage based on
tests/modules/datatype.c which did not exist at the time of the original
commit.
2019-12-12 18:50:11 +02:00
Oran Agra
18e72c5cc7 Converting more configs to use generic infra, and moving defaults to config.c
Changes in behavior:
- Change server.stream_node_max_entries from int64_t to long long, so that it can be used by the generic infra
- standard error reply instead of "repl-backlog-size must be 1 or greater" and such
- tls-port and a few TLS booleans were readable (config get) even when USE_OPENSSL was off (now they aren't)
- syslog-enabled, syslog-ident, cluster-enabled, appendfilename, and supervised didn't have a get (now they do)
- pidfile was initialized to NULL in InitServerConfig but had CONFIG_DEFAULT_PID_FILE in rewriteConfig (so the real default was "", but rewrite would cause it to be set), fixed the rewrite.
- TLS config in server.h was uninitialized (if no tls config args were provided)

Adding test for sanity and coverage
2019-11-28 11:24:57 +02:00
Salvatore Sanfilippo
a1b654819c
Merge pull request #6598 from oranagra/module-hook-test
try to fix an unstable test (module hook for loading progress)
2019-11-25 17:54:21 +01:00
Salvatore Sanfilippo
64c2508ee3
Merge branch 'unstable' into rm_get_server_info 2019-11-21 10:06:15 +01:00
Salvatore Sanfilippo
808394b77d
Merge pull request #6603 from daidaotong/typofix
fix typo in scripting.acl
2019-11-20 10:06:33 +01:00
Daniel Dai
99b5696390 fix typo 2019-11-19 20:14:59 -05:00
Oran Agra
ed2269762b try to fix an unstable test (module hook for loading progress)
there were two lssues, one is taht BGREWRITEAOF failed since the initial one was still in progress
the solution for this one is to enable appendonly from the server startup so there's no initial aofrw.

the other problem was 0 loading progress events, theory is that on some
platforms a sleep of 1 will cause a much greater delay due to the context
switch, but on other platform it doesn't. in theory a sleep of 100 micro
for 1k keys whould take 100ms, and with hz of 500 we should be gettering
50 events (one every 2ms). in practise it doesn't work like that, so trying
to find a sleep that would be long enough but still not cause the test to take
too long.
2019-11-19 15:01:51 +02:00
Salvatore Sanfilippo
e7144fbed8
Merge branch 'unstable' into module-long-double 2019-11-19 12:15:45 +01:00
Salvatore Sanfilippo
e916058f0b
Merge pull request #6557 from oranagra/rm_lru_lfu_revized
rename RN_SetLRUOrLFU -> RM_SetLRU and RN_SetLFU
2019-11-19 11:58:07 +01:00
antirez
936e01e5bb Fix stream test after addition of 0-0 ID test. 2019-11-19 11:49:05 +01:00
Salvatore Sanfilippo
656e40eed2
Merge branch 'unstable' into scan_module_impl 2019-11-19 11:08:02 +01:00
Salvatore Sanfilippo
3d89210477
Merge pull request #3383 from yossigo/datatype_load_save
Redis Module API calls to allow re-use of data type RDB save/load.
2019-11-19 10:55:42 +01:00
Guy Benoish
4a12047c61 XADD with ID 0-0 stores an empty key
Calling XADD with 0-0 or 0 would result in creating an
empty key and storing it in the database.
Even worse, because XADD will reply with error the action
will not be replicated, creating a master-replica
inconsistency
2019-11-13 16:47:30 +05:30
Oran Agra
0f8692b464 Add RM_ScanKey to scan hash, set, zset, changes to RM_Scan API
- Adding RM_ScanKey
- Adding tests for RM_ScanKey
- Refactoring RM_Scan API

Changes in RM_Scan
- cleanup in docs and coding convention
- Moving out of experimantal Api
- Adding ctx to scan callback
- Dont use cursor of -1 as an indication of done (can be a valid cursor)
- Set errno when returning 0 for various reasons
- Rename Cursor to ScanCursor
- Test filters key that are not strings, and opens a key if NULL
2019-11-11 16:05:55 +02:00
meir@redislabs.com
11c6ce812a Added scan implementation to module api.
The implementation expose the following new functions:
1. RedisModule_CursorCreate - allow to create a new cursor object for
keys scanning
2. RedisModule_CursorRestart - restart an existing cursor to restart the
scan
3. RedisModule_CursorDestroy - destroy an existing cursor
4. RedisModule_Scan - scan keys

The RedisModule_Scan function gets a cursor object, a callback and void*
(used as user private data).
The callback will be called for each key in the database proving the key
name and the value as RedisModuleKey.
2019-11-11 16:01:41 +02:00
Oran Agra
28c20b4ef9 rename RN_SetLRUOrLFU -> RM_SetLRU and RN_SetLFU
- the API name was odd, separated to two apis one for LRU and one for LFU
- the LRU idle time was in 1 second resolution, which might be ok for RDB
  and RESTORE, but i think modules may need higher resolution
- adding tests for LFU and for handling maxmemory policy mismatch
2019-11-10 09:27:01 +02:00
Guy Benoish
8beec4f0e7 Make sure Redis does not reply with negative zero 2019-11-05 19:23:37 +05:30
Yossi Gottlieb
5350e7669e Add ModuleDataType to/from string serialization.
Add two new functions that leverage the RedisModuleDataType mechanism
for RDB serialization/deserialization and make it possible to use it
to/from arbitrary strings:

* RM_SaveDataTypeToString()
* RM_LoadDataTypeFromString()
2019-11-04 21:53:59 +02:00
Salvatore Sanfilippo
a15a5d7097
Merge pull request #6540 from oranagra/simple_module_api_tests
Test coverage for new module APIs: dbsize, flushall, randomkey, lru get/set
2019-11-04 18:52:31 +01:00
artix
060af1858d Fix RedisModule_ReplyWithLongDouble ptr definition, add tests 2019-11-04 18:49:50 +01:00
Oran Agra
3adf10b809 Test coverage for new module APIs: dbsize, flushall, randomkey, lru get/set 2019-11-04 19:30:31 +02:00
Loris Cro
b12d2f65d6 fix unreported overflow in autogerenared stream IDs 2019-11-04 16:36:06 +01:00
Salvatore Sanfilippo
23c681b51d
Merge pull request #6535 from guybe7/module_block_on_keys_tests
Modules: Test RedisModule_BlockClientOnKeys
2019-11-04 10:53:59 +01:00
Guy Benoish
b81f486c2f Modules: Test RedisModule_BlockClientOnKeys 2019-11-04 14:20:24 +05:30
Oran Agra
0423309768 Add RM_ServerInfoGetFieldUnsigned
rename RM_ServerInfoGetFieldNumerical RM_ServerInfoGetFieldSigned
move string2ull to util.c
fix leak in RM_GetServerInfo when duplicate info fields exist
2019-11-04 08:50:29 +02:00
Oran Agra
deebed23e1 Adding RM_ServerInfoGetFieldC 2019-11-04 07:57:52 +02:00
Oran Agra
4d580438b0 Add module api for looking into INFO fields
- Add RM_GetServerInfo and friends
- Add auto memory for new opaque struct
- Add tests for new APIs

other minor fixes:
- add const in various char pointers
- requested_section in modulesCollectInfo was actually not sds but char*
- extract new string2d out of getDoubleFromObject for code reuse

Add module API for
2019-11-03 15:02:25 +02:00
Oran Agra
51c3ff8d75 Modules hooks: complete missing hooks for the initial set of hooks
* replication hooks: role change, master link status, replica online/offline
* persistence hooks: saving, loading, loading progress
* misc hooks: cron loop, shutdown, module loaded/unloaded
* change the way hooks test work, and add tests for all of the above

startLoading() now gets flag indicating what is loaded.
stopLoading() now gets an indication of success or failure.
adding startSaving() and stopSaving() with similar args and role.
2019-10-29 17:59:09 +02:00
Oran Agra
0399b5a27e Module api tests for RM_Call
Adding a test for coverage for RM_Call in a new "misc" unit
to be used for various short simple tests

also solves compilation warnings in redismodule.h and fork.c
2019-10-28 12:39:57 +02:00
Salvatore Sanfilippo
c328c807e7
Merge pull request #6496 from oranagra/module_tests_valgrind
Make module tests pass with valgrind, and fix a leak in diskless load
2019-10-28 10:05:52 +01:00
antirez
6e98214f74 Modules hooks: test flush event. 2019-10-24 10:51:03 +02:00
antirez
39f2ab595c Modules hooks: initial Tcl test file. 2019-10-24 10:41:25 +02:00
Oran Agra
be352633a0 Make module tests pass with valgrind, and fix a leak in diskless load 2019-10-24 09:45:25 +03:00
Yossi Gottlieb
0db3b0a0ff Merge remote-tracking branch 'upstream/unstable' into tls 2019-10-16 17:08:07 +03:00
antirez
dd29d44136 Test: fix implementation-dependent test after code change. 2019-10-10 15:22:42 +02:00
antirez
009862ab7e Geo: output 10 chars of geohash, not 11.
This does not limit the actual precision, because the last digit bits were
garbage, and the shift value became even negative in the last iteration.
2019-10-08 17:09:37 +02:00
Yossi Gottlieb
61733ded14 TLS: Configuration options.
Add configuration options for TLS protocol versions, ciphers/cipher
suites selection, etc.
2019-10-07 21:07:27 +03:00
Yossi Gottlieb
b087dd1db6 TLS: Connections refactoring and TLS support.
* Introduce a connection abstraction layer for all socket operations and
integrate it across the code base.
* Provide an optional TLS connections implementation based on OpenSSL.
* Pull a newer version of hiredis with TLS support.
* Tests, redis-cli updates for TLS support.
2019-10-07 21:06:13 +03:00
antirez
1b8b8c029f Modules: add RM_Replicate() Tcl test file & fix the module. 2019-10-03 18:44:50 +02:00
Salvatore Sanfilippo
2e2fe98f9c
Merge pull request #6270 from oranagra/modules_info
Extend modules API to allow modules report to redis INFO
2019-10-01 18:02:33 +02:00
Oran Agra
d5c14c70b7 Merge remote-tracking branch 'antirez/unstable' into modules_info 2019-09-30 20:47:35 +03:00
antirez
09041b9359 ACLs: change hashed passwords opcode to also remove them.
Related to PR #6405
2019-09-30 18:28:45 +02:00
Madelyn Olson
ea7c3fe7fd Allowed passing in of password hash and fixed config rewrite 2019-09-30 17:57:49 +02:00
Salvatore Sanfilippo
6129758558
Merge branch 'unstable' into modules_fork 2019-09-27 11:24:06 +02:00
Salvatore Sanfilippo
959fb5cf68
Merge pull request #6235 from oranagra/module_rdb_load_errors
Allow modules to handle RDB loading errors.
2019-09-26 11:52:42 +02:00
valentino
7a73b7f168 DISCARD should not fail during OOM
discard command should not fail during OOM, otherwise client MULTI state
will not be cleared.
2019-09-22 09:22:53 +03:00
Oran Agra
61853ad8de Module INFO, support default section for simple modules 2019-08-18 10:01:57 +03:00
Oran Agra
1d6e5dc4dc Module INFO, add support for dict fields, rename API to have common prefix 2019-08-18 09:41:45 +03:00
Oran Agra
07b1abab95 Add test for module diskless short reads 2019-07-30 15:20:03 +03:00
Oran Agra
e91d9a6fff Extend modules API to allow modules report to redis INFO
this implements #6012
2019-07-24 12:58:15 +03:00
Oran Agra
3b6aeea44c Implement module api for aux data in rdb
Other changes:
* fix memory leak in error handling of rdb loading of type OBJ_MODULE
2019-07-22 21:15:33 +03:00
Oran Agra
56258c6b7d Module API for Forking
* create module API for forking child processes.
* refactor duplicate code around creating and tracking forks by AOF and RDB.
* child processes listen to SIGUSR1 and dies exitFromChild in order to
  eliminate a valgrind warning of unhandled signal.
* note that BGSAVE error reply has changed.

valgrind error is:
  Process terminating with default action of signal 10 (SIGUSR1)
2019-07-17 16:40:24 +03:00
Salvatore Sanfilippo
4b2579a064
Merge pull request #5779 from madolson/dev-unstable-geo-bugfix
Fixed a rounding bug in geo.tcl
2019-07-15 23:41:57 +02:00
Angus Pearson
bf963253ec Implement SCAN cursor [TYPE type] modifier suggested in issue #6107.
Add tests to check basic functionality of this optional keyword, and also tested with
a module (redisgraph). Checked quickly with valgrind, no issues.

Copies name the type name canonicalisation code from `typeCommand`, perhaps this would
be better factored out to prevent the two diverging and both needing to be edited to
add new `OBJ_*` types, but this is a little fiddly with C strings.

The [redis-doc](https://github.com/antirez/redis-doc/blob/master/commands.json) repo
will need to be updated with this new arg if accepted.

A quirk to be aware of here is that the GEO commands are backed by zsets not their own
type, so they're not distinguishable from other zsets.

Additionally, for sparse types this has the same behaviour as `MATCH` in that it may
return many empty results before giving something, even for large `COUNT`s.
2019-05-22 16:39:04 +01:00
antirez
1a1ba48390 Test: fix slowlog test false positive.
In fast systems "SLOWLOG RESET" is fast enough to don't be logged even
when the time limit is "1" sometimes. Leading to false positives such
as:

[err]: SLOWLOG - can be disabled in tests/unit/slowlog.tcl
Expected '1' to be equal to '0'
2019-05-14 16:55:52 +02:00
antirez
4f4676a142 Fix test false positive introduced by threaded I/O.
Now clients that are ready to be terminated asynchronously are processed
more often in beforeSleep() instead of being processed in serverCron().
This means that the test will not be able to catch the moment the client
was terminated, also note that the 'omem' figure now changes in big
steps, because of the new client output buffers layout.

So we have to change the test range in order to accomodate for that.
Yet the test is useful enough to be worth taking, even if its precision
is reduced by this commit. Probably if we get more problems, a thing
that makes sense is just to check that the limit is < 200k. That's more
than enough actually.
2019-05-13 17:27:10 +02:00
Oran Agra
ba809f26d4 make replication tests more stable on slow machines
solving few replication related tests race conditions which fail on slow machines

bugfix in slave buffers test: since the test is executed twice, each time with
a different commands count, the threshold for the delta can't be a constant.
2019-05-05 08:25:01 +03:00
Salvatore Sanfilippo
d044e33c20
Merge pull request #5961 from yossigo/modules-tests
Modules tests
2019-04-11 07:56:23 -07:00
antirez
c24e32041b ACL: Fix memory leak in ACLResetSubcommandsForCommand().
This commit fixes bug reported at #5998. Thanks to @tomcat1102.
2019-04-08 18:08:37 +02:00
antirez
f8a9708aa7 ACL: regression test for #5998. 2019-04-08 18:06:50 +02:00
Yossi Gottlieb
ec0b6bd2c3 Add runtest-moduleapi with commandfilter coverage. 2019-03-24 12:03:03 +02:00
Yossi Gottlieb
822a992f91 fix: missing initialization. 2019-03-24 12:00:33 +02:00
antirez
dca7358279 HyperLogLog: speedup fuzz test. 2019-03-15 17:13:19 +01:00
antirez
4208666797 HyperLogLog: dense/sparse repr parsing fuzz test. 2019-03-15 13:52:29 +01:00
Salvatore Sanfilippo
3e648907ee
Merge pull request #5907 from spjwebster/xclaim-increment-delivery-count
Increment delivery counter on XCLAIM unless RETRYCOUNT specified
2019-03-13 11:55:46 +01:00
Steve Webster
dfcb227b50 Only increment delivery count if JUSTID option is omitted 2019-03-12 20:27:53 +00:00
Salvatore Sanfilippo
e5acc5ef4f
Merge pull request #2774 from rouzier/blocking-list-commands-support-milliseconds-floating
Added millisecond resolution for blpop command && friends
2019-03-12 18:10:28 +01:00
Steve Webster
f1e7df4b7c Increment delivery counter on XCLAIM unless RETRYCOUNT specified
The XCLAIM docs state the XCLAIM increments the delivery counter for
messages. This PR makes the code match the documentation - which seems
like the desired behaviour - whilst still allowing RETRYCOUNT to be
specified manually.

My understanding of the way streamPropagateXCLAIM() works is that this
change will safely propagate to replicas since retry count is pulled
directly from the streamNACK struct.

Fixes #5194
2019-03-08 17:09:11 +00:00
antirez
f021da5e30 Acl: Test: check command rules synthesis. 2019-01-30 12:01:37 +01:00
antirez
e103fd4208 ACL: Test: check subcommands (test fails). 2019-01-28 18:29:22 +01:00
antirez
f4c39db450 ACL: Test: nopass user flag, commands/groups +/- rules. 2019-01-28 12:40:07 +01:00
antirez
26f98bca97 ACL: Test: check default behavior and keys ACLs. 2019-01-28 12:33:18 +01:00
antirez
6cec82b943 ACL: Test: check passwords validity and removal. 2019-01-28 12:06:25 +01:00
antirez
3c67c1c394 ACL: Test: enabled/disabled user. 2019-01-28 11:44:10 +01:00
antirez
9fc1ce2f05 ACL: create unit test. 2019-01-28 11:39:58 +01:00
antirez
ac6e49de48 ACL: implement resetpass directive and adjust test. 2019-01-18 11:26:32 +01:00
antirez
b87815c1f8 ACL: AUTH + no default user password raises an error.
This way the behavior is very similar to the past one.
This is useful in order to remember the user she probably failed to
configure a password correctly.
2019-01-17 18:30:23 +01:00
Madelyn Olson
b00e1891c0 Fixed a rounding bug in geo.tcl 2019-01-15 07:26:19 +00:00
Salvatore Sanfilippo
46a51cdcdc
Merge pull request #5549 from oranagra/fix_test_races
fix small test suite race conditions
2018-11-28 18:17:05 +01:00
antirez
fc022031d3 Merge branch 'unstable' of github.com:/antirez/redis into unstable 2018-11-28 17:12:32 +01:00
Qu Chen
c99f1206b7 Add unit test for stream XCLAIM command. 2018-11-28 17:12:03 +01:00
Salvatore Sanfilippo
6a6471aad5
Merge pull request #4737 from guybe7/zlexcount_fix
Don't call sdscmp() with shared.maxstring or shared.minstring
2018-11-28 16:53:32 +01:00
antirez
30a455f14a Test: regression test for #5570. 2018-11-19 17:19:33 +01:00
antirez
db8d7d3dc4 Test: regression test for #5577. 2018-11-19 16:50:54 +01:00
Oran Agra
d0850369c4 fix small test suite race conditions 2018-11-12 10:26:10 +02:00
antirez
56871aeb60 Tests for XGROUP CREATE MKSTREAM. 2018-10-17 12:11:10 +02:00
zhaozhao.zz
c2e4c64db4 Streams: Tests modified XSTREAM -> XSETID 2018-10-16 23:56:26 +08:00
antirez
b4f8268371 Tests modified to use XADD MAXLEN 0 + XSETID.
See #5426.
2018-10-16 17:28:56 +02:00
Salvatore Sanfilippo
af09df08d7
Merge pull request #5426 from soloestoy/feature-xstream
Bugfix data inconsistency after aof rewrite, and add XSTREAM command.
2018-10-16 13:10:36 +02:00
antirez
3c140e7bcd Test: avoid time related false positive in RESTORE test. 2018-10-13 14:17:11 +02:00
antirez
fbfd61b471 Test: cgroup propagation test also for NOACK variant.
Related to #5433.
2018-10-10 17:37:41 +02:00
antirez
cfad5e4587 Test: consumer group last ID slave propagation test.
This is a regression for #5433.
2018-10-10 17:32:17 +02:00
zhaozhao.zz
3094eb3626 Streams: add tests for aof rewrite 2018-10-09 15:45:58 +08:00
zhaozhao.zz
5f3adbee33 Streams: add tests for XSTREAM command 2018-10-09 15:21:08 +08:00
Salvatore Sanfilippo
e5f1de1448
Merge pull request #5141 from soloestoy/fix-xtrim-inconsistency
Fix XTRIM and XADD with MAXLEN inconsistency
2018-10-08 12:00:00 +02:00
Oran Agra
f03aed3ca9 fix #5024 - commandstats for multi-exec were logged as EXEC.
this was broken a while back by ba9154d7e7bf959b002533384319a1e90545447b
the purpose of which was to fix commandstats for GEOADD
2018-09-30 12:43:11 +03:00
antirez
52e7192e4a Slave removal: remove slave from top-level tests descriptions. 2018-09-11 15:32:28 +02:00
antirez
6bd0d342dd Fix scripting tests now that we default to commands repl. 2018-09-05 19:54:54 +02:00
Salvatore Sanfilippo
5b4bec9d33
Merge pull request #5265 from oranagra/stabilize_tests
Fix unstable tests on slow machines.
2018-08-27 13:19:31 +02:00
Oran Agra
c8452ab005 Fix unstable tests on slow machines.
Few tests had borderline thresholds that were adjusted.

The slave buffers test had two issues, preventing the slave buffer from growing:
1) the slave didn't necessarily go to sleep on time, or woke up too early,
   now using SIGSTOP to make sure it goes to sleep exactly when we want.
2) the master disconnected the slave on timeout
2018-08-21 11:46:07 +03:00
zhaozhao.zz
b89302c462 adjust qbuf to 26 in test case for client list 2018-08-14 00:57:22 +08:00
antirez
d506334b67 Test: new sorted set skiplist order consistency.
This should be able to find new bugs and regressions about the new
sorted set update function when ZADD is used to update an element
already existing.

The test is able to find the bug fixed at 2f282aee immediately.
2018-08-02 14:15:53 +02:00
zhaozhao.zz
60acac4cd0 Streams: add test cases for XADD/XTRIM maxlen 2018-08-01 10:34:29 +08:00
Oran Agra
d4ae76d1a6 fix slave buffer test suite false positives
it looks like on slow machines we're getting:
[err]: slave buffer are counted correctly in tests/unit/maxmemory.tcl
Expected condition '$slave_buf > 2*1024*1024' to be true (16914 > 2*1024*1024)

this is a result of the slave waking up too early and eating the
slave buffer before the traffic and the test ends.
2018-07-24 11:24:27 +03:00
Oran Agra
f89c93c8ad make active defrag test more stable
on slower machines, the active defrag test tended to fail.
although the fragmentation ratio was below the treshold, the defragger was
still in the middle of a scan cycle.

this commit changes:
- the defragger uses the current fragmentation state, rather than the cache one
  that is updated by server cron every 100ms. this actually fixes a bug of
  starting one excess scan cycle
- the test lets the defragger use more CPU cycles, in hope that the defrag
  will be faster, but also give it more time before we give up.
2018-07-18 10:16:33 +03:00
Oran Agra
bf680b6f8c slave buffers were wasteful and incorrectly counted causing eviction
A) slave buffers didn't count internal fragmentation and sds unused space,
   this caused them to induce eviction although we didn't mean for it.

B) slave buffers were consuming about twice the memory of what they actually needed.
- this was mainly due to sdsMakeRoomFor growing to twice as much as needed each time
  but networking.c not storing more than 16k (partially fixed recently in 237a38737).
- besides it wasn't able to store half of the new string into one buffer and the
  other half into the next (so the above mentioned fix helped mainly for small items).
- lastly, the sds buffers had up to 30% internal fragmentation that was wasted,
  consumed but not used.

C) inefficient performance due to starting from a small string and reallocing many times.

what i changed:
- creating dedicated buffers for reply list, counting their size with zmalloc_size
- when creating a new reply node from, preallocate it to at least 16k.
- when appending a new reply to the buffer, first fill all the unused space of the
  previous node before starting a new one.

other changes:
- expose mem_not_counted_for_evict info field for the benefit of the test suite
- add a test to make sure slave buffers are counted correctly and that they don't cause eviction
2018-07-16 16:43:42 +03:00
antirez
2352a51992 Test: XDEL fuzz testing. Remove and check stage. 2018-07-13 17:58:17 +02:00
antirez
d6efd5fc1d Test: XDEL fuzz testing, stream creation. 2018-07-13 17:47:26 +02:00
antirez
699971535e Merge branch 'unstable' of github.com:/antirez/redis into unstable 2018-07-13 17:41:10 +02:00
antirez
a93f8f0998 Test: XDEL basic test. 2018-07-13 17:40:48 +02:00
WuYunlong
b3660be8f5 Add test in slowlog.tcl 2018-07-13 17:51:06 +08:00
antirez
8d6b7861a7 Add regression test for #5111. 2018-07-12 13:35:17 +02:00
Jack Drogon
93238575f7 Fix typo 2018-07-03 18:19:46 +02:00
chendianqiang
cbb2ac0799
Merge branch 'unstable' into pending-querybuf 2018-07-03 10:07:26 +08:00
chendianqiang
7de1ada070 limit the size of pending-querybuf in masterclient 2018-07-01 14:43:53 +08:00
Oran Agra
de495ee7ab minor fix in creating a stream NACK for rdb and defrag tests 2018-06-27 15:34:17 +03:00
Oran Agra
5616d4c603 add active defrag support for streams 2018-06-27 15:00:41 +03:00
shenlongxing
ec55df117f fix typo 2018-06-21 22:08:09 +08:00
Guy Benoish
b5197f1fc9 Enhance RESTORE with RDBv9 new features
RESTORE now supports:
1. Setting LRU/LFU
2. Absolute-time TTL

Other related changes:
1. RDB loading will not override LRU bits when RDB file
   does not contain the LRU opcode.
2. RDB loading will not set LRU/LFU bits if the server's
   maxmemory-policy does not match.
2018-06-20 15:11:08 +07:00
antirez
1e92fde3d3 Fix SCAN bug regression test, avoiding empty SREM call. 2018-06-14 12:21:58 +02:00
antirez
6bf65138de Regression test for issue #5006. 2018-06-12 13:13:35 +02:00
antirez
00613bed06 Improved regression test for #4906.
Removing the fix about 50% of the times the test will not be able to
pass cleanly. It's very hard to write a test that will always fail, or
actually, it is possible but then it's likely that it will consistently
pass if we change some random bit, so better to use randomization here.
2018-06-11 13:10:06 +02:00
antirez
27beaf2f22 Regression test for the dictScan() issue #4906. 2018-06-11 12:51:26 +02:00
antirez
0a698e499a ZPOP: invert score-ele to match ZRANGE WITHSCORES order. 2018-06-05 17:06:25 +02:00
antirez
2bd36616ba Streams: fix test ID format. 2018-05-25 16:57:08 +02:00
antirez
98d5d3f118 Make active defragmentation tests optional.
They failed when active defrag could not be activated because the
Jemalloc version does not include the additional APIs.
2018-05-24 18:04:21 +02:00
Oran Agra
ad133e1023 Active defrag fixes for 32bit builds
problems fixed:
* failing to read fragmentation information from jemalloc
* overflow in jemalloc fragmentation hint to the defragger
* test suite not triggering eviction after population
2018-05-17 09:52:00 +03:00
antirez
e87c1f1e6c ZPOP: fix the tests according to new non-blocking "count" argument. 2018-05-11 18:07:10 +02:00
antirez
6efb6c1e06 ZPOP: renaming to have explicit MIN/MAX score idea.
This commit also adds a top comment about a subtle behavior of mixing
blocking operations of different types in the same key.
2018-05-11 17:31:53 +02:00
Itamar Haber
438125b47c Implements [B]Z[REV]POP and the respective unit tests
An implementation of the
[Ze POP Redis Module](https://github.com/itamarhaber/zpop) as core
Redis commands.

Fixes #1861.
2018-04-30 02:10:42 +03:00
antirez
2b2652d7c4 AOF: run tests with preamble off when it makes sense. 2018-03-25 13:03:38 +02:00
Salvatore Sanfilippo
da621783f0
Merge pull request #4691 from oranagra/active_defrag_v2
Active defrag v2
2018-03-22 09:16:32 +01:00
antirez
54b9a0e612 CG: test XACK remaining features. 2018-03-15 12:54:10 +01:00
antirez
5f8c57f28a CG: test XACK ability to remove items from the PELs. 2018-03-15 12:54:10 +01:00
antirez
f5799e728a CG: test XPENDING ability to return pending items. 2018-03-15 12:54:10 +01:00
antirez
c2ecac4746 CG: test XGROUPREAD abilities. 2018-03-15 12:54:10 +01:00
antirez
c9d86c2b16 CG: More specific duplicated group error. 2018-03-15 12:54:10 +01:00
Oran Agra
806736cdf9 Adding real allocator fragmentation to INFO and MEMORY command + active defrag test
other fixes / improvements:
- LUA script memory isn't taken from zmalloc (taken from libc malloc)
  so it can cause high fragmentation ratio to be displayed (which is false)
- there was a problem with "fragmentation" info being calculated from
  RSS and used_memory sampled at different times (now sampling them together)

other details:
- adding a few more allocator info fields to INFO and MEMORY commands
- improve defrag test to measure defrag latency of big keys
- increasing the accuracy of the defrag test (by looking at real grag info)
  this way we can use an even lower threshold and still avoid false positives
- keep the old (total) "fragmentation" field unchanged, but add new ones for spcific things
- add these the MEMORY DOCTOR command
- deduct LUA memory from the rss in case of non jemalloc allocator (one for which we don't "allocator active/used")
- reduce sampling rate of the rss and allocator info
2018-03-12 15:08:52 +02:00
Guy Benoish
290a63dc54 Don't call sdscmp() with shared.maxstring or shared.minstring 2018-03-06 20:14:35 +07:00
antirez
c17a0e134f Test: MIGRATE AUTH test added.
Related to #2507.
2018-01-09 18:49:19 +01:00
antirez
45fe1f5e00 Streams: add some initial test for XREVRANGE. 2017-12-01 10:24:25 +01:00
antirez
1898c50573 Streams: fix XREAD test broken after previous tests improvements.
10% of times the data is not just "item 0" but there is also the
"otherfield" part. Use [lrange] to avoid the issue.
This commit fixes #4416.
2017-12-01 10:24:24 +01:00
antirez
5082ec6419 Streams: move ID ms/seq separator from '.' to '-'
After checking with the community via Twitter (here:
https://twitter.com/antirez/status/915130876861788161) the verdict was to
use ":". However I later realized, after users lamented the fact that
it's hard to copy IDs just with double click, that this was the reason
why I moved to "." in the first instance. Fortunately "-", that was the
other option with most votes, also gets selected with double click on
most terminal applications on Linux and MacOS.

So my reasoning was:

1) We can't retain "." because it's actually confusing to newcomers, it
looks like a floating number, people may be tricked into thinking they
can order IDs numerically as floats.

2) Moving to a double-click-to-select format is much better. People will
work with such IDs for long time when coding / debugging. Why making now
a choice that will impact this for the next years?

The only other viable option was "-", and that's what I did. Thanks.
2017-12-01 10:24:24 +01:00
antirez
e53c90308b Streams: add XADD + MAXLEN test. 2017-12-01 10:24:24 +01:00
antirez
7d0d9693c1 Streams: modify tests to stress compression. 2017-12-01 10:24:24 +01:00
antirez
ae9065d808 Streams: tests for blocking and non-blocking XREAD. 2017-12-01 10:24:24 +01:00
antirez
eb1230c999 Streams: XRANGE fuzz testing. 2017-12-01 10:24:24 +01:00
antirez
fa707ca154 Streams: more advanced XADD and XRANGE tests. 2017-12-01 10:24:24 +01:00
antirez
7a41b402c1 Streams: basic XADD tests. 2017-12-01 10:24:24 +01:00
antirez
dc2df135b3 Test: regression test for latency expire events logging bug.
Regression for #4452.
2017-11-24 18:33:31 +01:00
Oran Agra
adf2701cc9 fix string to double conversion, stopped parsing on \0 even if the string has more data.
getLongLongFromObject calls string2ll which has this line:
/* Return if not all bytes were used. */
so if you pass an sds with 3 characters "1\01" it will fail.

but getLongDoubleFromObject calls strtold, and considers it ok if eptr[0]==`\0`
i.e. if the end of the string found by strtold ends with null terminator

127.0.0.1:6379> set a 1
OK
127.0.0.1:6379> setrange a 2 2
(integer) 3
127.0.0.1:6379> get a
"1\x002"
127.0.0.1:6379> incrbyfloat a 2
"3"
127.0.0.1:6379> get a
"3"
2017-11-23 17:15:27 +02:00
antirez
b2e295971f Regression test for issue #4391. 2017-10-30 13:45:46 +01:00
antirez
b2cd9fcab6 Fix GEORADIUS edge case with huge radius.
This commit closes issue #3698, at least for now, since the root cause
was not fixed: the bounding box function, for huge radiuses, does not
return a correct bounding box, there are points still within the radius
that are left outside.

So when using GEORADIUS queries with radiuses in the order of 5000 km or
more, it was possible to see, at the edge of the area, certain points
not correctly reported.

Because the bounding box for now was used just as an optimization, and
such huge radiuses are not common, for now the optimization is just
switched off when the radius is near such magnitude.

Three test cases found by the Continuous Integration test were added, so
that we can easily trigger the bug again, both for regression testing
and in order to properly fix it as some point in the future.
2017-07-03 19:38:31 +02:00
xuzhou
530fcf8687 Fix set with ex/px option when propagated to aof 2017-06-16 17:51:38 +08:00
antirez
53cb27b1d7 SLOWLOG: log offending client address and name. 2017-06-15 12:57:54 +02:00
antirez
c861e1e1ee Defrag: test currently disabled, too many false positives.
Related to #3786.
2017-04-22 15:59:57 +02:00
antirez
a17390853d Defrag: fix test false positive.
Apparently 1.4 is too low compared to what you get in certain setups
(including mine). I raised it to 1.55 that hopefully is still enough to
test that the fragmentation went down from 1.7 but without incurring in
issues, however the test setup may be still fragile so certain times this
may lead to false positives again, it's hard to test for these things
in a determinsitic way.

Related to #3786.
2017-04-22 13:21:41 +02:00
oranagra
0fb5c4ebd8 add test for active defrag 2017-04-22 13:17:09 +02:00
Oran Agra
4acb4da1d1 add LFU policies to the test suite, just for coverage 2017-03-15 01:05:15 -07:00
antirez
95883313b5 Solaris fixes about tail usage and atomic vars.
Testing with Solaris C compiler (SunOS 5.11 11.2 sun4v sparc sun4v)
there were issues compiling due to atomicvar.h and running the
tests also failed because of "tail" usage not conform with Solaris
tail implementation. This commit fixes both the issues.
2017-02-22 13:08:21 +01:00
antirez
7c8ddab4f8 Test: fix conditional execution of HINCRBYFLOAT representation test. 2017-02-22 12:00:09 +01:00
antirez
af0284926c Geo: fuzzy test inconsistency report fixed to show all points.
We need to report all the points added into the set, not just the ones
matching the Tcl distance algo.
2016-12-20 12:22:11 +01:00
antirez
b1fc06f7eb Geo: improve fuzz test.
The test now uses more diverse radius sizes, especially sizes near or
greater the whole earth surface are used, that are known to trigger edge
cases. Moreover the PRNG seeding was probably resulting into the same
sequence tested over and over again, now seeding unsing the current unix
time in milliseconds.

Related to #3631.
2016-12-05 14:16:46 +01:00
antirez
f115461f4e Test: WAIT tests added in wait.tcl unit. 2016-11-18 13:10:29 +01:00
antirez
9749e96f42 Test: regression test for #3564 added. 2016-10-31 15:46:58 +01:00
antirez
f633212073 Fix SELECT test, broken cause change in error msg. 2016-10-14 15:48:11 +02:00
antirez
dacb69ed00 RDB AOF preamble: test it in the aofrw unit. 2016-08-24 15:39:39 +02:00
antirez
356a6304ec Multiple GEORADIUS bugs fixed.
By grepping the continuous integration errors log a number of GEORADIUS
tests failures were detected.

Fortunately when a GEORADIUS failure happens, the test suite logs enough
information in order to reproduce the problem: the PRNG seed,
coordinates and radius of the query.

By reproducing the issues, three different bugs were discovered and
fixed in this commit. This commit also improves the already good
reporting of the fuzzer and adds the failure vectors as regression
tests.

The issues found:

1. We need larger squares around the poles in order to cover the area
requested by the user. There were already checks in order to use a
smaller step (larger squares) but the limit set (+/- 67 degrees) is not
enough in certain edge cases, so 66 is used now.

2. Even near the equator, when the search area center is very near the
edge of the square, the north, south, west or ovest square may not be
able to fully cover the specified radius. Now a test is performed at the
edge of the initial guessed search area, and larger squares are used in
case the test fails.

3. Because of rounding errors between Redis and Tcl, sometimes the test
signaled false positives. This is now addressed.

Whenever possible the original code was improved a bit in other ways. A
debugging example stanza was added in order to make the next debugging
session simpler when the next bug is found.
2016-07-27 11:34:25 +02:00
antirez
abb3385e8d Regression test for issue #3333. 2016-07-06 11:50:20 +02:00
antirez
24bd9b19f6 Test: new randomized stress tester for #3343 alike bugs. 2016-06-28 09:42:20 +02:00
antirez
f983318e52 Stress tester WIP. 2016-06-28 09:33:36 +02:00
antirez
49899866c8 Regression test for issue #3343 exact min crash sequence.
Note: it was verified that it can crash the test suite without the patch
applied.
2016-06-28 09:27:14 +02:00
antirez
3bd20ea2f1 Test TOUCH and new TTL / TYPE behavior about object access time. 2016-06-15 17:15:51 +02:00
antirez
212f157855 Regression test for #3282. 2016-06-15 11:49:49 +02:00
Pierre Chapuis
d88c3c77be make RPUSHX and LPUSHX variadic 2016-06-05 16:50:24 +02:00
antirez
231c9db1b5 Now that SPOP can be called by scripts use BLPOP on 's' flag test. 2016-05-31 16:43:23 +02:00
antirez
078f46126c Test for BITFIELD regression #3221. 2016-05-18 14:53:30 +02:00
antirez
f9ee039a76 Scripting test: match new error message. 2016-05-06 09:12:56 +02:00
Oran Agra
5e3880a492 various cleanups and minor fixes 2016-04-25 16:49:57 +03:00
Damian Janowski
0b4bb502a2 Fix ZINCRBY return value. 2016-04-18 00:35:54 -03:00
antirez
28c291c55c BITFIELD: overflow wrap behavior fuzz tester. 2016-03-02 17:22:42 +01:00
antirez
ae7317e8e9 BITFIELD basic unit tests. 2016-03-02 16:31:02 +01:00
antirez
9a00da0d14 BITFIELD: overflow fuzzy testing. 2016-03-02 15:16:17 +01:00
antirez
27fc01a7b8 Fix typo in bitops.tcl comment. 2016-03-02 15:14:59 +01:00
James Rouzier
eca0187370 If the unit of a timeout is seconds treat it a float 2016-02-23 12:05:29 -05:00
antirez
f4befcc0ff GEOADD STORE/STOREDIST tests. 2016-02-18 14:42:42 +01:00
Salvatore Sanfilippo
8637384191 Merge pull request #2726 from seppo0010/patch-2
Fix race condition in unit/introspection
2016-01-15 16:24:06 +01:00
antirez
f43c794b0b Scripting: handle trailing comments.
This fix, provided by Paul Kulchenko (@pkulchenko), allows the Lua
scripting engine to evaluate statements with a trailing comment like the
following one:

    EVAL "print() --comment" 0

Lua can't parse the above if the string does not end with a newline, so
now a final newline is always added automatically. This does not change
the SHA1 of scripts since the SHA1 is computed on the body we pass to
EVAL, without the other code we add to register the function.

Close #2951.
2016-01-08 15:44:21 +01:00
antirez
82fd74a118 MIGRATE: test more corner cases. 2015-12-11 14:27:08 +01:00
antirez
29d680ed5a Test: pipelined MIGRATE tests added. 2015-12-11 13:41:58 +01:00
antirez
fceaa46dda Test HINCRBYFLOAT rounding only in x86_64 and when valgrind is not in use.
64 bit double math is not enough to make the test passing, and rounding
to 1.2999999 instead of 1.23 is not an error in the implementation.
Valgrind and sometimes other archs are not able to work with 80 bit
doubles.
2015-11-28 09:28:37 +01:00
antirez
f6255703b0 Add regression test for HINCRBYFLOAT formatting change.
This test was kindly provided by Jan-Erik Rediger (@badboy here on
Github) that discovered the issue.

See issue #2846.
2015-11-04 17:02:34 +01:00
antirez
30b324698f Test: improve PFCOUNT with multiple keys testing.
An user raised a question about a given behavior of PFCOUNT. Added a
test to show the behavior (union) is correct when most of the items are
in common.
2015-11-03 19:03:17 +01:00
antirez
5b63ae37ff Scripting: commands replication tests. 2015-10-30 12:06:09 +01:00
antirez
073a42b997 Scripting: execute tests with command replication as well. 2015-10-30 12:06:09 +01:00
antirez
eda06b51fb Scripting: test Redis provided Lua functions error reporting. 2015-10-30 12:06:09 +01:00
antirez
6ddcba6ec9 Test: basic lazyfree unit test. 2015-10-09 09:47:17 +02:00
antirez
ceaf58dfd5 Regression test for GEORADIUS COUNT arity check. 2015-10-06 09:27:29 +02:00
antirez
846da5b22e Test: fix false positive in HSTRLEN test.
HINCRBY* tests later used the value "tmp" that was sometimes generated
by the random key generation function. The result was ovewriting what
Tcl expected to be inside Redis with another value, causing the next
HSTRLEN test to fail.
2015-09-15 09:37:30 +02:00
antirez
3c23b5ffd0 GEORADIUS: Don't report duplicates when radius is huge.
Georadius works by computing the center + neighbors squares covering all
the area of the specified position and radius. Then a distance filter is
used to remove elements which are actually outside the range.

When a huge radius is used, like 5000 km or more, adjacent neighbors may
collide and be the same, leading to the reporting of the same element
multiple times. This only happens in the edge case of huge radius but is
not ideal.

A robust but slow solution would involve qsorting the range to remove
all the duplicates. However since the collisions are only in adjacent
boxes, for the way they are ordered in the code, it is much faster to
just check if the current box is the same as the previous one processed.

This commit adds a regression test for the bug.

Fixes #2767.
2015-09-14 23:10:50 +02:00
antirez
0a91fc459f Test: MOVE expire test improved.
Related to #2765.
2015-09-14 12:35:55 +02:00
antirez
f529a01c1b MOVE now can move TTL metadata as well.
MOVE was not able to move the TTL: when a key was moved into a different
database number, it became persistent like if PERSIST was used.

In some incredible way (I guess almost nobody uses Redis MOVE) this bug
remained unnoticed inside Redis internals for many years.
Finally Andy Grunwald discovered it and opened an issue.

This commit fixes the bug and adds a regression test.

Close #2765.
2015-09-14 12:30:00 +02:00
antirez
467de61c84 Test: print info on HSTRLEN test failure.
This additional info may provide more clues about the test randomly
failing from time to time. Probably the failure is due to some previous
test that overwrites the logical content in the Tcl variable, but this
will make the problem more obvious.
2015-09-07 11:14:52 +02:00
Sebastian Waisbrot
97a2248309 Fix race condition in unit/introspection
Make sure monitor is attached in one connection before issuing commands to be monitored in another one
2015-08-11 22:56:17 -07:00
antirez
b96af595a5 GEOENCODE / GEODECODE commands removed.
Rationale:

1. The commands look like internals exposed without a real strong use
case.
2. Whatever there is an use case, the client would implement the
commands client side instead of paying RTT just to use a simple to
reimplement library.
3. They add complexity to an otherwise quite straightforward API.

So for now KILLED ;-)
2015-07-09 17:42:59 +02:00
antirez
f108c687ad Geo: GEODIST and tests. 2015-06-29 12:44:34 +02:00
antirez
aae0a1f9cc Geo: GEOPOS command and tests. 2015-06-29 10:47:07 +02:00
antirez
f6edd0cb93 Geo: GEORADIUS COUNT tests. 2015-06-29 09:52:23 +02:00
antirez
7cd2a4e196 Geo: GEOENCODE test fixed for new return value. 2015-06-29 09:46:58 +02:00
antirez
cd91beea1c Geo: only one way to specify any given option. 2015-06-27 09:43:47 +02:00
antirez
fa9d62d34f Geo: from lat,lon API to lon,lat API according to GIS standard
The GIS standard and all the major DBs implementing GIS related
functions take coordinates as x,y that is longitude,latitude.
It was a bad start for Redis to do things differently, so even if this
means that existing users of the Geo module will be required to change
their code, Redis now conforms to the standard.

Usually Redis is very backward compatible, but this is not an exception
to this rule, since this is the first Geo implementation entering the
official Redis source code. It is not wise to try to be backward
compatible with code forks... :-)

Close #2637.
2015-06-26 10:58:27 +02:00
antirez
5fd756bf13 Geo: GEOHASH command test. 2015-06-24 16:34:20 +02:00
antirez
cf89a19f16 Geo: GEORADIUS fuzzy testing by reimplementing it in Tcl.
We set random points in the world, pick a random position, and check if
the returned points by Redis match the ones computed by Tcl by brute
forcing all the points using the distance between two points formula.

This approach is sounding since immediately resulted in finding a bug in
the original implementation.
2015-06-24 10:38:46 +02:00
antirez
0425c60381 Geo: test GEOADD with wrong input coordinates 2015-06-23 10:20:15 +02:00
antirez
575e247a0e Geo: fix tests after distance precision change 2015-06-22 15:00:37 +02:00
antirez
73134f6a0b Geo: removed JSON failing test (false positive)
Server output is matched to a pre-computed output. The last digits
differ because of rouding errors.
2015-06-22 11:16:36 +02:00
Matt Stancliff
7f4ac3d19c [In-Progress] Add Geo Commands
Current todo:
  - replace functions in zset.{c,h} with a new unified Redis
    zset access API.

Once we get the zset interface fixed, we can squash
relevant commits in this branch and have one nice commit
to merge into unstable.

This commit adds:
  - Geo commands
  - Tests; runnable with: ./runtest --single unit/geo
  - Geo helpers in deps/geohash-int/
  - src/geo.{c,h} and src/geojson.{c,h} implementing geo commands
  - Updated build configurations to get everything working
  - TEMPORARY: src/zset.{c,h} implementing zset score and zset
    range reading without writing to client output buffers.
  - Modified linkage of one t_zset.c function for use in zset.c

Conflicts:
	src/Makefile
	src/redis.c
2015-06-22 09:07:13 +02:00
antirez
39b49bcaaf Test: ZADD CH tests 2015-05-29 11:34:43 +02:00
antirez
23ba5c1092 Test: ZADD INCR test 2015-05-29 11:28:52 +02:00
antirez
910e72d1c1 Test: ZADD NX and XX options tests 2015-05-29 11:23:49 +02:00
Glenn Nethercutt
626b4f6907 uphold the smove contract to return 0 when the element is not a member of the source set, even if source=dest 2015-04-17 09:27:54 -04:00
antirez
084a59c324 Test: HSTRLEN stress test of corner cases.
Main point here is to correctly report LLONG_MIN length, since to take
the absolute value we need care in sdigits10().
2015-02-27 15:44:44 +01:00
antirez
4e54b85a19 Hash: HSTRLEN (was HVSTRLEN) improved.
1. HVSTRLEN -> HSTRLEN. It's unlikely one needs the length of the key,
   not clear how the API would work (by value does not make sense) and
   there will be better names anyway.
2. Default is to return 0 when field is missing.
3. Default is to return 0 when key is missing.
4. The implementation was slower than needed, and produced unnecessary COW.

Related issue #2415.
2015-02-27 15:31:55 +01:00
Salvatore Sanfilippo
b49c00a79c Merge pull request #2415 from landmime/unstable
added a new hvstrlen command
2015-02-27 15:24:04 +01:00
antirez
74354ceef5 Test: fixes a few tests after basic unit refactoring. 2015-02-25 10:37:52 +01:00
antirez
954151f62b Test: split basic unit into string, incr, keyspace units. 2015-02-25 10:33:29 +01:00
antirez
fc365a3a00 Change RENAME behavior when src and dst keys are the same.
Fixes issue #2392.
2015-02-23 11:24:24 +01:00
Jason Roth
db9461e466 added a new hvstrlen command
the hvstrlen command returns the length of a hash field value
2015-02-21 15:01:18 +00:00
antirez
dffbbb5a78 SPOP explicit tests for the three different code paths. 2015-02-11 10:52:28 +01:00
antirez
5e3dcc522b Faster memory efficiency test.
This test on Linux was extremely slow, since in Tcl we can't enable
easily tcp-nodelay, so the busy loop used to take *a lot* with bigger
writes. Fixed using pipelining.
2015-02-10 14:47:45 +01:00
Matt Stancliff
02bb515a09 Config: Add quicklist, remove old list options
This removes:
  - list-max-ziplist-entries
  - list-max-ziplist-value

This adds:
  - list-max-ziplist-size
  - list-compress-depth

Also updates config file with new sections and updates
tests to use quicklist settings instead of old list settings.
2015-01-02 11:16:10 -05:00
Matt Stancliff
e0d94a7b01 Increase test size for migrating large values
Previously, the old test ran 5,000 loops and used about 500k.

With quicklist, storing those same 5,000 loops takes up 24k, so the
"large value check" failed!

This increases the test to 20,000 loops which makes the object dump 96k.
2015-01-02 11:16:09 -05:00
Matt Stancliff
5e362b84ab Add quicklist implementation
This replaces individual ziplist vs. linkedlist representations
for Redis list operations.

Big thanks for all the reviews and feedback from everybody in
https://github.com/antirez/redis/pull/2143
2015-01-02 11:16:08 -05:00
Alon Diamant
288028876f Added <count> parameter to SPOP:
spopCommand() now runs spopWithCountCommand() in case the <count> param is found.
Added intsetRandomMembers() to Intset: Copies N random members from the set into inputted 'values' array. Uses either the Knuth or Floyd sample algos depending on ratio count/size.
Added setTypeRandomElements() to SET type: Returns a number of random elements from a non empty set. This is a version of setTypeRandomElement() that is modified in order to return multiple entries, using dictGetRandomKeys() and intsetRandomMembers().
Added tests for SPOP with <count>: unit/type/set, unit/scripting, integration/aof
--
Cleaned up code a bit to match with required Redis coding style
2014-12-14 12:25:42 +02:00
Salvatore Sanfilippo
c50693d40f Merge pull request #2094 from mattsta/nosort
Fix zero-ordering SORT when called against lists
2014-12-11 15:54:39 +01:00
antirez
b8a48ad5fe Regression test for issue #2175. 2014-12-03 10:38:56 +01:00
antirez
8a75ec0fca Merge remote-tracking branch 'origin/unstable' into unstable 2014-11-14 17:10:48 +01:00
Matt Stancliff
ace628c792 Lua: add cmsgpack scripting tests
Basically: test to make sure we can load cmsgpack
and do some sanity checks to make sure pack/unpack works
properly.  We also have a bonus test for circular encoding
and decoding because I was curious how it worked.
2014-11-14 17:08:57 +01:00
Matt Stancliff
e327c8edb9 Lua: add cjson scripting test
Two simple decode tests added mainly to check that
the 'cjson' global gets registered and is usable.
2014-11-14 17:08:22 +01:00
Matt Stancliff
6c0abc4a0e Fix zero-ordering SORT when called against lists
People mostly use SORT against lists, but our prior
behavior was pretending lists were an unordered bag
requiring a forced-sort when no sort was requested.

We can just use the native list ordering to ensure
consistency across replicaion and scripting calls.

Closes #2079
Closes #545 (again)
2014-10-29 14:57:35 -04:00
Matt Stancliff
3fecb96122 Lua: Add bitop
A few people have written custom C commands because bit
manipulation isn't exposed through Lua.  Let's give
them Mike Pall's bitop.

This adds bitop 1.0.2 (2012-05-08) from http://bitop.luajit.org/

bitop is imported as "bit" into the global namespace.

New Lua commands: bit.tobit, bit.tohex, bit.bnot, bit.band, bit.bor, bit.bxor,
bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror, bit.bswap

Verification of working (the asserts would abort on error, so (nil) is correct):
127.0.0.1:6379> eval "assert(bit.tobit(1) == 1); assert(bit.band(1) == 1); assert(bit.bxor(1,2) == 3); assert(bit.bor(1,2,4,8,16,32,64,128) == 255)" 0
(nil)
127.0.0.1:6379> eval 'assert(0x7fffffff == 2147483647, "broken hex literals"); assert(0xffffffff == -1 or 0xffffffff == 2^32-1, "broken hex literals"); assert(tostring(-1) == "-1", "broken tostring()"); assert(tostring(0xffffffff) == "-1" or tostring(0xffffffff) == "4294967295", "broken tostring()")' 0
(nil)

Tests also integrated into the scripting tests and can be run with:
./runtest --single unit/scripting

Tests are excerpted from `bittest.lua` included in the bitop distribution.
2014-10-09 11:51:30 -04:00
Salvatore Sanfilippo
3c6f9ac37c Merge pull request #1902 from mattsta/comment-fixes
ALL comment fixes
2014-10-06 09:44:54 +02:00
antirez
389ec305b3 Test: check that INCR object sharing works as expected. 2014-10-03 12:28:56 +01:00
Matt Stancliff
1cedebb799 Remove trailing spaces from tests 2014-09-29 06:49:08 -04:00
Matt Stancliff
09cb281bc3 Fix spelling in some test cases 2014-09-29 06:49:08 -04:00
Paddy Byers
a23502e5e8 Add regression test for issue #1939 2014-09-01 10:42:27 +02:00
Matt Stancliff
498ad7482b Reject MOVE to non-integer DBs
Previously, "MOVE key somestring" would move the key to
DB 0 which is just unexpected and wrong.
String as DB == error.

Test added too.

Modified by @antirez in order to use the getLongLongFromObject() API
instead of strtol().

Fixes #1428
2014-08-08 12:38:43 +02:00
Matt Stancliff
25791550e0 pubsub: Return integers for NUMSUB, not strings
Also adds test for numsub — due to tcl being tcl,
it doesn't capture the "numberness" of the fix,
but now we at least have one test case for numsub.

Closes #1561
2014-08-08 11:19:37 +02:00
Matt Stancliff
87815ab5ba Fix key extraction for SORT
We only want to use the last STORE key, but we have to record
we actually found a STORE key so we can increment the final return
key count.

Test added to prevent further regression.

Closes #1883, #1645, #1647
2014-08-07 16:14:15 +02:00
Jan-Erik Rediger
53fdfda9e3 Handle large getrange requests
Previously the end was casted to a smaller type
which resulted in a wrong check and failed
with values larger than handled by unsigned.

Closes #1847, #1844
2014-08-07 12:40:44 +02:00
Matt Stancliff
f17f8521f0 scripting: no eval with negative key count
Negative key count causes segfault in Lua functions.

Fixes #1842
Closes #1843
2014-08-07 12:38:36 +02:00
antirez
b9bb7e2d4a Test: check sorted set elements order after union.
This is not a regression but issue #1786 showed the need for this test.
2014-07-22 17:52:04 +02:00
antirez
509c888dfa Test: Pub/Sub PING. 2014-07-18 12:03:31 +02:00
antirez
420584a46d Test: small integer sharing depends on maxmemory policy. 2014-07-18 10:55:08 +02:00
antirez
3bf72d0d5f Test: more reliable AOF rewrite test under write load. 2014-07-10 16:42:43 +02:00
antirez
a94aa39c86 LATENCY command / monitor basic tests. 2014-07-10 16:23:54 +02:00
antirez
e01195e90d Test: AOF rewrite during write load. 2014-07-10 11:25:12 +02:00
antirez
1c343ec29f Test: use higher level redis.tcl proc to read replies. 2014-06-18 16:25:53 +02:00
antirez
aa19fd612b Scripting: regression test for issue #1811. 2014-06-12 16:20:30 +02:00
antirez
96e0fe6232 Fix semantics of Lua calls to SELECT.
Lua scripts are executed in the context of the currently selected
database (as selected by the caller of the script).

However Lua scripts are also free to use the SELECT command in order to
affect other DBs. When SELECT is called frm Lua, the old behavior, before
this commit, was to automatically set the Lua caller selected DB to the
last DB selected by Lua. See for example the following sequence of
commands:

    SELECT 0
    SET x 10
    EVAL "redis.call('select','1')" 0
    SET x 20

Before this commit after the execution of this sequence of commands,
we'll have x=10 in DB 0, and x=20 in DB 1.

Because of the problem above, there was a bug affecting replication of
Lua scripts, because of the actual implementation of replication. It was
possible to fix the implementation of Lua scripts in order to fix the
issue, but looking closely, the bug is the consequence of the behavior
of Lua ability to set the caller's DB.

Under the old semantics, a script selecting a different DB, has no simple
ways to restore the state and select back the previously selected DB.
Moreover the script auhtor must remember that the restore is needed,
otherwise the new commands executed by the caller, will be executed in
the context of a different DB.

So this commit fixes both the replication issue, and this hard-to-use
semantics, by removing the ability of Lua, after the script execution,
to force the caller to switch to the DB selected by the Lua script.

The new behavior of the previous sequence of commadns is to just set
X=20 in DB 0. However Lua scripts are still capable of writing / reading
from different DBs if needed.

WARNING: This is a semantical change that will break programs that are
conceived to select the client selected DB via Lua scripts.

This fixes issue #1811.
2014-06-12 16:05:52 +02:00
Matt Stancliff
76efe1225f Scripting: Fix regression from #1118
The new check-for-number behavior of Lua arguments broke
users who use large strings of just integers.

The Lua number check would convert the string to a number, but
that breaks user data because
Lua numbers have limited precision compared to an arbitrarily
precise number wrapped in a string.

Regression fixed and new test added.

Fixes #1118 again.
2014-06-10 14:26:13 -04:00
Salvatore Sanfilippo
c7f93143f6 Merge pull request #1669 from mattsta/blpop-internally-added-keys
Fix blocking operations from missing new lists
2014-06-09 11:37:28 +02:00
Salvatore Sanfilippo
e8ebd7d0e0 Merge pull request #1789 from yoav-steinberg/fix_eval_in_tests
Fix eval usage in tests to conform with eval semantics
2014-06-06 10:37:57 +02:00
antirez
3307db49bd Regression test for issue #1118. 2014-06-04 18:51:20 +02:00
antirez
17b05afda9 Test: dump.tcl fixed for RESTORE new error msg. 2014-05-22 15:56:17 +02:00
Matt Stancliff
33f943b4cd Fix blocking operations from missing new lists
Behrad Zari discovered [1] and Josiah reported [2]: if you block
and wait for a list to exist, but the list creates from
a non-push command, the blocked client never gets notified.

This commit adds notification of blocked clients into
the DB layer and away from individual commands.

Lists can be created by [LR]PUSH, SORT..STORE, RENAME, MOVE,
and RESTORE.  Previously, blocked client notifications were
only triggered by [LR]PUSH.  Your client would never get
notified if a list were created by SORT..STORE or RENAME or
a RESTORE, etc.

Blocked client notification now happens in one unified place:
  - dbAdd() triggers notification when adding a list to the DB

Two new tests are added that fail prior to this commit.

All test pass.

Fixes #1668

[1]: https://groups.google.com/forum/#!topic/redis-db/k4oWfMkN1NU
[2]: #1668
2014-05-21 09:52:52 -04:00
antirez
7f772355f4 Regression test for issue #1764. 2014-05-20 16:20:16 +02:00
antirez
a9e62ab9fa HyperLogLog regression test for issue #1762. 2014-05-19 15:44:04 +02:00
antirez
76c31d425e Scripting test: check that Lua can call commands rewirting argv.
SPOP, tested in the new test, is among the commands rewritng the
client->argv argument vector (it gets rewritten as SREM) for command
replication purposes.

Because of recent optimizations to client->argv caching in the context
of the Lua internal Redis client, it is important to test for SPOP to be
callable from Lua without bad effects to the other commands.
2014-05-07 16:12:32 +02:00
antirez
93e7a130fc Test: fixed scripting.tcl test false positive. 2014-04-24 21:44:32 +02:00
Salvatore Sanfilippo
32c917964e Merge pull request #1677 from mattsta/expire-before-delete
Check key expiration before deleting
2014-04-23 16:13:49 +02:00
yoav
fdaab02347 Merge remote-tracking branch 'upstream/unstable' into unstable 2014-04-22 10:01:21 +03:00
antirez
9caa1ae96a Fuzzy test for ZREMRANGEBYLEX added. 2014-04-18 13:02:16 +02:00
antirez
85a2f2354e PFCOUNT multi-key test added. 2014-04-18 12:36:33 +02:00
antirez
c0ccd4da7d Sorted set lex ranges stress tester. 2014-04-17 10:25:58 +02:00