Skip to content

Commit 3e4bf5f

Browse files
authored
Merge pull request #421 from FalkorDB/add-falkordb-tests
chore: add FalkorDB tests
1 parent f64448f commit 3e4bf5f

File tree

17 files changed

+370
-28
lines changed

17 files changed

+370
-28
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
9+
### Added
10+
- Add tests to ensure FalkorDB Graphs are correctly handled

dt-tests/docker-compose.ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,37 @@ services:
183183
start_period: 10s
184184
interval: 3s
185185

186+
# FalkorDB (RedisGraph) instances
187+
falkordb-src:
188+
image: falkordb/falkordb:v4.12.5
189+
container_name: falkordb-src-ci
190+
ports:
191+
- "6381:6379"
192+
healthcheck:
193+
test: ["CMD", "redis-cli", "-a", "123456", "ping"]
194+
timeout: 5s
195+
retries: 5
196+
start_period: 10s
197+
interval: 3s
198+
environment:
199+
- REDIS_ARGS=--requirepass 123456 --save 60 1 --loglevel warning
200+
- FALKORDB_ARGS=MAX_INFO_QUERIES 0
201+
202+
falkordb-dst:
203+
image: falkordb/falkordb:v4.12.5
204+
container_name: falkordb-dst-ci
205+
ports:
206+
- "6391:6379"
207+
healthcheck:
208+
test: ["CMD", "redis-cli", "-a", "123456", "ping"]
209+
timeout: 5s
210+
retries: 5
211+
start_period: 10s
212+
interval: 3s
213+
environment:
214+
- REDIS_ARGS=--requirepass 123456 --save 60 1 --loglevel warning
215+
- FALKORDB_ARGS=MAX_INFO_QUERIES 0
216+
186217
# ClickHouse for testing
187218
clickhouse:
188219
image: yandex/clickhouse-server:21.8

dt-tests/tests/.env

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,20 @@ redis_sinker_url_7_0=redis://:[email protected]:6390
5252
redis_extractor_url_8_0=redis://:[email protected]:6385
5353
redis_sinker_url_8_0=redis://:[email protected]:6395
5454

55-
redis_extractor_url_2_8=redis://:@[host]:6379
56-
redis_sinker_url_2_8=redis://:@[host]:6379
55+
redis_extractor_url_2_8=redis://:@127.0.0.1:6379
56+
redis_sinker_url_2_8=redis://:@127.0.0.1:6379
5757

58-
redis_extractor_url_rebloom=redis://:@[host]:6379
59-
redis_sinker_url_rebloom=redis://:@[host]:6379
58+
redis_extractor_url_rebloom=redis://:@127.0.0.1:6379
59+
redis_sinker_url_rebloom=redis://:@127.0.0.1:6379
6060

61-
redis_extractor_url_redisearch=redis://:@[host]:6379
62-
redis_sinker_url_redisearch=redis://:@[host]:6379
61+
redis_extractor_url_redisearch=redis://:@127.0.0.1:6379
62+
redis_sinker_url_redisearch=redis://:@127.0.0.1:6379
6363

64-
redis_extractor_url_rejson=redis://:@[host]:6379
65-
redis_sinker_url_rejson=redis://:@[host]:6379
64+
redis_extractor_url_rejson=redis://:@127.0.0.1:6380
65+
redis_sinker_url_rejson=redis://:@127.0.0.1:6390
66+
67+
redis_extractor_url_graph=redis://:@127.0.0.1:6381
68+
redis_sinker_url_graph=redis://:@127.0.0.1:6391
6669

