Skip to content

Commit

Permalink
Merge pull request #406 from deniszh/DZ-tests-fix
Browse files Browse the repository at this point in the history
Tests fix
  • Loading branch information
deniszh committed Mar 5, 2021
2 parents a4126c6 + 072bba3 commit a02fb72
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

strategy:
fail-fast: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ on:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.31
version: v1.38.0

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:

tests:
name: Test code
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
go:
- ^1.13
- ^1.14
- ^1.15
- ^1.16
- ^1
steps:

Expand Down
8 changes: 5 additions & 3 deletions api/sample/cache-query/cache-query.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ func main() {
timeout := flag.Duration("timeout", time.Second, "connect and read timeout")
flag.Parse()

// TODO: grpc.WithTimeout deprecated
conn, err := grpc.Dial(*server, grpc.WithInsecure(), grpc.WithTimeout(*timeout)) //nolint:staticcheck skipcq:SCC-SA1019
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
conn, err := grpc.DialContext(ctx, *server, grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
log.Fatalf("did not connect: %v", err)
}

defer cancel()
defer conn.Close()

c := carbonpb.NewCarbonClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), *timeout)
ctx, cancel = context.WithTimeout(context.Background(), *timeout)
defer cancel()

res, err := c.CacheQuery(ctx, &carbonpb.CacheRequest{Metrics: flag.Args()})
Expand Down
2 changes: 1 addition & 1 deletion carbonserver/carbonserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ func (listener *CarbonserverListener) updateFileList(dir string, cacheMetricName

var freeSpace uint64
// diskspace can be negative and Bavail is therefore int64
if stat.Bavail >= 0 { // nolint:staticcheck skipcq: SCC-SA4003
if stat.Bavail >= 0 { // nolint:staticcheck // skipcq: SCC-SA4003
freeSpace = uint64(stat.Bavail) * uint64(stat.Bsize)
}
totalSpace := stat.Blocks * uint64(stat.Bsize)
Expand Down
4 changes: 2 additions & 2 deletions persister/throttle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func TestThrottleChan(t *testing.T) {

for _, perSecond := range perSecondTable {
bw := doTestThrottleTicker(perSecond, time.Second, false)
max := float64(perSecond) * 1.05
min := float64(perSecond) * 0.95
max := float64(perSecond) * 1.10
min := float64(perSecond) * 0.90
assert.True(t, float64(bw) >= min, fmt.Sprintf("perSecond: %d, bw: %d", perSecond, bw))
assert.True(t, float64(bw) <= max, fmt.Sprintf("perSecond: %d, bw: %d", perSecond, bw))
}
Expand Down

0 comments on commit a02fb72

Please sign in to comment.