Skip to content
Permalink
Browse files

Merge pull request #70 from simonpasquier/use-stdlib-context

*: use stdlib context instead of golang.org/x/net/context
  • Loading branch information...
bwplotka committed Apr 2, 2019
2 parents 19183a6 + be4fd51 commit ae0d8660c5f2108ca70a3776dbe0fb53cf79f1da
@@ -1,24 +1,23 @@
sudo: false
language: go
# * github.com/grpc/grpc-go still supports go1.6
# - When we drop support for go1.6 we can remove golang.org/x/net/context
# below as it is part of the Go std library since go1.7
# * github.com/prometheus/client_golang already requires at least go1.7 since
# September 2017
go:
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
- master

env:
- GO111MODULE=on

install:
- go get github.com/prometheus/client_golang/prometheus
- go get google.golang.org/grpc
- go get golang.org/x/net/context
- go get github.com/stretchr/testify
# With Go modules (eg Go >= 1.11), it isn't necessary anymore to 'go get' the dependencies before running the tests.
- if [[ $TRAVIS_GO_VERSION =~ ^1\.(7|8|9|10)\. ]]; then go get github.com/prometheus/client_golang/prometheus; fi
- if [[ $TRAVIS_GO_VERSION =~ ^1\.(7|8|9|10)\. ]]; then go get google.golang.org/grpc; fi
- if [[ $TRAVIS_GO_VERSION =~ ^1\.(7|8|9|10)\. ]]; then go get github.com/stretchr/testify; fi

script:
- make test
- make test

after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
@@ -1,10 +1,10 @@
package grpc_prometheus

import (
"context"
"io"

prom "github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -4,18 +4,16 @@
package grpc_prometheus

import (
"context"
"io"
"net"
"testing"

"time"

"io"

pb_testproto "github.com/grpc-ecosystem/go-grpc-prometheus/examples/testproto"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -38,6 +36,7 @@ type ClientInterceptorTestSuite struct {
clientConn *grpc.ClientConn
testClient pb_testproto.TestServiceClient
ctx context.Context
cancel context.CancelFunc
}

func (s *ClientInterceptorTestSuite) SetupSuite() {
@@ -69,7 +68,7 @@ func (s *ClientInterceptorTestSuite) SetupSuite() {

func (s *ClientInterceptorTestSuite) SetupTest() {
// Make all RPC calls last at most 2 sec, meaning all async issues or deadlock will not kill tests.
s.ctx, _ = context.WithTimeout(context.TODO(), 2*time.Second)
s.ctx, s.cancel = context.WithTimeout(context.TODO(), 2*time.Second)

// Make sure every test starts with same fresh, intialized metric state.
DefaultClientMetrics.clientStartedCounter.Reset()
@@ -91,6 +90,10 @@ func (s *ClientInterceptorTestSuite) TearDownSuite() {
}
}

func (s *ClientInterceptorTestSuite) TearDownTest() {
s.cancel()
}

func (s *ClientInterceptorTestSuite) TestUnaryIncrementsMetrics() {
_, err := s.testClient.PingEmpty(s.ctx, &pb_testproto.Empty{}) // should return with code=OK
require.NoError(s.T(), err)
@@ -2,14 +2,14 @@ package main

import (
"bufio"
"context"
"fmt"
"log"
"net/http"
"os"
"strings"
"time"

"golang.org/x/net/context"
"google.golang.org/grpc"

"github.com/grpc-ecosystem/go-grpc-prometheus"

Some generated files are not rendered by default. Learn more.

@@ -1,12 +1,12 @@
package main

import (
"context"
"fmt"
"log"
"net"
"net/http"

"golang.org/x/net/context"
"google.golang.org/grpc"

"github.com/grpc-ecosystem/go-grpc-prometheus"

0 comments on commit ae0d866

Please sign in to comment.
You can’t perform that action at this time.