Skip to content

Commit ef276da

Browse files
Merge pull request #28 from thandayuthapani/master
Changes for travis Unit Test
2 parents 833955f + d604b4b commit ef276da

File tree

3 files changed

+24
-38
lines changed

3 files changed

+24
-38
lines changed

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: go
22
sudo: required
3-
go:
3+
go:
44
- 1.8.3
55
install: true
66

@@ -15,11 +15,11 @@ jobs:
1515
- stage: Format Checker
1616
script: bash -x scripts/travis/formatChecker.sh
1717
- stage: DeadCode Checker
18-
script:
18+
script:
1919
- go get -u github.com/tsenart/deadcode
2020
- bash -x scripts/travis/deadCodeChecker.sh
2121
- stage: Misspell Checker
22-
script:
22+
script:
2323
- go get -u github.com/client9/misspell
2424
- bash -x scripts/travis/misspellChecker.sh
2525
- stage: GoConst Checker
@@ -34,3 +34,6 @@ jobs:
3434
script:
3535
- go get github.com/fzipp/gocyclo
3636
- bash -x scripts/travis/goCycloChecker.sh
37+
- stage: Unit Test
38+
script:
39+
- bash -x scripts/travis/unit_test.sh

csemonitor_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ func initEnv() {
5050
func TestNewReporter(t *testing.T) {
5151
initEnv()
5252
assert := assert.New(t)
53-
reporter := NewReporter(metrics.DefaultRegistry, "127.0.0.1:8080", http.Header{"Content-Type": []string{"application/json"}}, time.Second, &tls.Config{}, "default", "0.0.1", "Server", "", "")
53+
reporter := NewReporter(metrics.DefaultRegistry, "127.0.0.1:8080", http.Header{"Content-Type": []string{"application/json"}}, time.Second, &tls.Config{}, "default", "0.0.1", "Server", "")
5454
assert.Equal(reporter.Interval, time.Second)
5555
assert.Equal(reporter.CseMonitorAddr, "127.0.0.1:8080")
5656
assert.Equal(reporter.Header, http.Header{"Content-Type": []string{"application/json"}})
5757
}
5858
func TestCseMonitor(t *testing.T) {
5959
initEnv()
6060
assert := assert.New(t)
61-
reporter := NewReporter(metrics.DefaultRegistry, "127.0.0.1:8080", http.Header{"Content-Type": []string{"application/json"}}, time.Second, &tls.Config{}, "default", "0.0.1", "Server", "", "")
61+
reporter := NewReporter(metrics.DefaultRegistry, "127.0.0.1:8080", http.Header{"Content-Type": []string{"application/json"}}, time.Second, &tls.Config{}, "default", "0.0.1", "Server", "")
6262
config.SelfServiceName = "testService"
6363
monitorData := reporter.getData("default", "0.0.1", "testService", "", "", "")
6464
assert.Equal(monitorData.Name, "testService")
@@ -67,7 +67,7 @@ func TestCseMonitor(t *testing.T) {
6767
func TestCseMonitor2(t *testing.T) {
6868
initEnv()
6969
assert := assert.New(t)
70-
reporter := NewReporter(metrics.DefaultRegistry, "127.0.0.1:8080", http.Header{"Content-Type": []string{"application/json"}}, time.Second, &tls.Config{}, "default", "0.0.1", "Server", "", "")
70+
reporter := NewReporter(metrics.DefaultRegistry, "127.0.0.1:8080", http.Header{"Content-Type": []string{"application/json"}}, time.Second, &tls.Config{}, "default", "0.0.1", "Server", "")
7171
metricCollector := NewCseCollector("source.Provider.Microservice.SchemaID.OperationId")
7272
config.SelfServiceName = "testService"
7373

@@ -90,7 +90,7 @@ func TestCseMonitorClient_PostMetrics(t *testing.T) {
9090
initEnv()
9191
assert := assert.New(t)
9292
config.SelfServiceName = "testService"
93-
reporter := NewReporter(metrics.DefaultRegistry, "127.0.0.1:8080", http.Header{"Content-Type": []string{"application/json"}}, time.Second, &tls.Config{}, "default", "0.0.1", "Server", "", "")
93+
reporter := NewReporter(metrics.DefaultRegistry, "127.0.0.1:8080", http.Header{"Content-Type": []string{"application/json"}}, time.Second, &tls.Config{}, "default", "0.0.1", "Server", "")
9494
cseMonitClient := NewCseMonitorClient(http.Header{"Content-Type": []string{"application/json"}}, "http://127.0.0.1:9098", &tls.Config{}, "v2")
9595
assert.Equal(cseMonitClient.URL, "http://127.0.0.1:9098")
9696
assert.Equal(cseMonitClient.Header, http.Header{"Content-Type": []string{"application/json"}})

scripts/travis/unit_test.sh

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,29 @@
11
#!/bin/sh
22
set -e
33

4-
go get -u github.com/FiloSottile/gvt
5-
mkdir -p $GOPATH/src/github.com/fsnotify
6-
mkdir -p $GOPATH/src/github.com/spf13
7-
mkdir -p $GOPATH/src/golang.org/x
8-
9-
gvt restore
10-
4+
go get github.com/rcrowley/go-metrics
5+
go get github.com/stretchr/testify/assert
116
go get gopkg.in/yaml.v2
7+
go get github.com/Masterminds/glide
128

13-
cd $GOPATH/src/github.com/ServiceComb
14-
git clone https://github.com/ServiceComb/go-chassis.git
15-
git clone https://github.com/ServiceComb/go-archaius.git
16-
git clone https://github.com/ServiceComb/paas-lager.git
17-
git clone https://github.com/ServiceComb/auth.git
18-
19-
cd $GOPATH/src/github.com/fsnotify
20-
git clone https://github.com/fsnotify/fsnotify.git
21-
cd fsnotify
22-
git reset --hard 629574ca2a5df945712d3079857300b5e4da0236
23-
24-
cd $GOPATH/src/github.com/spf13
25-
git clone https://github.com/spf13/cast.git
26-
cd cast
27-
git reset --hard acbeb36b902d72a7a4c18e8f3241075e7ab763e4
28-
29-
mkdir -p $GOPATH/src/github.com/stathat
30-
31-
cd $GOPATH/src/github.com/stathat
32-
git clone https://github.com/stathat/go.git
9+
mkdir -p $HOME/gopath/src/github.com/ServiceComb/
10+
cd $HOME/gopath/src/github.com/ServiceComb
11+
git clone http://github.com/ServiceComb/go-chassis
12+
cd $HOME/gopath/src/github.com/ServiceComb/go-chassis
13+
glide install
14+
mkdir -p $HOME/gopath/src/github.com/ServiceComb/go-chassis/vendor/github.com/ServiceComb/cse-collector/
15+
rsync -az ${TRAVIS_BUILD_DIR}/ $HOME/gopath/src/github.com/ServiceComb/go-chassis/vendor/github.com/ServiceComb/cse-collector/
16+
export TRAVIS_BUILD_DIR=$HOME/gopath/src/github.com/ServiceComb/go-chassis/vendor/github.com/ServiceComb/cse-collector/
17+
cd $HOME/gopath/src/github.com/ServiceComb/go-chassis/vendor/github.com/ServiceComb/cse-collector/
3318

34-
cd $GOPATH/src/golang.org/x
35-
git clone https://github.com/golang/sys.git
3619

37-
cd $GOPATH/src/github.com/ServiceComb/cse-collector
20+
cd $GOPATH/src/github.com/ServiceComb/go-chassis/vendor/github.com/ServiceComb/cse-collector
3821
#Start unit test
3922
for d in $(go list ./...); do
4023
echo $d
4124
echo $GOPATH
4225
cd $GOPATH/src/$d
4326
if [ $(ls | grep _test.go | wc -l) -gt 0 ]; then
44-
go test
27+
go test
4528
fi
4629
done

0 commit comments

Comments
 (0)