Skip to content

Commit

Permalink
JAV-14 Updated Coverage Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
asifdxtreme committed Jun 1, 2017
1 parent 61e3690 commit 4ef0b20
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 15 deletions.
31 changes: 29 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
language: go
sudo: false

sudo: required

services:
- docker

go:
- 1.7.3

before_install:
- docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 40010:40010 -p 23800:23800 -p 23790:23790 --name etcd quay.io/coreos/etcd etcd -name etcd0 -advertise-client-urls http://127.0.0.1:23790,http://127.0.0.1:40010 -listen-client-urls http://0.0.0.0:23790,http://0.0.0.0:40010 -initial-advertise-peer-urls http://127.0.0.1:23800 -listen-peer-urls http://0.0.0.0:23800 -initial-cluster-token etcd-cluster-1 -initial-cluster etcd0=http://127.0.0.1:23800 -initial-cluster-state new
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
- go get github.com/tedsuo/rata
- go get github.com/onsi/ginkgo/config
- go get github.com/onsi/ginkgo/types
- go get github.com/onsi/ginkgo
- go get github.com/onsi/gomega/gbytes
- go get github.com/onsi/gomega
- go get github.com/onsi/ginkgo/ginkgo

install: true

script:
- bash +x scripts/build.sh
- mkdir -p $HOME/gopath/src/github.com/servicecomb/service-center
- rsync -az ${TRAVIS_BUILD_DIR}/ $HOME/gopath/src/github.com/servicecomb/service-center/
- export TRAVIS_BUILD_DIR=$HOME/gopath/src/github.com/servicecomb/service-center
- cd $HOME/gopath/src/github.com/servicecomb/service-center
- CGO_ENABLED=0 GO_EXTLINK_ENABLED=0 go build --ldflags '-w -extldflags "-static"' -o servicecenter
- bash +x scripts/prepare_env_ut.sh
- bash -x scripts/ut.sh common
- bash -x scripts/ut.sh etcdsync
- bash -x scripts/ut.sh server/interceptor
- $HOME/gopath/bin/goveralls -coverprofile=coverage.txt -service=travis-ci


