From 87320ed01152af5fa6c72452e34d27f2fe10467c Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 19 May 2016 21:34:17 +0800 Subject: [PATCH 1/2] Rewrite docker testing. Signed-off-by: Bo-Yi Wu --- docker/Dockerfile.testing | 16 ---------------- docker/docker-compose.testing.yml | 9 +++++---- docker/golang/Dockerfile | 11 +++++++++++ docker/redis/Dockerfile | 7 +++++++ docker/testing.sh | 7 +++++++ 5 files changed, 30 insertions(+), 20 deletions(-) delete mode 100644 docker/Dockerfile.testing create mode 100644 docker/golang/Dockerfile create mode 100644 docker/redis/Dockerfile create mode 100755 docker/testing.sh diff --git a/docker/Dockerfile.testing b/docker/Dockerfile.testing deleted file mode 100644 index 4e90628..0000000 --- a/docker/Dockerfile.testing +++ /dev/null @@ -1,16 +0,0 @@ -FROM golang:1.6.2-alpine - -MAINTAINER Bo-Yi Wu - -RUN apk update \ - && apk add git make && rm -rf /var/cache/apk/* - -# install glide package management. -RUN go get github.com/Masterminds/glide && cd $GOPATH/src/github.com/Masterminds/glide && make install -RUN mkdir -p $GOPATH/src/github.com/appleboy/gorush -RUN git clone https://github.com/appleboy/gorush.git $GOPATH/src/github.com/appleboy/gorush/ -WORKDIR $GOPATH/src/github.com/appleboy/gorush -RUN sed -i"" -e "s/localhost/redis/g" config/config.yml -RUN sed -i"" -e "s/localhost/redis/g" gorush/status_test.go -RUN sed -i"" -e "s/localhost/redis/g" storage/redis/redis_test.go -RUN make bundle diff --git a/docker/docker-compose.testing.yml b/docker/docker-compose.testing.yml index 13bf5ac..5d755b7 100644 --- a/docker/docker-compose.testing.yml +++ b/docker/docker-compose.testing.yml @@ -1,14 +1,15 @@ gorush: - build: "." - dockerfile: Dockerfile.testing + build: ./golang links: - redis privileged: true environment: - ANDROID_API_KEY - ANDROID_TEST_TOKEN - command: /bin/sh -c "make test" + volumes: + - ../:/go/src/github.com/appleboy/gorush + command: /bin/sh -c './docker/testing.sh' redis: - image: redis:alpine + build: ./redis privileged: true diff --git a/docker/golang/Dockerfile b/docker/golang/Dockerfile new file mode 100644 index 0000000..282b7fc --- /dev/null +++ b/docker/golang/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:1.6.2-alpine + +MAINTAINER Bo-Yi Wu + +RUN apk update \ + && apk add git make && rm -rf /var/cache/apk/* + +# install glide package management. +RUN go get github.com/Masterminds/glide && cd $GOPATH/src/github.com/Masterminds/glide && make install + +WORKDIR $GOPATH/src/github.com/appleboy/gorush diff --git a/docker/redis/Dockerfile b/docker/redis/Dockerfile new file mode 100644 index 0000000..1192e28 --- /dev/null +++ b/docker/redis/Dockerfile @@ -0,0 +1,7 @@ +FROM redis:alpine + +MAINTAINER Bo-Yi Wu + +CMD [ "redis-server" ] + +EXPOSE 6379 diff --git a/docker/testing.sh b/docker/testing.sh new file mode 100755 index 0000000..c6e7240 --- /dev/null +++ b/docker/testing.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# +cd /go/src/github.com/appleboy/gorush +sed -i"" -e "s/localhost/redis/g" config/config.yml +sed -i"" -e "s/localhost/redis/g" gorush/status_test.go +sed -i"" -e "s/localhost/redis/g" storage/redis/redis_test.go +make bundle && make test From 349099fcf648a4d0c2df1002613b99c4ba0de838 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 19 May 2016 22:45:42 +0800 Subject: [PATCH 2/2] test gorush version. Signed-off-by: Bo-Yi Wu --- gorush/server_test.go | 4 ++++ gorush/version.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/gorush/server_test.go b/gorush/server_test.go index 4255201..45c36f0 100644 --- a/gorush/server_test.go +++ b/gorush/server_test.go @@ -21,7 +21,11 @@ func initTest() { } func TestPrintGoRushVersion(t *testing.T) { + SetVersion("3.0.0") + ver := GetVersion() PrintGoRushVersion() + + assert.Equal(t, "3.0.0", ver) } func TestRunNormalServer(t *testing.T) { diff --git a/gorush/version.go b/gorush/version.go index cd177c6..b7dbd08 100644 --- a/gorush/version.go +++ b/gorush/version.go @@ -12,6 +12,10 @@ func SetVersion(ver string) { version = ver } +func GetVersion() string { + return version +} + // PrintGoRushVersion provide print server engine func PrintGoRushVersion() { fmt.Printf(`GoRush %s, Compiler: %s %s, Copyright (C) 2016 Bo-Yi Wu, Inc.`,