Skip to content

Commit 1a4a155

Browse files
committed
Clean up
Signed-off-by: Kevin Zhang <kzhang@tecton.ai>
1 parent 0b5dabd commit 1a4a155

3 files changed

Lines changed: 39 additions & 33 deletions

File tree

.github/workflows/pr_integration_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,4 @@ jobs:
169169
flags: integrationtests
170170
env_vars: OS,PYTHON
171171
fail_ci_if_error: true
172-
verbose: true
172+
verbose: true

docs/how-to-guides/adding-or-reusing-tests.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_historical_features(environment, universal_data_sources, full_feature_n
7979
datasets["global"],
8080
datasets["entity"],
8181
)
82-
82+
8383
# ... more test code
8484

8585
customer_fv, driver_fv, driver_odfv, order_fv, global_fv = (
@@ -93,7 +93,7 @@ def test_historical_features(environment, universal_data_sources, full_feature_n
9393
feature_service = FeatureService(
9494
"convrate_plus100",
9595
features=[
96-
feature_views["driver"][["conv_rate"]],
96+
feature_views["driver"][["conv_rate"]],
9797
feature_views["driver_odfv"]
9898
],
9999
)
@@ -138,7 +138,7 @@ def test_historical_features(environment, universal_data_sources, full_feature_n
138138
assert_frame_equal(
139139
expected_df, actual_df_from_df_entities, check_dtype=False,
140140
)
141-
141+
142142
# ... more test code
143143
```
144144
{% endtab %}
@@ -186,6 +186,24 @@ def your_test(environment: Environment):
186186
your_fv = driver_feature_view(data_source)
187187
entity = driver(value_type=ValueType.UNKNOWN)
188188
fs.apply([fv, entity])
189-
189+
190190
# ... run test
191191
```
192+
193+
### Running your own redis cluster for testing
194+
195+
* Install redis on your computer. If you are a mac user, you should be able to `brew install redis`.
196+
* Running `redis-server --help` and `redis-cli --help` should show corresponding help menus.
197+
* Run `cd scripts/create-cluster` and run `./create-cluster start` then `./create-cluster create` to start the server. You should see output that looks like this:
198+
~~~~
199+
Starting 6001
200+
Starting 6002
201+
Starting 6003
202+
Starting 6004
203+
Starting 6005
204+
Starting 6006
205+
~~~~
206+
* You should be able to run the integration tests and have the redis cluster tests pass.
207+
* If you would like to run your own redis cluster, you can run the above commands with your own specified ports and connect to the newly configured cluster.
208+
* To stop the cluster, run `./create-cluster stop` and then `./create-cluster clean`.
209+

scripts/create-cluster

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Settings
22
# Make sure you run "brew install redis"
3-
# Assumes you are running a Mac OS environment
4-
BIN_PATH="/opt/homebrew/bin"
3+
4+
# BIN_PATH="/opt/homebrew/bin"
5+
REDIS_CLI=`which redis-cli`
6+
REDIS_SERVER=`which redis-server`
57
CLUSTER_HOST=127.0.0.1
6-
PORT=6000
7-
TIMEOUT=2000
88
# Creates a cluster at ports 6001-6006 with 3 masters 6001-6003 and 3 slaves 6004-6006
9+
PORT=${2:-6000}
10+
TIMEOUT=2000
911
NODES=6
1012
REPLICAS=1
1113
PROTECTED_MODE=yes
@@ -24,7 +26,7 @@ then
2426
while [ $((PORT < ENDPORT)) != "0" ]; do
2527
PORT=$((PORT+1))
2628
echo "Starting $PORT"
27-
$BIN_PATH/redis-server --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS}
29+
$REDIS_SERVER --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS}
2830
done
2931
exit 0
3032
fi
@@ -40,7 +42,7 @@ then
4042
if [ "$2" == "-f" ]; then
4143
OPT_ARG="--cluster-yes"
4244
fi
43-
$BIN_PATH/redis-cli --cluster create $HOSTS --cluster-replicas $REPLICAS $OPT_ARG
45+
$REDIS_CLI --cluster create $HOSTS --cluster-replicas $REPLICAS $OPT_ARG
4446
exit 0
4547
fi
4648

@@ -49,7 +51,7 @@ then
4951
while [ $((PORT < ENDPORT)) != "0" ]; do
5052
PORT=$((PORT+1))
5153
echo "Stopping $PORT"
52-
$BIN_PATH/redis-cli -p $PORT shutdown nosave
54+
$REDIS_CLI -p $PORT shutdown nosave
5355
done
5456
exit 0
5557
fi
@@ -60,26 +62,12 @@ then
6062
while [ 1 ]; do
6163
clear
6264
date
63-
$BIN_PATH/redis-cli -p $PORT cluster nodes | head -30
65+
$REDIS_CLI -p $PORT cluster nodes | head -30
6466
sleep 1
6567
done
6668
exit 0
6769
fi
6870

69-
if [ "$1" == "tail" ]
70-
then
71-
INSTANCE=$2
72-
PORT=$((PORT+INSTANCE))
73-
tail -f ${PORT}.log
74-
exit 0
75-
fi
76-
77-
if [ "$1" == "tailall" ]
78-
then
79-
tail -f *.log
80-
exit 0
81-
fi
82-
8371
if [ "$1" == "clean" ]
8472
then
8573
echo "Cleaning *.log"
@@ -101,9 +89,9 @@ then
10189
fi
10290

10391
echo "Usage: $0 [start|create|stop|watch|clean|clean-logs|call]"
104-
echo "start -- Launch Redis Cluster instances."
105-
echo "create [-f] -- Create a cluster using redis-cli --cluster create."
106-
echo "stop -- Stop Redis Cluster instances."
107-
echo "watch -- Show CLUSTER NODES output (first 30 lines) of first node."
108-
echo "clean -- Remove all instances data, logs, configs."
109-
echo "clean-logs -- Remove just instances logs."
92+
echo "start [PORT] -- Launch Redis Cluster instances."
93+
echo "create [PORT] [-f] -- Create a cluster using redis-cli --cluster create."
94+
echo "stop [PORT] -- Stop Redis Cluster instances."
95+
echo "watch [PORT] -- Show CLUSTER NODES output (first 30 lines) of first node."
96+
echo "clean -- Remove all instances data, logs, configs."
97+
echo "clean-logs -- Remove just instances logs."

0 commit comments

Comments
 (0)