after_success:
- bash <(curl -s https://codecov.io/bash)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The easiest way to get Service Center is to use one of the pre-built release bin

### Running Service Center

First, you need to run a etcd(version: 3.x) as a database service£¬and then modify the etcd IP and port in the Service Center configuration file (./conf/app.conf : manager_cluster).
First, you need to run a etcd(version: 3.x) as a database service£¬and then modify the etcd IP and port in the Service Center configuration file (./conf/app.conf : manager_cluster).

```sh
./bin/start.sh
Expand All @@ -26,7 +26,7 @@ Project documentation is available on the ServiceComb website.

## Building

You don¡¯t need to build from source to use Service Center (binaries on the [GitHub releases page][github-release]), but if you want to try out the latest and greatest, Service Center can be easily built. You can refer to this compilation script([.travis.yml][travis.yml]).
You don¡¯t need to build from source to use Service Center (binaries on the [GitHub releases page][github-release]), but if you want to try out the latest and greatest, Service Center can be easily built. You can refer to this compilation script([.travis.yml][travis.yml]).

[github-release]: https://github.com/servicecomb/service-center/releases/
[travis.yml]: https://github.com/ServiceComb/service-center/blob/master/.travis.yml
Expand Down
18 changes: 9 additions & 9 deletions common/cron/cron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,59 +29,59 @@ var _ = Describe("Cron", func() {
It("Test every second cron", func() {
job := Every(1).Seconds()
job.Do(DummyTask)
Expect(job.String()).To(Equal("[JOB]type: 1(seconds), interval: 1, delay: 0, at: , task: servicecenter/common/cron_test.DummyTask"))
Expect(job.String()).To(ContainSubstring("[JOB]type: 1(seconds), interval: 1, delay: 0, at: ,"))
})

It("Test every minute cron", func() {
job := Every(3).Minutes()
job.Do(DummyTask)
Expect(job.String()).To(Equal("[JOB]type: 2(minutes), interval: 3, delay: 0, at: , task: servicecenter/common/cron_test.DummyTask"))
Expect(job.String()).To(ContainSubstring("[JOB]type: 2(minutes), interval: 3, delay: 0, at: , "))
})

It("Test every hour cron", func() {
job := Every(5).Hours()
job.Do(DummyTask)
Expect(job.String()).To(Equal("[JOB]type: 3(hours), interval: 5, delay: 0, at: , task: servicecenter/common/cron_test.DummyTask"))
Expect(job.String()).To(ContainSubstring("[JOB]type: 3(hours), interval: 5, delay: 0, at: , "))
})

It("Test every day cron", func() {
job := Every(7).Days()
job.Do(DummyTask)
Expect(job.String()).To(Equal("[JOB]type: 4(days), interval: 7, delay: 0, at: , task: servicecenter/common/cron_test.DummyTask"))
Expect(job.String()).To(ContainSubstring("[JOB]type: 4(days), interval: 7, delay: 0, at: ,"))
})
})

Describe("cron every with delay test", func() {
It("Test every second with delay cron", func() {
job := EveryWithDelay(1, 2).Seconds()
job.Do(DummyTask)
Expect(job.String()).To(Equal("[JOB]type: 1(seconds), interval: 1, delay: 2, at: , task: servicecenter/common/cron_test.DummyTask"))
Expect(job.String()).To(ContainSubstring("[JOB]type: 1(seconds), interval: 1, delay: 2, at: , "))
})

It("Test every minutewith delay cron", func() {
job := EveryWithDelay(3, 4).Minutes()
job.Do(DummyTask)
Expect(job.String()).To(Equal("[JOB]type: 2(minutes), interval: 3, delay: 4, at: , task: servicecenter/common/cron_test.DummyTask"))
Expect(job.String()).To(ContainSubstring("[JOB]type: 2(minutes), interval: 3, delay: 4, at: , "))
})

It("Test every hourwith delay cron", func() {
job := EveryWithDelay(5, 6).Hours()
job.Do(DummyTask)
Expect(job.String()).To(Equal("[JOB]type: 3(hours), interval: 5, delay: 6, at: , task: servicecenter/common/cron_test.DummyTask"))
Expect(job.String()).To(ContainSubstring("[JOB]type: 3(hours), interval: 5, delay: 6, at: ,"))
})

It("Test every daywith delay cron", func() {
job := EveryWithDelay(7, 8).Days()
job.Do(DummyTask)
Expect(job.String()).To(Equal("[JOB]type: 4(days), interval: 7, delay: 8, at: , task: servicecenter/common/cron_test.DummyTask"))
Expect(job.String()).To(ContainSubstring("[JOB]type: 4(days), interval: 7, delay: 8, at: ,"))
})
})

Describe("cron at time test", func() {
It("Test at time cron", func() {
job := Every(1).Days().At("01:23")
job.Do(DummyTask)
Expect(job.String()).To(Equal("[JOB]type: 4(days), interval: 1, delay: 0, at: 01:23, task: servicecenter/common/cron_test.DummyTask"))
Expect(job.String()).To(ContainSubstring("[JOB]type: 4(days), interval: 1, delay: 0, at: 01:23,"))
})

It("Test at time format invalid", func() {
Expand Down
4 changes: 2 additions & 2 deletions etc/conf/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ registry_lease_duration = 30s
# manager_addr = "http://127.0.0.1:9982"
# manager_cluster = "sr-0=http://127.0.0.1:9982"
# registry_plugin equals to 'etcd'
manager_cluster = "127.0.0.1:2379"
manager_cluster = "127.0.0.1:23790"

#heartbeat that sync synchronizes client's endpoints with the known endpoints from the etcd membership,unit is second.
#<=0, use default 30s
Expand Down Expand Up @@ -64,7 +64,7 @@ encode_request = false

#SSL options
# 0=Non-SSL mode, 1==SSL mode
ssl_mode = 1
ssl_mode = 0
ssl_verify_client = 1
# minimal tls protocol, [TLSv1.0, TLSv1.1, TLSv1.2]
ssl_protocols = TLSv1.2
Expand Down
5 changes: 5 additions & 0 deletions scripts/prepare_env_ut.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cp -r etc/conf common/cron/
cp -r etc/conf common/
cp -r etc/conf etcdsync/
cp -r etc/conf server/interceptor/ratelimiter/
echo "mode: atomic" > coverage.txt
14 changes: 14 additions & 0 deletions scripts/ut.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
set -e
export COVERAGE_PATH=$(pwd)
cd $1
for d in $(go list ./... | grep -v vendor); do
cd $HOME/gopath/src/
cd $d
set +e
ginkgo -r -v -cover
if [ -f *.coverprofile ]; then
sed '1d;$d' *.coverprofile >> $HOME/gopath/src/github.com/servicecomb/service-center/coverage.txt
fi
set -e
done

0 comments on commit 4ef0b20

Please sign in to comment.