-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
126 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.DS_Store | ||
.idea | ||
build/containers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
### [3.0.5] | ||
|
||
* From image: alpine:3.4 | ||
* Redis 3.2.0 | ||
|
||
### [3.0.5] | ||
|
||
* From image: alpine:3.3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
FROM imega/base-builder:1.1.0 | ||
FROM imega/base-builder:1.2.0 | ||
|
||
EXPOSE 6379 | ||
MAINTAINER Dmitry Gavriloff <info@imega.ru> | ||
|
||
COPY . / | ||
|
||
RUN apk add --update redis && \ | ||
rm -rf /var/cache/apk/* | ||
ADD build/rootfs.tar.gz / | ||
|
||
CMD ["redis-server","/redis.conf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
DOCKER_RM = false | ||
|
||
build: buildfs | ||
@docker build -t imega/redis . | ||
|
||
buildfs: | ||
@docker run --rm=$(DOCKER_RM) \ | ||
-v $(CURDIR)/runner:/runner \ | ||
-v $(CURDIR)/build:/build \ | ||
-v $(CURDIR)/src:/src \ | ||
imega/base-builder \ | ||
--packages="redis" | ||
|
||
build/containers/container_data: | ||
@mkdir -p $(shell dirname $@) | ||
@docker run -d --name container_data imega/redis | ||
@touch $@ | ||
|
||
discovery_data: build/containers/container_data | ||
@while [ "`docker inspect -f {{.State.Running}} container_data`" != "true" ]; do \ | ||
echo "wait db"; sleep 0.3; \ | ||
done | ||
|
||
get_containers: | ||
$(eval CONTAINERS := $(subst build/containers/,,$(shell find build/containers -type f))) | ||
|
||
stop: get_containers | ||
@-docker stop $(CONTAINERS) | ||
|
||
clean: stop | ||
@-docker rm -fv $(CONTAINERS) | ||
@-rm -rf build/containers/* | ||
|
||
test: build discovery_data | ||
@docker run --rm=$(DOCKER_RM) \ | ||
-v $(CURDIR)/tests:/data \ | ||
-w /data \ | ||
--link container_data:server \ | ||
alpine \ | ||
sh -c 'apk add --update bash && ./test.sh server' | ||
|
||
.PHONY: build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
machine: | ||
services: | ||
- docker | ||
|
||
dependencies: | ||
pre: | ||
- sudo apt-get install -y make | ||
|
||
test: | ||
pre: | ||
- make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
cp $SRC/redis.conf $ROOTFS/redis.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bash | ||
|
||
printf '%.0s-' {1..80} | ||
echo | ||
|
||
URL=$1 | ||
|
||
COUNT_TESTS=0 | ||
COUNT_TESTS_FAIL=0 | ||
|
||
assertTrue() { | ||
testName="$3" | ||
pad=$(printf '%0.1s' "."{1..80}) | ||
padlength=78 | ||
|
||
if [ "$1" != "$2" ]; then | ||
printf ' %s%*.*s%s' "$3" 0 $((padlength - ${#testName} - 4)) "$pad" "Fail" | ||
printf ' (expected %s, assertion %s)\n' "$1" "$2" | ||
let "COUNT_TESTS_FAIL++" | ||
else | ||
printf ' %s%*.*s%s\n' "$3" 0 $((padlength - ${#testName} - 2)) "$pad" "Ok" | ||
let "COUNT_TESTS++" | ||
fi | ||
} | ||
|
||
testSet() { | ||
ACTUAL=$(echo "SET my-key 'my-value'" | nc server 6379 2>/dev/null | cat | sed 's/\r//g') | ||
|
||
assertTrue "+OK" $ACTUAL "$FUNCNAME" | ||
} | ||
|
||
testGet() { | ||
ACTUAL=$(echo "GET my-key" | nc server 6379 2>/dev/null | cat | sed 's/[8\$\r]//g' | tr -d '[[:space:]]') | ||
|
||
assertTrue "my-value" $ACTUAL "$FUNCNAME" | ||
} | ||
|
||
testSet | ||
testGet | ||
|
||
printf '%.0s-' {1..80} | ||
echo | ||
printf 'Total test: %s, fail: %s\n\n' "$COUNT_TESTS" "$COUNT_TESTS_FAIL" | ||
|
||
if [ $COUNT_TESTS_FAIL -gt 0 ]; then | ||
exit 1 | ||
fi | ||
|
||
exit 0 |