Skip to content

Commit

Permalink
Merge pull request #902 from camptocamp/test
Browse files Browse the repository at this point in the history
Fix master, for Redis 6.2
  • Loading branch information
sbrunner authored Mar 1, 2021
2 parents f23ff09 + 3c9f8d1 commit 5221630
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- DL3008
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ build_test_app: build_docker
.PHONY: pull
pull:
for image in `find -name "Dockerfile*" | xargs grep --no-filename FROM | awk '{print $$2}' | sort -u | grep -v c2cwsgiutils`; do docker pull $$image; done
for image in `find -name "docker-compose*.yml" | xargs grep --no-filename "image:" | awk '{print $$2}' | sort -u | grep -v $(DOCKER_BASE) | grep -v rancher`; do docker pull $$image; done
for image in `find -name "docker-compose*.yaml" | xargs grep --no-filename "image:" | awk '{print $$2}' | sort -u | grep -v $(DOCKER_BASE) | grep -v rancher`; do docker pull $$image; done

.PHONY: run
run: build_test_app
TEST_IP=172.17.0.1 docker-compose -f acceptance_tests/tests/docker-compose.yaml up
TEST_IP=172.17.0.1 docker-compose --file=acceptance_tests/tests/docker-compose.yaml up

.PHONY: mypy_local
mypy_local: .venv/timestamp
Expand Down
4 changes: 0 additions & 4 deletions acceptance_tests/tests/redis/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
FROM redis:6

RUN apt-get update && \
apt-get install --yes curl && \
apt-get clean

COPY entrypoint /

EXPOSE 26379
Expand Down
70 changes: 34 additions & 36 deletions acceptance_tests/tests/redis/entrypoint
Original file line number Diff line number Diff line change
@@ -1,86 +1,84 @@
#!/usr/bin/env bash

set -e

SENTINEL_CONFIGURATION_FILE=/etc/sentinel.conf

if [ "$AWS_IP_DISCOVERY" ]; then
ANNOUNCE_IP=`curl http://169.254.169.254/latest/meta-data/local-ipv4`
fi

DEFAULT_REDIS_PORT=6379
: ${REDIS_PORT:=$DEFAULT_REDIS_PORT}
: ${SENTINEL_PORT:=26379}
: "${REDIS_PORT:=$DEFAULT_REDIS_PORT}"
: "${SENTINEL_PORT:=26379}"

# Backward compatibility fix previously existed DEFAULT_PORT
if [ "$DEFAULT_PORT" ] && [ "$REDIS_PORT" -eq $DEFAULT_REDIS_PORT ]; then
REDIS_PORT=$DEFAULT_PORT
REDIS_PORT=$DEFAULT_PORT
fi

: ${QUORUM:=2}
: ${DOWN_AFTER:=30000}
: ${FAILOVER_TIMEOUT:=180000}
: ${PARALLEL_SYNCS:=1}
: "${QUORUM:=2}"
: "${DOWN_AFTER:=30000}"
: "${FAILOVER_TIMEOUT:=180000}"
: "${PARALLEL_SYNCS:=1}"

