Browse Source

Move test package to pkg/testutil

pull/762/head
Fabian Reinartz 10 years ago
parent
commit
3c8fbf1e15
  1. 2
      pkg/testutil/directory.go
  2. 2
      pkg/testutil/error.go
  3. 2
      promql/test.go
  4. 4
      storage/local/flock/flock_test.go
  5. 8
      storage/local/persistence_test.go
  6. 6
      storage/local/storage_test.go
  7. 8
      storage/local/test_helpers.go

2
utility/test/directory.go → pkg/testutil/directory.go

@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package test
package testutil
import (
"io/ioutil"

2
utility/test/error.go → pkg/testutil/error.go

@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package test
package testutil
// ErrorEqual compares Go errors for equality.
func ErrorEqual(left, right error) bool {

2
promql/test.go

@ -29,7 +29,7 @@ import (
"github.com/prometheus/prometheus/storage/metric"
"github.com/prometheus/prometheus/utility"
testutil "github.com/prometheus/prometheus/utility/test"
"github.com/prometheus/prometheus/pkg/testutil"
)
var (

4
storage/local/flock/flock_test.go

@ -5,11 +5,11 @@ import (
"path/filepath"
"testing"
"github.com/prometheus/prometheus/utility/test"
"github.com/prometheus/prometheus/pkg/testutil"
)
func TestLocking(t *testing.T) {
dir := test.NewTemporaryDirectory("test_flock", t)
dir := testutil.NewTemporaryDirectory("test_flock", t)
defer dir.Close()
fileName := filepath.Join(dir.Path(), "LOCK")

8
storage/local/persistence_test.go

@ -20,10 +20,10 @@ import (
clientmodel "github.com/prometheus/client_golang/model"
"github.com/prometheus/prometheus/pkg/testutil"
"github.com/prometheus/prometheus/storage/local/codable"
"github.com/prometheus/prometheus/storage/local/index"
"github.com/prometheus/prometheus/storage/metric"
"github.com/prometheus/prometheus/utility/test"
)
var (
@ -34,16 +34,16 @@ var (
m5 = clientmodel.Metric{"label": "value5"}
)
func newTestPersistence(t *testing.T, encoding chunkEncoding) (*persistence, test.Closer) {
func newTestPersistence(t *testing.T, encoding chunkEncoding) (*persistence, testutil.Closer) {
*defaultChunkEncoding = int(encoding)
dir := test.NewTemporaryDirectory("test_persistence", t)
dir := testutil.NewTemporaryDirectory("test_persistence", t)
p, err := newPersistence(dir.Path(), false, false, func() bool { return false })
if err != nil {
dir.Close()
t.Fatal(err)
}
go p.run()
return p, test.NewCallbackCloser(func() {
return p, testutil.NewCallbackCloser(func() {
p.close()
dir.Close()
})

6
storage/local/storage_test.go

@ -24,8 +24,8 @@ import (
clientmodel "github.com/prometheus/client_golang/model"
"github.com/prometheus/prometheus/pkg/testutil"
"github.com/prometheus/prometheus/storage/metric"
"github.com/prometheus/prometheus/utility/test"
)
func TestFingerprintsForLabelMatchers(t *testing.T) {
@ -217,7 +217,7 @@ func TestLoop(t *testing.T) {
Value: clientmodel.SampleValue(float64(i) * 0.2),
}
}
directory := test.NewTemporaryDirectory("test_storage", t)
directory := testutil.NewTemporaryDirectory("test_storage", t)
defer directory.Close()
o := &MemorySeriesStorageOptions{
MemoryChunks: 50,
@ -902,7 +902,7 @@ func benchmarkFuzz(b *testing.B, encoding chunkEncoding) {
*defaultChunkEncoding = int(encoding)
const samplesPerRun = 100000
rand.Seed(42)
directory := test.NewTemporaryDirectory("test_storage", b)
directory := testutil.NewTemporaryDirectory("test_storage", b)
defer directory.Close()
o := &MemorySeriesStorageOptions{
MemoryChunks: 100,

8
storage/local/test_helpers.go

@ -21,12 +21,12 @@ package local
import (
"time"
"github.com/prometheus/prometheus/utility/test"
"github.com/prometheus/prometheus/pkg/testutil"
)
type testStorageCloser struct {
storage Storage
directory test.Closer
directory testutil.Closer
}
func (t *testStorageCloser) Close() {
@ -37,9 +37,9 @@ func (t *testStorageCloser) Close() {
// NewTestStorage creates a storage instance backed by files in a temporary
// directory. The returned storage is already in serving state. Upon closing the
// returned test.Closer, the temporary directory is cleaned up.
func NewTestStorage(t test.T, encoding chunkEncoding) (*memorySeriesStorage, test.Closer) {
func NewTestStorage(t testutil.T, encoding chunkEncoding) (*memorySeriesStorage, testutil.Closer) {
*defaultChunkEncoding = int(encoding)
directory := test.NewTemporaryDirectory("test_storage", t)
directory := testutil.NewTemporaryDirectory("test_storage", t)
o := &MemorySeriesStorageOptions{
MemoryChunks: 1000000,
MaxChunksToPersist: 1000000,

Loading…
Cancel
Save