Skip to content

Commit

Permalink
add makefile to support testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pubalokta committed Jul 25, 2024
1 parent 01044b6 commit 021dcb8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
33 changes: 16 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
#node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [18.x]
node-version: [14.x, 16.x, 18.x, 20.x]

steps:
- name: Checkout
Expand All @@ -29,26 +28,26 @@ jobs:
- name: install redis-ci
run: sudo apt-get install redis-tools

# - name: Install dependencies
# run: npm install

# - name: Setup Standalone Tests
# run: make test-standalone-setup
#
# - name: Run Standalone tests
# run: make test-standalone
#
# - name: Teardown Standalone Tests
# run: make test-standalone-teardown
#
- name: Install dependencies
run: npm install

- name: Setup Standalone Tests
run: make test-standalone-setup

- name: Run Standalone tests
run: make test-standalone

- name: Teardown Standalone Tests
run: make test-standalone-teardown

- name: Setup Clustered Tests
run: make test-cluster-setup

- name: Check Redis Cluster
run: redis-cli -c -p 16371 cluster info
run: timeout 60 bash <<< "until redis-cli -c -p 16371 cluster info | grep 'cluster_state:ok'; do sleep 1; done"

# - name: Run Clustered tests
# run: make test-cluster
- name: Run Clustered tests
run: make test-cluster

- name: Teardown Clustered Tests
run: make test-cluster-teardown
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ test-standalone-teardown:

test-cluster-setup:
docker-compose -f docker-compose-cluster.yml up -d
timeout 60s sh -c 'until ! docker ps | grep limitd-redis-redis-cluster-create; do echo "Waiting for cluster create container to finish..."; sleep 2; done'

test-cluster-teardown:
docker-compose -f docker-compose-cluster.yml down
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"test-standalone": "CLUSTERED_ENV=false NODE_ENV=test nyc mocha --exit",
"test-cluster": "DEBUG=ioredis:* CLUSTERED_ENV=true NODE_ENV=test nyc mocha --exit"
"test-cluster": "CLUSTERED_ENV=true NODE_ENV=test nyc mocha --exit"
},
"author": "Auth0",
"license": "MIT",
Expand Down
2 changes: 0 additions & 2 deletions test-resources/redis-cluster/redis-cluster-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ node_2_ip="0.0.0.0"
node_3_ip="0.0.0.0"

redis-cli --cluster create $node_1_ip:16371 $node_2_ip:16372 $node_3_ip:16373 --cluster-replicas 0 --cluster-yes
echo "Waiting for cluster status to be ok..."
timeout 60s sh -c 'until redis-cli -p 16371 -c cluster info | grep cluster_state:ok ; do echo "Waiting for cluster create container to finish..."; sleep 1; done'
2 changes: 1 addition & 1 deletion test/client.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const _ = require('lodash');
const assert = require('chai').assert;
const LimitRedis = require('../lib/client');
const ValidationError = LimitRedis.ValidationError;
const clusterNodes = [{ host: 'localhost', port: 16371 }, { host: 'localhost', port: 16372 }, { host: 'localhost', port: 16373 }];
const clusterNodes = [{ host: '127.0.0.1', port: 16371 }, { host: '127.0.0.1', port: 16372 }, { host: '127.0.0.1', port: 16373 }];

const standaloneClientFn = (params) => {
return new LimitRedis({ uri: 'localhost', buckets: {}, prefix: 'tests:', ..._.omit(params, ['nodes']) });
Expand Down
2 changes: 1 addition & 1 deletion test/db.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { Toxiproxy, Toxic } = require('toxiproxy-node-client');
const crypto = require('crypto');
const { endOfMonthTimestamp, replicateHashtag } = require('../lib/utils');

const clusterNodes = [{ host: 'localhost', port: 16371 }, { host: 'localhost', port: 16372 }, { host: 'localhost', port: 16373 }];
const clusterNodes = [{ host: '127.0.0.1', port: 16371 }, { host: '127.0.0.1', port: 16372 }, { host: '127.0.0.1', port: 16373 }];

const standaloneClientFn = (params) => {
return new LimitDB({ uri: 'localhost', buckets: {}, prefix: 'tests:', ..._.omit(params, ['nodes']) });
Expand Down

0 comments on commit 021dcb8

Please sign in to comment.