parse_addr () {
parse_addr() {
local _retvar=$1
IFS=':' read -ra ADDR <<< "$2"
IFS=':' read -ra ADDR <<<"$2"

if [ "${ADDR[1]}" = "" ]; then
ADDR[1]=$REDIS_PORT
fi

eval $_retvar='("${ADDR[@]}")'
eval "$_retvar"='("${ADDR[@]}")'
}

print_slave () {
print_slave() {
local -a ADDR
parse_addr ADDR $1
echo "sentinel known-slave $MASTER_NAME ${ADDR[0]} ${ADDR[1]}" >> $SENTINEL_CONFIGURATION_FILE
parse_addr ADDR "$1"
echo "sentinel known-slave $MASTER_NAME ${ADDR[0]} ${ADDR[1]}" >>$SENTINEL_CONFIGURATION_FILE
}

print_master () {
print_master() {
local -a ADDR
parse_addr ADDR $1
echo "sentinel monitor $MASTER_NAME ${ADDR[0]} ${ADDR[1]} $QUORUM" >> $SENTINEL_CONFIGURATION_FILE
parse_addr ADDR "$1"
echo "sentinel monitor $MASTER_NAME ${ADDR[0]} ${ADDR[1]} $QUORUM" >>$SENTINEL_CONFIGURATION_FILE
}

echo "port $SENTINEL_PORT" > $SENTINEL_CONFIGURATION_FILE
echo "port $SENTINEL_PORT" >$SENTINEL_CONFIGURATION_FILE

if [ "$ANNOUNCE_IP" ]; then
echo "sentinel announce-ip $ANNOUNCE_IP" >> $SENTINEL_CONFIGURATION_FILE
echo "sentinel announce-ip $ANNOUNCE_IP" >>$SENTINEL_CONFIGURATION_FILE
fi

if [ "$ANNOUNCE_PORT" ]; then
echo "sentinel announce-port $ANNOUNCE_PORT" >> $SENTINEL_CONFIGURATION_FILE
echo "sentinel announce-port $ANNOUNCE_PORT" >>$SENTINEL_CONFIGURATION_FILE
fi

if [ "$MASTER_NAME" ]; then
print_master $MASTER
echo "sentinel down-after-milliseconds $MASTER_NAME $DOWN_AFTER" >> $SENTINEL_CONFIGURATION_FILE
echo "sentinel failover-timeout $MASTER_NAME $FAILOVER_TIMEOUT" >> $SENTINEL_CONFIGURATION_FILE
echo "sentinel parallel-syncs $MASTER_NAME $PARALLEL_SYNCS" >> $SENTINEL_CONFIGURATION_FILE
print_master "${MASTER}"
{
echo "sentinel down-after-milliseconds $MASTER_NAME $DOWN_AFTER"
echo "sentinel failover-timeout $MASTER_NAME $FAILOVER_TIMEOUT"
echo "sentinel parallel-syncs $MASTER_NAME $PARALLEL_SYNCS"
echo "sentinel resolve-hostnames yes"
} >>$SENTINEL_CONFIGURATION_FILE

if [ "$NOTIFICATION_SCRIPT" ]; then
echo "sentinel notification-script $MASTER_NAME $NOTIFICATION_SCRIPT" >> $SENTINEL_CONFIGURATION_FILE
echo "sentinel notification-script $MASTER_NAME $NOTIFICATION_SCRIPT" >>$SENTINEL_CONFIGURATION_FILE
fi

if [ "$CLIENT_RECONFIG_SCRIPT" ]; then
echo "sentinel client-reconfig-script $MASTER_NAME $CLIENT_RECONFIG_SCRIPT" >> $SENTINEL_CONFIGURATION_FILE
echo "sentinel client-reconfig-script $MASTER_NAME $CLIENT_RECONFIG_SCRIPT" >>$SENTINEL_CONFIGURATION_FILE
fi

if [ "$AUTH_PASS" ]; then
echo "sentinel auth-pass $MASTER_NAME $AUTH_PASS" >> $SENTINEL_CONFIGURATION_FILE
echo "sentinel auth-pass $MASTER_NAME $AUTH_PASS" >>$SENTINEL_CONFIGURATION_FILE
fi

if [ "$SLAVES" ]; then
for SLAVE in $(echo $SLAVES | tr ";" "\n")
do
if [ "$SLAVE" ]; then
print_slave $SLAVE
if [ "${SLAVES}" ]; then
for SLAVE in $(echo "${SLAVES}" | tr ";" "\n"); do
if [ "${SLAVE}" ]; then
print_slave "${SLAVE}"
fi
done
fi
fi

cat $SENTINEL_CONFIGURATION_FILE
exec redis-server $SENTINEL_CONFIGURATION_FILE --sentinel

0 comments on commit 5221630

Please sign in to comment.