Skip to content

Commit

Permalink
Update travis to use go 1.13 (#206)
Browse files Browse the repository at this point in the history
* use go113

* fix test.v for go113

* remove empty gardener main test files

* remove coverpkg

* replace with isTest()
  • Loading branch information
gfr10598 committed Nov 18, 2019
1 parent efa2e39 commit caa0cde
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 36 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
- docker

go:
- 1.12
- 1.13

###########################################################################
before_install:
Expand Down Expand Up @@ -65,12 +65,14 @@ before_script:
script:
# To start, run all the non-integration unit tests.
- cd $TRAVIS_BUILD_DIR
- go test -v -coverpkg=./... -coverprofile=_unit.cov ./...
# This is failing since go 1.13. See https://github.com/golang/go/issues/30374
# - go test -v -coverpkg=./... -coverprofile=_unit.cov ./...
- go test -v -coverprofile=_unit.cov ./...

# Rerun modules with integration tests. This means that some tests are
# repeated, but otherwise we lose some coverage.
- if [[ -n "$SERVICE_ACCOUNT_mlab_testing" ]] ; then
go test -v -coverpkg=./... -coverprofile=_integration.cov ./... -tags=integration ;
go test -v -coverprofile=_integration.cov ./... -tags=integration ;
fi

# Combine coverage of unit tests and integration tests and send the results to coveralls.
Expand Down
9 changes: 3 additions & 6 deletions cloud/bq/dedup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ import (
"github.com/m-lab/go/dataset"
)

// testMode is set IFF the test.v flag is defined, as it is in all go testing.T tests.
// Use with caution!
var testMode bool

func init() {
testMode = flag.Lookup("test.v") != nil
func isTest() bool {
return flag.Lookup("test.v") != nil
}

// Dedup related errors.
Expand All @@ -44,7 +41,7 @@ func WaitForStableTable(ctx context.Context, tt bqiface.Table) error {
emptyBufferWaitTime := 60 * time.Minute

errorTimeout := 2 * time.Minute
if testMode {
if isTest() {
errorTimeout = 100 * time.Millisecond
}
errorDeadline := time.Now().Add(errorTimeout)
Expand Down
5 changes: 0 additions & 5 deletions cmd/gardener/gardener_integration_test.go

This file was deleted.

3 changes: 0 additions & 3 deletions cmd/gardener/gardener_test.go

This file was deleted.

26 changes: 7 additions & 19 deletions rex/rex.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,8 @@ import (
"google.golang.org/api/option"
)

// Environment provides "global" variables.
// TODO - use entries in context instead.
type environment struct {
TestMode bool
}

// env provides environment vars.
var env environment

func init() {
// HACK This allows some modified behavior when running unit tests.
if flag.Lookup("test.v") != nil {
env.TestMode = true
}
func isTest() bool {
return flag.Lookup("test.v") != nil
}

// ReprocessingExecutor handles all reprocessing steps.
Expand Down Expand Up @@ -142,8 +130,7 @@ func (rex *ReprocessingExecutor) Next(ctx context.Context, t *state.Task, termin
err = bq.WaitForStableTable(ctx, s)
if err != nil {
// When testing, we expect to get ErrTableNotFound here.
if !env.TestMode || err != state.ErrTableNotFound {
// SetError also pushes to datastore, like Update(ctx, )
if err != state.ErrTableNotFound || !isTest() {
t.SetError(ctx, err, "bq.WaitForStableTable")
return err
}
Expand Down Expand Up @@ -211,8 +198,9 @@ func (rex *ReprocessingExecutor) waitForParsing(ctx context.Context, t *state.Ta
if err == tq.ErrTerminated {
break
}
if err == io.EOF && env.TestMode {
if err == io.EOF && isTest() {
// Expected when using test client.
log.Println("TestMode")
return nil
}
// We don't expect errors here, so try logging, and a large backoff
Expand Down Expand Up @@ -248,7 +236,7 @@ func (rex *ReprocessingExecutor) queue(ctx context.Context, t *state.Task) (int,
// TODO - try cancelling the context instead?
bucket, err := tq.GetBucket(ctx, rex.StorageClient, rex.Project, prefix.Bucket, false)
if err != nil {
if err == io.EOF && env.TestMode {
if err == io.EOF && isTest() {
log.Println("Using fake client, ignoring EOF error")
return 0, 0, nil
}
Expand Down Expand Up @@ -289,7 +277,7 @@ func (rex *ReprocessingExecutor) dedup(ctx context.Context, t *state.Task) error
job, err := bq.Dedup(ctx, &ds, src.TableID(), dest)
if err != nil {
if err == io.EOF {
if env.TestMode {
if isTest() {
t.JobID = "fakeJobID"
return nil
}
Expand Down

0 comments on commit caa0cde

Please sign in to comment.