-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Joe Hu <[email protected]> Signed-off-by: Joe Hu <[email protected]> Co-authored-by: Joe Hu <[email protected]>
- Loading branch information
Showing
14 changed files
with
124 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#### How to create rdb file for a new ReJSON release? | ||
|
||
e.g., testing RDB compatibility with rejson 2.2.0. | ||
|
||
1. Run docker image redis-stack: | ||
```text | ||
docker run -d -p 6379:6379 --name rejson redislabs/rejson:2.2.0 | ||
``` | ||
2. Load store.json and create a key named "store": | ||
```text | ||
python3 utils/load_1file_hostport.py tst/integration/data/store.json store | ||
``` | ||
3. Save rdb: | ||
```text | ||
valkey-cli save | ||
``` | ||
4. Copy out the RDB file: | ||
```text | ||
docker cp $(docker ps -q):/data/dump.rdb tst/integration/rdb_rejson/rejson-<version>.rdb | ||
``` | ||
5. run test_json_rdb_import.py: | ||
```text | ||
TEST_PATTERN=test_import_rejson_rdbs make test | ||
``` |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!python3 | ||
# | ||
# Load a JSON file and create a key. | ||
# Usage: | ||
# [HOST=<host>] [PORT=<port>] [SSL=<ssl>] python3 load_1file_hostport.py <path_to_json> <key> | ||
# | ||
# e.g. | ||
# python3 load_1file_hostport.py ../amztests/data/wikipedia.json wikipedia | ||
# PORT=6380 python3 load_1file_hostport.py ../amztests/data/wikipedia.json wikipedia | ||
# | ||
import redis, sys, os, logging | ||
from redis.exceptions import ResponseError, ConnectionError, TimeoutError | ||
|
||
if len(sys.argv) < 3: | ||
print("Usage: [HOST=<host>] [PORT=<port>] [SSL=<ssl>] python3 load_1file_hostport.py <path_to_json> <redis_key>") | ||
exit(1) | ||
|
||
host = os.getenv('HOST', 'localhost') | ||
port = os.getenv('PORT', '6379') | ||
ssl = os.getenv('SSL', 'False') | ||
is_ssl = (ssl == 'True') | ||
json_file_path = sys.argv[1] | ||
key = sys.argv[2] | ||
|
||
r = redis.Redis(host=host, port=port, ssl=is_ssl, socket_timeout=3) | ||
try: | ||
r.ping() | ||
logging.info(f"Connected to valkey {host}:{port}, ssl: {is_ssl}") | ||
except (ConnectionError, TimeoutError): | ||
logging.error(f"Failed to connect to valkey {host}:{port}, ssl: {is_ssl}") | ||
exit(1) | ||
|
||
def load_file(json_file_path, key): | ||
with open(json_file_path, 'r') as f: | ||
data = f.read() | ||
r.execute_command('json.set', key, '.', data) | ||
logging.info("Created key %s" %key) | ||
|
||
load_file(json_file_path, key) |