Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Added TLS support for running tests; CI runs tests with both http and…
Browse files Browse the repository at this point in the history
… https
  • Loading branch information
yuce committed Oct 25, 2017
1 parent 9ab4bcb commit be0ff7c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ go:
sudo: required
group: deprecated-2017Q2
before_install:
- openssl req -x509 -newkey rsa:4096 -keyout test.pilosa.local.key -out test.pilosa.local.crt -days 3650 -nodes -subj "/C=US/ST=Texas/L=Austin/O=Pilosa/OU=Com/CN=test.pilosa.local"
- wget https://s3.amazonaws.com/build.pilosa.com/pilosa-master-linux-amd64.tar.gz && tar xf pilosa-master-linux-amd64.tar.gz
- ./pilosa-master-linux-amd64/pilosa server &
- ./pilosa-master-linux-amd64/pilosa server -d http_data &
- ./pilosa-master-linux-amd64/pilosa server -b https://:20101 -d https_data --tls.skip-verify --tls.certificate test.pilosa.local.crt --tls.key test.pilosa.local.key &
- go get github.com/mattn/goveralls
- go get -u github.com/golang/dep/cmd/dep
addons:
script:
- dep ensure && $HOME/gopath/bin/goveralls -service=travis-ci -ignore "gopilosa_pbuf/public.pb.go" -flags="-tags=integration fullcoverage"
- dep ensure
- PILOSA_BIND="https://:20101" make test-all
- $HOME/gopath/bin/goveralls -service=travis-ci -ignore "gopilosa_pbuf/public.pb.go" -flags="-tags=integration fullcoverage"
14 changes: 12 additions & 2 deletions client_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ package pilosa

import (
"bytes"
"crypto/tls"
"errors"
"io"
"net/http"
Expand All @@ -47,7 +48,6 @@ import (
"testing"
"time"

"crypto/tls"
"github.com/golang/protobuf/proto"
pbuf "github.com/pilosa/go-pilosa/gopilosa_pbuf"
)
Expand Down Expand Up @@ -1371,14 +1371,24 @@ func TestStatusToNodeSlicesForIndex(t *testing.T) {
}

func getClient() *Client {
uri, err := NewURIFromAddress("http://:10101")
uri, err := NewURIFromAddress(getPilosaBindAddress())
if err != nil {
panic(err)
}
cluster := NewClusterWithHost(uri)
return NewClientWithCluster(cluster, &ClientOptions{TLSConfig: &tls.Config{InsecureSkipVerify: true}})
}

func getPilosaBindAddress() string {
for _, kvStr := range os.Environ() {
kv := strings.SplitN(kvStr, "=", 2)
if kv[0] == "PILOSA_BIND" {
return kv[1]
}
}
return "http://:10101"
}

func getMockServer(statusCode int, response []byte, contentLength int) *httptest.Server {
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/x-protobuf")
Expand Down

0 comments on commit be0ff7c

Please sign in to comment.