Skip to content

Commit

Permalink
add enable_flaky_tests and skip some flaky tests in gctuner (#5975)
Browse files Browse the repository at this point in the history
ref #5953

Signed-off-by: Sen Han <[email protected]>
  • Loading branch information
hnes authored Feb 13, 2023
1 parent 0ed822c commit b719db2
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pkg/cgroup/cgroup_cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build linux
//go:build linux && enable_flaky_tests

package cgroup

Expand Down
2 changes: 2 additions & 0 deletions pkg/gctuner/finalizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build enable_flaky_tests

package gctuner

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/gctuner/memory_limit_tuner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build enable_flaky_tests

package gctuner

import (
Expand Down
39 changes: 39 additions & 0 deletions pkg/gctuner/tuner_calc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2023 TiKV Project Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package gctuner

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestCalcGCPercent(t *testing.T) {
const gb = 1024 * 1024 * 1024
// use default value when invalid params
require.Equal(t, defaultGCPercent, calcGCPercent(0, 0))
require.Equal(t, defaultGCPercent, calcGCPercent(0, 1))
require.Equal(t, defaultGCPercent, calcGCPercent(1, 0))

require.Equal(t, maxGCPercent.Load(), calcGCPercent(1, 3*gb))
require.Equal(t, maxGCPercent.Load(), calcGCPercent(gb/10, 4*gb))
require.Equal(t, maxGCPercent.Load(), calcGCPercent(gb/2, 4*gb))
require.Equal(t, uint32(300), calcGCPercent(1*gb, 4*gb))
require.Equal(t, uint32(166), calcGCPercent(1.5*gb, 4*gb))
require.Equal(t, uint32(100), calcGCPercent(2*gb, 4*gb))
require.Equal(t, uint32(100), calcGCPercent(3*gb, 4*gb))
require.Equal(t, minGCPercent.Load(), calcGCPercent(4*gb, 4*gb))
require.Equal(t, minGCPercent.Load(), calcGCPercent(5*gb, 4*gb))
}
20 changes: 2 additions & 18 deletions pkg/gctuner/tuner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build enable_flaky_tests

package gctuner

import (
Expand Down Expand Up @@ -73,21 +75,3 @@ func TestTuner(t *testing.T) {
require.Equal(t, minGCPercent.Load(), tn.getGCPercent())
}
}

func TestCalcGCPercent(t *testing.T) {
const gb = 1024 * 1024 * 1024
// use default value when invalid params
require.Equal(t, defaultGCPercent, calcGCPercent(0, 0))
require.Equal(t, defaultGCPercent, calcGCPercent(0, 1))
require.Equal(t, defaultGCPercent, calcGCPercent(1, 0))

require.Equal(t, maxGCPercent.Load(), calcGCPercent(1, 3*gb))
require.Equal(t, maxGCPercent.Load(), calcGCPercent(gb/10, 4*gb))
require.Equal(t, maxGCPercent.Load(), calcGCPercent(gb/2, 4*gb))
require.Equal(t, uint32(300), calcGCPercent(1*gb, 4*gb))
require.Equal(t, uint32(166), calcGCPercent(1.5*gb, 4*gb))
require.Equal(t, uint32(100), calcGCPercent(2*gb, 4*gb))
require.Equal(t, uint32(100), calcGCPercent(3*gb, 4*gb))
require.Equal(t, minGCPercent.Load(), calcGCPercent(4*gb, 4*gb))
require.Equal(t, minGCPercent.Load(), calcGCPercent(5*gb, 4*gb))
}

0 comments on commit b719db2

Please sign in to comment.