Skip to content

Commit

Permalink
Add shell script to start redis-cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth More authored and Siddharth More committed Nov 28, 2023
1 parent 54e1c83 commit 760ed68
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
31 changes: 31 additions & 0 deletions inabox/create-redis-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
set -e

REDIS_CLUSTER_ID="test-eigenda-redis-cluster"
REDIS_PORT="6379"
AWS_REGION="us-east-1"

# Check if the Redis cluster already exists
function redis_cluster_exists() {
aws elasticache describe-cache-clusters --region $AWS_REGION | grep -q $REDIS_CLUSTER_ID
return $?
}

# Start Redis service using LocalStack
function create_redis_cluster() {
aws elasticache create-cache-cluster \
--cache-cluster-id $REDIS_CLUSTER_ID \
--engine redis \
--cache-node-type cache.t2.micro \
--num-cache-nodes 1 \
--port $REDIS_PORT \
--region $AWS_REGION
}

# Check if Redis cluster exists and create it if it does not
if redis_cluster_exists; then
echo "Redis cluster $REDIS_CLUSTER_ID already exists."
else
echo "Creating Redis cluster $REDIS_CLUSTER_ID."
create_redis_cluster
fi
10 changes: 9 additions & 1 deletion inabox/deploy/localstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,16 @@ func DeployResources(pool *dockertest.Pool, localStackPort, metadataTableName, b

_, err = test_utils.CreateTable(context.Background(), cfg, bucketTableName, store.GenerateTableSchema(10, 10, bucketTableName))

return err
// Create Redis Cluster
if err := pool.Retry(func() error {
fmt.Println("Creating Redis Cluster")
return execCmd("./create-redis-cluster.sh", []string{}, []string{fmt.Sprintf("AWS_URL=http://0.0.0.0:%s", localStackPort)})
}); err != nil {
fmt.Println("Could not connect to docker to create Redis cluster:", err)
return err
}

return err
}

func PurgeDockertestResources(pool *dockertest.Pool, resource *dockertest.Resource) {
Expand Down

0 comments on commit 760ed68

Please sign in to comment.