6770
# redis cluster
6871
redis_cluster_sinker_url=redis://:@127.0.0.1:6371
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flushall
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flushall
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
-- Create nodes
2+
GRAPH.QUERY graph1 "CREATE (:Person {name: 'John', age: 30})"
3+
GRAPH.QUERY graph1 "CREATE (:Person {name: 'Jane', age: 25})"
4+
GRAPH.QUERY graph1 "CREATE (:Company {name: 'TechCorp', founded: 2010})"
5+
6+
-- Create relationships
7+
GRAPH.QUERY graph2 "CREATE (:Person {name: 'Alice', age: 28})-[:WORKS_FOR {since: 2020}]->(:Company {name: 'DataCorp', employees: 500})"
8+
GRAPH.QUERY graph2 "MATCH (p:Person {name: 'Alice'}), (c:Company {name: 'DataCorp'}) CREATE (p)-[:LIVES_IN]->(:City {name: 'New York', population: 8000000})"
9+
10+
-- Match and return queries
11+
GRAPH.QUERY graph3 "MATCH (p:Person) RETURN p.name, p.age"
12+
GRAPH.QUERY graph3 "MATCH (p:Person)-[:WORKS_FOR]->(c:Company) RETURN p.name, c.name"
13+
14+
-- Update node properties
15+
GRAPH.QUERY graph4 "CREATE (:Employee {id: 1, name: 'Bob', salary: 50000})"
16+
GRAPH.QUERY graph4 "MATCH (e:Employee {id: 1}) SET e.salary = 55000"
17+
GRAPH.QUERY graph4 "MATCH (e:Employee {id: 1}) SET e.department = 'Engineering'"
18+
19+
-- Delete operations
20+
GRAPH.QUERY graph5 "CREATE (:TempNode {id: 'temp1'})"
21+
GRAPH.QUERY graph5 "MATCH (t:TempNode {id: 'temp1'}) DELETE t"
22+
23+
-- Create with multiple nodes and relationships
24+
GRAPH.QUERY graph6 "CREATE (p1:Person {name: 'Charlie', age: 35})-[:KNOWS {since: 2015}]->(p2:Person {name: 'David', age: 32})-[:WORKS_FOR]->(c:Company {name: 'StartupXYZ'})"
25+
26+
-- Complex queries with WHERE clauses
27+
GRAPH.QUERY graph7 "CREATE (:Product {name: 'Laptop', price: 1200, category: 'Electronics'})"
28+
GRAPH.QUERY graph7 "CREATE (:Product {name: 'Book', price: 25, category: 'Education'})"
29+
GRAPH.QUERY graph7 "MATCH (p:Product) WHERE p.price > 100 RETURN p.name, p.price"
30+
31+
-- Aggregation queries
32+
GRAPH.QUERY graph8 "CREATE (:Order {id: 1, amount: 150, date: '2023-01-15'})"
33+
GRAPH.QUERY graph8 "CREATE (:Order {id: 2, amount: 300, date: '2023-01-16'})"
34+
GRAPH.QUERY graph8 "MATCH (o:Order) RETURN count(o), sum(o.amount), avg(o.amount)"
35+
36+
-- Path queries
37+
GRAPH.QUERY graph9 "CREATE (a:Airport {code: 'JFK', city: 'New York'})-[:FLIGHT {duration: 360}]->(b:Airport {code: 'LAX', city: 'Los Angeles'})"
38+
GRAPH.QUERY graph9 "CREATE (b:Airport {code: 'LAX'})-[:FLIGHT {duration: 240}]->(c:Airport {code: 'SFO', city: 'San Francisco'})"
39+
GRAPH.QUERY graph9 "MATCH path = (a:Airport {code: 'JFK'})-[:FLIGHT*1..2]->(c:Airport) RETURN path"
40+
41+
-- Update relationships
42+
GRAPH.QUERY graph10 "CREATE (p:Person {name: 'Eve'})-[r:FRIEND_OF {since: 2020}]->(f:Person {name: 'Frank'})"
43+
GRAPH.QUERY graph10 "MATCH (p:Person {name: 'Eve'})-[r:FRIEND_OF]->(f:Person {name: 'Frank'}) SET r.closeness = 'high'"
44+
45+
-- Conditional updates
46+
GRAPH.QUERY graph11 "CREATE (:User {id: 1, status: 'active', last_login: '2023-01-01'})"
47+
GRAPH.QUERY graph11 "MATCH (u:User {id: 1}) SET u.status = CASE WHEN u.last_login < '2023-06-01' THEN 'inactive' ELSE 'active' END"
48+
49+
-- Multiple labels
50+
GRAPH.QUERY graph12 "CREATE (:Person:Employee {name: 'Grace', id: 123, department: 'HR'})"
51+
GRAPH.QUERY graph12 "MATCH (pe:Person:Employee) RETURN pe.name, pe.department"
52+
53+
-- Index operations (if supported)
54+
GRAPH.QUERY graph13 "CREATE (:Customer {email: '[email protected]', name: 'John Doe'})"
55+
GRAPH.QUERY graph13 "CREATE (:Customer {email: '[email protected]', name: 'Jane Smith'})"
56+
57+
-- Complex relationship patterns
58+
GRAPH.QUERY graph14 "CREATE (m:Manager {name: 'Sarah'})-[:MANAGES]->(e1:Employee {name: 'Tom'}), (m)-[:MANAGES]->(e2:Employee {name: 'Lisa'})"
59+
GRAPH.QUERY graph14 "MATCH (m:Manager)-[:MANAGES]->(e:Employee) RETURN m.name, collect(e.name)"
60+
61+
-- Optional match
62+
GRAPH.QUERY graph15 "CREATE (:Person {name: 'Alex'})"
63+
GRAPH.QUERY graph15 "CREATE (:Person {name: 'Beth'})-[:HAS_PHONE]->(:Phone {number: '555-0123'})"
64+
GRAPH.QUERY graph15 "MATCH (p:Person) OPTIONAL MATCH (p)-[:HAS_PHONE]->(phone:Phone) RETURN p.name, phone.number"
65+
66+
-- Union queries
67+
GRAPH.QUERY graph16 "CREATE (:Student {name: 'Mike', grade: 'A'})"
68+
GRAPH.QUERY graph16 "CREATE (:Teacher {name: 'Prof. Wilson', subject: 'Math'})"
69+
GRAPH.QUERY graph16 "MATCH (s:Student) RETURN s.name AS name, 'Student' AS type UNION MATCH (t:Teacher) RETURN t.name AS name, 'Teacher' AS type"
70+
71+
-- Delete with relationships
72+
GRAPH.QUERY graph17 "CREATE (p:Person {name: 'DeleteMe'})-[:OWNS]->(c:Car {model: 'Toyota'})"
73+
GRAPH.QUERY graph17 "MATCH (p:Person {name: 'DeleteMe'})-[r:OWNS]->(c:Car) DELETE r, p, c"
74+
75+
-- Bulk operations
76+
GRAPH.QUERY graph18 "UNWIND range(1, 5) AS i CREATE (:Number {value: i})"
77+
GRAPH.QUERY graph18 "MATCH (n:Number) WHERE n.value % 2 = 0 SET n.type = 'even'"
78+
GRAPH.QUERY graph18 "MATCH (n:Number) WHERE n.value % 2 = 1 SET n.type = 'odd'"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[extractor]
2+
db_type=redis
3+
extract_type=cdc
4+
repl_id=
5+
now_db_id=0
6+
repl_port=10008
7+
repl_offset=0
8+
heartbeat_interval_secs=10
9+
url={redis_extractor_url_graph}
10+
11+
[filter]
12+
do_dbs=*
13+
do_events=
14+
ignore_dbs=
15+
ignore_tbs=
16+
do_tbs=
17+
18+
[sinker]
19+
db_type=redis
20+
sink_type=write
21+
url={redis_sinker_url_graph}
22+
batch_size=2
23+
24+
[router]
25+
db_map=
26+
col_map=
27+
tb_map=
28+
29+
[pipeline]
30+
buffer_size=4
31+
checkpoint_interval_secs=1
32+
33+
[parallelizer]
34+
parallel_type=redis
35+
parallel_size=2
36+
37+
[runtime]
38+
log_level=info
39+
log4rs_file=./log4rs.yaml
40+
log_dir=./logs
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#[cfg(test)]
2+
mod test {
3+
use crate::test_runner::test_base::TestBase;
4+
use serial_test::serial;
5+
6+
#[tokio::test]
7+
#[serial]
8+
async fn cdc_cmds_test() {
9+
TestBase::run_redis_graph_cdc_test("redis_to_redis/cdc/graph/cmds_test", 2000, 10000).await;
10+
}
11+
}

dt-tests/tests/redis_to_redis/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub mod cdc_6_2_tests;
66
pub mod cdc_7_0_tests;
77
pub mod cdc_8_0_tests;
88
pub mod cdc_cross_version_tests;
9+
pub mod cdc_graph_tests;
910
pub mod cdc_rebloom_tests;
1011
pub mod cdc_redisearch_tests;
1112
pub mod cdc_rejson_tests;
@@ -19,6 +20,7 @@ pub mod snapshot_7_0_tests;
1920
pub mod snapshot_8_0_tests;
2021
pub mod snapshot_and_cdc_7_0_tests;
2122
pub mod snapshot_cross_version_tests;
23+
pub mod snapshot_graph_tests;
2224
pub mod snapshot_rebloom_tests;
2325
pub mod snapshot_redisearch_tests;
2426
pub mod snapshot_rejson_tests;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flushall

0 commit comments

Comments
 (0)